Update of /cvsroot/blob/blob/src/blob
In directory usw-pr-cvs1:/tmp/cvs-serv14606/src/blob
Modified Files:
bootldrpart.c
Log Message:
Construct a bootldr partition block from blob partition information.
Index: bootldrpart.c
===================================================================
RCS file: /cvsroot/blob/blob/src/blob/bootldrpart.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- bootldrpart.c 2001/12/19 22:53:45 1.1
+++ bootldrpart.c 2001/12/26 23:38:36 1.2
@@ -39,13 +39,15 @@
-#define FLASH_PARTITION_NAMELEN 32
+#define BOOTLDR_PARTITION_NAMELEN 32
enum LFR_FLAGS {
LFR_SIZE_PREFIX = 1, /* prefix data with 4-byte size */
LFR_PATCH_BOOTLDR = 2, /* patch bootloader's 0th instruction */
LFR_KERNEL = 4, /* add BOOTIMG_MAGIC, imgsize and
VKERNEL_BASE to head of programmed
region (see bootldr.c) */
+ /* LFR_KERNEL is actually never used
+ * so it's safe to ignore -- Erik */
LFR_EXPAND = 8 /* expand partition size to fit rest
of flash */
};
@@ -54,7 +56,7 @@
typedef struct {
- char name[FLASH_PARTITION_NAMELEN];
+ char name[BOOTLDR_PARTITION_NAMELEN];
unsigned long base;
unsigned long size;
enum LFR_FLAGS flags;
@@ -67,7 +69,11 @@
int magic; /* should be filled with 0x646c7470 (btlp)
BOOTLDR_PARTITION_MAGIC */
int npartitions;
- FlashRegion partition[0];
+
+ /* the kernel code uses FlashRegion partition[0] over here,
+ * but because we want to allocate a partition table we'll
+ * have to use a certain maximum amount of partitions. */
+ FlashRegion partition[PART_MAX_PARTITIONS];
} BootldrFlashPartitionTable;
@@ -93,6 +99,12 @@
+/* used for construct_bootldr_partition_table() */
+static BootldrFlashPartitionTable bootldr_ptable;
+
+
+
+
static BootldrFlashPartitionTable *find_bootldr_partition_table(void)
{
BootldrFlashPartitionTable *table;
@@ -112,8 +124,6 @@
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
/* returns number of partitions, or negative error number otherwise */
int read_bootldr_partition_table(partition_table_t *ptable)
{
@@ -139,7 +149,7 @@
strlcpy(ptable->partition[i].name, bootldr->partition[i].name,
- MIN(PARTITION_NAMELEN, FLASH_PARTITION_NAMELEN));
+ PART_PARTITION_NAMELEN);
/* the caller should figure out the real size */
if(bootldr->partition[i].flags & LFR_EXPAND)
@@ -147,7 +157,7 @@
/* NOTE: this is a hack -- Erik */
if(strncmp(ptable->partition[i].name, "kernel",
- PARTITION_NAMELEN) == 0) {
+ PART_PARTITION_NAMELEN) == 0) {
ptable->partition[i].mem_base = KERNEL_RAM_BASE;
ptable->partition[i].entry_point = KERNEL_RAM_BASE;
ptable->partition[i].flags |= PART_LOAD;
@@ -155,11 +165,41 @@
/* NOTE: and this is a hack as well -- Erik */
if(strncmp(ptable->partition[i].name, "ramdisk",
- PARTITION_NAMELEN) == 0) {
+ PART_PARTITION_NAMELEN) == 0) {
ptable->partition[i].mem_base = RAMDISK_RAM_BASE;
ptable->partition[i].flags |= PART_LOAD;
}
}
return ptable->numpartitions;
+}
+
+
+
+
+int construct_bootldr_partition_table(const partition_table_t *src,
+ void** dst, int *len)
+{
+ int i;
+
+ bootldr_ptable.magic = BOOTLDR_PARTITION_MAGIC;
+ bootldr_ptable.npartitions = src->numpartitions;
+
+ for(i = 0; i < src->numpartitions; i++) {
+ bootldr_ptable.partition[i].flags = 0;
+
+ strlcpy(bootldr_ptable.partition[i].name,
+ src->partition[i].name, BOOTLDR_PARTITION_NAMELEN);
+ bootldr_ptable.partition[i].base = src->partition[i].offset;
+ bootldr_ptable.partition[i].size = src->partition[i].size;
+
+ if(src->partition[i].flags & PART_EXPAND)
+ bootldr_ptable.partition[i].flags |= LFR_EXPAND;
+ }
+
+ *dst = &bootldr_ptable;
+
+ *len = sizeof(bootldr_ptable);
+
+ return 0;
}
|