[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
|
---|
| 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
|
---|
| 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
|
---|
[97] | 96 | ; Fall to .InitializeDriveTranslationAndReturn
|
---|
[3] | 97 |
|
---|
[97] | 98 | ;--------------------------------------------------------------------
|
---|
| 99 | ; .InitializeDriveTranslationAndReturn
|
---|
| 100 | ; Parameters:
|
---|
| 101 | ; DS: RAMVARS segment
|
---|
| 102 | ; Returns:
|
---|
| 103 | ; Nothing
|
---|
| 104 | ; Corrupts registers:
|
---|
| 105 | ; AX
|
---|
| 106 | ;--------------------------------------------------------------------
|
---|
| 107 | .InitializeDriveTranslationAndReturn:
|
---|
| 108 | pop es
|
---|
[395] | 109 | %ifdef MODULE_HOTKEYS
|
---|
[97] | 110 | jmp DriveXlate_Reset
|
---|
[395] | 111 | %else
|
---|
| 112 | ret
|
---|
| 113 | %endif
|
---|
[33] | 114 |
|
---|
[97] | 115 |
|
---|
[3] | 116 | ;--------------------------------------------------------------------
|
---|
| 117 | ; Returns segment to RAMVARS.
|
---|
| 118 | ; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
|
---|
| 119 | ; or at the top of system base RAM.
|
---|
| 120 | ;
|
---|
| 121 | ; RamVars_GetSegmentToDS
|
---|
| 122 | ; Parameters:
|
---|
| 123 | ; Nothing
|
---|
| 124 | ; Returns:
|
---|
| 125 | ; DS: RAMVARS segment
|
---|
| 126 | ; Corrupts registers:
|
---|
| 127 | ; DI
|
---|
| 128 | ;--------------------------------------------------------------------
|
---|
| 129 | ALIGN JUMP_ALIGN
|
---|
| 130 | RamVars_GetSegmentToDS:
|
---|
[368] | 131 |
|
---|
[400] | 132 | %ifndef USE_AT ; Always in Full Mode for AT builds
|
---|
[3] | 133 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
[33] | 134 | jnz SHORT .GetStolenSegmentToDS
|
---|
[400] | 135 | %ifndef USE_186
|
---|
| 136 | mov di, LITE_MODE_RAMVARS_SEGMENT
|
---|
| 137 | mov ds, di
|
---|
| 138 | %else
|
---|
| 139 | push LITE_MODE_RAMVARS_SEGMENT
|
---|
| 140 | pop ds
|
---|
| 141 | %endif
|
---|
| 142 | ret
|
---|
[181] | 143 | %endif
|
---|
[3] | 144 |
|
---|
| 145 | ALIGN JUMP_ALIGN
|
---|
[33] | 146 | .GetStolenSegmentToDS:
|
---|
[3] | 147 | LOAD_BDA_SEGMENT_TO ds, di
|
---|
| 148 | mov di, [BDA.wBaseMem] ; Load available base memory size in kB
|
---|
[33] | 149 | eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
|
---|
[3] | 150 | ALIGN JUMP_ALIGN
|
---|
| 151 | .LoopStolenKBs:
|
---|
| 152 | mov ds, di ; EBDA segment to DS
|
---|
| 153 | add di, BYTE 64 ; DI to next stolen kB
|
---|
[444] | 154 | cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE
|
---|
[3] | 155 | jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
|
---|
| 156 | ret
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 | ;--------------------------------------------------------------------
|
---|
[258] | 160 | ; RamVars_GetHardDiskCountFromBDAtoAX
|
---|
[3] | 161 | ; Parameters:
|
---|
| 162 | ; DS: RAMVARS segment
|
---|
| 163 | ; Returns:
|
---|
[258] | 164 | ; AX: Total hard disk count
|
---|
[3] | 165 | ; Corrupts registers:
|
---|
[258] | 166 | ; CX
|
---|
[116] | 167 | ;--------------------------------------------------------------------
|
---|
[392] | 168 | %ifdef MODULE_BOOT_MENU
|
---|
[258] | 169 | RamVars_GetHardDiskCountFromBDAtoAX:
|
---|
| 170 | call RamVars_GetCountOfKnownDrivesToAX
|
---|
[294] | 171 | push ds
|
---|
| 172 | LOAD_BDA_SEGMENT_TO ds, cx
|
---|
| 173 | mov cl, [BDA.bHDCount]
|
---|
[258] | 174 | MAX_U al, cl
|
---|
[294] | 175 | pop ds
|
---|
[3] | 176 | ret
|
---|
[392] | 177 | %endif
|
---|
[32] | 178 |
|
---|
[392] | 179 |
|
---|
[32] | 180 | ;--------------------------------------------------------------------
|
---|
[258] | 181 | ; RamVars_GetCountOfKnownDrivesToAX
|
---|
[32] | 182 | ; Parameters:
|
---|
| 183 | ; DS: RAMVARS segment
|
---|
| 184 | ; Returns:
|
---|
[258] | 185 | ; AX: Total hard disk count
|
---|
[32] | 186 | ; Corrupts registers:
|
---|
[258] | 187 | ; None
|
---|
[116] | 188 | ;--------------------------------------------------------------------
|
---|
[32] | 189 | ALIGN JUMP_ALIGN
|
---|
[258] | 190 | RamVars_GetCountOfKnownDrivesToAX:
|
---|
[433] | 191 | mov ax, [RAMVARS.wFirstDrvAndCount]
|
---|
[258] | 192 | add al, ah
|
---|
[368] | 193 | and ax, BYTE 7fh
|
---|
[32] | 194 | ret
|
---|
[294] | 195 |
|
---|
[33] | 196 | ;--------------------------------------------------------------------
|
---|
| 197 | ; RamVars_GetIdeControllerCountToCX
|
---|
| 198 | ; Parameters:
|
---|
| 199 | ; Nothing
|
---|
| 200 | ; Returns:
|
---|
| 201 | ; CX: Number of IDE controllers to handle
|
---|
| 202 | ; Corrupts registers:
|
---|
| 203 | ; Nothing
|
---|
[116] | 204 | ;--------------------------------------------------------------------
|
---|
[258] | 205 | ALIGN JUMP_ALIGN
|
---|
[33] | 206 | RamVars_GetIdeControllerCountToCX:
|
---|
[294] | 207 | eMOVZX cx, [cs:ROMVARS.bIdeCnt]
|
---|
[33] | 208 | ret
|
---|
[258] | 209 |
|
---|
[473] | 210 |
|
---|
[258] | 211 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 212 | ;--------------------------------------------------------------------
|
---|
| 213 | ; RamVars_UnpackFlopCntAndFirstToAL
|
---|
| 214 | ; Parameters:
|
---|
[473] | 215 | ; DS: RAMVARS segment
|
---|
[258] | 216 | ; Returns:
|
---|
| 217 | ; AL: First floppy drive number supported
|
---|
| 218 | ; CF: Number of floppy drives supported (clear = 1, set = 2)
|
---|
[270] | 219 | ; SF: Emulating drives (clear = yes, set = no)
|
---|
[258] | 220 | ; Corrupts registers:
|
---|
| 221 | ; Nothing
|
---|
[294] | 222 | ;--------------------------------------------------------------------
|
---|
[258] | 223 | ALIGN JUMP_ALIGN
|
---|
| 224 | RamVars_UnpackFlopCntAndFirstToAL:
|
---|
| 225 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
|
---|
[294] | 226 | sar al, 1
|
---|
[258] | 227 | ret
|
---|
| 228 | %endif
|
---|
[473] | 229 |
|
---|
| 230 |
|
---|
[489] | 231 | %if 0 ; unused...
|
---|
[473] | 232 | ;--------------------------------------------------------------------
|
---|
| 233 | ; RamVars_IsDriveDetectionInProgress
|
---|
| 234 | ; Parameters:
|
---|
| 235 | ; DS: RAMVARS segment
|
---|
| 236 | ; Returns:
|
---|
| 237 | ; ZF: Set if drive detection is in progress (ROM initialization)
|
---|
| 238 | ; Corrupts registers:
|
---|
| 239 | ; None
|
---|
| 240 | ;--------------------------------------------------------------------
|
---|
| 241 | RamVars_IsDriveDetectionInProgress:
|
---|
| 242 | cmp WORD [RAMVARS.wSignature], RAMVARS_DRV_DETECT_SIGNATURE
|
---|
| 243 | ret
|
---|
[489] | 244 | %endif
|
---|