[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

aboot



Hi,

Attached you will find a patch for aboot which fixes the following
problems :

- compile with gcc 3.3
- initrd netboot support with cmdline. The patch expects the following
  data after net_aboot.nh :
  	4 bytes : kernel size
	4 bytes : initrd size
	kernel commandline (zero terminated) only first 255 chars are
	actually used due to kernel limitations
	gzipped kernel image
	gzipped initrd image

Note that the kernel image has to be linked at 0xfffffc0000810000 or
higher otherwise the aboot stack will be overwritten by the kernel
image.

Cheers,

p2.
diff -wur -x '*.o' -x '*.a' aboot-0.9/Makefile my-aboot-0.9/Makefile
--- aboot-0.9/Makefile	2003-08-03 20:00:37.000000000 +0200
+++ my-aboot-0.9/Makefile	2003-08-03 22:03:02.000000000 +0200
@@ -12,6 +12,8 @@
 KSRC		= /usr/src/linux
 VMLINUX		= $(KSRC)/vmlinux
 VMLINUXGZ	= $(KSRC)/arch/alpha/boot/vmlinux.gz
+INITRD		= netboot-initrd.gz
+CMDLINE		= cmdline
 
 # for userspace testing
 #TESTING	= yes
@@ -109,8 +111,11 @@
 	$(CC) $(ABOOT_OBJS) $(DISK_OBJS) -o $@ $(LIBS)
 endif
 
-vmlinux.bootp: net_aboot.nh $(VMLINUXGZ) net_pad
-	cat net_aboot.nh $(VMLINUXGZ) net_pad > $@
+vmlinux.bootp: net_aboot.nh net_aboot.lds
+	$(LD) -Tnet_aboot.lds -o $@
+
+net_aboot.lds: net_aboot.lds.in Makefile
+	$(CPP) -xc -P net_aboot.lds.in -o net_aboot.lds -DCMDLINE=\"$(CMDLINE)\" -DINITRD=\"$(INITRD)\" -DVMLINUXGZ=\"$(VMLINUXGZ)\" -DNET_ABOOT=\"net_aboot.nh\"
 
 net_aboot.nh: net_aboot tools/objstrip
 	tools/objstrip -vb net_aboot $@
diff -wur -x '*.o' -x '*.a' aboot-0.9/aboot.c my-aboot-0.9/aboot.c
--- aboot-0.9/aboot.c	2001-10-17 00:46:07.000000000 +0200
+++ my-aboot-0.9/aboot.c	2003-08-03 21:10:55.000000000 +0200
@@ -95,15 +95,15 @@
 		int i;
 		/* looks like an ELF binary: */
 		if (elf->e_type != ET_EXEC) {
-			printf("aboot: not an executable ELF file\n");
+			xprintf("aboot: not an executable ELF file\n");
 			return -1;
 		}
 		if (!aboot_elf_check_arch(elf)) {
-			printf("aboot: ELF executable not for this machine\n");
+			xprintf("aboot: ELF executable not for this machine\n");
 			return -1;
 		}
 		if (elf->e_phoff + elf->e_phnum * sizeof(*phdrs) > (unsigned) blocksize) {
-			printf("aboot: "
+			xprintf("aboot: "
 			       "ELF program headers not in first block (%ld)\n",
 			       (long) elf->e_phoff);
 			return -1;
@@ -114,7 +114,7 @@
 		start_addr = phdrs[0].p_vaddr; /* assume they are sorted */
 		entry_addr = elf->e_entry;
 #ifdef DEBUG
-		printf("aboot: %d program headers, start address %#lx, entry %#lx\n",
+		xprintf("aboot: %d program headers, start address %#lx, entry %#lx\n",
 		       nchunks, start_addr, entry_addr);
 #endif
 		for (i = 0; i < elf->e_phnum; ++i) {
@@ -122,7 +122,7 @@
 			chunks[i].offset = phdrs[i].p_offset;
 			chunks[i].size   = phdrs[i].p_filesz;
 #ifdef DEBUG
-			printf("aboot: segment %d vaddr %#lx offset %#lx size %#lx\n",
+			xprintf("aboot: segment %d vaddr %#lx offset %#lx size %#lx\n",
 			       i, chunks[i].addr, chunks[i].offset, chunks[i].size);
 #endif
 		}
@@ -131,7 +131,7 @@
 		bss_size = (phdrs[elf->e_phnum - 1].p_memsz -
 			    phdrs[elf->e_phnum - 1].p_filesz);
 #ifdef DEBUG
-		printf("aboot: bss at 0x%p, size %#lx\n", bss_start, bss_size);
+		xprintf("aboot: bss at 0x%p, size %#lx\n", bss_start, bss_size);
 #endif
 	} else {
 		/* Fail silently, it might be a compressed file */
@@ -164,14 +164,14 @@
 #else
 	result = cons_getenv(ENV_BOOTED_FILE, boot_file, sizeof(boot_file));
 	if (result < 0) {
-		printf("aboot: warning: can't get ENV_BOOTED_FILE "
+		xprintf("aboot: warning: can't get ENV_BOOTED_FILE "
 		       "(result=%lx)!\n", result);
 		strcpy(boot_file, "vmlinux.gz");
 	}
 	result = cons_getenv(ENV_BOOTED_OSFLAGS,
 			     kernel_args, sizeof(kernel_args));
 	if  (result < 0) {
-		printf("aboot: warning: can't get ENV_BOOTED_OSFLAGS "
+		xprintf("aboot: warning: can't get ENV_BOOTED_OSFLAGS "
 		       "(result=%lx)!\n", result);
 		strcpy(kernel_args, "i");
 	}
@@ -187,7 +187,7 @@
 
 void unzip_error(char *x)
 {
-	printf("unzip: %s\n", x);
+	xprintf("unzip: %s\n", x);
 }
 
 
@@ -199,7 +199,7 @@
 	get_boot_args();
 	result = load_kernel();
 	if (result < 0) {
-		printf("aboot: kernel load failed (%ld)\n", result);
+		xprintf("aboot: kernel load failed (%ld)\n", result);
 		return 0;
 	}
 	return 0;
@@ -217,11 +217,11 @@
 
 	cons_init();
 
-	printf("aboot: Linux/Alpha SRM bootloader version "ABOOT_VERSION"\n");
+	xprintf("aboot: Linux/Alpha SRM bootloader version "ABOOT_VERSION"\n");
 
 	/* don't know how to deal with this yet */
 	if (INIT_HWRPB->pagesize != 8192) {
-		printf("aboot: expected 8kB pages, got %ldkB\n",
+		xprintf("aboot: expected 8kB pages, got %ldkB\n",
 		       INIT_HWRPB->pagesize >> 10);
 		return;
 	}
@@ -230,10 +230,10 @@
 	get_boot_args();
 	result = load_kernel();
 	if (result < 0) {
-		printf("aboot: kernel load failed (%ld)\n", result);
+		xprintf("aboot: kernel load failed (%ld)\n", result);
 		return;
 	}
-	printf("aboot: starting kernel %s with arguments %s\n",
+	xprintf("aboot: starting kernel %s with arguments %s\n",
 	       boot_file, kernel_args);
 	strcpy((char*)start_addr + PARAM_OFFSET, kernel_args);
 	*(unsigned long *)(start_addr + PARAM_OFFSET + 0x100)
@@ -243,7 +243,7 @@
 
 	run_kernel(entry_addr, start_addr + STACK_OFFSET);
 
-	printf("aboot: kernel returned unexpectedly.  Halting slowly...\n");
+	xprintf("aboot: kernel returned unexpectedly.  Halting slowly...\n");
 	for (i = 0 ; i < 0x100000000 ; i++)
 		/* nothing */;
 	halt();
diff -wur -x '*.o' -x '*.a' aboot-0.9/cons.c my-aboot-0.9/cons.c
--- aboot-0.9/cons.c	2001-10-09 01:03:50.000000000 +0200
+++ my-aboot-0.9/cons.c	2003-07-27 00:07:12.000000000 +0200
@@ -127,7 +127,7 @@
 				retval = dispatch(CCB_READ, dev, iosize, buf,
 						  lbn);
 				if (retval != iosize) {
-					printf("read error 0x%lx\n",retval);
+					xprintf("read error 0x%lx\n",retval);
 					return -1;
 				}
 			} else {
@@ -138,7 +138,7 @@
 				retval = dispatch(CCB_READ, dev, SECT_SIZE,
 						  readbuf, lbn);
 				if (retval != SECT_SIZE) {
-					printf("read error, lbn %ld: 0x%lx\n",
+					xprintf("read error, lbn %ld: 0x%lx\n",
 					       lbn, retval);
 					return -1;
 				}
diff -wur -x '*.o' -x '*.a' aboot-0.9/disk.c my-aboot-0.9/disk.c
--- aboot-0.9/disk.c	2001-10-09 22:45:57.000000000 +0200
+++ my-aboot-0.9/disk.c	2003-07-27 00:07:24.000000000 +0200
@@ -72,7 +72,7 @@
 	long nread;
 	int i;
 
-	printf("aboot: loading kernel from boot sectors...\n");
+	xprintf("aboot: loading kernel from boot sectors...\n");
 
 	/* We only need the program headers so this should be fine */
 	buf = malloc(SECT_SIZE);
@@ -80,7 +80,7 @@
 	/* Read ELF headers: */
 	nread = cons_read(dev, buf, SECT_SIZE, ksect * SECT_SIZE);
 	if (nread != SECT_SIZE) {
-		printf("aboot: read returned %ld instead of %ld bytes\n",
+		xprintf("aboot: read returned %ld instead of %ld bytes\n",
 		       nread, (long) SECT_SIZE);
 		return -1;
 	}
@@ -91,7 +91,7 @@
 	for (i = 0; i < nchunks; ++i) {
 		char *dest;
 
-		printf("aboot: segment %d, %ld bytes at %#lx\n", i, chunks[i].size,
+		xprintf("aboot: segment %d, %ld bytes at %#lx\n", i, chunks[i].size,
 		       chunks[i].addr);
 #ifdef TESTING
 		dest = malloc(chunks[i].size);
@@ -102,7 +102,7 @@
 		nread = cons_read(dev, dest, chunks[i].size,
 				  chunks[i].offset + ksect * SECT_SIZE);
 		if (nread != chunks[i].size) {
-			printf("aboot: read returned %ld instead of %ld bytes\n",
+			xprintf("aboot: read returned %ld instead of %ld bytes\n",
 			       nread, chunks[i].size);
 			return -1;
 		}
@@ -123,7 +123,7 @@
 	/* read ELF headers: */
 	nread = (*bfs->bread)(fd, 0, 1, buf);
 	if (nread != bfs->blocksize) {
-		printf("aboot: read returned %ld instead of %ld bytes\n",
+		xprintf("aboot: read returned %ld instead of %ld bytes\n",
 		       nread, sizeof(buf));
 		return -1;
 	}
@@ -133,12 +133,12 @@
 	
 		for(i = 0; i < 16; i++) {
 			for (j = 0; j < 16; j++)
-				printf("%02X ", buf[j+16*i]);
+				xprintf("%02X ", buf[j+16*i]);
 			for(j = 0; j < 16; j++) {
 				c = buf[j+16*i];
-				printf("%c", (c >= ' ') ? c : ' ');
+				xprintf("%c", (c >= ' ') ? c : ' ');
 			}
-			printf("\n");
+			xprintf("\n");
 		}
 	}
 #endif
@@ -153,7 +153,7 @@
 		/* include any unaligned bits of the offset */
 		nblocks = (chunks[i].size + (chunks[i].offset & (bfs->blocksize - 1)) +
 			   bfs->blocksize - 1) / bfs->blocksize;
-		printf("aboot: segment %d, %ld bytes at %#lx\n", i, chunks[i].size,
+		xprintf("aboot: segment %d, %ld bytes at %#lx\n", i, chunks[i].size,
 		       chunks[i].addr);
 #ifdef TESTING
 		dest = malloc(nblocks * bfs->blocksize);
@@ -164,7 +164,7 @@
 		nread = (*bfs->bread)(fd, chunks[i].offset / bfs->blocksize,
 				      nblocks, dest);
 		if (nread != nblocks * bfs->blocksize) {
-			printf("aboot: read returned %ld instead of %ld bytes\n",
+			xprintf("aboot: read returned %ld instead of %ld bytes\n",
 			       nread, nblocks * bfs->blocksize);
 			return -1;
 		}
@@ -194,7 +194,7 @@
 #	define NUM_METHODS ((int)(sizeof(read_method)/sizeof(read_method[0])))
 
 #ifdef DEBUG
-	printf("read_kernel(%s)\n", filename);
+	xprintf("read_kernel(%s)\n", filename);
 #endif
 
 	method = 0;
@@ -209,10 +209,10 @@
 	for (attempt = 0; attempt < NUM_METHODS; ++attempt) {
 		fd = (*bfs->open)(filename);
 		if (fd < 0) {
-			printf("%s: file not found\n", filename);
+			xprintf("%s: file not found\n", filename);
 			return -1;
 		}
-		printf("aboot: loading %s %s...\n",
+		xprintf("aboot: loading %s %s...\n",
 		       read_method[method].name, filename);
 
 		if (!_setjmp(jump_buffer)) {
@@ -236,7 +236,7 @@
 
 	fd = (*bfs->open)(initrd_file);
 	if (fd < 0) {
-		printf("%s: file not found\n", initrd_file);
+		xprintf("%s: file not found\n", initrd_file);
 		return -1;
 	}
 	(*bfs->fstat)(fd, &buf);
@@ -255,12 +255,12 @@
 #endif
 
 	nblocks = initrd_size / bfs->blocksize;
-	printf("aboot: loading initrd (%ld bytes/%d blocks) at %#lx\n",
+	xprintf("aboot: loading initrd (%ld bytes/%d blocks) at %#lx\n",
 		initrd_size, nblocks, initrd_start);
 	if (nblocks & (bfs->blocksize - 1)) nblocks++;
 	nread = (*bfs->bread)(fd, 0, nblocks, (char*) initrd_start);
 	if (nread != nblocks * bfs->blocksize) {
-		printf("aboot: read returned %d instead of %d (%d*%d) bytes\n",
+		xprintf("aboot: read returned %d instead of %d (%d*%d) bytes\n",
 			nread, nblocks * bfs->blocksize,
 			nblocks, bfs->blocksize);
 		return -1;
@@ -275,12 +275,12 @@
 	long nread;
 
 #ifdef DEBUG
-	printf("load_label(dev=%lx)\n", dev);
+	xprintf("load_label(dev=%lx)\n", dev);
 #endif
 	nread = cons_read(dev, &lsect, LABELOFFSET + sizeof(*label),
 			  LABELSECTOR);
 	if (nread != LABELOFFSET + sizeof(*label)) {
-		printf("aboot: read of disklabel sector failed (nread=%ld)\n",
+		xprintf("aboot: read of disklabel sector failed (nread=%ld)\n",
 		       nread);
 		return;
 	}
@@ -288,10 +288,10 @@
 	if (label->d_magic  == DISKLABELMAGIC &&
 	    label->d_magic2 == DISKLABELMAGIC)
 	{
-		printf("aboot: valid disklabel found: %d partitions.\n",
+		xprintf("aboot: valid disklabel found: %d partitions.\n",
 		       label->d_npartitions);
 	} else {
-		printf("aboot: no disklabel found.\n");
+		xprintf("aboot: no disklabel found.\n");
 		label = 0;
 	}
 }
@@ -305,12 +305,12 @@
 	int i;
 
 #ifdef DEBUG
-	printf("mount_fs(%lx, %d)\n", dev, partition);
+	xprintf("mount_fs(%lx, %d)\n", dev, partition);
 #endif
 	if (partition == 0) {
 		fs = &dummyfs;
 		if ((*fs->mount)(dev, 0, 0) < 0) {
-			printf("aboot: disk mount failed\n");
+			xprintf("aboot: disk mount failed\n");
 			return 0;
 		}
 	} else if (!label) {
@@ -322,12 +322,12 @@
 			}
 		}
 		if (!fs) {
-			printf("aboot: unknown filesystem type\n");
+			xprintf("aboot: unknown filesystem type\n");
 			return 0;
 		}
 	} else {
 		if ((unsigned) (partition - 1) >= label->d_npartitions) {
-			printf("aboot: invalid partition %u\n", partition);
+			xprintf("aboot: invalid partition %u\n", partition);
 			return 0;
 		}
 		part = &label->d_partitions[partition - 1];
@@ -335,7 +335,7 @@
 			if (i + 1
 			    >= (int) (sizeof(bootfs)/sizeof(bootfs[0])))
 			{
-				printf("aboot: don't know how to mount "
+				xprintf("aboot: don't know how to mount "
 				       "partition %d (filesystem type %d)\n",
 				       partition, part->p_fstype);
 				return 0;
@@ -344,7 +344,7 @@
 		fs = bootfs[i];
 		if ((*fs->mount)(dev, (long)(part->p_offset) * (long)(label->d_secsize), 0)
 		    < 0) {
-			printf("aboot: mount of partition %d failed\n",
+			xprintf("aboot: mount of partition %d failed\n",
 			       partition);
 			return 0;
 		}
@@ -361,12 +361,12 @@
 	const char * ent;
 
 	if (fd < 0) {
-		printf("%s: directory not found\n", dir);
+		xprintf("%s: directory not found\n", dir);
 		return;
 	}
 	
 	while ((ent = (*fs->readdir)(fd, !rewind++))) {
-		printf("%s\n", ent);
+		xprintf("%s\n", ent);
 	}
 	(*fs->close)(fd);
 }
@@ -399,18 +399,18 @@
 
 	fd = open_config_file(fs);
 	if (fd < 0) {
-		printf("%s: file not found\n", CONFIG_FILE);
+		xprintf("%s: file not found\n", CONFIG_FILE);
 		return;
 	}
 	buf = malloc(fs->blocksize + 1);
 	if (!buf) {
-		printf("aboot: malloc failed!\n");
+		xprintf("aboot: malloc failed!\n");
 		return;
 	}
 	do {
 		nread = (*fs->bread)(fd, blkno++, 1, buf);
 		buf[nread] = '\0';
-		printf("%s", buf);
+		xprintf("%s", buf);
 	} while (nread > 0);
 	(*fs->close)(fd);
 }
@@ -425,12 +425,12 @@
 	*str = '\0';
 	fd = open_config_file(fs);
 	if (fd < 0) {
-		printf("%s: file not found\n", CONFIG_FILE);
+		xprintf("%s: file not found\n", CONFIG_FILE);
 		return -1;
 	}
 	buf = malloc(fs->blocksize);
 	if (!buf) {
-		printf("aboot: malloc failed!\n");
+		xprintf("aboot: malloc failed!\n");
 		return -1;
 	}
 	d = str;
@@ -468,7 +468,7 @@
 					state = 4;	/* copy string */
 				} else {
 					state = 2;	/* ignore rest */
-					printf("aboot: syntax error in line "
+					xprintf("aboot: syntax error in line "
 					       "%d: `:' expected\n", line);
 				}
 				break;
@@ -489,15 +489,15 @@
 	} while (nread > 0 && state != 5);
 	(*fs->close)(fd);
 #ifdef DEBUG
-	printf("get_default done\n");
+	xprintf("get_default done\n");
 #endif
 
 	if (state != 5) {
-		printf("aboot: could not find default config `%c'\n", num);
+		xprintf("aboot: could not find default config `%c'\n", num);
 		return -1;
 	}
 #ifdef DEBUG
-	printf("get_default_args(%s,%d)\n", str, num);
+	xprintf("get_default_args(%s,%d)\n", str, num);
 #endif
 	return 0;
 }
@@ -506,7 +506,7 @@
 static void
 print_help(void)
 {
-	printf("Commands:\n"
+	xprintf("Commands:\n"
 	       " h, ?			Display this message\n"
 	       " q			Halt the system and return to SRM\n"
 	       " p 1-8			Look in partition <num> for configuration/kernel\n"
@@ -525,7 +525,7 @@
 	int interactive = 0;  /* non-interactive */
 
 #ifdef DEBUG
-	printf("get_aboot_options(%lx)\n",dev);
+	xprintf("get_aboot_options(%lx)\n",dev);
 #endif
 
 	/* Forms of -flags argument from SRM */
@@ -539,7 +539,7 @@
 		config_file_partition = kernel_args[0] - '0';
 		preset = kernel_args[2];
 #ifdef DEBUG
-		printf("partition:preset = %ld:%c\n", config_file_partition,
+		xprintf("partition:preset = %ld:%c\n", config_file_partition,
 		       preset);
 #endif
 	} else if (kernel_args[0] && kernel_args[1] == '\0') {
@@ -565,7 +565,7 @@
 			/* If we have a setting from /etc/aboot.conf, use it */
 			if (preset) {
 #ifdef DEBUG
-				printf("trying preset %c\n", preset);
+				xprintf("trying preset %c\n", preset);
 #endif
 				if (!fs) {
 					fs = mount_fs(dev, config_file_partition);
@@ -585,18 +585,18 @@
 			/* Otherwise, clear out kernel_args and prompt the user */
 			kernel_args[0] = 0;
 			if (first) {
-				printf("Welcome to aboot " ABOOT_VERSION "\n");
+				xprintf("Welcome to aboot " ABOOT_VERSION "\n");
 				print_help();
 				first = 0;
 			}
-			printf("aboot> ");
+			xprintf("aboot> ");
 #ifdef TESTING
 			fgets(buf, sizeof(buf), stdin);
 			buf[strlen(buf)-1] = 0;
 #else
 			getline(buf, sizeof(buf));
 #endif
-			printf("\n");
+			xprintf("\n");
 
 			switch (buf[0]) {
 			case 'h':
@@ -615,14 +615,14 @@
 					config_file_partition = p[0] - '0';
 					fs = 0; /* force reread */
 				} else {
-					printf("Please specify a number between 1 and 8\n");
+					xprintf("Please specify a number between 1 and 8\n");
 				}
 				break;
 			case 'l':
 				if (!fs) {
 					fs = mount_fs(dev, config_file_partition);
 					if (!fs) {
-						printf("Partition %ld is invalid. "
+						xprintf("Partition %ld is invalid. "
 						       "Please specify another with 'p'\n",
 						       config_file_partition);
 						continue;
@@ -634,7 +634,7 @@
 				if (!fs) {
 					fs = mount_fs(dev, config_file_partition);
 					if (!fs) {
-						printf("Partition %ld is invalid. "
+						xprintf("Partition %ld is invalid. "
 						       "Please specify another with 'p'\n",
 						       config_file_partition);
 						continue;
@@ -656,7 +656,7 @@
 					strcpy(buf, p);
 					done = 1;
 				} else {
-					printf("Please specify a file to load the kernel from, "
+					xprintf("Please specify a file to load the kernel from, "
 					       "or '-' to load the kernel from the boot sector\n");
 				}
 				break;
@@ -667,7 +667,7 @@
 				if (p)
 					strcpy(initrd_file, p);
 				else {
-					printf("Please specify a file to use as initial ramdisk\n");
+					xprintf("Please specify a file to use as initial ramdisk\n");
 				}
 				break;
 			case '0' ... '9':
@@ -730,7 +730,7 @@
 	char *fname;
 
 #ifdef DEBUG
-	printf("load(%lx)\n", dev);
+	xprintf("load(%lx)\n", dev);
 #endif
 	fname = boot_file;
 	if (fname[0] == '-' && fname[1] == '\0') {
@@ -742,7 +742,7 @@
 		/* if there's no disklabel, boot_part will be ignored anyway */
 		bfs = mount_fs(dev, boot_part);
 		if (!bfs) {
-			printf("aboot: mount of partition %d failed\n", boot_part);
+			xprintf("aboot: mount of partition %d failed\n", boot_part);
 			return -1;
 		}
 		if (read_kernel(fname) < 0) {
@@ -750,7 +750,7 @@
 		}
 	}
 	/* clear bss: */
-	printf("aboot: zero-filling %ld bytes at 0x%p\n", bss_size, bss_start);
+	xprintf("aboot: zero-filling %ld bytes at 0x%p\n", bss_size, bss_start);
 #ifndef TESTING
 	memset((char*)bss_start, 0, bss_size);
 #endif
@@ -761,7 +761,7 @@
 	/* work around a bug in the ext2 code */
 	bfs = mount_fs(dev, boot_part);
 	if (!bfs) {
-		printf("aboot: mount of partition %d failed\n", boot_part);
+		xprintf("aboot: mount of partition %d failed\n", boot_part);
 		return -1;
 	}
 	if (read_initrd() < 0) {
@@ -784,20 +784,20 @@
 		strncpy(envval, e, sizeof(envval)-1);
 		envval[sizeof(envval)-1] = 0;
 	} else {
-		printf("aboot: Can't get BOOTED_DEV environment variable!\n");
+		xprintf("aboot: Can't get BOOTED_DEV environment variable!\n");
 		return -1;
 	}
 #else
 	if (cons_getenv(ENV_BOOTED_DEV, envval, sizeof(envval)) < 0) {
-		printf("aboot: Can't get BOOTED_DEV environment variable!\n");
+		xprintf("aboot: Can't get BOOTED_DEV environment variable!\n");
 		return -1;
 	}
 #endif
 
-	printf("aboot: booting from device '%s'\n", envval);
+	xprintf("aboot: booting from device '%s'\n", envval);
 	dev = cons_open(envval);
 	if (dev < 0) {
-		printf("aboot: unable to open boot device `%s': %lx\n",
+		xprintf("aboot: unable to open boot device `%s': %lx\n",
 		       envval, dev);
 		return -1;
 	}
@@ -813,7 +813,7 @@
 		strcpy(kernel_args, "i");
 	}
 #ifdef DEBUG
-	printf("load done\n");
+	xprintf("load done\n");
 #endif
 	cons_close(dev);
 	return result;
diff -wur -x '*.o' -x '*.a' aboot-0.9/fs/dummy.c my-aboot-0.9/fs/dummy.c
--- aboot-0.9/fs/dummy.c	2001-10-09 01:03:52.000000000 +0200
+++ my-aboot-0.9/fs/dummy.c	2003-07-27 00:11:29.000000000 +0200
@@ -58,7 +58,7 @@
 		      BOOT_SECTOR*SECT_SIZE + blkno*BLOCKSIZE + aboot_size)
 	    != nblks*BLOCKSIZE)
 	{
-		printf("dummy_bread: read error\n");
+		xprintf("dummy_bread: read error\n");
 		return -1;
 	}
 	return nblks*BLOCKSIZE;
diff -wur -x '*.o' -x '*.a' aboot-0.9/fs/ext2.c my-aboot-0.9/fs/ext2.c
--- aboot-0.9/fs/ext2.c	2001-10-10 05:32:52.000000000 +0200
+++ my-aboot-0.9/fs/ext2.c	2003-07-27 00:11:34.000000000 +0200
@@ -90,13 +90,13 @@
 	if (cons_read(dev, &sb, sizeof(sb), partition_offset + sb_offset)
 	    != sizeof(sb))
 	{
-		printf("ext2 sb read failed\n");
+		xprintf("ext2 sb read failed\n");
 		return -1;
 	}
 	
 	if (sb.s_magic != EXT2_SUPER_MAGIC) {
 		if (!quiet) {
-			printf("ext2_init: bad magic 0x%x\n", sb.s_magic);
+			xprintf("ext2_init: bad magic 0x%x\n", sb.s_magic);
 		}
 		return -1;
 	}
@@ -144,7 +144,7 @@
 	ip = 0;
 	for (i = 0; i < MAX_OPEN_FILES; i++) {
 #ifdef DEBUG
-		printf("ext2_iget: looping, entry %d inode %d free %d\n",
+		xprintf("ext2_iget: looping, entry %d inode %d free %d\n",
 		       i, inode_table[i].inumber, inode_table[i].free);
 #endif
 		if (inode_table[i].free) {
@@ -154,20 +154,20 @@
 		}
 	}
 	if (!ip) {
-		printf("ext2_iget: no free inodes\n");
+		xprintf("ext2_iget: no free inodes\n");
 		return NULL;
 	}
 
 	group = (ino-1) / sb.s_inodes_per_group;
 #ifdef DEBUG
-	printf("group is %d\n", group);
+	xprintf("group is %d\n", group);
 #endif
 	offset = partition_offset
 		+ ((long) gds[group].bg_inode_table * (long)ext2fs.blocksize)
 		+ (((ino - 1) % EXT2_INODES_PER_GROUP(&sb))
 		   * EXT2_INODE_SIZE(&sb));
 #ifdef DEBUG
-	printf("ext2_iget: reading %ld bytes at offset %ld "
+	xprintf("ext2_iget: reading %ld bytes at offset %ld "
 	       "(%ld + (%d * %d) + ((%d) %% %d) * %d) "
 	       "(inode %d -> table %d)\n", 
 	       sizeof(struct ext2_inode), offset, partition_offset,
@@ -178,7 +178,7 @@
 	if (cons_read(dev, ip, sizeof(struct ext2_inode), offset) 
 	    != sizeof(struct ext2_inode))
 	{
-		printf("ext2_iget: read error\n");
+		xprintf("ext2_iget: read error\n");
 		return NULL;
 	}
 
@@ -202,7 +202,7 @@
 	itp = (struct inode_table_entry *)ip;
 
 #ifdef DEBUG
-	printf("ext2_iput: inode %d table %d\n", itp->inumber,
+	xprintf("ext2_iput: inode %d table %d\n", itp->inumber,
 	       (int) (itp - inode_table));
 #endif
 	itp->inumber = 0;
@@ -252,7 +252,7 @@
 			if (cons_read(dev, iblkbuf, ext2fs.blocksize, offset)
 			    != ext2fs.blocksize)
 			{
-				printf("ext2_blkno: error on iblk read\n");
+				xprintf("ext2_blkno: error on iblk read\n");
 				return 0;
 			}
 			cached_iblkno = iblkno;
@@ -277,7 +277,7 @@
 			if (cons_read(dev, diblkbuf, ext2fs.blocksize, offset)
 			    != ext2fs.blocksize)
 			{
-				printf("ext2_blkno: err reading dindr blk\n");
+				xprintf("ext2_blkno: err reading dindr blk\n");
 				return 0;
 			}
 			cached_diblkno = diblkno;
@@ -297,7 +297,7 @@
 			if (cons_read(dev, iblkbuf, ext2fs.blocksize, offset)
 			    != ext2fs.blocksize)
 			{
-				printf("ext2_blkno: err on iblk read\n");
+				xprintf("ext2_blkno: err on iblk read\n");
 				return 0;
 			}
 			cached_iblkno = iblkno;
@@ -309,7 +309,7 @@
 	}
 
 	if (blkoff > ind2lim) {
-		printf("ext2_blkno: block number too large: %d\n", blkoff);
+		xprintf("ext2_blkno: block number too large: %d\n", blkoff);
 		return 0;
 	}
 	return -1;
@@ -345,13 +345,13 @@
 			/* Read it for real */
 			offset = partition_offset + (long) dev_blkno* (long) ext2fs.blocksize;
 #ifdef DEBUG
-			printf("ext2_bread: reading %ld bytes at offset %ld\n",
+			xprintf("ext2_bread: reading %ld bytes at offset %ld\n",
 			       nbytes, offset);
 #endif
 			if (cons_read(dev, buffer, nbytes, offset)
 			    != nbytes)
 			{
-				printf("ext2_bread: read error\n");
+				xprintf("ext2_bread: read error\n");
 				return -1;
 			}
 		}
@@ -377,7 +377,7 @@
 	}
 
 #ifdef DEBUG
-	printf("ext2_readdiri: blkoffset %d diroffset %d len %d\n",
+	xprintf("ext2_readdiri: blkoffset %d diroffset %d len %d\n",
 		blockoffset, diroffset, dir_inode->i_size);
 #endif
 	if (blockoffset >= ext2fs.blocksize) {
@@ -385,7 +385,7 @@
 		if (diroffset >= dir_inode->i_size)
 			return NULL;
 #ifdef DEBUG
-		printf("ext2_readdiri: reading block at %d\n",
+		xprintf("ext2_readdiri: reading block at %d\n",
 			diroffset);
 #endif
 		/* assume that this will read the whole block */
@@ -399,7 +399,7 @@
 	dp = (struct ext2_dir_entry_2 *) (blkbuf + blockoffset);
 	blockoffset += dp->rec_len;
 #ifdef DEBUG
-	printf("ext2_readdiri: returning %p = %.*s\n", dp, dp->name_len, dp->name);
+	xprintf("ext2_readdiri: returning %p = %.*s\n", dp, dp->name_len, dp->name);
 #endif
 	return dp;
 }
@@ -441,19 +441,19 @@
 			{
 				/* Found it! */
 #ifdef DEBUG
-				printf("ext2_namei: found entry %s\n",
+				xprintf("ext2_namei: found entry %s\n",
 					component);
 #endif
 				next_ino = dp->inode;
 				break;
 			}
 #ifdef DEBUG
-			printf("ext2_namei: looping\n");
+			xprintf("ext2_namei: looping\n");
 #endif
 		}
 	
 #ifdef DEBUG
-		printf("ext2_namei: next_ino = %d\n", next_ino);
+		xprintf("ext2_namei: next_ino = %d\n", next_ino);
 #endif
 
 		/*
@@ -509,7 +509,7 @@
 	struct ext2_inode * ip = &inode_table[fd].inode;
 	struct ext2_dir_entry_2 * ent;
 	if (!S_ISDIR(ip->i_mode)) {
-		printf("fd %d (inode %d) is not a directory (mode %x)\n",
+		xprintf("fd %d (inode %d) is not a directory (mode %x)\n",
 		       fd, inode_table[fd].inumber, ip->i_mode);
 		return NULL;
 	}
@@ -555,13 +555,13 @@
 		if (ext2_breadi(from, 0, 1, blkbuf) == -1)
 			return NULL;
 #ifdef DEBUG
-		printf("long link!\n");
+		xprintf("long link!\n");
 #endif
 	} else {
 		linkto = (char*)from->i_block;
 	}
 #ifdef DEBUG
-	printf("symlink to %s\n", linkto);
+	xprintf("symlink to %s\n", linkto);
 #endif
 
 	/* Resolve relative links */
@@ -573,7 +573,7 @@
 			fullname[end - base + 1] = '\0';
 			strcat(fullname, linkto);
 #ifdef DEBUG
-			printf("resolved to %s\n", fullname);
+			xprintf("resolved to %s\n", fullname);
 #endif
 			return ext2_namei(fullname);
 		} else {
diff -wur -x '*.o' -x '*.a' aboot-0.9/fs/iso.c my-aboot-0.9/fs/iso.c
--- aboot-0.9/fs/iso.c	2001-10-09 01:03:52.000000000 +0200
+++ my-aboot-0.9/fs/iso.c	2003-07-27 00:11:40.000000000 +0200
@@ -30,7 +30,7 @@
 iso_mount (long cons_dev, long p_offset, long quiet)
 {
 #ifdef DEBUG_ISO 
-	printf("iso_mount() called\n");
+	xprintf("iso_mount() called\n");
 #endif	
 	cd_device = cons_dev;
 	/*
diff -wur -x '*.o' -x '*.a' aboot-0.9/fs/ufs.c my-aboot-0.9/fs/ufs.c
--- aboot-0.9/fs/ufs.c	2001-10-09 01:03:52.000000000 +0200
+++ my-aboot-0.9/fs/ufs.c	2003-07-27 00:11:44.000000000 +0200
@@ -95,7 +95,7 @@
 
 	offset = fsbtodb(fs, disk_block) * DEV_BSIZE + partition_offset;
 	if (cons_read(dev, fp->f_buf, fs->fs_bsize, offset) != fs->fs_bsize) {
-		printf("ufs_read_inode: read error\n");
+		xprintf("ufs_read_inode: read error\n");
 		return 1;
 	}
 	dp = (struct dinode *)fp->f_buf;
@@ -169,7 +169,7 @@
 		file_block -= fp->f_nindir[level];
 	}
 	if (level == NIADDR) {
-		printf("ufs_block_map: block number too high\n");
+		xprintf("ufs_block_map: block number too high\n");
 		return -1;
 	}
 
@@ -192,7 +192,7 @@
 				      offset)
 			    != fs->fs_bsize) 
 			{
-				printf("ufs_block_map: read error\n");
+				xprintf("ufs_block_map: read error\n");
 				return -1;
 			}
 			fp->f_blkno[level] = ind_block_num;
@@ -241,7 +241,7 @@
 			offset = fsbtodb(fs, disk_block) * DEV_BSIZE
 			  + partition_offset;
 			if (cons_read(dev, buffer, nbytes, offset) != nbytes) {
-				printf("ufs_breadi: read error\n");
+				xprintf("ufs_breadi: read error\n");
 				return -1;
 			}
 		}
@@ -308,7 +308,7 @@
 	rc = cons_read(dev, buf, SBSIZE, SBLOCK*DEV_BSIZE + partition_offset);
 	if (rc != SBSIZE)
 	{
-		printf("ufs_mount: superblock read failed (retval=%ld)\n", rc);
+		xprintf("ufs_mount: superblock read failed (retval=%ld)\n", rc);
 		return -1;
 	}
 
@@ -318,7 +318,7 @@
 	    fs->fs_bsize < (int) sizeof(struct fs))
 	{
 		if (!quiet) {
-			printf("ufs_mount: invalid superblock "
+			xprintf("ufs_mount: invalid superblock "
 			       "(magic=%x, bsize=%d)\n",
 			       fs->fs_magic, fs->fs_bsize);
 		}
diff -wur -x '*.o' -x '*.a' aboot-0.9/include/utils.h my-aboot-0.9/include/utils.h
--- aboot-0.9/include/utils.h	2001-10-09 01:03:52.000000000 +0200
+++ my-aboot-0.9/include/utils.h	2003-08-03 22:13:43.000000000 +0200
@@ -6,7 +6,8 @@
 #ifdef TESTING
 #define pal_init()
 #else
-extern int		printf (const char *fmt, ...);
+extern int		xprintf (const char *fmt, ...)
+	__attribute__ ((format (printf, 1,2)));
 extern struct pcb_struct *find_pa (unsigned long vptb, struct pcb_struct *pcb);
 extern void		pal_init (void);
 
diff -wur -x '*.o' -x '*.a' aboot-0.9/lib/_longjmp.S my-aboot-0.9/lib/_longjmp.S
--- aboot-0.9/lib/_longjmp.S	2001-10-09 01:03:52.000000000 +0200
+++ my-aboot-0.9/lib/_longjmp.S	2003-07-27 01:33:30.000000000 +0200
@@ -4,7 +4,7 @@
 #include <setjmp.h>
 #include <asm/system.h>
 
-	.extern	printf
+	.extern	xprintf
 
 	.globl	_longjmp
 	.ent	_longjmp
@@ -54,8 +54,8 @@
 	.text
 bad_magic:
 	lda	$16, error_msg
-	lda	$27, printf
-	jsr	$27, printf
+	lda	$27, xprintf
+	jsr	$27, xprintf
 	call_pal PAL_halt
 
 	.end _longjmp
diff -wur -x '*.o' -x '*.a' aboot-0.9/lib/isolib.c my-aboot-0.9/lib/isolib.c
--- aboot-0.9/lib/isolib.c	2001-10-09 01:03:53.000000000 +0200
+++ my-aboot-0.9/lib/isolib.c	2003-07-27 00:10:34.000000000 +0200
@@ -125,7 +125,7 @@
 iso_bmap (struct iso_inode *inode, int block)
 {
 	if (block < 0) {
-		printf("iso_bmap: block<0");
+		xprintf("iso_bmap: block<0");
 		return 0;
 	}
 	return (inode->i_first_extent >> sb.s_blocksize_bits) + block;
@@ -192,7 +192,7 @@
 	int block;
 
 #ifdef DEBUG_ISO
-	printf("iso_iget(ino=%d)\n", ino);
+	xprintf("iso_iget(ino=%d)\n", ino);
 #endif
 
 	/* find a free inode to play with */
@@ -206,14 +206,14 @@
 		}
 	}
 	if ((inode == NULL) || (itp == NULL)) {
-		printf("iso9660 (iget): no free inodes\n");
+		xprintf("iso9660 (iget): no free inodes\n");
 		return (NULL);
 	}
 
 	block = ino >> sb.s_blocksize_bits;
 	if (iso_dev_read(data_block, block * sb.s_blocksize, sb.s_blocksize)
 	    != sb.s_blocksize) {
-		printf("iso9660: unable to read i-node block");
+		xprintf("iso9660: unable to read i-node block");
 		return NULL;
 	}
 
@@ -234,7 +234,7 @@
 		if (iso_dev_read(data_block, ++block * sb.s_blocksize,
 				 sb.s_blocksize)
 		    != sb.s_blocksize) {
-			printf("unable to read i-node block");
+			xprintf("unable to read i-node block");
 			return NULL;
 		}
 		memcpy((char *)cpnt+frag1, data_block, offset);
@@ -271,7 +271,7 @@
 	if((itp->size < 0 || itp->size > 700000000) &&
 	   sb.s_cruft == 'n')
 	{
-		printf("Warning: defective cdrom.  "
+		xprintf("Warning: defective cdrom.  "
 		       "Enabling \"cruft\" mount option.\n");
 		sb.s_cruft = 'y';
 	}
@@ -289,21 +289,21 @@
 	}
 
 	if (raw_inode->interleave[0]) {
-		printf("Interleaved files not (yet) supported.\n");
+		xprintf("Interleaved files not (yet) supported.\n");
 		itp->size = 0;
 	}
 
 	/* I have no idea what file_unit_size is used for, so
 	   we will flag it for now */
 	if (raw_inode->file_unit_size[0] != 0){
-		printf("File unit size != 0 for ISO file (%d).\n", ino);
+		xprintf("File unit size != 0 for ISO file (%d).\n", ino);
 	}
 
 	/* I have no idea what other flag bits are used for, so
 	   we will flag it for now */
 #ifdef DEBUG_ISO
 	if ((raw_inode->flags[-high_sierra] & ~2)!= 0){
-		printf("Unusual flag settings for ISO file (%d %x).\n",
+		xprintf("Unusual flag settings for ISO file (%d %x).\n",
 		       ino, raw_inode->flags[-high_sierra]);
 	}
 #endif
@@ -357,7 +357,7 @@
 		return 0;
 
 #ifdef DEBUG_ISO
-	printf("iso_match: comparing %d chars of %s with %s\n",
+	xprintf("iso_match: comparing %d chars of %s with %s\n",
 	       dlen, name, compare);
 #endif
 
@@ -523,21 +523,21 @@
 		if (match) {
 		  if ((int) inode_number == -1) {
 		    /* Should never happen */
-		    printf("iso9660: error inode_number = -1\n");
+		    xprintf("iso9660: error inode_number = -1\n");
 		    return -1;
 		  }
 
 		  *ino = inode_number;
 		  *ino_back = backlink;
 #ifdef DEBUG_ISO
-		  printf("iso_find_entry returning successfully (ino = %d)\n",
+		  xprintf("iso_find_entry returning successfully (ino = %d)\n",
 			 inode_number);
 #endif
 		  return 0;
 		}
 	}
 #ifdef DEBUG_ISO
-		  printf("iso_find_entry returning unsuccessfully (ino = %d)\n",
+		  xprintf("iso_find_entry returning unsuccessfully (ino = %d)\n",
 			 inode_number);
 #endif
 	return -1;
@@ -558,13 +558,13 @@
 	int first, last;
 
 #ifdef DEBUG_ISO
-	printf("iso_lookup: %s\n", name);
+	xprintf("iso_lookup: %s\n", name);
 #endif
 
 	/* is the current inode a directory? */
 	if (!S_ISDIR(itp->mode)) {
 #ifdef DEBUG_ISO
-		printf("iso_lookup: inode %d not a directory\n", itp->inumber);
+		xprintf("iso_lookup: inode %d not a directory\n", itp->inumber);
 #endif
 		iso_iput(dir);
 		return NULL;
@@ -623,7 +623,7 @@
 	char *linkto;
 	
 #ifdef DEBUG_ISO
-	printf("iso_follow_link(%s): ",basename);
+	xprintf("iso_follow_link(%s): ",basename);
 #endif
 
 	if (!S_ISLNK(itp->mode)) /* Hey, that's not a link! */
@@ -637,7 +637,7 @@
 
 	linkto[itp->size]='\0';
 #ifdef DEBUG_ISO
-	printf("%s->%s\n",basename,linkto ? linkto : "[failed]");
+	xprintf("%s->%s\n",basename,linkto ? linkto : "[failed]");
 #endif
 	
 	/* Resolve relative links. */
@@ -650,7 +650,7 @@
 			fullname[end - basename + 1] = '\0';
 			strcat(fullname, linkto);
 #ifdef DEBUG_ISO
-			printf("resolved to %s\n", fullname);
+			xprintf("resolved to %s\n", fullname);
 #endif
 			result = iso_lookup(root,fullname);
 		} else {
@@ -672,7 +672,7 @@
 iso_get_last_session (void)
 {
 #ifdef DEBUG_ISO 
-	printf("iso_get_last_session() called\n");
+	xprintf("iso_get_last_session() called\n");
 #endif	
 	return 0;
 }
@@ -702,7 +702,7 @@
 	}
 
 #ifdef DEBUG_ISO 
-	printf("iso_read_super() called\n");
+	xprintf("iso_read_super() called\n");
 #endif	
 
 	/* set up the block size */
@@ -716,12 +716,12 @@
 	for (iso_blknum = vol_desc_start+16; iso_blknum < vol_desc_start+100; 
 	     iso_blknum++) {
 #ifdef DEBUG_ISO
-		printf("iso_read_super: iso_blknum=%d\n", iso_blknum);
+		xprintf("iso_read_super: iso_blknum=%d\n", iso_blknum);
 #endif
 		if (iso_dev_read(data_block, iso_blknum * 2048,
 				 sb.s_blocksize) != sb.s_blocksize)
 		{
-			printf("iso_read_super: bread failed, dev "
+			xprintf("iso_read_super: bread failed, dev "
 			       "iso_blknum %d\n", iso_blknum);
 			return -1;
 		}
@@ -753,7 +753,7 @@
 	}
 	if(iso_blknum == vol_desc_start + 100) {
 		if (!silent)
-			printf("iso: Unable to identify CD-ROM format.\n");
+			xprintf("iso: Unable to identify CD-ROM format.\n");
 		return -1;
 	}
 	
@@ -761,7 +761,7 @@
 		rootp = (struct iso_directory_record *)
 			h_pri->root_directory_record;
 		if (isonum_723 (h_pri->volume_set_size) != 1) {
-			printf("Multi-volume disks not (yet) supported.\n");
+			xprintf("Multi-volume disks not (yet) supported.\n");
 			return -1;
 		};
 		sb.s_nzones = isonum_733 (h_pri->volume_space_size);
@@ -772,7 +772,7 @@
 		rootp = (struct iso_directory_record *)
 			pri->root_directory_record;
 		if (isonum_723 (pri->volume_set_size) != 1) {
-			printf("Multi-volume disks not (yet) supported.\n");
+			xprintf("Multi-volume disks not (yet) supported.\n");
 			return -1;
 		}
 		sb.s_nzones = isonum_733 (pri->volume_space_size);
@@ -790,7 +790,7 @@
 	      case 2048: sb.s_log_zone_size = 11; break;
 
 	      default:
-		printf("Bad logical zone size %ld\n", sb.s_log_zone_size);
+		xprintf("Bad logical zone size %ld\n", sb.s_log_zone_size);
 		return -1;
 	}
 
@@ -806,13 +806,13 @@
 	 */
 	if (first_time) {
 		first_time = 0;
-		printf("iso: Max size:%ld   Log zone size:%ld\n",
+		xprintf("iso: Max size:%ld   Log zone size:%ld\n",
 		       sb.s_max_size, 1UL << sb.s_log_zone_size);
-		printf("iso: First datazone:%ld   Root inode number %d\n",
+		xprintf("iso: First datazone:%ld   Root inode number %d\n",
 		       sb.s_firstdatazone >> sb.s_log_zone_size,
 		       isonum_733 (rootp->extent) << sb.s_log_zone_size);
 		if (high_sierra)
-			printf("iso: Disc in High Sierra format.\n");
+			xprintf("iso: Disc in High Sierra format.\n");
 	}
 
 	/* set up enough so that it can read an inode */
@@ -855,7 +855,7 @@
 	/* get the root directory */
 	root = iso_iget(root_inode);
 	if (!root) {
-		printf("iso9660: get root inode failed\n");
+		xprintf("iso9660: get root inode failed\n");
 		return -1;
 	}
 
@@ -864,10 +864,10 @@
 
 #ifdef DEBUG_ISO
 	if (inode && S_ISLNK(((struct inode_table_entry *)inode)->mode)) {
-		printf("%s is a link (len %u)\n",filename,
+		xprintf("%s is a link (len %u)\n",filename,
 		       ((struct inode_table_entry *)inode)->size);
 	} else {
-		printf("%s is not a link\n",filename);
+		xprintf("%s is not a link\n",filename);
 	}
 #endif
 
@@ -936,7 +936,7 @@
     static unsigned int blockoffset = 0, diroffset = 0;
     
     if (!S_ISDIR(itp->mode)) {
-	printf("Not a directory\n");
+	xprintf("Not a directory\n");
 	return NULL;
     }
     
@@ -945,7 +945,7 @@
 	blockoffset = diroffset = 0;
 	block = iso_bmap(&itp->inode,0); 
 #ifdef DEBUG_ISO
-	printf("fd #%d, inode %d, first_extent %d, block %u\n",
+	xprintf("fd #%d, inode %d, first_extent %d, block %u\n",
 	       fd,itp->inumber,itp->inode.i_first_extent,block);
 #endif
 	if (!block) return NULL;
@@ -960,7 +960,7 @@
 	dirent = (struct iso_directory_record *) (data_block + blockoffset);
 	dirent_len = isonum_711(dirent->length);
 #ifdef DEBUG_ISO
-	printf("diroffset=%u, blockoffset=%u, length=%u\n",
+	xprintf("diroffset=%u, blockoffset=%u, length=%u\n",
 	       diroffset,blockoffset,dirent_len);
 #endif
     
@@ -970,17 +970,17 @@
 	    diroffset = ((diroffset & ~(ISOFS_BLOCK_SIZE - 1))
 			 + ISOFS_BLOCK_SIZE);
 #ifdef DEBUG_ISO
-	    printf("dirent_len == 0. diroffset=%u, itp->size=%u. ",
+	    xprintf("dirent_len == 0. diroffset=%u, itp->size=%u. ",
 		   diroffset,itp->size);
 #endif
 	    if (diroffset >= itp->size) {
 #ifdef DEBUG_ISO
-		printf("End of directory.\n");
+		xprintf("End of directory.\n");
 #endif
 		return NULL;
 	    } else {
 #ifdef DEBUG_ISO
-		printf("End of sector. Need next block.\n");
+		xprintf("End of sector. Need next block.\n");
 #endif
 		/* Get the next block. */
 		block = iso_bmap(&itp->inode, diroffset>>sb.s_blocksize_bits);
@@ -993,7 +993,7 @@
 		dirent = (struct iso_directory_record *) data_block;
 		dirent_len = isonum_711(dirent->length);
 #ifdef DEBUG_ISO
-		printf("diroffset=%u, blockoffset=%u, length=%u\n",
+		xprintf("diroffset=%u, blockoffset=%u, length=%u\n",
 		       diroffset,blockoffset,dirent_len);
 #endif
 	    }
@@ -1011,7 +1011,7 @@
 	if (blockoffset >= sb.s_blocksize) {
 	    fraglen = sb.s_blocksize - oldoffset; 
 #ifdef DEBUG_ISO
-	    printf("fragmented block: blockoffset = %u, fraglen = %u\n",
+	    xprintf("fragmented block: blockoffset = %u, fraglen = %u\n",
 		   blockoffset, fraglen);
 #endif
 	    /* copy the fragment at end of old block to front of new buffer */
@@ -1023,7 +1023,7 @@
 	    if (iso_dev_read(big_data_block + fraglen, block * sb.s_blocksize, sb.s_blocksize) 
 		!= sb.s_blocksize) return NULL;
 #ifdef DEBUG_ISO
-	    printf("read %u bytes from offset %u\n",
+	    xprintf("read %u bytes from offset %u\n",
 		   sb.s_blocksize, block * sb.s_blocksize);
 #endif
 	    
@@ -1037,7 +1037,7 @@
 	 */
 	name_len = isonum_711(dirent->name_len);
 #ifdef DEBUG_ISO
-	if (name_len==0) printf("dirent->name_len = 0, skipping.\n");
+	if (name_len==0) xprintf("dirent->name_len = 0, skipping.\n");
 #endif
 	
 	/* skip '.' and '..' */
@@ -1105,7 +1105,7 @@
             int len = sb.s_blocksize - dirent_len;
 	    memcpy(data_block, big_data_block + dirent_len, len);
 #ifdef DEBUG_ISO
-	    printf("copied %u bytes of data back to data_block\n", len);
+	    xprintf("copied %u bytes of data back to data_block\n", len);
 #endif
 	    blockoffset = 0;
 	    fraglen = 0;
@@ -1160,7 +1160,7 @@
         cont_extent = cont_size = cont_offset = 0; \
         goto LABEL; \
     }; \
-    printf("Unable to read rock-ridge attributes\n");    \
+    xprintf("Unable to read rock-ridge attributes\n");    \
   }}
 
 int get_rock_ridge_filename(struct iso_directory_record * de,
@@ -1222,7 +1222,7 @@
 	}
 
 	if (rr->u.NM.flags & ~1) {
-	  printf("Unsupported NM flag settings (%d)\n",rr->u.NM.flags);
+	  xprintf("Unsupported NM flag settings (%d)\n",rr->u.NM.flags);
 	  break;
 	};
 	if((strlen(retname) + rr->len - 5) >= 254) {
@@ -1268,7 +1268,7 @@
   CONTINUE_DECLS;
 
 #ifdef DEBUG_ROCK
-  printf("parse_rock_ridge_inode(%u)\n",itp->inumber);
+  xprintf("parse_rock_ridge_inode(%u)\n",itp->inumber);
 #endif
 
   if (!sb.s_rock) return 0;
@@ -1291,35 +1291,35 @@
       switch(sig){
       case SIG('R','R'):
 #ifdef DEBUG_ROCK
-  printf("RR ");
+  xprintf("RR ");
 #endif
 	if((rr->u.RR.flags[0] & 
  	    (RR_PX | RR_TF | RR_SL | RR_CL)) == 0) goto out;
 	break;
       case SIG('S','P'):
 #ifdef DEBUG_ROCK
-  printf("SP ");
+  xprintf("SP ");
 #endif
 	CHECK_SP(goto out);
 	break;
       case SIG('C','E'):
 #ifdef DEBUG_ROCK
-  printf("CE ");
+  xprintf("CE ");
 #endif
 	CHECK_CE;
 	break;
       case SIG('E','R'):
 #ifdef DEBUG_ROCK
-	printf("ISO 9660 Extensions: ");
+	xprintf("ISO 9660 Extensions: ");
 	{ int p;
-	  for(p=0;p<rr->u.ER.len_id;p++) printf("%c",rr->u.ER.data[p]);
+	  for(p=0;p<rr->u.ER.len_id;p++) xprintf("%c",rr->u.ER.data[p]);
 	};
-	printf("\n");
+	xprintf("\n");
 #endif
 	break;
       case SIG('P','X'):
 #ifdef DEBUG_ROCK
-  printf("PX ");
+  xprintf("PX ");
 #endif
 	itp->mode  = isonum_733(rr->u.PX.mode);
 	itp->nlink = isonum_733(rr->u.PX.n_links);
@@ -1333,7 +1333,7 @@
 	break;
       case SIG('S','L'):
 #ifdef DEBUG_ROCK
-  printf("SL ");
+  xprintf("SL ");
 #endif
 	{int slen;
 	 struct SL_component * slp;
@@ -1358,7 +1358,7 @@
 	     itp->size += 1;
 	     break;
 	   default:
-	     printf("Symlink component flag not implemented\n");
+	     xprintf("Symlink component flag not implemented\n");
 	   };
 	   slen -= slp->len + 2;
 	   oldslp = slp;
@@ -1380,18 +1380,18 @@
 	symlink_len = itp->size;
 	break;
       case SIG('R','E'):
-	printf("Attempt to read inode for relocated directory\n");
+	xprintf("Attempt to read inode for relocated directory\n");
 	goto out;
       case SIG('C','L'):
 #ifdef DEBUG_ROCK
-  printf("CL(!) ");
+  xprintf("CL(!) ");
 #endif
         /* I'm unsure as to the function of this signature.
 	   We'll ignore it and hope that everything will be OK.
 	*/
 #if 0
 #ifdef DEBUG
-	printf("RR CL (%x)\n",inode->i_ino);
+	xprintf("RR CL (%x)\n",inode->i_ino);
 #endif
 	inode->inode.first_extent = isonum_733(rr->u.CL.location);
 	reloc = iso_iget(inode->i_sb,
@@ -1412,13 +1412,13 @@
   }
   MAYBE_CONTINUE(repeat);
 #ifdef DEBUG_ROCK
-  printf("\nparse_rock_ridge_inode(): ok\n");
+  xprintf("\nparse_rock_ridge_inode(): ok\n");
 #endif
   return 1;
  out:
   if(buffer) free(buffer);
 #ifdef DEBUG_ROCK
-  printf("\nparse_rock_ridge_inode(): failed\n");
+  xprintf("\nparse_rock_ridge_inode(): failed\n");
 #endif
   return 0;
 }
@@ -1443,7 +1443,7 @@
   struct rock_ridge * rr;
 
 #ifdef DEBUG_ROCK
-  printf("get_rock_ridge_symlink(%u): link is %u bytes long\n",itp->inumber, itp->size);
+  xprintf("get_rock_ridge_symlink(%u): link is %u bytes long\n",itp->inumber, itp->size);
 #endif
   
   if (!sb.s_rock) goto out;
@@ -1480,7 +1480,7 @@
     len -= rr->len;
     
 #ifdef DEBUG_ROCK
-    printf("%c%c ",chr[0],chr[1]);
+    xprintf("%c%c ",chr[0],chr[1]);
 #endif
     switch(sig){
     case SIG('R','R'):
@@ -1518,7 +1518,7 @@
 	   break;
 	 default:
 #ifdef DEBUG_ROCK
-	   printf("Symlink component flag not implemented (%d)\n",slen);
+	   xprintf("Symlink component flag not implemented (%d)\n",slen);
 #endif
 	 };
 	 slen -= slp->len + 2;
@@ -1555,7 +1555,7 @@
   
  out_freebh:
 #ifdef DEBUG_ROCK
-  printf("\nget_rock_ridge_symlink() exiting\n");
+  xprintf("\nget_rock_ridge_symlink() exiting\n");
 #endif
         if (buf)
 		free(buf);
@@ -1564,7 +1564,7 @@
 	/* error exit from macro */
 out:
 #ifdef DEBUG_ROCK
-	printf("abort");
+	xprintf("abort");
 #endif
 	if(buffer)
 		free(buffer);
@@ -1573,10 +1573,10 @@
 	rpnt = NULL;
 	goto out_freebh;
 out_noread:
-	printf("unable to read block");
+	xprintf("unable to read block");
 	goto out_freebh;
 out_bad_span:
-	printf("symlink spans iso9660 blocks\n");
+	xprintf("symlink spans iso9660 blocks\n");
 	goto out_freebh;
 }
 
diff -wur -x '*.o' -x '*.a' aboot-0.9/net.c my-aboot-0.9/net.c
--- aboot-0.9/net.c	2001-10-17 00:46:07.000000000 +0200
+++ my-aboot-0.9/net.c	2003-08-03 20:49:03.000000000 +0200
@@ -29,27 +29,33 @@
 #include <bootfs.h>
 #include <utils.h>
 
+#include "zip/gzip.h"
+#define LOCSIZ 18
+
+
 extern char boot_file[256];
+static char net_kernel_args[256];
+extern char _end;
+static char * imagebase; 
+static char * src = 0;
 
 void
 dang (void)
 {
-	printf("aboot: oops, unimplemented net-bfs function called!\n");
+	xprintf("aboot: oops, unimplemented net-bfs function called!\n");
 }
 
 
 int
 net_bread (int fd, long blkno, long nblks, char * buf)
 {
-        static char * src = 0;
-	extern char _end;
 	int nbytes;
 
 	if (!src)
-		src = (char *) (((unsigned long) &_end + 511) & ~511);
+		src = (char *) imagebase;
 
 #ifdef DEBUG
-	printf("net_bread: %p -> %p (%ld blocks at %ld)\n", src, buf,
+	xprintf("net_bread: %p -> %p (%ld blocks at %ld)\n", src, buf,
 	       nblks, blkno);
 #endif
 	nbytes = bfs->blocksize * nblks;
@@ -75,18 +81,52 @@
 long
 load_kernel (void)
 {
+	int kernel_size,net_kernel_args_len=0;
+	char *kargs=&net_kernel_args[0];
+
 	bfs = &netfs;
 
+	imagebase=(char *)(((unsigned long) &_end + 511) & ~511);
+	kernel_size=be32_to_cpu(((int *) imagebase)[0]);
+	initrd_size=be32_to_cpu(((int *) imagebase)[1]);
+	
+	imagebase+=8;
+
+	for(;(net_kernel_args_len < 255) && (*imagebase); net_kernel_args_len++)
+		*kargs++=*imagebase++;
+
+	if(net_kernel_args_len!=255)
+		*kargs++=*imagebase++;
+	else {
+		*kargs++=0;
+		while(*imagebase++);
+	}
+
 	strcpy(boot_file, "network");
 	uncompress_kernel(-1);
 
 	memset((char*)bss_start, 0, bss_size);	        /* clear bss */
 
+	if(kernel_args[0] == 'i' && !kernel_args[1]) {
 	while (kernel_args[0] == 'i' && !kernel_args[1]) {
-	    printf("Enter kernel arguments:\n");
-	    printf("aboot> ");
+	    		xprintf("Enter kernel arguments:\n");
+	    		xprintf("aboot> ");
 	    getline(kernel_args, sizeof(kernel_args));
-	    printf("\n");
+	    		xprintf("\n");
+		}
+	}
+	else 
+		strcpy(kernel_args,net_kernel_args);
+
+	imagebase+=kernel_size;
+
+	if(memcmp((char *)imagebase, GZIP_MAGIC, 2) == 0
+	   || memcmp((char *)imagebase, OLD_GZIP_MAGIC, 2) == 0) {
+	        if (!free_mem_ptr)
+	                free_mem_ptr = memory_end();
+		initrd_start = (free_mem_ptr - initrd_size) & ~(PAGE_SIZE-1);
+		free_mem_ptr = initrd_start;
+		memcpy(initrd_start, imagebase, initrd_size);
 	}
 	return 0;
 }
diff -wur -x '*.o' -x '*.a' aboot-0.9/tools/Makefile my-aboot-0.9/tools/Makefile
--- aboot-0.9/tools/Makefile	2001-10-09 01:03:53.000000000 +0200
+++ my-aboot-0.9/tools/Makefile	2003-08-03 20:04:24.000000000 +0200
@@ -13,7 +13,7 @@
 clean:
 	rm -f *~ *.o *.a core $(PGMS)
 
-isomarkboot:	isomarkboot.o ../lib/isolib.o
+isomarkboot:	isomarkboot.o ../lib/isolib.o xprintf.o
 e2writeboot:	e2writeboot.o e2lib.o bio.o
 
 e2writeboot.o:	e2lib.h
diff -wur -x '*.o' -x '*.a' aboot-0.9/utils.c my-aboot-0.9/utils.c
--- aboot-0.9/utils.c	2001-10-17 00:46:07.000000000 +0200
+++ my-aboot-0.9/utils.c	2003-08-03 21:14:17.000000000 +0200
@@ -14,7 +14,7 @@
 unsigned long free_mem_ptr = 0;
 
 
-int printf(const char *fmt, ...)
+int xprintf(const char *fmt, ...)
 {
 	static char buf[1024];
 	va_list args;
@@ -105,7 +105,7 @@
 	pcb_va->unique = 0;
 	pcb_va->flags = 1;
 	pcb_pa = find_pa((unsigned long *) old_vptb, pcb_va);
-	printf("aboot: switching to OSF/1 PALcode");
+	xprintf("aboot: switching to OSF/1 PALcode");
 	/*
 	 * a0 = 2 (OSF)
 	 * a1 = return address, but we give the asm the virtual addr of the PCB
@@ -120,7 +120,7 @@
 		new_vptb,
 		0);
 	if (i) {
-		printf("---failed, code %ld\n", i);
+		xprintf("---failed, code %ld\n", i);
 		halt();
 	}
 	rev = percpu->pal_revision = percpu->palcode_avail[2];
@@ -133,7 +133,7 @@
 		sum += *l;
 	INIT_HWRPB->chksum = sum;
 
-	printf(" version %ld.%ld\n", (rev >> 8) & 0xff, rev & 0xff);
+	xprintf(" version %ld.%ld\n", (rev >> 8) & 0xff, rev & 0xff);
 	/* remove the old virtual page-table mapping */
 	L1[1] = 0;
 	tbia();
@@ -169,14 +169,14 @@
 
 static void error(char *x)
 {
-	printf("%s\n", x);
+	xprintf("%s\n", x);
 	_longjmp(jump_buffer, 1);
 }
 
 
 void unzip_error(char *x)
 {
-	printf("\nunzip: ");
+	xprintf("\nunzip: ");
 	error(x);
 }
 
@@ -191,6 +191,7 @@
 	if ((char*) free_mem_ptr <= dest_addr + INIT_HWRPB->pagesize) {
 		error("\nout of memory");
 	}
+
 	return (void*) free_mem_ptr;
 }
 
diff -wur -x '*.o' -x '*.a' aboot-0.9/zip/misc.c my-aboot-0.9/zip/misc.c
--- aboot-0.9/zip/misc.c	2001-10-09 01:03:54.000000000 +0200
+++ my-aboot-0.9/zip/misc.c	2003-08-03 22:01:29.000000000 +0200
@@ -19,7 +19,6 @@
 #include "utils.h"
 #include "gzip.h"
 
-
 unsigned char *inbuf;
 unsigned char *window;
 unsigned outcnt;
@@ -179,7 +178,7 @@
 	long nblocks, nread;
 
 	if (INBUFSIZ % bfs->blocksize != 0) {
-		printf("INBUFSIZ (%d) is not multiple of block-size (%d)\n",
+		xprintf("INBUFSIZ (%d) is not multiple of block-size (%d)\n",
 		       INBUFSIZ, bfs->blocksize);
 		unzip_error("bad block-size");
 	}
@@ -191,19 +190,19 @@
 	nblocks = INBUFSIZ / bfs->blocksize;
 	nread = (*bfs->bread)(input_fd, block_number, nblocks, inbuf);
 #ifdef DEBUG
-	printf("read %ld blocks of %d, got %ld\n", nblocks, bfs->blocksize,
+	xprintf("read %ld blocks of %d, got %ld\n", nblocks, bfs->blocksize,
 	       nread);
 #endif
 	if (nread != nblocks * bfs->blocksize) {
 		if (nread < nblocks * bfs->blocksize) {
 			/* this is the EOF */
 #ifdef DEBUG
-			printf("at EOF\n");
+			xprintf("at EOF\n");
 #endif
 			insize = nblocks * bfs->blocksize;
 			block_number = -1;
 		} else {
-			printf("Read returned %ld instead of %ld bytes\n",
+			xprintf("Read returned %ld instead of %ld bytes\n",
 			       nread, nblocks * bfs->blocksize);
 			unzip_error("read error");
 		}
@@ -253,7 +252,7 @@
 
 		/* print a vanity message */
 		if (chunk_offset == 0)
-			printf("aboot: segment %d, %ld bytes at %#lx\n",
+			xprintf("aboot: segment %d, %ld bytes at %#lx\n",
 			       chunk, chunks[chunk].size,
 			       chunks[chunk].addr);
 
@@ -262,7 +261,7 @@
 		if (to_copy > outcnt)
 			to_copy = outcnt;
 #ifdef DEBUG
-		printf("copying %ld bytes from offset %#lx "
+		xprintf("copying %ld bytes from offset %#lx "
 		       "(segment %d) to %p\n",
 		       to_copy, file_offset, chunk, dest);
 #endif
@@ -273,7 +272,7 @@
 
 		if (to_copy < outcnt) {
 #ifdef DEBUG
-			printf("new segment or EOF\n");
+			xprintf("new segment or EOF\n");
 #endif
 			outcnt -= to_copy;
 			chunk++;

Reply to: