File tree Expand file tree Collapse file tree 6 files changed +64
-208
lines changed Expand file tree Collapse file tree 6 files changed +64
-208
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ ALL_OBJ := environment.o \
12
12
kernel.o \
13
13
string.o \
14
14
idt.o \
15
- gdt.o \
16
15
load_gdt.o
17
16
ALL_DEP := $(patsubst % .o,.% .d,$(ALL_OBJ ) )
18
17
@@ -49,8 +48,7 @@ testos.bin: $(ALL_OBJ)
49
48
@$(LD ) -o $@ $(LD_FLAGS ) $^
50
49
51
50
clean :
52
- rm -f * .o
53
- rm -f testos.bin
51
+ rm -f $(ALL_DEP ) $(ALL_OBJ )
54
52
55
53
ifneq ($(MAKECMDGOALS ) ,clean)
56
54
-include $(ALL_DEP )
Original file line number Diff line number Diff line change
1
+ gdtr:
2
+ gdt_limit dw 8 * 5
3
+ gdt_base dd gd_table
4
+
5
+ align 8
6
+ gd_table:
7
+ .gdt_e_null:
8
+ dq 0
9
+ .gdt_e_code_0:
10
+ dw 0xffff
11
+ dw 0
12
+ db 0
13
+ db 0x9a
14
+ db 11001111b
15
+ db 0
16
+ .gdt_e_data_0:
17
+ dw 0xffff
18
+ dw 0
19
+ db 0
20
+ db 0x92
21
+ db 11001111b
22
+ db 0
23
+ .gdt_e_code_3:
24
+ dw 0xffff
25
+ dw 0
26
+ db 0
27
+ db 0xfa
28
+ db 11001111b
29
+ db 0
30
+ .gdt_e_data_3:
31
+ dw 0xffff
32
+ dw 0
33
+ db 0
34
+ db 0xf2
35
+ db 11001111b
36
+ db 0
37
+
1
38
global environment
2
39
environment:
3
40
mov esp , stack_top
41
+ gdt_setup:
42
+ lgdt [ gdtr ]
43
+ jmp 0x08 :gdt_reload
44
+ gdt_reload:
45
+ mov ax , 0x10
46
+ mov ds , ax
47
+ mov es , ax
48
+ mov fs , ax
49
+ mov gs , ax
50
+ mov ss , ax
51
+ finish:
4
52
extern kernel_main
5
53
call kernel_main
6
54
cli
@@ -9,6 +57,7 @@ environment:
9
57
10
58
section .bss
11
59
align 4
60
+
12
61
stack_bottom:
13
62
resb 16384
14
63
stack_top:
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
#include "terminal.h"
2
- #include "gdt.h"
3
2
4
3
void kernel_main ()
5
4
{
6
5
terminal_clear (vga_entry (' ' , vga_entry_color (VGA_COLOR_GRAY , VGA_COLOR_BLUE )));
7
- terminal_write_str ("TestOS V 0.0000001\n" );
8
- gdt_init ();
9
6
10
- return ;
11
- }
7
+ terminal_write_str ("Test\n" );
12
8
13
- void * do_nothing (void * ptr )
14
- {
15
- return ptr + 1 ;
16
- }
9
+ return ;
10
+ }
Original file line number Diff line number Diff line change @@ -4,9 +4,17 @@ gdt_base DD 0 ;base
4
4
5
5
global load_gdt
6
6
load_gdt:
7
- mov eax , [ esp + 4 ]
8
- mov cx , [ esp + 8 ]
7
+ mov eax , [ esp + 4 ] ;load base parameter
8
+ mov cx , [ esp + 8 ] ;load limit parameter
9
9
mov [ gdt_base ], eax
10
10
mov [ gdt_limit ], cx
11
11
lgdt [ gdtr ]
12
- ret
12
+ jmp 2 * 8 :reload
13
+ reload:
14
+ mov ax , 0x10
15
+ mov ds , ax
16
+ mov es , ax
17
+ mov fs , ax
18
+ mov gs , ax
19
+ mov ss , ax
20
+ ret
You can’t perform that action at this time.
0 commit comments