00001 ; ndk - [ pmode.asm ] 00002 ; 00003 ; These are x86 specific assembly language routines for ndk. 00004 ; For portability reasons I've tried to encapsulate all the 00005 ; assembly language routines in external files. 00006 ; 00007 ; I've tried to avoid inline assembly at all costs. I'd like 00008 ; the C source to be completely ANSI portable (although there 00009 ; are __attribute__ ((packed))'s throughout, for GCC. 00010 ; 00011 ; Please see: 00012 ; /src/pager.{c,h} 00013 ; 00014 ; (c)2002 dcipher / neuraldk 00015 ; www.neuraldk.org 00016 00017 [bits 32] 00018 00019 global jumpToTSS 00020 global loadTaskReg 00021 global invalidatePage 00022 global getCR0 00023 global setCR0 00024 global getCR2 00025 global setCR2 00026 global getCR3 00027 global setCR3 00028 00029 segment .text 00030 00031 jumpToTSS: 00032 push ebp 00033 mov ebp, esp 00034 jmp far [ss:ebp+4] 00035 pop ebp 00036 ret 00037 00038 loadTaskReg: 00039 push ebp 00040 mov ebp, esp 00041 ltr word [ss:ebp+8] 00042 pop ebp 00043 ret 00044 00045 invalidatePage: 00046 push ebp 00047 mov ebp, esp 00048 mov eax, [ss:ebp+8] 00049 invlpg [eax] 00050 pop ebp 00051 ret 00052 00053 getCR0: 00054 mov eax, cr0 00055 ret 00056 00057 setCR0: 00058 push ebp 00059 mov ebp, esp 00060 push eax 00061 mov eax, [ss:ebp+8] 00062 mov cr0, eax 00063 pop eax 00064 pop ebp 00065 ret 00066 00067 getCR2: 00068 mov eax, cr2 00069 ret 00070 00071 setCR2: 00072 push ebp 00073 mov ebp, esp 00074 push eax 00075 mov eax, [ss:ebp+8] 00076 mov cr2, eax 00077 pop eax 00078 pop ebp 00079 ret 00080 00081 getCR3: 00082 mov eax, cr3 00083 ret 00084 00085 setCR3: 00086 push ebp 00087 mov ebp, esp 00088 push eax 00089 mov eax, [ss:ebp+8] 00090 mov cr3, eax 00091 pop eax 00092 pop ebp 00093 ret