6 #include "libopenbios/bindings.h"
7 #include "arch/common/nvram.h"
8 #include "drivers/drivers.h"
9 #include "libc/diskio.h"
10 #include "libc/vsprintf.h"
11 #include "libopenbios/sys_info.h"
16 uint32_t kernel_image
;
18 uint32_t qemu_cmdline
;
19 uint32_t cmdline_size
;
25 ucell address
, type
, size
;
26 int image_retval
= 0, proplen
, unit
, part
;
28 char *prop
, *id
, bootid
;
29 static char bootpathbuf
[128], bootargsbuf
[128], buf
[128];
31 /* Get the entry point and the type (see forth/debugging/client.fs) */
32 feval("saved-program-state >sps.entry @");
34 feval("saved-program-state >sps.file-type @");
36 feval("saved-program-state >sps.file-size @");
39 /* SPARC32 is slightly unusual in that before invoking any loaders, a romvec array
40 needs to be set up to pass certain parameters using a C struct. Hence this section
41 extracts the relevant boot information and places it in obp_arg. */
43 /* Get the name of the selected boot device, along with the device and unit number */
44 chosen
= find_dev("/chosen");
45 prop
= get_property(chosen
, "bootpath", &proplen
);
46 strncpy(bootpathbuf
, prop
, proplen
);
47 prop
= get_property(chosen
, "bootargs", &proplen
);
48 strncpy(bootargsbuf
, prop
, proplen
);
50 /* Set bootpath pointer used in romvec table to the bootpath */
51 bootpath
= bootpathbuf
;
53 if (!strcmp(bootpathbuf
, "cdrom") || !strcmp(bootpathbuf
, "disk")) {
55 /* Controller currently always 0 */
56 obp_arg
.boot_dev_ctrl
= 0;
58 /* Grab the device and unit number string (in form unit,partition) */
59 push_str(bootpathbuf
);
60 feval("pathres-resolve-aliases ascii @ right-split 2drop");
63 /* A bit hacky, but we have no atoi() function */
67 obp_arg
.boot_dev_unit
= unit
;
68 obp_arg
.dev_partition
= part
;
70 /* Generate the "oldpath"
71 FIXME: hardcoding this looks almost definitely wrong.
72 With sd(0,2,0):b we get to see the solaris kernel though */
73 if (!strcmp(bootpathbuf
, "disk"))
78 snprintf(buf
, sizeof(buf
), "sd(0,%d,%d):%c", unit
, part
, bootid
);
80 obp_arg
.boot_dev
[0] = buf
[0];
81 obp_arg
.boot_dev
[1] = buf
[1];
82 obp_arg
.argv
[0] = buf
;
83 obp_arg
.argv
[1] = bootargsbuf
;
85 } else if (!strcmp(bootpathbuf
, "floppy")) {
87 obp_arg
.boot_dev_ctrl
= 0;
88 obp_arg
.boot_dev_unit
= 0;
89 obp_arg
.dev_partition
= 0;
93 obp_arg
.boot_dev
[0] = buf
[0];
94 obp_arg
.boot_dev
[1] = buf
[1];
95 obp_arg
.argv
[0] = buf
;
96 obp_arg
.argv
[1] = bootargsbuf
;
98 } else if (!strcmp(bootpathbuf
, "net")) {
100 obp_arg
.boot_dev_ctrl
= 0;
101 obp_arg
.boot_dev_unit
= 0;
102 obp_arg
.dev_partition
= 0;
106 obp_arg
.boot_dev
[0] = buf
[0];
107 obp_arg
.boot_dev
[1] = buf
[1];
108 obp_arg
.argv
[0] = buf
;
109 obp_arg
.argv
[1] = bootargsbuf
;
113 printk("\nJumping to entry point " FMT_ucellx
" for type " FMT_ucellx
"...\n", address
, type
);
117 /* Start ELF boot image */
118 image_retval
= start_elf((unsigned long)address
,
119 (unsigned long)romvec
);
124 /* Start ELF image */
125 image_retval
= start_elf((unsigned long)address
,
126 (unsigned long)romvec
);
131 /* Start a.out image */
132 image_retval
= start_elf((unsigned long)address
,
133 (unsigned long)romvec
);
138 /* Start Fcode image */
139 printk("Evaluating FCode...\n");
147 /* Start Forth image */
155 printk("Image returned with return value %#x\n", image_retval
);
161 /* Boot preloaded kernel */
163 printk("[sparc] Kernel already loaded\n");
164 start_elf(kernel_image
, (unsigned long)romvec
);