Save progess, then delete GDT for rewrite
This commit saves the progress made on the GDT; the files are deleted quickly thereafter as the code was quite buggy.
This commit is contained in:
parent
83eb29d55c
commit
993864e364
|
@ -26,8 +26,8 @@ gdt_set_segment:
|
|||
|
||||
.get_work_address:
|
||||
mov eax, [ebp - 4]
|
||||
mov edx, GDT_ENTRY_SIZE
|
||||
mul edx
|
||||
shl eax, 3
|
||||
add eax, GDT_MEMORY_AREA
|
||||
mov [esi], eax
|
||||
|
||||
.prepare_flags_and_access_byte:
|
||||
|
@ -45,22 +45,23 @@ gdt_set_segment:
|
|||
|
||||
xor al, al
|
||||
or al, (1 << 7) ; Present-Bit
|
||||
cmp [ebp - 15], byte 0
|
||||
|
||||
cmp [ebp - 16], byte 0
|
||||
je .after_task_segment_bit_setter
|
||||
or al, (1 << 4)
|
||||
.after_task_segment_bit_setter:
|
||||
|
||||
cmp [ebp - 14], byte 0
|
||||
cmp [ebp - 15], byte 0
|
||||
je .after_executable_bit_setter
|
||||
or al, (1 << 3)
|
||||
.after_executable_bit_setter:
|
||||
|
||||
cmp [ebp - 13], byte 0
|
||||
cmp [ebp - 14], byte 0
|
||||
je .after_direction_bit_setter
|
||||
or al, (1 << 2)
|
||||
.after_direction_bit_setter:
|
||||
|
||||
cmp [ebp - 12], byte 0
|
||||
cmp [ebp - 13], byte 0
|
||||
je .after_read_write_bit_setter
|
||||
or al, (1 << 1)
|
||||
.after_read_write_bit_setter:
|
||||
|
@ -105,6 +106,8 @@ gdt_set_segment:
|
|||
pop dword esi
|
||||
ret
|
||||
|
||||
|
||||
|
||||
db "load_flat_gdt"
|
||||
; [Furthest from EBP]
|
||||
; 0. 4B Return address
|
||||
|
@ -120,15 +123,17 @@ load_flat_gdt:
|
|||
mov [esi + (64 - 16)], edx
|
||||
mov [esi + (64 - 20)], edi
|
||||
mov eax, [ebp - 4]
|
||||
|
||||
mov [esi + 20], eax
|
||||
|
||||
.create_gdt:
|
||||
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push dword (GDT_MEMORY_AREA)
|
||||
push dword (GDT_ENTRIES_CAPACITY * GDT_ENTRY_SIZE)
|
||||
push dword 0
|
||||
call mem_set
|
||||
push dword (GDT_MEMORY_AREA - 16)
|
||||
push dword gdt_identifier_text
|
||||
push dword 8
|
||||
call mem_copy
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
|
||||
|
@ -136,7 +141,7 @@ load_flat_gdt:
|
|||
push ebp
|
||||
mov ebp, esp
|
||||
push dword 1
|
||||
push dword 0x0a00
|
||||
push dword 0
|
||||
push dword 0xfffff
|
||||
push byte 1
|
||||
push byte 0
|
||||
|
@ -150,8 +155,8 @@ load_flat_gdt:
|
|||
push ebp
|
||||
mov ebp, esp
|
||||
push dword 2
|
||||
push dword 0
|
||||
push dword 0xfffff
|
||||
push dword LOWER_STACK_POINTER
|
||||
push dword 0fxffff
|
||||
push byte 1
|
||||
push byte 1
|
||||
push byte 0
|
||||
|
@ -186,23 +191,33 @@ load_flat_gdt:
|
|||
mov ax, (2 << 3)
|
||||
mov ss, ax
|
||||
|
||||
jmp dword (1 << 3):.epilog
|
||||
.epilog:
|
||||
; mov eax, cr0
|
||||
; or eax, 1
|
||||
; mov cr0, eax
|
||||
|
||||
cli
|
||||
jmp dword 1:.after_far_jump
|
||||
|
||||
.after_far_jump:
|
||||
mov eax, cr0
|
||||
or eax, 1
|
||||
mov cr0, eax
|
||||
|
||||
mov esi, [esi + 20]
|
||||
jmp esi
|
||||
|
||||
mov ebx, [esi + (64 - 8)]
|
||||
mov ecx, [esi + (64 - 12)]
|
||||
mov edx, [esi + (64 - 16)]
|
||||
mov edi, [esi + (64 - 20)]
|
||||
|
||||
mov esi, [esi + 20]
|
||||
jmp esi
|
||||
|
||||
align 16
|
||||
.gdtr:
|
||||
.gdtr.length:
|
||||
dw 31
|
||||
.gdtr.address:
|
||||
dd GDT_MEMORY_AREA
|
||||
dd GDT_MEMORY_AREA
|
||||
|
||||
gdt_identifier_text:
|
||||
db "GDT !!!!"
|
||||
|
|
Loading…
Reference in New Issue