[PATCH] 2/2 RFC: yaboot --bootonce (bootloader-space)
Dustin Kirkland
dustin.kirkland at us.ibm.com
Tue Sep 19 08:07:28 EST 2006
This is a not-yet-working prototype of the changes I suggest to the
second stage of yaboot to enable this bootonce capability.
This functionality should be relatively easy to accommodate, assuming
this list can help me clear up 2 items...
(1) I need to be able to access the prom_handle of the PReP boot device
in the context of the second/cfg.c functions. Can someone specifically
show me if/how I can pass/access this information in this context? In
the code below, I simply refer to it as prom_readblocks(disk... and
prom_writeblocks(disk... But I haven't been able to figure out how to
populate "prom_handle disk".
(2) There exists a prom_write() function, but this function has no
callers. I suppose this means that this function is substantially
untested? Assuming prom_write() works, a prom_writeblocks() that
mirrors prom_readblocks() would be a very nice helper. Anyone have any
information as to the workability of prom_write()?
Cowardly-commented-out patch follows ;-)
:-Dustin
Signed-off-by: Dustin Kirkland <dustin.kirkland at us.ibm.com>
diff -urpN yaboot.orig/include/prom.h yaboot.new/include/prom.h
--- yaboot.orig/include/prom.h 2006-09-13 18:01:49.000000000 -0500
+++ yaboot.new/include/prom.h 2006-09-18 16:44:58.000000000 -0500
@@ -53,6 +53,7 @@ int prom_write (prom_handle file, void *
int prom_seek (prom_handle file, int pos);
int prom_lseek (prom_handle file, unsigned long long pos);
int prom_readblocks (prom_handle file, int blockNum, int blockCount, void *buffer);
+// int prom_writeblocks (prom_handle file, int blockNum, int blockCount, void *buffer);
void prom_close (prom_handle file);
int prom_getblksize (prom_handle file);
int prom_loadmethod (prom_handle device, void* addr);
diff -urpN yaboot.orig/second/cfg.c yaboot.new/second/cfg.c
--- yaboot.orig/second/cfg.c 2006-09-13 18:01:49.000000000 -0500
+++ yaboot.new/second/cfg.c 2006-09-18 16:41:06.000000000 -0500
@@ -441,6 +441,20 @@ char *cfg_get_default (void)
char *label;
char *ret = cfg_get_strg_i (cf_options, "default");
+/*
+ * char bootonce[512];
+ * char zero[512];
+ * int i;
+ * for (i=0; i<512; i++)
+ * bootonce[i] = zero[i] = '\000';
+ * prom_readblocks(disk, 1600, 1, bootonce);
+ * prom_writeblocks(disk, 1600, 1, zero);
+ *
+ * if (bootonce)
+ * return bootonce;
+ */
+
if (ret)
return ret;
if (!images)
diff -urpN yaboot.orig/second/prom.c yaboot.new/second/prom.c
--- yaboot.orig/second/prom.c 2006-09-13 18:01:49.000000000 -0500
+++ yaboot.new/second/prom.c 2006-09-18 16:43:52.000000000 -0500
@@ -362,6 +362,31 @@ prom_readblocks (prom_handle dev, int bl
#endif
}
+/*
+ * int
+ * prom_writeblocks (prom_handle dev, int blockNum, int blockCount, void *buffer)
+ * {
+ * int status;
+ * unsigned int blksize;
+ *
+ * blksize = prom_getblksize(dev);
+ * if (blksize <= 1)
+ * blksize = 512;
+ * status = prom_seek(dev, blockNum * blksize);
+ * if (status != 1) {
+ * return 0;
+ * prom_printf("Can't seek to 0x%x\n", blockNum * blksize);
+ * }
+ *
+ * status = prom_write(dev, buffer, blockCount * blksize);
+ * // prom_printf("prom_writeblocks, bl: %d, cnt: %d, status: %d\n",
+ * // blockNum, blockCount, status);
+ *
+ * return status == (blockCount * blksize);
+ *
+ * }
+ */
+
int
prom_getchar ()
{
More information about the Yaboot-devel
mailing list