PERFORCE change 106125 for review

Warner Losh imp at FreeBSD.org
Thu Sep 14 16:32:08 PDT 2006


http://perforce.freebsd.org/chv.cgi?CH=106125

Change 106125 by imp at imp_lighthouse on 2006/09/14 23:31:13

	o Remove some unneeded printfs, shorten strings.
	o kill unneeded read the symbols code.
	o fix a couple of bugs with reading in chars.
	o read mac directly into mac rather than reading all of euid64 and
	  copying.
	
	This fixes a few bugs, and saves another 164 bytes.  boot2 now has
	> 1k (1056) free.  Almost, but not quite, enough to allow both
	MMC and SD support with FPGA loading...

Affected files ...

.. //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#18 edit

Differences ...

==== //depot/projects/arm/src/sys/boot/arm/at91/boot2/boot2.c#18 (text+ko) ====

@@ -68,7 +68,7 @@
 //#define PATH_KERNEL	"/boot/kernel/kernel"
 #define PATH_KERNEL	"/kernel.gz.tramp"
 
-#define NOPT		6
+#define NOPT		5
 
 #define OPT_SET(opt)	(1 << (opt))
 #define OPT_CHECK(opt)	((opts) & OPT_SET(opt))
@@ -105,20 +105,19 @@
 {
     ssize_t rv;
 
-    if ((size_t)(rv = fsread(inode, buf, nbyte)) != nbyte) {
-	printf("Invalid %s\n", "sector");
+    if ((size_t)(rv = fsread(inode, buf, nbyte)) != nbyte)
 	return -1;
-    }
     return 0;
 }
 
 static inline void
-getstr(void)
+getstr(int c)
 {
     char *s;
-    int c;
 
     s = cmd;
+    if (c)
+	*s++ = c;
     for (;;) {
 	switch (c = getc(10000)) {
 	case 0:
@@ -190,8 +189,6 @@
 #if 0
 	uint8_t euid64[8] = { 0x00, 0x30, 0x96, 0x20,
 			      0x00, 0x00, 0x00, 0x05 };
-#else
-	uint8_t euid64[8];
 #endif
 
 #if 0
@@ -202,25 +199,18 @@
 #endif
 	sig = 0;
 	EERead(0, (uint8_t *)&sig, sizeof(sig));
-	if (sig != 0xaa55aa55) {
-		printf("Bad signature %x\n", sig);
+	if (sig != 0xaa55aa55)
 		return;
-	}
-	EERead(48, euid64, sizeof(euid64));
-	mac[0] = euid64[0];
-	mac[1] = euid64[1];
-	mac[2] = euid64[2];
-	mac[3] = euid64[5];
-	mac[4] = euid64[6];
-	mac[5] = euid64[7];
-	printf("MAC Address %x:%x:%x:%x:%x:%x\n", mac[0],
+	EERead(48, mac, 3);
+	EERead(48+5, mac+3, 3);
+	printf("MAC %x:%x:%x:%x:%x:%x\n", mac[0],
 	  mac[1], mac[2], mac[3], mac[4], mac[5]);
 }
 
 int
 main(void)
 {
-    int autoboot;
+    int autoboot, c = 0;
     ino_t ino;
 
 #ifdef TSC_FPGA
@@ -253,14 +243,13 @@
 
     p_strcpy(kname, PATH_KERNEL);
     for (;;) {
-	printf("\nFreeBSD/arm boot\n"
-		   "Default: %s\n"
-		   "boot: ", kname);
-	if (!autoboot || getc(5) == -1)
-	    getstr();
+	printf("\nDefault: %s\nboot: ", kname);
+	if (!autoboot || (c = getc(2)) != -1)
+	    getstr(c);
 	else if (!autoboot)
 	    xputchar('\n');
 	autoboot = 0;
+	c = 0;
 	if (parse())
 	    xputchar('\a');
 	else
@@ -273,9 +262,6 @@
 {
     Elf32_Ehdr eh;
     static Elf32_Phdr ep[2];
-#if 0
-    static Elf32_Shdr es[2];
-#endif
     caddr_t p;
     ino_t ino;
     uint32_t addr;
@@ -305,30 +291,6 @@
 	if (xfsread(ino, p, ep[i].p_filesz))
 	    return;
     }
-#if 0
-    printf("3\n");
-    p += roundup2(ep[1].p_memsz, PAGE_SIZE);
-    if (eh.e_shnum == eh.e_shstrndx + 3) {
-	printf("4\n");
-	fs_off = eh.e_shoff + sizeof(es[0]) *
-	  (eh.e_shstrndx + 1);
-	printf("5\n");
-	if (xfsread(ino, &es, sizeof(es))) {
-	    printf("5a\n");
-	    return;
-	}
-	printf("6\n");
-	for (i = 0; i < 2; i++) {
-	    printf("6.%d\n", i);
-	    memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
-	    p += sizeof(es[i].sh_size);
-	    fs_off = es[i].sh_offset;
-	    if (xfsread(ino, p, es[i].sh_size))
-		return;
-	    p += es[i].sh_size;
-	}
-    }
-#endif
     addr = eh.e_entry;
     ((void(*)(int))addr)(RB_BOOTINFO | (opts & RBX_MASK));
 }
@@ -384,10 +346,8 @@
 	    if (dp[i].dp_typ == DOSPTYP_386BSD)
 		    break;
 	}
-	if (i == NDOSPART) {
-		printf("No BSD partition found\n");
+	if (i == NDOSPART)
 		return -1;
-	}
 	// Although dp_start is aligned within the disk partition structure,
 	// DOSPARTOFF is 446, which is only word (2) aligned, not longword (4)
 	// aligned.  Cope by using memcpy to fetch the start of this partition.


More information about the p4-projects mailing list