1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Functions to access BOOTVARS struct.
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .text
|
---|
6 |
|
---|
7 | ;--------------------------------------------------------------------
|
---|
8 | ; Stores POST stack pointer to BOOTVARS.
|
---|
9 | ;
|
---|
10 | ; BootVars_StorePostStackPointer
|
---|
11 | ; Parameters:
|
---|
12 | ; DS: BDA and Interrupt Vector segment (zero)
|
---|
13 | ; Returns:
|
---|
14 | ; Nothing
|
---|
15 | ; Corrupts registers:
|
---|
16 | ; AX
|
---|
17 | ;--------------------------------------------------------------------
|
---|
18 | ALIGN JUMP_ALIGN
|
---|
19 | BootVars_StorePostStackPointer:
|
---|
20 | pop ax ; Pop return address
|
---|
21 | mov [BOOTVARS.dwPostStack], sp
|
---|
22 | mov [BOOTVARS.dwPostStack+2], ss
|
---|
23 | jmp ax
|
---|
24 |
|
---|
25 |
|
---|
26 | ;--------------------------------------------------------------------
|
---|
27 | ; Initializes stack for boot menu usage.
|
---|
28 | ; POST stack is not large enough when DPTs are stored to 30:0h.
|
---|
29 | ;
|
---|
30 | ; Note regarding LOAD_BDA_SEGMENT_TO: If you force the use of SP
|
---|
31 | ; then you also have to unconditionally enable the CLI/STI pair.
|
---|
32 | ; The reason for this is that only some buggy 808x CPU:s need the
|
---|
33 | ; CLI/STI instruction pair when changing stacks. Other CPU:s disable
|
---|
34 | ; interrupts automatically when SS is modified for the duration of
|
---|
35 | ; the immediately following instruction to give time to change SP.
|
---|
36 | ;
|
---|
37 | ; BootVars_SwitchToBootMenuStack
|
---|
38 | ; Parameters:
|
---|
39 | ; Nothing
|
---|
40 | ; Returns:
|
---|
41 | ; SS:SP: Pointer to top of Boot Menu stack
|
---|
42 | ; Corrupts registers:
|
---|
43 | ; AX
|
---|
44 | ;--------------------------------------------------------------------
|
---|
45 | ALIGN JUMP_ALIGN
|
---|
46 | BootVars_SwitchToBootMenuStack:
|
---|
47 | pop ax ; Pop return address
|
---|
48 | %ifndef USE_186
|
---|
49 | cli ; Disable interrupts
|
---|
50 | %endif
|
---|
51 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
52 | mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
|
---|
53 | %ifndef USE_186
|
---|
54 | sti ; Enable interrupts
|
---|
55 | %endif
|
---|
56 | jmp ax
|
---|
57 |
|
---|
58 |
|
---|
59 | ;--------------------------------------------------------------------
|
---|
60 | ; Restores SS and SP to initial boot loader values.
|
---|
61 | ;
|
---|
62 | ; Before doing any changes, see the note regarding
|
---|
63 | ; LOAD_BDA_SEGMENT_TO in BootVars_SwitchToBootMenuStack
|
---|
64 | ;
|
---|
65 | ; BootVars_SwitchBackToPostStack
|
---|
66 | ; Parameters:
|
---|
67 | ; Nothing
|
---|
68 | ; Returns:
|
---|
69 | ; SS:SP: Ptr to POST stack
|
---|
70 | ; Corrupts registers:
|
---|
71 | ; AX
|
---|
72 | ;--------------------------------------------------------------------
|
---|
73 | ALIGN JUMP_ALIGN
|
---|
74 | BootVars_SwitchBackToPostStack:
|
---|
75 | pop ax ; Pop return address
|
---|
76 | %ifndef USE_386
|
---|
77 | cli ; Disable interrupts
|
---|
78 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
79 | mov sp, [ss:BOOTVARS.dwPostStack]
|
---|
80 | mov ss, [ss:BOOTVARS.dwPostStack+2]
|
---|
81 | sti ; Enable interrupts
|
---|
82 | %else
|
---|
83 | LOAD_BDA_SEGMENT_TO ss, sp
|
---|
84 | lss sp, [ss:BOOTVARS.dwPostStack]
|
---|
85 | %endif
|
---|
86 | jmp ax
|
---|