4 extern char _binary_realmode_bin_start[];
5 extern int _binary_realmode_bin_size;
10 unsigned long mem_lower, mem_upper;
11 unsigned long boot_dev;
13 unsigned long mod_cnt;
14 struct mod_info *mods;
25 void c_start(unsigned int magic, struct mb_info *wee)
27 unsigned short *grubptr = (unsigned short *)0x7CFE;
31 void (*realmode)() = (void (*)()) 0x4000;
35 puts("\nMultiboot header is: ");
45 for (i = 0; i < wee->mod_cnt; i++)
48 puts(" Start: "); puthex(wee->mods[i].mod_start); puts("\n");
49 puts(" Size: "); puthex(wee->mods[i].mod_end - wee->mods[i].mod_start); puts("\n");
50 puts(" Name: "); puts(wee->mods[i].mod_string); puts("\n");
53 if (wee->mod_cnt != 1)
55 puts("Expected exactly one module; cannot continue.\n");
59 puts("Current USB state is: "); puthex(pci_read16(0, 31, 2, 0xC0)); puts(" "); puthex(pci_read16(0, 31, 4, 0xC0)); puts("\n");
60 puts("Current SMI state is: "); puthex(inl(0x830)); puts("\n");
61 puts("Current SMRAMC state is: "); puthex(pci_read8(0, 0, 0, 0x70)); puts("\n");
63 outl(0x830, inl(0x830) & ~0x2001); /* turn off SMIs */
65 /* Try really hard to shut up USB_LEGKEY. */
66 pci_write16(0, 31, 2, 0xC0, pci_read16(0, 31, 2, 0xC0));
67 pci_write16(0, 31, 2, 0xC0, 0);
68 pci_write16(0, 31, 4, 0xC0, pci_read16(0, 31, 4, 0xC0));
69 pci_write16(0, 31, 4, 0xC0, 0);
70 smramc = pci_read8(0, 0, 0, 0x70);
71 pci_write8(0, 0, 0, 0x70, (smramc & 0xF0) | 0x04);
72 load_elf(wee->mods[0].mod_start, wee->mods[0].mod_end - wee->mods[0].mod_start);
73 pci_write8(0, 0, 0, 0x70, smramc);
74 outb(0x830, inb(0x830) | 0x41); /* turn on the SMIs we want */
76 puts("Waiting for a bit before returning to real mode...");
77 for (i=0; i<0x500000; i++)
79 if ((i % 0x100000) == 0)
85 puts("Now returning to real mode.\n");
86 memcpy(0x4000, _binary_realmode_bin_start, (int)&_binary_realmode_bin_size);
87 realmode(); // goodbye!