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

Last change on this file since 619 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 5.1 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessings RAMVARS.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
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:
31; DS: RAMVARS segment
32; Corrupts registers:
33; AX, CX, DX, DI
34;--------------------------------------------------------------------
35RamVars_Initialize:
36 push es
37
38%ifndef USE_AT
39 mov ax, LITE_MODE_RAMVARS_SEGMENT
40 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
41 jz SHORT .InitializeRamvars ; No need to steal RAM
42%endif
43
44 LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
45 mov al, [cs:ROMVARS.bStealSize]
46 sub [BDA.wBaseMem], ax
47%ifdef USE_186
48 imul ax, [BDA.wBaseMem], 64
49%else
50 mov al, 64
51 mul WORD [BDA.wBaseMem]
52%endif
53
54.InitializeRamvars:
55 xor di, di
56 mov ds, ax
57 mov es, ax
58 mov cx, RAMVARS_size
59 call Memory_ZeroESDIwithSizeInCX
60 mov WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE
61 mov WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
62%ifdef MODULE_DRIVEXLATE
63 call DriveXlate_Reset
64%endif
65
66 pop es
67 ret
68
69;--------------------------------------------------------------------
70; Returns segment to RAMVARS.
71; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
72; or at the top of system base RAM.
73;
74; RamVars_GetSegmentToDS
75; Parameters:
76; Nothing
77; Returns:
78; DS: RAMVARS segment
79; Corrupts registers:
80; DI
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83RamVars_GetSegmentToDS:
84
85%ifndef USE_AT ; Always in Full Mode for AT builds
86 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
87 jnz SHORT .GetStolenSegmentToDS
88 %ifndef USE_186
89 mov di, LITE_MODE_RAMVARS_SEGMENT
90 mov ds, di
91 %else
92 push LITE_MODE_RAMVARS_SEGMENT
93 pop ds
94 %endif
95 ret
96%endif
97
98ALIGN JUMP_ALIGN
99.GetStolenSegmentToDS:
100 LOAD_BDA_SEGMENT_TO ds, di
101;%ifdef USE_186
102; imul di, [BDA.wBaseMem], 64 ; 2 bytes less but slower, especially on 386/486 processors
103;%else
104 mov di, [BDA.wBaseMem] ; Load available base memory size in kB
105 eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
106;%endif
107ALIGN JUMP_ALIGN
108.LoopStolenKBs:
109 mov ds, di ; EBDA segment to DS
110 add di, BYTE 64 ; DI to next stolen kB
111 cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
112 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
113 ret
114
115
116;--------------------------------------------------------------------
117; RamVars_GetHardDiskCountFromBDAtoAX
118; Parameters:
119; DS: RAMVARS segment
120; Returns:
121; AX: Total hard disk count
122; Corrupts registers:
123; BX
124;--------------------------------------------------------------------
125%ifdef MODULE_BOOT_MENU
126RamVars_GetHardDiskCountFromBDAtoAX:
127 call RamVars_GetCountOfKnownDrivesToAX
128 push ds
129 LOAD_BDA_SEGMENT_TO ds, bx
130 mov bl, [BDA.bHDCount]
131 MAX_U al, bl
132 pop ds
133 ret
134%endif
135
136
137;--------------------------------------------------------------------
138; RamVars_GetCountOfKnownDrivesToAX
139; Parameters:
140; DS: RAMVARS segment
141; Returns:
142; AX: Total hard disk count
143; Corrupts registers:
144; None
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147RamVars_GetCountOfKnownDrivesToAX:
148 mov ax, [RAMVARS.wFirstDrvAndCount]
149 add al, ah
150 and ax, BYTE 7fh
151 ret
152
153;--------------------------------------------------------------------
154; RamVars_GetIdeControllerCountToCX
155; Parameters:
156; Nothing
157; Returns:
158; CX: Number of IDE controllers to handle
159; Corrupts registers:
160; Nothing
161;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
163RamVars_GetIdeControllerCountToCX:
164 eMOVZX cx, [cs:ROMVARS.bIdeCnt]
165 ret
166
167
168%ifdef MODULE_SERIAL_FLOPPY
169;--------------------------------------------------------------------
170; RamVars_UnpackFlopCntAndFirstToAL
171; Parameters:
172; DS: RAMVARS segment
173; Returns:
174; AL: First floppy drive number supported
175; CF: Number of floppy drives supported (clear = 1, set = 2)
176; SF: Emulating drives (clear = yes, set = no)
177; Corrupts registers:
178; Nothing
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181RamVars_UnpackFlopCntAndFirstToAL:
182 mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
183 sar al, 1
184 ret
185%endif
Note: See TracBrowser for help on using the repository browser.