Orion
Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)diff --git a/mem/page.S b/mem/page.S new file mode 100644 index 0000000..5e1dd4a --- /dev/null +++ b/mem/page.S @@ -0,0 +1,60 @@ +; This file implements some simple low level assembly helper functions for the +; paging system. The functions are done in assembly for the speed benefit. +; They may be called frequently by the memory manager, so the benefit will be +; significant. + +[bits 32] + +; Enable paging +[global enable_paging] +enable_paging: + mov edx, cr0 + or edx, 0x80000000 + mov cr0, edx + ret + +; Disable paging +[global disable_paging] +disable_paging: + mov edx, cr0 + and edx, 0x7FFFFFFF + mov cr0, edx + ret + +; Copy the contents of a page frame +[global copy_page_frame] +copy_page_frame: +; push ebx +; pushf +; mov esi, [esp + 12] +; mov edi, [esp + 16] +; call disable_paging +; mov ecx, 1024 +; rep movsd +; call enable_paging +; popf +; pop ebx +; ret + push ebx + pushf + cli + mov ebx, [esp + 12] + mov ecx, [esp + 16] + mov edx, cr0 + and edx, 0x7FFFFFFF + mov cr0, edx + mov edx, 1024 +.loop: + mov eax, [ebx] + mov [ecx], eax + add ebx, 4 + add ecx, 4 + dec edx + jnz .loop + mov edx, cr0 + or edx, 0x80000000 + mov cr0, edx + sti + popf + pop ebx + ret