diff --git a/.editorconfig b/.editorconfig index 059f2de..cda6cd4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,3 +6,7 @@ insert_final_newline = true charset = utf-8 indent_style = tab indent_size = 4 + +[*.py] +indent_style = space +indent_size = 4 diff --git a/kernel/init.inc b/kernel/init.inc index 79870be..d1731d4 100644 --- a/kernel/init.inc +++ b/kernel/init.inc @@ -1,10 +1,29 @@ struc TSS { - .link dw ? - .link_h dw ? - .esp0 dd ? - .ss0 dw ? - .ss0_h dw ? - .esp1 dd ? - .ss1 dw ? - + .prev_tss dd ? + .esp0 dd ? + .ss0 dd ? + .esp1 dd ? + .ss1 dd ? + .esp2 dd ? + .ss2 dd ? + .cr3 dd ? + .eip dd ? + .eflags dd ? + .eax dd ? + .ecx dd ? + .edx dd ? + .ebx dd ? + .esp dd ? + .ebp dd ? + .esi dd ? + .edi dd ? + .es dd ? + .cs dd ? + .ss dd ? + .ds dd ? + .fs dd ? + .gs dd ? + .ldt dd ? + .trap dw ? + .iomap dw ? } diff --git a/kernel/isr.inc b/kernel/isr.inc new file mode 100644 index 0000000..82c810e --- /dev/null +++ b/kernel/isr.inc @@ -0,0 +1,34 @@ +macro ISR_ERROR num { + cli + + jmp isr_common +} + +macro ISR_NOERROR num { + cli + + jmp isr_common +} + +isr_common: + pusha + + mov ax, ds + push eax + + mov ax, 0x10 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + + pop eax + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + + popa + add esp, 8 + sti + iret diff --git a/kernel/mm/mm.inc b/kernel/mm/mm.inc index d47b1b6..b233aa0 100644 --- a/kernel/mm/mm.inc +++ b/kernel/mm/mm.inc @@ -82,6 +82,67 @@ mm_kmap: leave ret + ;; Function: mm_clone_pte + ;; + ;; In: + ;; EAX - source page table + ;; + ;; Out: + ;; EAX - cloned page table + ;; +mm_clone_pte: + push esp + mov ebp, esp + sub esp, 0x10 + + leave + ret + + ;; Function: mm_clone_pgdir + ;; + ;; In: + ;; EAX - source page dir + ;; + ;; Out: + ;; EAX - cloned page dir +mm_clone_pgdir: + push esp + mov ebp, esp + sub esp, 0x10 + + mov [ebp-4], eax + call pmm_alloc_page + + mov [ebp-8], eax + mov ecx, 4096 + mov edi, eax + xor al, al + rep stosb + + xor ecx, ecx +.loop: + mov eax, [ebp-4] + add eax, ecx + mov eax, [eax] + cmp eax, 0 + je .next + cmp ecx, (768*4) + jb @f + mov edx, [ebp-8] + add edx, ecx + mov [edx], eax + jmp .next +@@: + mov edx, eax + call pmm_alloc_page +.next: + add ecx, 4 + cmp ecx, 4096 + jb .loop + + leave + ret + ;; Function: mm_init mm_init: mov esi, szMsgMmInit diff --git a/kernel/mm/pmm.inc b/kernel/mm/pmm.inc index 1f5c4ca..b11a1fd 100644 --- a/kernel/mm/pmm.inc +++ b/kernel/mm/pmm.inc @@ -96,14 +96,18 @@ pmm_free_range: cmp esi, [ebp-8] jb .loop + call pmm_stats + leave + ret + + ;; Function: pmm_stats +pmm_stats: push dword [cFreePage] push dword [cUsedPage] push dword [cTotalPage] mov esi, szMsgPmmStats call klog - - leave ret pFreeList dd 0