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

Last change on this file since 84 was 84, checked in by krille_n_@…, 14 years ago

Minor size optimizations in various files.

File size: 3.4 KB
Line 
1; File name : BootVars.asm
2; Project name : IDE BIOS
3; Created date : 1.4.2010
4; Last update : 14.1.2011
5; Author : Tomi Tilli,
6; : Krister Nordvall (optimizations)
7; Description : Functions to access BOOTVARS struct.
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Stores POST stack pointer to BOOTVARS.
14;
15; BootVars_StorePostStackPointer
16; Parameters:
17; DS: BDA and Interrupt Vector segment (zero)
18; Returns:
19; Nothing
20; Corrupts registers:
21; AX
22;--------------------------------------------------------------------
23ALIGN JUMP_ALIGN
24BootVars_StorePostStackPointer:
25 pop ax ; Pop return address
26 mov [BOOTVARS.dwPostStack], sp
27 mov [BOOTVARS.dwPostStack+2], ss
28 jmp ax
29
30
31;--------------------------------------------------------------------
32; Initializes stack for boot menu usage.
33; POST stack is not large enough when DPTs are stored to 30:0h.
34;
35; BootVars_SwitchToBootMenuStack
36; Parameters:
37; Nothing
38; Returns:
39; SS:SP: Pointer to top of Boot Menu stack
40; Corrupts registers:
41; AX
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44BootVars_SwitchToBootMenuStack:
45 pop ax ; Pop return address
46 cli ; Disable interrupts
47 LOAD_BDA_SEGMENT_TO ss, sp
48 mov sp, BOOTVARS.rgbMnuStack ; Load offset to stack
49 sti ; Enable interrupts
50 jmp ax
51
52
53;--------------------------------------------------------------------
54; Restores SS and SP to initial boot loader values.
55;
56; BootVars_SwitchBackToPostStack
57; Parameters:
58; Nothing
59; Returns:
60; SS:SP: Ptr to POST stack
61; Corrupts registers:
62; AX
63;--------------------------------------------------------------------
64ALIGN JUMP_ALIGN
65BootVars_SwitchBackToPostStack:
66 pop ax ; Pop return address
67 cli ; Disable interrupts
68 LOAD_BDA_SEGMENT_TO ss, sp
69; eLSS sp, ss:BOOTVARS.dwPostStack ; Expanded macro to remove
70 ; unneeded CLI instruction
71%ifndef USE_386
72 mov sp, [ss:BOOTVARS.dwPostStack]
73 mov ss, [ss:BOOTVARS.dwPostStack+2]
74%else
75 lss sp, [ss:BOOTVARS.dwPostStack]
76%endif
77 sti ; Enable interrupts
78 jmp ax
79
80
81;--------------------------------------------------------------------
82; Backups system INT 18h ROM Boot / Boot Failure handler and
83; installs our own for boot menu INT 18h callbacks.
84;
85; BootVars_StoreSystemInt18hAndInstallOurs
86; Parameters:
87; DS: BDA and Interrupt Vector segment (zero)
88; Returns:
89; Nothing
90; Corrupts registers:
91; AX, BX, ES
92;--------------------------------------------------------------------
93ALIGN JUMP_ALIGN
94BootVars_StoreSystemInt18hAndInstallOurs:
95 mov bx, INTV_BOOT_FAILURE*4 ; Offset to INT 18h vector
96 les ax, [bx] ; Load system INT 18h
97 mov [BOOTVARS.dwSys18h], ax
98 mov [BOOTVARS.dwSys18h+2], es
99 mov WORD [bx], Int18h_BootError ; Install our INT 18h
100 mov WORD [bx+2], cs
101 ret
102
103
104;--------------------------------------------------------------------
105; Restores system INT 18h ROM Boot or Boot Error handler.
106;
107; BootVars_RestoreSystemInt18h
108; Parameters:
109; Nothing
110; Returns:
111; Nothing
112; Corrupts registers:
113; AX, DS, ES
114;--------------------------------------------------------------------
115ALIGN JUMP_ALIGN
116BootVars_RestoreSystemInt18h:
117 LOAD_BDA_SEGMENT_TO ds, ax
118 les ax, [BOOTVARS.dwSys18h]
119 mov [INTV_BOOT_FAILURE*4], ax
120 mov [INTV_BOOT_FAILURE*4+2], es
121 ret
Note: See TracBrowser for help on using the repository browser.