xref: /reactos/boot/environ/lib/arch/i386/transfer.s (revision 3f976713)
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
24
25PUBLIC _Archx86TransferTo32BitApplicationAsm
26_Archx86TransferTo32BitApplicationAsm:
27
28    /* Save non-volatile registers */
29    push ebp
30    push esi
31    push edi
32    push ebx
33
34    /* Save data segments */
35    push es
36    push ds
37
38    /* Save the old stack */
39    mov ebx, esp
40
41    /* Save current GDT/IDT, then load new one */
42    sgdt _GdtRegister+2
43    sidt _IdtRegister+2
44    lgdt _BootAppGdtRegister+2
45    lidt _BootAppIdtRegister+2
46
47    /* Load the new stack */
48    xor ebp, ebp
49    mov esp, _BootApp32Stack
50
51    /* Push old stack onto new stack */
52    push ebx
53
54    /* Call the entry routine, passing the parameters */
55    mov eax, _BootApp32Parameters
56    push eax
57    mov eax, _BootApp32EntryRoutine
58    call eax
59
60    /* Retore old stack */
61    pop ebx
62    mov esp, ebx
63
64    /* Restore old GDT/IDT */
65    lgdt _GdtRegister+2
66    lidt _IdtRegister+2
67
68    /* Retore old segments */
69    pop ds
70    pop es
71
72    /* Retore non-volatiles */
73    pop ebx
74    pop edi
75    pop esi
76    pop ebp
77
78    /* All done */
79    ret
80
81END
82