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
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
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:
.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
void init_psaux(void)
{
interrupt(IRQ_TO_INTR(12), psaux_intr);
+ unmask_irq(12);
init_mouse();
set_mouse_bounds(0, 0, 319, 199);
%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
/* set the timer interrupt handler */
interrupt(IRQ_TO_INTR(0), timer_handler);
+ unmask_irq(0);
}
void set_alarm(unsigned long msec, void (*func)(void))