Update of /cvsroot/blob/blob/src/blob
In directory sc8-pr-cvs1:/tmp/cvs-serv18073
Modified Files:
partition.c
Log Message:
Added pt_first,pt_next for iterating over partition table.
Added pt_flash_start to get absolute address of start of partition in flash.
Index: partition.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/partition.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- partition.c 27 Jan 2003 23:23:49 -0000 1.8
+++ partition.c 28 Jan 2003 03:38:48 -0000 1.9
@@ -344,27 +344,60 @@
/* 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) ||
- (fixup_ptable(ptable) != 0)) {
- dprintf("no valid partition table found\n");
+ if (check_ptable_magic(ptable, BLOB_COPY_PART_TABLE_MAGIC) != 0) {
+ dprintf("invalid partition table magic\n");
+ goto invalid_part;
+ }
- /* construct a minimal partition table */
- ptable[0].magic = BLOB_COPY_PART_TABLE_MAGIC;
- ptable[0].next = sizeof(blob_partition_t);
- ptable[0].offset = 0;
- ptable[0].size = 0;
- ptable[1].magic = BLOB_PART_LAST_MAGIC;
+ if (fixup_ptable(ptable) != 0) {
+ dprintf("could not fix up partition table\n");
+ goto invalid_part;
}
+done:
#ifdef BLOB_DEBUG
ptable_print(ptable);
-#endif
+#endif
+ return;
+
+invalid_part:
+ /* construct a minimal partition table */
+ ptable[0].magic = BLOB_COPY_PART_TABLE_MAGIC;
+ ptable[0].next = sizeof(blob_partition_t);
+ ptable[0].offset = 0;
+ ptable[0].size = 0;
+ ptable[1].magic = BLOB_PART_LAST_MAGIC;
+
+ goto done;
}
__initlist(ptable_init, INIT_LEVEL_OTHER_STUFF + 2);
+const blob_partition_t *pt_first(void)
+{
+ return pt_next(ptable);
+}
+
+const blob_partition_t *pt_next(const blob_partition_t *p)
+{
+ for (;;) {
+ p = next_ptable_entry(p);
+
+ switch (p->magic) {
+ case BLOB_PART_LAST_MAGIC:
+ return 0;
+ case BLOB_PART_VALID_MAGIC:
+ return p;
+ case BLOB_PART_INVALID_MAGIC:
+ break;
+ default:
+ return 0;
+ }
+ }
+}
+
const blob_partition_t *pt_find_by_name(const char *s)
{
@@ -427,6 +460,11 @@
}
}
+void *pt_flash_start(const blob_partition_t *p)
+{
+ /* absolute location within flash of the given partition */
+ return (void *) (ptable->offset + p->offset);
+}
|