Mercurial > lcfOS
comparison cos/kernel/asmcode.asm @ 17:f3e3e0e9c4bc
First attempt IDT loader 64 bits. INT13 occurs
author | windel |
---|---|
date | Sat, 19 Nov 2011 20:01:28 +0100 |
parents | a58904747019 |
children | 6129643f5c34 |
comparison
equal
deleted
inserted
replaced
16:ddefe6d97cd7 | 17:f3e3e0e9c4bc |
---|---|
4 | 4 |
5 section .text | 5 section .text |
6 align 4 | 6 align 4 |
7 | 7 |
8 ; Port helpers: | 8 ; Port helpers: |
9 global outb | 9 ;global outb |
10 outb: | 10 ;outb: |
11 mov eax, [esp + 8] | 11 ; mov eax, [esp + 8] |
12 mov edx, [esp + 4] | 12 ; mov edx, [esp + 4] |
13 out dx, al | 13 ; out dx, al |
14 ret | 14 ; ret |
15 | 15 |
16 global inb | 16 ;global inb |
17 inb: | 17 ;inb: |
18 xor eax, eax | 18 ; xor eax, eax |
19 mov edx, [esp + 4] | 19 ; mov edx, [esp + 4] |
20 in al, dx | 20 ; in al, dx |
21 ret | 21 ; ret |
22 | |
23 ; Helper functions: | |
24 global enableinterrupts | |
25 enableinterrupts: | |
26 sti | |
27 ret | |
28 | 22 |
29 global halt | 23 global halt |
30 halt: | 24 halt: |
31 cli | 25 cli |
32 hlt | 26 hlt |
33 | 27 |
28 global magicBochsBreak | |
29 magicBochsBreak: | |
30 xchg bx,bx | |
31 ret | |
32 | |
34 global loadIDT | 33 global loadIDT |
35 loadIDT: | 34 loadIDT: |
35 extern idtP | |
36 ; TODO: make this pointer thing more insightfull: | |
37 ;xchg bx, bx ; For debugging with bochs | |
38 lidt [idtP] | |
36 ret | 39 ret |
40 | |
41 %macro pushAll 0 | |
42 push rax | |
43 push rcx | |
44 push rdx | |
45 push rbx | |
46 push rbp | |
47 push rsi | |
48 push rdi | |
49 %endmacro | |
50 | |
51 %macro popAll 0 | |
52 pop rdi | |
53 pop rsi | |
54 pop rbp | |
55 pop rbx | |
56 pop rdx | |
57 pop rcx | |
58 pop rax | |
59 %endmacro | |
37 | 60 |
38 ; Define macro with two arguments: | 61 ; Define macro with two arguments: |
39 %macro INTX 2 | 62 %macro INTX 2 |
40 global %1 | 63 global %1 |
41 %1: | 64 %1: |
42 ; Do some saving: | 65 ; Do some saving: |
43 extern %2 | 66 pushAll |
44 call %2 | 67 extern %2 |
68 call %2 | |
45 ; Do restoration | 69 ; Do restoration |
46 iret | 70 popAll |
71 iretq | |
47 | 72 |
48 %endmacro | 73 %endmacro |
49 | 74 |
50 ; Exception handlers: | 75 ; Exception handlers: |
51 INTX INTDEF, INTDEF_handler | 76 INTX INTDEF, INTDEF_handler |