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 .PHONY: docs
docs: docs:
-mkdir -p $(DOC_DIR)/html -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 { Group: Lib {
File: base.inc (lib/base.inc) File: base.inc (lib/base.inc)
File: log.s (lib/base/log.s)
} # Group: Lib } # Group: Lib
Group: Index { Group: Index {
Index: Everything Index: Everything
Class Index: Classes
Constant Index: Constants
File Index: Files File Index: Files
Function Index: Functions Function Index: Functions
Macro Index: Macros Macro Index: Macros
Type Index: Types
Variable Index: Variables Variable Index: Variables
} # Group: Index } # Group: Index

View file

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

View file

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

View file

@ -16,7 +16,7 @@ extern isr %+ i
; zero (skip) ; zero (skip)
; attr: 1 (Present) 00 (DPL) 0 1 (D: 32bits) 110 ; 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) ; offset (high)
shr eax, 16 shr eax, 16

View file

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

View file

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

View file

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