From: John Tsiombikas Date: Tue, 3 Oct 2023 20:59:09 +0000 (+0300) Subject: clear bss and move on X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=deedd497760693c4810008f247d1fc5ce16455dd;p=com32 clear bss and move on --- diff --git a/com32.ld b/com32.ld index b83e861..701a0b4 100644 --- a/com32.ld +++ b/com32.ld @@ -25,7 +25,6 @@ SECTIONS { * (COMMON); . = ALIGN(4); _bss_end = .; - _bss_size = _bss_end - _bss_start; } . = ALIGN(4); diff --git a/src/intr.c b/src/intr.c index 6feb03d..29ca70e 100644 --- a/src/intr.c +++ b/src/intr.c @@ -90,6 +90,11 @@ void init_intr(void) interrupt(i, 0); } + /* mask all IRQs by default */ + for(i=0; i<16; i++) { + mask_irq(i); + } + /* by including intrtab.h here the series of INTR_ENTRY_* macros will be * expanded to a series of function prototypes for all interrupt entry * points and the corresponding calls to set_intr_entry to set up the IDT diff --git a/src/keyb.c b/src/keyb.c index b6e31f3..2b01408 100644 --- a/src/keyb.c +++ b/src/keyb.c @@ -57,6 +57,7 @@ void kb_init(void) interrupt(IRQ_TO_INTR(KB_IRQ), kbintr); kb_intr_enable(); + unmask_irq(KB_IRQ); } void kb_intr_enable(void) diff --git a/src/loader.asm b/src/loader.asm index 4cdb702..ea0de70 100644 --- a/src/loader.asm +++ b/src/loader.asm @@ -238,6 +238,13 @@ detect_memory: mov esi, str_fail call printstr + mov esi, memdet_cmos_msg + call printstr + call detect_mem_cmos + jnc .done + mov esi, str_fail + call printstr + mov si, memdet_fail_msg call printstr jmp exit @@ -249,9 +256,10 @@ detect_memory: str_ok db 'OK',10,0 str_fail db 'failed',10,0 memdet_fail_msg db 'Failed to detect available memory!',10,0 -memdet_e820_msg db "Detecting RAM (BIOS 15h/0xe820)... ",0 -memdet_e801_msg db "Detecting RAM (BIOS 15h/0xe801)... ",0 -memdet_88_msg db "Detecting RAM (BIOS 15h/0x88, max 64mb)... ",0 +memdet_e820_msg db 'Detecting RAM (BIOS 15h/0xe820)... ',0 +memdet_e801_msg db 'Detecting RAM (BIOS 15h/0xe801)... ',0 +memdet_88_msg db 'Detecting RAM (BIOS 15h/0x88, max 64mb)... ',0 +memdet_cmos_msg db 'Detecting RAM (CMOS)...',0 ; detect extended memory using BIOS call 15h/e820 detect_mem_e820: @@ -387,6 +395,32 @@ detect_mem_88: .fail: stc ret +detect_mem_cmos: + mov al, 31h + out 70h, al + in al, 71h + mov ah, al + mov al, 30h + out 70h, al + in al, 71h + + test ax, ax + jz .fail + + ; ax has size in KB, convert to bytes in eax + and eax, 0xffff + shl eax, 10 + + mov esi, mem_map + mov dword [si], 100000h + mov [si + 4], eax + mov dword [mem_map_size], 1 + clc + ret +.fail: stc + ret + + align 4 mem_map_size dd 0 mem_map times 128 db 0 diff --git a/src/psaux.c b/src/psaux.c index 4f1e2b0..a0fb58d 100644 --- a/src/psaux.c +++ b/src/psaux.c @@ -35,6 +35,7 @@ static int intr_mode; void init_psaux(void) { interrupt(IRQ_TO_INTR(12), psaux_intr); + unmask_irq(12); init_mouse(); set_mouse_bounds(0, 0, 319, 199); diff --git a/src/startup.asm b/src/startup.asm index 21e25e9..8c7dfbb 100644 --- a/src/startup.asm +++ b/src/startup.asm @@ -4,16 +4,25 @@ %include 'macros.inc' extern main + extern _bss_start + extern _bss_end global startup startup: - mov ebx, 0xb8000 + 156 - mov byte [ebx], '@' - mov byte [ebx + 2], '@' - mov byte [ebx + 160], '@' - mov byte [ebx + 162], '@' + ; clear .bss + mov eax, _bss_end + sub eax, _bss_start + test eax, eax + jz .nobss + mov ecx, eax + mov edi, _bss_start + xor eax, eax + shr ecx, 2 + rep stosd +.nobss: call main + cli ; XXX .waitkey: in al, 64h diff --git a/src/timer.c b/src/timer.c index da313f9..f4a812b 100644 --- a/src/timer.c +++ b/src/timer.c @@ -86,6 +86,7 @@ void init_timer(void) /* set the timer interrupt handler */ interrupt(IRQ_TO_INTR(0), timer_handler); + unmask_irq(0); } void set_alarm(unsigned long msec, void (*func)(void))