- smramc = pci_read8(0, 0, 0, 0x70);
- pci_write8(0, 0, 0, 0x70, (smramc & 0xF0) | 0x04);
- load_elf(wee->mods[0].mod_start, wee->mods[0].mod_end - wee->mods[0].mod_start);
- pci_write8(0, 0, 0, 0x70, smramc);
- outb(0x830, inb(0x830) | 0x41); /* turn on the SMIs we want */
-
+
+
+ /* Open the SMRAM aperture and load our ELF. */
+ smram_state_t old_smramc = smram_save_state();
+
+ if (smram_aseg_set_state(SMRAM_ASEG_OPEN) != 0)
+ {
+ puts("Opening SMRAM failed; cannot load ELF.\n");
+ }
+ else
+ {
+ load_elf(mods[0].mod_start, mods[0].mod_end - mods[0].mod_start);
+
+ struct info_section * info = (struct info_section *)0x10000;
+ if (info->signature != INFO_SIGNATURE)
+ {
+ smram_restore_state(old_smramc);
+ puts("Info section signature mismatch.\n");
+ }
+ else {
+ info->firstrun();
+ smram_restore_state(old_smramc);
+ }
+ }
+