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:
|
.get_work_address:
|
||||||
mov eax, [ebp - 4]
|
mov eax, [ebp - 4]
|
||||||
mov edx, GDT_ENTRY_SIZE
|
shl eax, 3
|
||||||
mul edx
|
add eax, GDT_MEMORY_AREA
|
||||||
mov [esi], eax
|
mov [esi], eax
|
||||||
|
|
||||||
.prepare_flags_and_access_byte:
|
.prepare_flags_and_access_byte:
|
||||||
|
@ -45,22 +45,23 @@ gdt_set_segment:
|
||||||
|
|
||||||
xor al, al
|
xor al, al
|
||||||
or al, (1 << 7) ; Present-Bit
|
or al, (1 << 7) ; Present-Bit
|
||||||
cmp [ebp - 15], byte 0
|
|
||||||
|
cmp [ebp - 16], byte 0
|
||||||
je .after_task_segment_bit_setter
|
je .after_task_segment_bit_setter
|
||||||
or al, (1 << 4)
|
or al, (1 << 4)
|
||||||
.after_task_segment_bit_setter:
|
.after_task_segment_bit_setter:
|
||||||
|
|
||||||
cmp [ebp - 14], byte 0
|
cmp [ebp - 15], byte 0
|
||||||
je .after_executable_bit_setter
|
je .after_executable_bit_setter
|
||||||
or al, (1 << 3)
|
or al, (1 << 3)
|
||||||
.after_executable_bit_setter:
|
.after_executable_bit_setter:
|
||||||
|
|
||||||
cmp [ebp - 13], byte 0
|
cmp [ebp - 14], byte 0
|
||||||
je .after_direction_bit_setter
|
je .after_direction_bit_setter
|
||||||
or al, (1 << 2)
|
or al, (1 << 2)
|
||||||
.after_direction_bit_setter:
|
.after_direction_bit_setter:
|
||||||
|
|
||||||
cmp [ebp - 12], byte 0
|
cmp [ebp - 13], byte 0
|
||||||
je .after_read_write_bit_setter
|
je .after_read_write_bit_setter
|
||||||
or al, (1 << 1)
|
or al, (1 << 1)
|
||||||
.after_read_write_bit_setter:
|
.after_read_write_bit_setter:
|
||||||
|
@ -105,6 +106,8 @@ gdt_set_segment:
|
||||||
pop dword esi
|
pop dword esi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
db "load_flat_gdt"
|
db "load_flat_gdt"
|
||||||
; [Furthest from EBP]
|
; [Furthest from EBP]
|
||||||
; 0. 4B Return address
|
; 0. 4B Return address
|
||||||
|
@ -120,15 +123,17 @@ load_flat_gdt:
|
||||||
mov [esi + (64 - 16)], edx
|
mov [esi + (64 - 16)], edx
|
||||||
mov [esi + (64 - 20)], edi
|
mov [esi + (64 - 20)], edi
|
||||||
mov eax, [ebp - 4]
|
mov eax, [ebp - 4]
|
||||||
|
|
||||||
mov [esi + 20], eax
|
mov [esi + 20], eax
|
||||||
|
|
||||||
.create_gdt:
|
.create_gdt:
|
||||||
|
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push dword (GDT_MEMORY_AREA)
|
push dword (GDT_MEMORY_AREA - 16)
|
||||||
push dword (GDT_ENTRIES_CAPACITY * GDT_ENTRY_SIZE)
|
push dword gdt_identifier_text
|
||||||
push dword 0
|
push dword 8
|
||||||
call mem_set
|
call mem_copy
|
||||||
mov esp, ebp
|
mov esp, ebp
|
||||||
pop ebp
|
pop ebp
|
||||||
|
|
||||||
|
@ -136,7 +141,7 @@ load_flat_gdt:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push dword 1
|
push dword 1
|
||||||
push dword 0x0a00
|
push dword 0
|
||||||
push dword 0xfffff
|
push dword 0xfffff
|
||||||
push byte 1
|
push byte 1
|
||||||
push byte 0
|
push byte 0
|
||||||
|
@ -150,8 +155,8 @@ load_flat_gdt:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
push dword 2
|
push dword 2
|
||||||
push dword 0
|
push dword LOWER_STACK_POINTER
|
||||||
push dword 0xfffff
|
push dword 0fxffff
|
||||||
push byte 1
|
push byte 1
|
||||||
push byte 1
|
push byte 1
|
||||||
push byte 0
|
push byte 0
|
||||||
|
@ -186,19 +191,26 @@ load_flat_gdt:
|
||||||
mov ax, (2 << 3)
|
mov ax, (2 << 3)
|
||||||
mov ss, ax
|
mov ss, ax
|
||||||
|
|
||||||
jmp dword (1 << 3):.epilog
|
; mov eax, cr0
|
||||||
.epilog:
|
; or eax, 1
|
||||||
|
; mov cr0, eax
|
||||||
|
|
||||||
|
cli
|
||||||
|
jmp dword 1:.after_far_jump
|
||||||
|
|
||||||
|
.after_far_jump:
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
or eax, 1
|
or eax, 1
|
||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
|
|
||||||
|
mov esi, [esi + 20]
|
||||||
|
jmp esi
|
||||||
|
|
||||||
mov ebx, [esi + (64 - 8)]
|
mov ebx, [esi + (64 - 8)]
|
||||||
mov ecx, [esi + (64 - 12)]
|
mov ecx, [esi + (64 - 12)]
|
||||||
mov edx, [esi + (64 - 16)]
|
mov edx, [esi + (64 - 16)]
|
||||||
mov edi, [esi + (64 - 20)]
|
mov edi, [esi + (64 - 20)]
|
||||||
|
|
||||||
mov esi, [esi + 20]
|
|
||||||
jmp esi
|
|
||||||
|
|
||||||
align 16
|
align 16
|
||||||
.gdtr:
|
.gdtr:
|
||||||
|
@ -206,3 +218,6 @@ align 16
|
||||||
dw 31
|
dw 31
|
||||||
.gdtr.address:
|
.gdtr.address:
|
||||||
dd GDT_MEMORY_AREA
|
dd GDT_MEMORY_AREA
|
||||||
|
|
||||||
|
gdt_identifier_text:
|
||||||
|
db "GDT !!!!"
|
||||||
|
|
Loading…
Reference in New Issue