xref: /reactos/boot/environ/lib/arch/i386/transfer.s (revision 4561998a)
1/*
2 * COPYRIGHT:       See COPYING.ARM in the top level directory
3 * PROJECT:         ReactOS UEFI Boot Library
4 * FILE:            boot/environ/lib/arch/transfer.asm
5 * PURPOSE:         Boot Library i386 Transfer Functions
6 * PROGRAMMER:      Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <asm.inc>
12#include <ks386.inc>
13
14EXTERN _GdtRegister:FWORD
15EXTERN _IdtRegister:FWORD
16EXTERN _BootAppGdtRegister:FWORD
17EXTERN _BootAppIdtRegister:FWORD
18EXTERN _BootApp32Stack:DWORD
19EXTERN _BootApp32EntryRoutine:DWORD
20EXTERN _BootApp32Parameters:DWORD
21
22/* FUNCTIONS ****************************************************************/
23.code
24ASSUME nothing
25
26PUBLIC _Archx86TransferTo32BitApplicationAsm
27_Archx86TransferTo32BitApplicationAsm:
28
29    /* Save non-volatile registers */
30    push ebp
31    push esi
32    push edi
33    push ebx
34
35    /* Save data segments */
36    push es
37    push ds
38
39    /* Save the old stack */
40    mov ebx, esp
41
42    /* Save current GDT/IDT, then load new one */
43    sgdt _GdtRegister+2
44    sidt _IdtRegister+2
45    lgdt _BootAppGdtRegister+2
46    lidt _BootAppIdtRegister+2
47
48    /* Load the new stack */
49    xor ebp, ebp
50    mov esp, _BootApp32Stack
51
52    /* Push old stack onto new stack */
53    push ebx
54
55    /* Call the entry routine, passing the parameters */
56    mov eax, _BootApp32Parameters
57    push eax
58    mov eax, _BootApp32EntryRoutine
59    call eax
60
61    /* Retore old stack */
62    pop ebx
63    mov esp, ebx
64
65    /* Restore old GDT/IDT */
66    lgdt _GdtRegister+2
67    lidt _IdtRegister+2
68
69    /* Retore old segments */
70    pop ds
71    pop es
72
73    /* Retore non-volatiles */
74    pop ebx
75    pop edi
76    pop esi
77    pop ebp
78
79    /* All done */
80    ret
81
82END
83