]> wirehaze git hosting - BOS.git/blob - kernel/kernel.asm

wirehaze git hosting

made it assemble under os x, moved loading position of kernel + install script for osx
[BOS.git] / kernel / kernel.asm
1 ;-------------------------------------------------------;
2 ; BOS kernel ;
3 ;-------------------------------------------------------;
4 ; BOS 32-bit kernel, expects to be loaded at 64kb ;
5 ; in mem. Small amount of 16-bit code included. ;
6 ; ;
7 ; For any comments on this code, mail me. ;
8 ; http://bos.asmhackers.net/ asmhacker@gmail.com ;
9 ; ;
10 ; by: Christoffer Bubach, 2003-2005 ;
11 ;-------------------------------------------------------;
12 use16
13 org 0x8000
14
15 ;---------------------------;
16 ; jump to starting point ;
17 ;---------------------------;
18 jmp start
19
20 ;----------------------------------------;
21 ; 16-bit include files ;
22 ;----------------------------------------;
23 include 'realmode/a20.inc' ; Function to set the a20-gate.
24 include 'realmode/gdt.inc' ; Global Description Table.
25 include 'realmode/idt.inc' ; The Interrupt Description Table.
26 include 'realmode/mem.inc' ; Get memory size.
27 include 'realmode/variables.inc' ; For/from realmode.
28 include 'realmode/do_all_16bit.inc' ; Save "go back to 16-bit"-info.
29
30
31
32 ;--------------------------;
33 ; 16-bit entry point ;
34 ;--------------------------;
35 start:
36 cli
37 mov ax, cs
38 mov ds, ax
39 ; fasm is more strict about
40 xor eax, eax ; "org 0x10000" then nasm, so
41 mov es, ax ; i have to do -0x10000 from
42 mov fs, ax ; all variable addresses while
43 mov gs, ax ; in realmode.
44 sti
45
46 call enable_a20
47 call do_all_16bit ; ... :P
48
49 cli
50 mov ax, cs ; save cs
51 mov [realmode_cs], ax ; in variables.inc
52
53 lgdt [gdtr] ; Load the GDT descriptor
54 lidt [idtr] ; Load the IDT descriptor
55
56 mov eax, cr0
57 or al, 1
58 mov cr0, eax
59
60 jmp pword 0x08:flush ; dword in nasm
61
62
63
64 ;--------------------------;
65 ; 32-bit entry point ;
66 ;--------------------------;
67 use32
68 flush:
69 mov ax, 0x10 ; refresh all segment registers
70 mov ds, ax
71 mov es, ax
72 mov fs, ax
73 mov gs, ax
74 mov ss, ax
75 mov esp, 0xFFFC
76
77 call bos_init ; fix everything
78
79 mov bx, 0x04B1 ; start the shell
80 call setcursor
81 mov esi, bos_shell
82 mov bl, 0x07
83 call print
84 call init_cmd
85 jmp shell
86
87 ;int 0x32
88
89 .hang:
90 cli
91 hlt
92 jmp .hang ; hang, just in case..
93
94
95 ;----------------------------------------;
96 ; 32-bit include files ;
97 ;----------------------------------------;
98 include 'krl_incs/idt.inc' ; The Interrupt Description Table.
99 include 'krl_incs/text.inc' ; The default textmode functions.
100 include 'krl_incs/bos_init.inc' ; Function that starts up BOS
101 include 'krl_incs/en_mess.inc' ; All strings in english (soon).
102 include 'krl_incs/rmode_int.inc' ; Get back to realmode and do an INT.
103 include 'krl_incs/pic.inc' ; PIC rutines.
104 include 'krl_incs/sys_ints.inc' ; System specific interrupts.
105 include 'krl_incs/keyboard.inc' ; Keyboard ISR.
106 include 'krl_incs/keymap.inc' ; Keymap(s).
107 include 'krl_incs/shell.inc' ; File with shell/kernel monitor functions.
108 include 'krl_incs/commands.inc' ; Command table, for valid shell commands.
109 include 'krl_incs/isr.inc' ; Interrupt Service Rutines.
110 include 'krl_incs/debug.inc' ; Print contents of all regs and hang.
111 include 'krl_incs/cmos.inc' ; To get CMOS data.
112 include 'krl_incs/time_date.inc' ; Print time and date.
113 include 'krl_incs/timer.inc' ; Timer IRQ.
114 include 'krl_incs/vga.inc' ; VGA functions.
115 ; include 'krl_incs/font8x16.inc' ; Standard font.
116 include 'krl_incs/dma.inc' ; DMA code.
117 include 'krl_incs/fdc.inc' ; Floppy code.
118 include 'krl_incs/mario.inc' ; Mario sprite.
119 include 'krl_incs/pc_speaker.inc' ; PC speaker.
120 include 'krl_incs/mem.inc' ; Memory allocation and freeing.