PERFORCE change 104740 for review
Warner Losh
imp at FreeBSD.org
Mon Aug 21 23:57:15 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=104740
Change 104740 by imp at imp_lighthouse on 2006/08/21 23:57:05
Restore missing bits from x86 boot2.
We can now read a kernel, it seems, at least up through offset
0x20fe00, or 2,162,176 (which should be more than enough to load
a 1MB kernel...)
Affected files ...
.. //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#8 edit
Differences ...
==== //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#8 (text+ko) ====
@@ -102,10 +102,11 @@
unsigned char mac[6] = { 0x42, 0x53, 0x44, 0, 0, 1 };
-int dsk_start;
+unsigned dsk_start;
static char cmd[512];
static char kname[1024];
static uint32_t opts;
+static int dsk_meta;
//static int comspeed = SIOSPD;
static void load(void);
@@ -138,7 +139,7 @@
xfsread(ino_t inode, void *buf, size_t nbyte)
{
if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
- printf("Invalid %s\r\n", "format");
+ printf("Invalid %s\r\n", "sector");
return -1;
}
return 0;
@@ -250,7 +251,7 @@
if (xfsread(ino, &eh, sizeof(eh)))
return;
if (!IS_ELF(eh)) {
- printf("Invalid format\r\n");
+ printf("Invalid %s\r\n", "format");
return;
}
fs_off = eh.e_phoff;
@@ -325,7 +326,7 @@
struct dos_partition *dp;
struct disklabel *d;
char *sec;
- unsigned sl;
+ int i;
if (!dsk_meta) {
sec = dmadat->secbuf;
@@ -333,12 +334,29 @@
if (drvread(sec, DOSBBSECTOR, 1))
return -1;
dp = (void *)(sec + DOSPARTOFF);
- sl = 1;
+ for (i = 0; i < NDOSPART; i++) {
+ if (dp[i].dp_typ == DOSPTYP_386BSD)
+ break;
+ }
+ if (i == NDOSPART) {
+ printf("No BSD partition found\r\n");
+ return -1;
+ }
+ memcpy(&dsk_start, &dp[i].dp_start, 4);
if (drvread(sec, dsk_start + LABELSECTOR, 1))
return -1;
d = (void *)(sec + LABELOFFSET);
+ if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) {
+ printf("Invalid %s\r\n", "label");
+ return -1;
+ }
+ if (!d->d_partitions[0].p_size) {
+ printf("Invalid %s\r\n", "partition");
+ return -1;
+ }
dsk_start += d->d_partitions[0].p_offset;
dsk_start -= d->d_partitions[RAW_PART].p_offset;
+ dsk_meta++;
}
return drvread(buf, dsk_start + lba, nblk);
}
More information about the p4-projects
mailing list