diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-08-30 01:21:56 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-08-30 01:21:56 +0200 |
| commit | 0ba95e7cdbfc7e9833e8c46b02e2248783ff6a5d (patch) | |
| tree | 68602e52ad69cb433b9bf81e401128ebc738cbad /asm | |
| parent | 47d22a238a6c5d60c6abfac724e6ad91885cdd67 (diff) | |
preparing for multitasking
Diffstat (limited to 'asm')
| -rw-r--r-- | asm/copy_page_physical.asm | 33 | ||||
| -rw-r--r-- | asm/read_eip.asm | 6 |
2 files changed, 39 insertions, 0 deletions
diff --git a/asm/copy_page_physical.asm b/asm/copy_page_physical.asm new file mode 100644 index 0000000..f8d3af1 --- /dev/null +++ b/asm/copy_page_physical.asm @@ -0,0 +1,33 @@ +[bits 32] + +global copy_page_physical +copy_page_physical: + push ebx ; According to __cdecl, we must preserve the contents of EBX. + pushf ; push EFLAGS, so we can pop it and reenable interrupts + ; later, if they were enabled anyway. + cli ; Disable interrupts, so we aren't interrupted. + ; Load these in BEFORE we disable paging! + mov ebx, [esp+12] ; Source address + mov ecx, [esp+16] ; Destination address + + mov edx, cr0 ; Get the control register... + and edx, 0x7fffffff ; and... + mov cr0, edx ; Disable paging. + + mov edx, 1024 ; 1024*4bytes = 4096 bytes to copy + +.loop: + mov eax, [ebx] ; Get the word at the source address + mov [ecx], eax ; Store it at the dest address + add ebx, 4 ; Source address += sizeof(word) + add ecx, 4 ; Dest address += sizeof(word) + dec edx ; One less word to do + jnz .loop + + mov edx, cr0 ; Get the control register again + or edx, 0x80000000 ; and... + mov cr0, edx ; Enable paging. + + popf ; Pop EFLAGS back. + pop ebx ; Get the original value of EBX back. + ret diff --git a/asm/read_eip.asm b/asm/read_eip.asm new file mode 100644 index 0000000..3341943 --- /dev/null +++ b/asm/read_eip.asm @@ -0,0 +1,6 @@ +; http://www.jamesmolloy.co.uk/tutorial_html/9.-Multitasking.html +[bits 32] +global read_eip +read_eip: + pop eax + jmp eax |
