Update of /cvsroot/blob/blob/src/blob
In directory sc8-pr-cvs1:/tmp/cvs-serv10477
Modified Files:
partition.c
Log Message:
Add supprot for BLOB_PART_OFS_APPEND and BLOB_PART_SIZ_FULL flags.
BLOB_PART_OFF_APPEND allows a partition offset to be defined
to start at the end of the previous partition.
BLOB_PART_SIZ_FULL allows a partition length to be defined to use up
all remaining flash space. This is especially useful with the
CFI query support (cf. QUERY_FLASH_FOR_DESCRIPTORS).
Index: partition.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/partition.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- partition.c 9 May 2002 12:22:22 -0000 1.5
+++ partition.c 27 Jan 2003 20:43:35 -0000 1.6
@@ -1,3 +1,4 @@
+#define BLOB_DEBUG
/*
* partition.c: flash partitioning
*
@@ -254,7 +255,61 @@
}
}
+static int fixup_ptable(blob_partition_t *ptable)
+{
+ /* walk through ptable and fix up BLOB_PART_OFS_APPEND and
+ BLOB_PART_SIZ_FULL entries */
+
+ u32 offset = ptable->offset;
+ u32 size = ptable->size;
+ int no_more_parts_allowed = 0;
+ blob_partition_t *t = ptable;
+
+ dprintf("ptable->offset = 0x%08X\n", ptable->offset);
+ dprintf("ptable->size = 0x%08X\n", ptable->size);
+ if (ptable->size == BLOB_PART_SIZ_FULL) {
+ ptable->size = size = flash_get_size();
+ dprintf("ptable->size => 0x%08X\n", ptable->size);
+ }
+
+ for(;;) {
+ t = next_ptable_entry(t);
+
+ switch(t->magic) {
+ case BLOB_PART_LAST_MAGIC:
+ return 0;
+
+ case BLOB_PART_VALID_MAGIC:
+ dprintf("part @ 0x%p\n", t);
+
+ if (no_more_parts_allowed) {
+ eprintf("ptable fixup found additional parts"
+ " after BLOB_PART_SIZ_FULL size\n");
+ return -EINVAL;
+ }
+
+ dprintf(" offset = 0x%08X\n", t->offset);
+ if (t->offset == BLOB_PART_OFS_APPEND) {
+ t->offset = offset;
+ dprintf(" offset => 0x%08X\n", t->offset);
+ }
+ dprintf(" size = 0x%08X\n", t->size);
+ if (t->size == BLOB_PART_SIZ_FULL) {
+ t->size = size;
+ no_more_parts_allowed = 1;
+ dprintf(" size => 0x%08X\n", t->size);
+ }
+ offset += t->size;
+ size -= t->size;
+ break;
+
+ default:
+ eprintf("ptable magic failed at 0x%08x\n", (u32)t);
+ return -EINVAL;
+ }
+ }
+}
static void ptable_init(void)
@@ -287,7 +342,8 @@
/* FIXME: if there is still no flash partition table found we
* could check for a bootldr partition table over here */
- if(check_ptable_magic(ptable, BLOB_COPY_PART_TABLE_MAGIC) != 0) {
+ if ((check_ptable_magic(ptable, BLOB_COPY_PART_TABLE_MAGIC) != 0) ||
+ (fixup_ptable(ptable) != 0)) {
dprintf("no valid partition table found\n");
/* construct a minimal partition table */
|