]> Joshua Wise's Git repositories - netwatch.git/commitdiff
Put BSS clearing in firstrun
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 25 Sep 2008 22:12:28 +0000 (18:12 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 25 Sep 2008 22:12:28 +0000 (18:12 -0400)
aseg/aseg.asm
aseg/aseg.lds
aseg/firstrun.c
grubload/multiboot_c.c
grubload/output.c
ich2/smram-ich2.c
include/smram.h

index a6f71c20cd79c5eed1b581654e9bfde5edaabb2a..7380dc0bac64c0ab689481a4f01f31e7326641ca 100644 (file)
@@ -22,18 +22,8 @@ continue:
        mov gs, ax
        mov ss, ax
        mov esp, [dataptr]              ; Load stack pointer.
-
-       mov al, [needclear]             ; Has the aseg been run before?
-       cmp al, 0                       ; If so,
-       jz noclear                      ; don't clear BSS.
-       mov al, 0                       ; Otherwise, clear BSS.
-       mov edi, [dataptr+4]
-       mov ecx, [dataptr+8]
-       rep stosb
-       mov [needclear], al
        
-noclear:
-       mov eax, [dataptr+12]           ; Load target jump address
+       mov eax, [dataptr+4]            ; Load target jump address
        call eax                        ; then jump into C.
 
        rsm                             ; and leave SMM
@@ -48,12 +38,7 @@ gdt:
        db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x93, 0xCF, 0x00       ; data segment
        db 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9B, 0xCF, 0x00       ; code segment
 
-needclear:
-       db 0x01
-
 dataptr:
        ; 4 bytes of stack top
-       ; 4 bytes of BSS start
-       ; 4 bytes of BSS length
        ; 4 bytes of C entry point
        ; These show up 
index e969a547ff826d23c7cecf6b8d217e79555d5eaf..83afbaeed1ef08323f9dc91b26df594a4dc2de54 100644 (file)
@@ -7,8 +7,6 @@ SECTIONS
                _start = .;
                aseg.o
                LONG(_stacktop);
-               LONG(_bss);
-               LONG(_bssend - _bss);
                LONG(smi_entry);
                *(.text);
                *(.data);
index c6eab7b29edaa736c3ecd75ef38d300d314027cd..9589a13432cf30db6a88e3d6780032d15fa2da33 100644 (file)
@@ -3,8 +3,20 @@
 #include <pci.h>
 #include <reg-82801b.h>
 #include "vga-overlay.h"
+#include <smram.h>
+
+extern int _bss, _bssend;
 
 void __firstrun_start() {
+       unsigned char *bp;
+       smram_state_t smram;
+       
+       smram = smram_save_state();
+       smram_tseg_set_state(SMRAM_TSEG_OPEN);
+       
+       for (bp = (void *)&_bss; (void *)bp < (void *)&_bssend; bp++)
+               *bp = 0;
+       
        dologf("NetWatch running");
 
        /* Try really hard to shut up USB_LEGKEY. */
@@ -17,5 +29,7 @@ void __firstrun_start() {
        outb(0x830, inb(0x830) | ICH2_SMI_EN_SWSMI_TMR_EN);
        outb(0x848, ICH2_DEVTRAP_EN_KBC_TRP_EN);
        smi_enable();
+       
+       smram_restore_state(smram);
 }
 
index 04f9b2f4f3bb3a901f9ba278b438753ac536dde9..17c1542cffcc1562ca2e4567801ca51e37c8f88d 100644 (file)
@@ -50,10 +50,10 @@ void c_start(unsigned int magic, struct mb_info *mbinfo)
 
        if (mbinfo->mod_cnt != 1)
                panic("Expected exactly one module; cannot continue.");
-
+       outputf("Current SMRAMC state is: %02x", pci_read8(0, 0, 0, 0x70));
        outputf("Current USB state is: %04x %04x", pci_read16(0, 31, 2, 0xC0), pci_read16(0, 31, 4, 0xC0));
        outputf("Current SMI state is: %08x", inl(0x830));
-       outputf("Current SMRAMC state is: %02x", pci_read8(0, 0, 0, 0x70));
+       
        
        smi_disable();
        
@@ -80,6 +80,8 @@ void c_start(unsigned int magic, struct mb_info *mbinfo)
 
        info->firstrun();
        smram_restore_state(old_smramc);
+       
+       outputf("New SMRAMC state is: %02x", pci_read8(0, 0, 0, 0x70));
 
        puts("Waiting for a bit before returning to real mode...");
        for (i=0; i<0x500000; i++)
index 6a6ffabc99698e5ec014170f2dc83b8f601bb301..6abc72ab6f1f7758695e62481b08f0d41c1186e5 100644 (file)
@@ -8,7 +8,7 @@
 
 static void safeputs(const char *s)
 {
-       unsigned long old = smram_save_state();
+       smram_state_t old = smram_save_state();
        smram_aseg_set_state(SMRAM_ASEG_SMMONLY);
        puts(s);
        smram_restore_state(old);
index d274c852028c497e932e91d4aa2df572bcbae605..edf8ad5ffda83d1f7a03a5264875da15910ebf07 100644 (file)
@@ -127,3 +127,25 @@ int smram_aseg_set_state (int open) {
 
        return 0;
 }
+
+int smram_tseg_set_state (int open) {
+       unsigned char smramc;
+
+       if (smram_locked())
+               return -1;
+               
+       smramc = pci_read8(0, 0, 0, SMRAMC);
+
+       switch (open)
+       {
+       case SMRAM_TSEG_OPEN:
+               smramc = (smramc & 0x8F) | 0x00;
+               break;
+       default:
+               return -1;
+       }
+
+       pci_write8(0, 0, 0, SMRAMC, smramc);
+
+       return 0;
+}
index 6c4ac69be6d6d1edd34cc19794d6294eeab8e6a6..5509d0913c96b07de004c281335c1149c2a73448 100644 (file)
@@ -6,11 +6,14 @@
 extern int smram_locked();
 extern smram_state_t smram_save_state();
 extern void smram_restore_state(smram_state_t state);
-extern int smram_aseg_set_state (int open);
+extern int smram_aseg_set_state(int open);
+extern int smram_tseg_set_state(int open);
 
 #define SMRAM_ASEG_CLOSED 0    /* SMRAM is not readable. */
 #define SMRAM_ASEG_OPEN 1      /* SMRAM is readable by everybody. */
 #define SMRAM_ASEG_SMMCODE 2   /* SMRAM is readable as SMM code only. */
 #define SMRAM_ASEG_SMMONLY 3   /* SMRAM is readable as SMM code and data only. */
 
+#define SMRAM_TSEG_OPEN 0
+
 #endif
This page took 0.040571 seconds and 4 git commands to generate.