source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm@ 502

Last change on this file since 502 was 493, checked in by gregli@…, 12 years ago

Separated MODULE_8BIT_IDE into the basic part used by XTIDE rev 1 and rev 2 which is PIO based, and MODULE_8BIT_IDE_ADVANCED for JRIDE and XTCF support which requires memory mapping and/or DMA. This allows for creating an 8KB image with boot menu support (but no hotkeys) for the XTIDE rev 1. Cleaned up how we reset the drive translation information, ensuring it is properly set between boot attempt on a primary and secondary drive - as a result we clean it when needed, rather than trying to always keep it clean. Also fixed translation bugs in int13h.asm where I had previously missed converting some MODULE_HOTKEYS into MODULE_DRIVEXLATE.

File size: 6.7 KB
RevLine 
[90]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for accessings RAMVARS.
3
[376]4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
[3]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Initializes RAMVARS.
25; Drive detection can be started after this function returns.
26;
27; RamVars_Initialize
28; Parameters:
29; Nothing
30; Returns:
[97]31; DS: RAMVARS segment
[3]32; Corrupts registers:
[97]33; AX, CX, DI
[3]34;--------------------------------------------------------------------
35RamVars_Initialize:
[90]36 push es
[97]37 ; Fall to .StealMemoryForRAMVARS
[3]38
39;--------------------------------------------------------------------
[33]40; .StealMemoryForRAMVARS
[3]41; Parameters:
42; Nothing
43; Returns:
44; DS: RAMVARS segment
45; Corrupts registers:
46; AX
47;--------------------------------------------------------------------
[33]48.StealMemoryForRAMVARS:
[400]49%ifndef USE_AT
[241]50 mov ax, LITE_MODE_RAMVARS_SEGMENT
[3]51 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[97]52 jz SHORT .InitializeRamvars ; No need to steal RAM
[364]53%endif
[3]54
[116]55 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
[3]56 mov al, [cs:ROMVARS.bStealSize]
[33]57 sub [BDA.wBaseMem], ax
58 mov ax, [BDA.wBaseMem]
[97]59 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
[150]60 ; Fall to .InitializeRamvars
[3]61
[33]62;--------------------------------------------------------------------
[97]63; .InitializeRamvars
[33]64; Parameters:
[241]65; AX: RAMVARS segment
[97]66; Returns:
[33]67; DS: RAMVARS segment
68; Corrupts registers:
69; AX, CX, DI, ES
70;--------------------------------------------------------------------
[97]71.InitializeRamvars:
[241]72 mov ds, ax
73 mov es, ax
[97]74 mov cx, RAMVARS_size
75 xor di, di
76 call Memory_ZeroESDIwithSizeInCX
[444]77 mov WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE
78 mov WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
[417]79 ; Fall to .InitializeInt13hStackChangeVariables
80
81;--------------------------------------------------------------------
82; .InitializeInt13hStackChangeVariables
83; Parameters:
84; DS: RAMVARS segment
85; Returns:
86; Nothing
87; Corrupts registers:
88; AX
89;--------------------------------------------------------------------
90%ifdef RELOCATE_INT13H_STACK
91.InitializeInt13hStackChangeVariables:
92 eMOVZX ax, BYTE [cs:ROMVARS.bStealSize]
93 eSHL_IM ax, 10 ; kiB to Bytes = Top of stack offset
94 mov [RAMVARS.wNewStackOffset], ax
95%endif
[3]96
[493]97;; There used to be a DriveXlate_Reset call here. It isn't necessary, as we reset
98;; when entering the boot menu and also before transferring control at boot time and
99;; for ROM boots (in int19h.asm).
100
[97]101 pop es
[395]102 ret
[33]103
[3]104;--------------------------------------------------------------------
105; Returns segment to RAMVARS.
106; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
107; or at the top of system base RAM.
108;
109; RamVars_GetSegmentToDS
110; Parameters:
111; Nothing
112; Returns:
113; DS: RAMVARS segment
114; Corrupts registers:
115; DI
116;--------------------------------------------------------------------
117ALIGN JUMP_ALIGN
118RamVars_GetSegmentToDS:
[368]119
[400]120%ifndef USE_AT ; Always in Full Mode for AT builds
[3]121 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
[33]122 jnz SHORT .GetStolenSegmentToDS
[400]123 %ifndef USE_186
124 mov di, LITE_MODE_RAMVARS_SEGMENT
125 mov ds, di
126 %else
127 push LITE_MODE_RAMVARS_SEGMENT
128 pop ds
129 %endif
130 ret
[181]131%endif
[3]132
133ALIGN JUMP_ALIGN
[33]134.GetStolenSegmentToDS:
[3]135 LOAD_BDA_SEGMENT_TO ds, di
136 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
[33]137 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
[3]138ALIGN JUMP_ALIGN
139.LoopStolenKBs:
140 mov ds, di ; EBDA segment to DS
141 add di, BYTE 64 ; DI to next stolen kB
[444]142 cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
[3]143 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
144 ret
145
146
147;--------------------------------------------------------------------
[258]148; RamVars_GetHardDiskCountFromBDAtoAX
[3]149; Parameters:
150; DS: RAMVARS segment
151; Returns:
[258]152; AX: Total hard disk count
[3]153; Corrupts registers:
[492]154; BX
[116]155;--------------------------------------------------------------------
[392]156%ifdef MODULE_BOOT_MENU
[258]157RamVars_GetHardDiskCountFromBDAtoAX:
158 call RamVars_GetCountOfKnownDrivesToAX
[294]159 push ds
160 LOAD_BDA_SEGMENT_TO ds, cx
[492]161 mov bl, [BDA.bHDCount]
162 MAX_U al, bl
[294]163 pop ds
[3]164 ret
[392]165%endif
[32]166
[392]167
[32]168;--------------------------------------------------------------------
[258]169; RamVars_GetCountOfKnownDrivesToAX
[32]170; Parameters:
171; DS: RAMVARS segment
172; Returns:
[258]173; AX: Total hard disk count
[32]174; Corrupts registers:
[258]175; None
[116]176;--------------------------------------------------------------------
[32]177ALIGN JUMP_ALIGN
[258]178RamVars_GetCountOfKnownDrivesToAX:
[433]179 mov ax, [RAMVARS.wFirstDrvAndCount]
[258]180 add al, ah
[368]181 and ax, BYTE 7fh
[32]182 ret
[294]183
[33]184;--------------------------------------------------------------------
185; RamVars_GetIdeControllerCountToCX
186; Parameters:
187; Nothing
188; Returns:
189; CX: Number of IDE controllers to handle
190; Corrupts registers:
191; Nothing
[116]192;--------------------------------------------------------------------
[258]193ALIGN JUMP_ALIGN
[33]194RamVars_GetIdeControllerCountToCX:
[294]195 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
[33]196 ret
[258]197
[473]198
[258]199%ifdef MODULE_SERIAL_FLOPPY
200;--------------------------------------------------------------------
201; RamVars_UnpackFlopCntAndFirstToAL
202; Parameters:
[473]203; DS: RAMVARS segment
[258]204; Returns:
205; AL: First floppy drive number supported
206; CF: Number of floppy drives supported (clear = 1, set = 2)
[270]207; SF: Emulating drives (clear = yes, set = no)
[258]208; Corrupts registers:
209; Nothing
[294]210;--------------------------------------------------------------------
[258]211ALIGN JUMP_ALIGN
212RamVars_UnpackFlopCntAndFirstToAL:
213 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
[294]214 sar al, 1
[258]215 ret
216%endif
[473]217
218
[489]219%if 0 ; unused...
[473]220;--------------------------------------------------------------------
221; RamVars_IsDriveDetectionInProgress
222; Parameters:
223; DS: RAMVARS segment
224; Returns:
225; ZF: Set if drive detection is in progress (ROM initialization)
226; Corrupts registers:
227; None
228;--------------------------------------------------------------------
229RamVars_IsDriveDetectionInProgress:
230 cmp WORD [RAMVARS.wSignature], RAMVARS_DRV_DETECT_SIGNATURE
231 ret
[489]232%endif
Note: See TracBrowser for help on using the repository browser.