BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / blob / e59e4fe0bbf5a3f56db0700ee49a81131b590f9c / mem / page.S

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
; 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