fix: gpf , pmm still wip

This commit is contained in:
d0p1 🏳️‍⚧️ 2023-05-22 14:01:20 +02:00
parent 8e77928997
commit 3cb67bf990
8 changed files with 36 additions and 23 deletions

View file

@ -1,4 +1,4 @@
.PHONY: docs
docs:
-mkdir -p $(DOC_DIR)/html
naturaldocs -p $(DOC_DIR)/config -i . -o HTML $(DOC_DIR)/html
naturaldocs -p $(DOC_DIR)/config -xi tmp -i . -o HTML $(DOC_DIR)/html

View file

@ -60,17 +60,15 @@ Group: Kernel {
Group: Lib {
File: base.inc (lib/base.inc)
File: log.s (lib/base/log.s)
} # Group: Lib
Group: Index {
Index: Everything
Class Index: Classes
Constant Index: Constants
File Index: Files
Function Index: Functions
Macro Index: Macros
Type Index: Types
Variable Index: Variables
} # Group: Index

View file

@ -5,6 +5,9 @@ section .text
global setup_gdt
setup_gdt:
lgdt [gdt_ptr]
mov eax, cr0
or al, 1
mov cr0, eax
jmp 0x08:.flush_cs
.flush_cs:
mov ax, 0x10 ; data segment
@ -28,7 +31,7 @@ gdt_entries:
;; kernel mode code segment
dw 0xFFFF ; Limit
dw 0x00 ; Base (low)
dw 0x0000 ; Base (low)
db 0x00 ; Base (mid)
db 0x9A ; Access: 1 (P) 0 (DPL), 1 (S), 1010 (Type)
db 0xCF ; Granularity: 1 (G), 1 (D/B), 0 (AVL), Limit
@ -36,7 +39,7 @@ gdt_entries:
;; kernel mode data segment
dw 0xFFFF
dw 0x00
dw 0x0000
db 0x00
db 0x92
db 0xCF
@ -44,7 +47,7 @@ gdt_entries:
;; user mode code segment
dw 0xFFFF
dw 0x00
dw 0x0000
db 0x00
db 0xFA
db 0xCF
@ -52,7 +55,7 @@ gdt_entries:
;; user mode data segment
dw 0xFFFF
dw 0x00
dw 0x0000
db 0x00
db 0xF2
db 0xCF

View file

@ -62,8 +62,11 @@ entry:
extern setup_gdt
call setup_gdt
extern setup_pic
call setup_pic
;extern setup_pic
;call setup_pic
mov al, 0xff
out 0xa1, al
out 0x21, al
extern setup_idt
call setup_idt

View file

@ -16,7 +16,7 @@ extern isr %+ i
; zero (skip)
; attr: 1 (Present) 00 (DPL) 0 1 (D: 32bits) 110
mov byte [idt_entries + (i * 8) + 5], 0x8E
mov byte [idt_entries + (i * 8) + 5], 0x8F
; offset (high)
shr eax, 16

View file

@ -15,7 +15,6 @@ isr%1:
global isr%1
isr%1:
xchg bx, bx
push dword 1
push dword %1
jmp isr_handler
%endmacro
@ -86,17 +85,16 @@ ISR_NO_ERR 31
panic:
LOG msg_interrupt
htl
jmp panic
;htl
;jmp panic
ret
global isr_handler
;global isr_handler
isr_handler:
push ds
push es
push fs
push gs
mov edi, 0x11111111
mov eax, 0xAAAAAAAA
pusha
mov ax, 0x10 ; data segment
@ -105,7 +103,7 @@ isr_handler:
mov fs, ax
mov gs, ax
call panic
LOG msg_interrupt
;extern pic_eoi
;call pic_eoi

View file

@ -80,10 +80,11 @@ init_bitmap:
push edi
mov ecx, [bitmap_info]
mov al, 0xFF
mov edi, [bitmap_info + bitmap.addr]
rep stosb
xchg bx, bx
pop edi
leave
ret
@ -203,7 +204,8 @@ setup_pmm_mmap:
mov [bitmap_info], eax
.bitmap_size_already_set:
mov edi, [ebp + 8] ; mb_mmap struct addr
mov esi, [ebp + 12] ; mmap length
inc ebx
cmp ebx, 2
jbe .loop
@ -364,8 +366,10 @@ free_frames:
section .data
bitmap_info:
dd 0 ; size
dd 0 ; ptr
istruc bitmap
at bitmap.length, dd 0
at bitmap.addr, dd 0
iend
section .rodata
warn_no_mmap db "[WARN] mmap flag not set", 0
@ -377,5 +381,6 @@ msg_mem_block db "Free Memory:", 0xA
db 0x9, "Address: %x", 0xA
db 0x9, "Length: %x", 0
msg_max_mem db "Max memory: %x", 0
msg_dump_x db "dump: %x", 0
msg_bitmap_stored_at db "Bitmap stored at: %x", 0
file db __FILE__, 0

View file

@ -1,3 +1,4 @@
; file: log.s
[BITS 32]
%ifdef __KERNEL__
@ -5,7 +6,8 @@ extern serial_write
%endif
section .text
; Function: putstr
;
putstr:
push ebp
mov ebp, esp
@ -29,6 +31,8 @@ putstr:
leave
ret
; Function: puthex
;
puthex:
push ebp
mov ebp, esp
@ -64,6 +68,8 @@ puthex:
leave
ret
; Function: log_impl
;
global log_impl
log_impl:
push ebp