Update of /cvsroot/blob/blob/src/blob
In directory usw-pr-cvs1:/tmp/cvs-serv26515/src/blob
Modified Files:
partition.c
Log Message:
This has been lying around in my CVS sandbox for too long. It's obviously
correct, so why don't commit it :)
Index: partition.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/partition.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- partition.c 13 Feb 2002 00:19:57 -0000 1.3
+++ partition.c 19 Mar 2002 21:08:38 -0000 1.4
@@ -1,7 +1,7 @@
/*
* partition.c: flash partitioning
*
- * Copyright (C) 2001 Erik Mouw <J.A...@it...>
+ * Copyright (C) 2001 2002 Erik Mouw <J.A...@it...>
*
* $Id$
*
@@ -202,7 +202,7 @@
-void ptable_print(const blob_partition_t *t)
+static void ptable_print(const blob_partition_t *t)
{
printf("Partition table for %d kB flash @ 0x%08x:\n",
t->size / 1024, t->offset);
@@ -304,6 +304,70 @@
}
__initlist(ptable_init, INIT_LEVEL_OTHER_STUFF + 2);
+
+
+
+
+const blob_partition_t *pt_find_by_name(const char *s)
+{
+ blob_partition_t *t = ptable;
+
+ /* first entry is always the descriptor so it's safe to skip
+ * it */
+
+ for(;;) {
+ t = next_ptable_entry(t);
+
+ switch(t->magic) {
+ case BLOB_PART_LAST_MAGIC:
+ /* this is the last one, we didn't find it :( */
+ return NULL;
+
+ case BLOB_PART_VALID_MAGIC:
+ if(strncmp(t->name, s, BLOB_PART_NAMELEN))
+ return t;
+ break;
+
+ case BLOB_PART_INVALID_MAGIC:
+ /* skip */
+ break;
+
+ default:
+ eprintf("ptable magic failed at 0x%08x\n", (u32)t);
+ return NULL;
+ }
+ }
+}
+
+
+
+
+const blob_partition_t *pt_find_by_address(u32 addr)
+{
+ blob_partition_t *t = ptable;
+
+ for(;;) {
+ t = next_ptable_entry(t);
+
+ switch(t->magic) {
+ case BLOB_PART_LAST_MAGIC:
+ return NULL;
+
+ case BLOB_PART_VALID_MAGIC:
+ if((addr >= t->offset) &&
+ (addr < (t->offset + t->size)))
+ return t;
+ break;
+
+ case BLOB_PART_INVALID_MAGIC:
+ break;
+
+ default:
+ eprintf("ptable magic failed at 0x%08x\n", (u32)t);
+ return NULL;
+ }
+ }
+}
|