From 015cd976c6ff9a00fded2edbc617daf85b7b3ca1 Mon Sep 17 00:00:00 2001 From: Joshua Wise Date: Fri, 5 Sep 2008 17:50:16 -0400 Subject: [PATCH 1/1] Don't clear BSS if we don't need to. --- aseg/Makefile | 2 +- aseg/aseg.asm | 30 +++++++++++++++++++----------- aseg/counter.c | 3 ++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/aseg/Makefile b/aseg/Makefile index 5bef71f..20e5ae9 100644 --- a/aseg/Makefile +++ b/aseg/Makefile @@ -6,5 +6,5 @@ aseg.bin: aseg.asm aseg.o: aseg.bin objcopy -I binary -B i386 -O elf32-i386 aseg.bin aseg.o -aseg.elf: aseg.bin aseg.lds counter.o +aseg.elf: aseg.o aseg.lds counter.o ld -o aseg.elf -T aseg.lds counter.o diff --git a/aseg/aseg.asm b/aseg/aseg.asm index ee83272..244cafc 100644 --- a/aseg/aseg.asm +++ b/aseg/aseg.asm @@ -74,29 +74,34 @@ continue: mov al, [esp-6] out dx, al - mov al, 0 - mov edi, [dataptr+4] ; clear BSS - mov ecx, [dataptr+8] - rep stosb - mov dx, 0xCFC ; restore smramc mov al, [esp-5] out dx, al - - mov eax, [dataptr+12] - call eax - mov dx, 0xCF8 ; restore the old config value + mov dx, 0xCF8 ; restore the old PCI config value mov eax, [esp-4] out dx, eax + mov al, [needclear] + cmp al, 0 + jz noclear + mov al, 0 ; clear BSS + mov edi, [dataptr+4] + mov ecx, [dataptr+8] + rep stosb + mov [needclear], al + +noclear: + mov eax, [dataptr+12] ; jump into C + call eax + mov al, 0x40 ; ack the periodic IRQ mov dx, 0x834 out dx, al - mov dx, 0x830 + mov dx, 0x830 ; now ack the SMI itself in al, dx - or al, 0x02 ; now ack the SMI itself + or al, 0x02 and al, 0xBF out dx, al or al, 0x40 @@ -104,6 +109,9 @@ continue: rsm ; and leave SMM +needclear: + db 0x01 + align 0x4 gdtr: db 0x27, 0x00 diff --git a/aseg/counter.c b/aseg/counter.c index 891c075..edad021 100644 --- a/aseg/counter.c +++ b/aseg/counter.c @@ -3,7 +3,8 @@ char counter = 0; #define outb(port, val) \ ({ asm volatile("outb %0, %%dx" : : "a" ((unsigned char)(val)) , "d" ((unsigned short)(port))); }) -void __start (void) { +void __start (void) +{ counter++; outb (0x80, counter); } -- 2.43.0