[90] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for accessings RAMVARS.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[505] | 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[376] | 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.
|
---|
[505] | 12 | ;
|
---|
[376] | 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
|
---|
[505] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
[505] | 18 | ;
|
---|
[376] | 19 |
|
---|
[3] | 20 | ; Section containing code
|
---|
| 21 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
| 35 | RamVars_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
|
---|
[531] | 58 | mov ax, [BDA.wBaseMem] ; We can save a byte here by using INT 12h instead
|
---|
[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
|
---|
[493] | 79 | ;; There used to be a DriveXlate_Reset call here. It isn't necessary, as we reset
|
---|
| 80 | ;; when entering the boot menu and also before transferring control at boot time and
|
---|
| 81 | ;; for ROM boots (in int19h.asm).
|
---|
[505] | 82 |
|
---|
[97] | 83 | pop es
|
---|
[395] | 84 | ret
|
---|
[33] | 85 |
|
---|
[3] | 86 | ;--------------------------------------------------------------------
|
---|
| 87 | ; Returns segment to RAMVARS.
|
---|
| 88 | ; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
|
---|
| 89 | ; or at the top of system base RAM.
|
---|
| 90 | ;
|
---|
| 91 | ; RamVars_GetSegmentToDS
|
---|
| 92 | ; Parameters:
|
---|
| 93 | ; Nothing
|
---|
| 94 | ; Returns:
|
---|
| 95 | ; DS: RAMVARS segment
|
---|
| 96 | ; Corrupts registers:
|
---|
| 97 | ; DI
|
---|
| 98 | ;--------------------------------------------------------------------
|
---|
| 99 | ALIGN JUMP_ALIGN
|
---|
| 100 | RamVars_GetSegmentToDS:
|
---|
[368] | 101 |
|
---|
[400] | 102 | %ifndef USE_AT ; Always in Full Mode for AT builds
|
---|
[3] | 103 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
[33] | 104 | jnz SHORT .GetStolenSegmentToDS
|
---|
[400] | 105 | %ifndef USE_186
|
---|
| 106 | mov di, LITE_MODE_RAMVARS_SEGMENT
|
---|
| 107 | mov ds, di
|
---|
| 108 | %else
|
---|
| 109 | push LITE_MODE_RAMVARS_SEGMENT
|
---|
| 110 | pop ds
|
---|
| 111 | %endif
|
---|
| 112 | ret
|
---|
[181] | 113 | %endif
|
---|
[3] | 114 |
|
---|
| 115 | ALIGN JUMP_ALIGN
|
---|
[33] | 116 | .GetStolenSegmentToDS:
|
---|
[3] | 117 | LOAD_BDA_SEGMENT_TO ds, di
|
---|
| 118 | mov di, [BDA.wBaseMem] ; Load available base memory size in kB
|
---|
[33] | 119 | eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
|
---|
[3] | 120 | ALIGN JUMP_ALIGN
|
---|
| 121 | .LoopStolenKBs:
|
---|
| 122 | mov ds, di ; EBDA segment to DS
|
---|
| 123 | add di, BYTE 64 ; DI to next stolen kB
|
---|
[444] | 124 | cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
|
---|
[3] | 125 | jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
|
---|
| 126 | ret
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | ;--------------------------------------------------------------------
|
---|
[258] | 130 | ; RamVars_GetHardDiskCountFromBDAtoAX
|
---|
[3] | 131 | ; Parameters:
|
---|
| 132 | ; DS: RAMVARS segment
|
---|
| 133 | ; Returns:
|
---|
[258] | 134 | ; AX: Total hard disk count
|
---|
[3] | 135 | ; Corrupts registers:
|
---|
[492] | 136 | ; BX
|
---|
[116] | 137 | ;--------------------------------------------------------------------
|
---|
[392] | 138 | %ifdef MODULE_BOOT_MENU
|
---|
[258] | 139 | RamVars_GetHardDiskCountFromBDAtoAX:
|
---|
| 140 | call RamVars_GetCountOfKnownDrivesToAX
|
---|
[294] | 141 | push ds
|
---|
[505] | 142 | LOAD_BDA_SEGMENT_TO ds, bx
|
---|
[492] | 143 | mov bl, [BDA.bHDCount]
|
---|
| 144 | MAX_U al, bl
|
---|
[294] | 145 | pop ds
|
---|
[3] | 146 | ret
|
---|
[392] | 147 | %endif
|
---|
[32] | 148 |
|
---|
[392] | 149 |
|
---|
[32] | 150 | ;--------------------------------------------------------------------
|
---|
[258] | 151 | ; RamVars_GetCountOfKnownDrivesToAX
|
---|
[32] | 152 | ; Parameters:
|
---|
| 153 | ; DS: RAMVARS segment
|
---|
| 154 | ; Returns:
|
---|
[258] | 155 | ; AX: Total hard disk count
|
---|
[32] | 156 | ; Corrupts registers:
|
---|
[258] | 157 | ; None
|
---|
[116] | 158 | ;--------------------------------------------------------------------
|
---|
[32] | 159 | ALIGN JUMP_ALIGN
|
---|
[258] | 160 | RamVars_GetCountOfKnownDrivesToAX:
|
---|
[433] | 161 | mov ax, [RAMVARS.wFirstDrvAndCount]
|
---|
[258] | 162 | add al, ah
|
---|
[368] | 163 | and ax, BYTE 7fh
|
---|
[32] | 164 | ret
|
---|
[294] | 165 |
|
---|
[33] | 166 | ;--------------------------------------------------------------------
|
---|
| 167 | ; RamVars_GetIdeControllerCountToCX
|
---|
| 168 | ; Parameters:
|
---|
| 169 | ; Nothing
|
---|
| 170 | ; Returns:
|
---|
| 171 | ; CX: Number of IDE controllers to handle
|
---|
| 172 | ; Corrupts registers:
|
---|
| 173 | ; Nothing
|
---|
[116] | 174 | ;--------------------------------------------------------------------
|
---|
[258] | 175 | ALIGN JUMP_ALIGN
|
---|
[33] | 176 | RamVars_GetIdeControllerCountToCX:
|
---|
[294] | 177 | eMOVZX cx, [cs:ROMVARS.bIdeCnt]
|
---|
[33] | 178 | ret
|
---|
[258] | 179 |
|
---|
[473] | 180 |
|
---|
[258] | 181 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 182 | ;--------------------------------------------------------------------
|
---|
| 183 | ; RamVars_UnpackFlopCntAndFirstToAL
|
---|
| 184 | ; Parameters:
|
---|
[473] | 185 | ; DS: RAMVARS segment
|
---|
[258] | 186 | ; Returns:
|
---|
| 187 | ; AL: First floppy drive number supported
|
---|
| 188 | ; CF: Number of floppy drives supported (clear = 1, set = 2)
|
---|
[270] | 189 | ; SF: Emulating drives (clear = yes, set = no)
|
---|
[258] | 190 | ; Corrupts registers:
|
---|
| 191 | ; Nothing
|
---|
[294] | 192 | ;--------------------------------------------------------------------
|
---|
[258] | 193 | ALIGN JUMP_ALIGN
|
---|
| 194 | RamVars_UnpackFlopCntAndFirstToAL:
|
---|
| 195 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
|
---|
[294] | 196 | sar al, 1
|
---|
[258] | 197 | ret
|
---|
| 198 | %endif
|
---|
[473] | 199 |
|
---|
| 200 |
|
---|
[489] | 201 | %if 0 ; unused...
|
---|
[473] | 202 | ;--------------------------------------------------------------------
|
---|
| 203 | ; RamVars_IsDriveDetectionInProgress
|
---|
| 204 | ; Parameters:
|
---|
| 205 | ; DS: RAMVARS segment
|
---|
| 206 | ; Returns:
|
---|
| 207 | ; ZF: Set if drive detection is in progress (ROM initialization)
|
---|
| 208 | ; Corrupts registers:
|
---|
| 209 | ; None
|
---|
| 210 | ;--------------------------------------------------------------------
|
---|
| 211 | RamVars_IsDriveDetectionInProgress:
|
---|
| 212 | cmp WORD [RAMVARS.wSignature], RAMVARS_DRV_DETECT_SIGNATURE
|
---|
| 213 | ret
|
---|
[489] | 214 | %endif
|
---|