ppc64: Don't set Kp bit on SLB
[openbios.git] / arch / sparc64 / boot.c
blob2bb3a9e672f1974b24cae63cef16f093749dc579
1 /*
3 */
4 #undef BOOTSTRAP
5 #include "config.h"
6 #include "libopenbios/bindings.h"
7 #include "arch/common/nvram.h"
8 #include "libc/diskio.h"
9 #include "libc/vsprintf.h"
10 #include "libopenbios/sys_info.h"
11 #include "boot.h"
13 uint64_t kernel_image;
14 uint64_t kernel_size;
15 uint64_t qemu_cmdline;
16 uint64_t cmdline_size;
17 char boot_device;
19 extern int sparc64_of_client_interface( int *params );
22 void go(void)
24 ucell address, type, size;
25 int image_retval = 0;
27 /* Get the entry point and the type (see forth/debugging/client.fs) */
28 feval("saved-program-state >sps.entry @");
29 address = POP();
30 feval("saved-program-state >sps.file-type @");
31 type = POP();
32 feval("saved-program-state >sps.file-size @");
33 size = POP();
35 printk("\nJumping to entry point " FMT_ucellx " for type " FMT_ucellx "...\n", address, type);
37 switch (type) {
38 case 0x0:
39 /* Start ELF boot image */
40 image_retval = start_elf(address, (uint64_t)&elf_boot_notes);
41 break;
43 case 0x1:
44 /* Start ELF image */
45 image_retval = start_client_image(address, (uint64_t)&sparc64_of_client_interface);
46 break;
48 case 0x5:
49 /* Start a.out image */
50 image_retval = start_client_image(address, (uint64_t)&sparc64_of_client_interface);
51 break;
53 case 0x10:
54 /* Start Fcode image */
55 printk("Evaluating FCode...\n");
56 PUSH(address);
57 PUSH(1);
58 fword("byte-load");
59 image_retval = 0;
60 break;
62 case 0x11:
63 /* Start Forth image */
64 PUSH(address);
65 PUSH(size);
66 fword("eval2");
67 image_retval = 0;
68 break;
71 printk("Image returned with return value %#x\n", image_retval);
75 void boot(void)
77 char *path, *param;
79 /* Copy the incoming path */
80 fword("2dup");
81 path = pop_fstr_copy();
83 /* Boot preloaded kernel */
84 if (kernel_size) {
85 void (*entry)(unsigned long p1, unsigned long p2, unsigned long p3,
86 unsigned long p4, unsigned long p5);
88 printk("[sparc64] Kernel already loaded\n");
89 entry = (void *) (unsigned long)kernel_image;
90 entry(0, 0, 0, 0, (unsigned long)&sparc64_of_client_interface);
93 /* Invoke Linux directly -- probably not supported */
94 if(!path) {
95 /* No path specified, so grab defaults from /chosen */
96 push_str("bootpath");
97 push_str("/chosen");
98 fword("(find-dev)");
99 POP();
100 fword("get-package-property");
101 POP();
102 path = pop_fstr_copy();
105 param = strchr(path, ' ');
106 if(param) {
107 *param = '\0';
108 param++;
109 } else if (cmdline_size) {
110 param = (char *)qemu_cmdline;
111 } else {
112 push_str("boot-args");
113 push_str("/options");
114 fword("(find-dev)");
115 POP();
116 fword("get-package-property");
117 POP();
118 param = pop_fstr_copy();
121 /* Invoke platform-specific Linux loader */
122 linux_load(&sys_info, path, param);
124 free(path);