Functions | |
Copyright (c) 2006-2013 | |
_BackFromUserCode () takes control in real mode after 'retf'has been executed | |
_ToUserCode () takes control in real mode before passing control to user code. | |
InternalAsmThunk16 (;IN IA32_REGISTER_SET *RegisterSet,;IN OUT VOID *Transition;) | |
Variables | |
Intel Corporation All rights reserved< BR > This program and the accompanying | materials |
are licensed and made available under the terms and conditions of the BSD | License |
which accompanies this distribution The full text of the license may be found | at |
http | __pad5__ |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS | BASIS |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY | KIND |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY EITHER EXPRESS OR | IMPLIED |
Module | Name |
Thunk | asm |
Abstract | __pad6__ |
Real mode | thunk |
global (m16Size) global(mThunk16Attr) global(m16Gdt) global(m16GdtrBase) global(mTransition) global(m16Start) struc IA32_REGS._EDI | |
const SECTION | data |
These are global constant to convey information to C | code |
m16Size | DW (InternalAsmThunk16)-(m16Start)(mThunk16Attr) DW _BackFromUserCode.ThunkAttrEnd-4-(m16Start)(m16Gdt) DW _NullSegDesc-(m16Start)(m16GdtrBase) DW _16GdtrBase-(m16Start)(mTransition) DW _EntryPoint-(m16Start) SECTION.text(m16Start) |
by user code It will be shadowed to somewhere in memory | below |
_BackFromUserCode | __pad7__ |
The order of saved registers on the stack matches the order they | appears |
in IA32_REGS structure This facilitates wrapper function to extract | them |
into that | structure |
BITS push ss push | cs |
Note | __pad8__ |
in NASM | through |
call dword | Base |
disable interrupts push gs push fs push es push ds pushad mov | edx |
disable interrupts push gs push fs push es push ds pushad mov strict dword | ThunkAttrEnd |
disable interrupts push gs push fs push es push ds pushad mov strict dword THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 jz mov | ax |
disable interrupts push gs push fs push es push ds pushad mov strict dword THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 jz mov int | cli |
disable interrupts | jnc |
disable interrupts THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL jz in | al |
disable interrupts THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL jz in or | out |
deactivate | A20M |
deactivate eax mov ss lea | ebp |
deactivate eax mov ss lea | mov [bp-IA32_REGS.size+IA32_REGS._ESP] |
deactivate eax mov ss lea ebp mov | bx |
deactivate eax mov ss lea ebp mov shl | eax |
add eax mov strict dword | SavedCr4End |
add eax mov strict dword eax o32 lgdt[cs:bx+(SavedGdt-.Base)] mov strict dword | SavedCr0End |
add eax mov strict dword eax o32 lgdt[cs:bx+(SavedGdt-.Base)] mov strict dword eax mov strict word | SavedSsEnd |
add eax mov strict dword eax o32 lgdt[cs:bx+(SavedGdt-.Base)] mov strict dword eax mov strict word eax mov | esp |
add eax mov strict dword eax o32 lgdt[cs:bx+(SavedGdt-.Base)] mov strict dword eax mov strict word eax mov strict dword | SavedEspEnd |
return to protected mode | _EntryPoint |
_ToUserCode | __pad9__ |
_ToUserCode ss mov | ss |
_ToUserCode ss mov | cx |
set new segment selectors mov | ds |
set new segment selectors mov cx mov | es |
set new segment selectors mov cx mov cx mov | fs |
set new segment selectors mov cx mov cx mov cx mov | gs |
set new segment selectors mov cx mov cx mov cx mov cx mov | cr0 |
real mode starts at next | instruction |
which(per SDM)*must *be a far JMP.jmp 0 set up bit stack segment xchg | ebx |
set up bit stack pointer mov | bp |
set up bit stack pointer mov dx ebx lidt[cs:bp+(_16Idtr-_BackFromUserCode)] popad pop ds pop es pop fs pop gs popfd o32 | retf |
transfer control to user code ALIGN _NullSegDesc DQ | _16CsDesc |
bit | segment |
bit limit DB | _16DsDesc |
bit limit DB | GdtEnd |
IA32_REGISTER_SET * | EFIAPI |
_BackFromUserCode | ( | ) |
_ToUserCode | ( | ) |
Copyright | ( | c | ) |
InternalAsmThunk16 | ( | ;IN IA32_REGISTER_SET * | RegisterSet, | |
;IN OUT VOID *Transition; | ||||
) |
bit limit DB _16DsDesc |
http __pad5__ |
Abstract __pad6__ |
_BackFromUserCode __pad7__ |
Note __pad8__ |
_ToUserCode __pad9__ |
return to protected mode _EntryPoint |
deactivate A20M |
disable interrupts THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL jz in or al |
The order of saved registers on the stack matches the order they appears |
Thunk asm |
which accompanies this distribution The full text of the license may be found at |
push eip Base |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS BASIS |
It will be shadowed to somewhere in memory below |
disable interrupts push gs push fs push es push ds pushad mov strict dword THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 jz mov int cli |
const SECTION data |
m16Size DW(InternalAsmThunk16)-(m16Start)(mThunk16Attr) DW _BackFromUserCode.ThunkAttrEnd-4-(m16Start)(m16Gdt) DW _NullSegDesc-(m16Start)(m16GdtrBase) DW _16GdtrBase-(m16Start)(mTransition) DW _EntryPoint-(m16Start) SECTION.text(m16Start) |
add ebp |
bit limit DB GdtEnd |
global(m16Size) global(mThunk16Attr) global(m16Gdt) global(m16GdtrBase) global(mTransition) global(m16Start) struc IA32_REGS._EDI |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY EITHER EXPRESS OR IMPLIED |
real mode starts at next instruction |
disable interrupts jnc |
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN AS IS WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND |
are licensed and made available under the terms and conditions of the BSD License |
set up bit stack pointer mov dx mov[cs:bp+(_BackFromUserCode.SavedEspEnd-4-_BackFromUserCode)] |
Module Name |
disable interrupts THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL jz in or out |
set up bit stack pointer mov dx ebx lidt [cs:bp + (_16Idtr - _BackFromUserCode)] popad pop ds pop es pop fs pop gs popfd o32 retf |
add eax mov strict dword SavedCr4End |
add eax mov strict dword eax o32 lgdt [cs:bx + (SavedGdt - .Base)] mov strict dword eax mov strict word eax mov strict dword SavedEspEnd |
add eax mov strict dword eax o32 lgdt [cs:bx + (SavedGdt - .Base)] mov strict dword eax mov strict word SavedSsEnd |
bit segment |
into that structure |
in NASM through |
Real mode thunk |