source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootVars.asm@ 119

Last change on this file since 119 was 117, checked in by krille_n_@…, 13 years ago

Changes to the XTIDE Universal BIOS:

  • Bugfix: The stack swapping in BootVars_SwitchBackToPostStack wasn't really an atomic operation anymore (on 186 and 286 CPUs) so I reverted the change I did in the previous revision.
  • A very small size optimization in AH15h_HSize.asm
File size: 2.5 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions to access BOOTVARS struct.
3
4; Section containing code
5SECTION .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;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19BootVars_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;--------------------------------------------------------------------
45ALIGN JUMP_ALIGN
46BootVars_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;--------------------------------------------------------------------
73ALIGN JUMP_ALIGN
74BootVars_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
Note: See TracBrowser for help on using the repository browser.