[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:
|
---|
[364] | 49 | ; Always steal memory when using Advanced ATA module since it
|
---|
| 50 | ; uses larger DPTs
|
---|
| 51 | %ifndef MODULE_ADVANCED_ATA
|
---|
[241] | 52 | mov ax, LITE_MODE_RAMVARS_SEGMENT
|
---|
[3] | 53 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
[97] | 54 | jz SHORT .InitializeRamvars ; No need to steal RAM
|
---|
[364] | 55 | %endif
|
---|
[3] | 56 |
|
---|
[116] | 57 | LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
|
---|
[3] | 58 | mov al, [cs:ROMVARS.bStealSize]
|
---|
[33] | 59 | sub [BDA.wBaseMem], ax
|
---|
| 60 | mov ax, [BDA.wBaseMem]
|
---|
[97] | 61 | eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h)
|
---|
[150] | 62 | ; Fall to .InitializeRamvars
|
---|
[3] | 63 |
|
---|
[33] | 64 | ;--------------------------------------------------------------------
|
---|
[97] | 65 | ; .InitializeRamvars
|
---|
[33] | 66 | ; Parameters:
|
---|
[241] | 67 | ; AX: RAMVARS segment
|
---|
[97] | 68 | ; Returns:
|
---|
[33] | 69 | ; DS: RAMVARS segment
|
---|
| 70 | ; Corrupts registers:
|
---|
| 71 | ; AX, CX, DI, ES
|
---|
| 72 | ;--------------------------------------------------------------------
|
---|
[97] | 73 | .InitializeRamvars:
|
---|
[241] | 74 | mov ds, ax
|
---|
| 75 | mov es, ax
|
---|
[97] | 76 | mov cx, RAMVARS_size
|
---|
| 77 | xor di, di
|
---|
| 78 | call Memory_ZeroESDIwithSizeInCX
|
---|
[150] | 79 | mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
|
---|
[97] | 80 | ; Fall to .InitializeDriveTranslationAndReturn
|
---|
[3] | 81 |
|
---|
[97] | 82 | ;--------------------------------------------------------------------
|
---|
| 83 | ; .InitializeDriveTranslationAndReturn
|
---|
| 84 | ; Parameters:
|
---|
| 85 | ; DS: RAMVARS segment
|
---|
| 86 | ; Returns:
|
---|
| 87 | ; Nothing
|
---|
| 88 | ; Corrupts registers:
|
---|
| 89 | ; AX
|
---|
| 90 | ;--------------------------------------------------------------------
|
---|
| 91 | .InitializeDriveTranslationAndReturn:
|
---|
| 92 | pop es
|
---|
| 93 | jmp DriveXlate_Reset
|
---|
[33] | 94 |
|
---|
[97] | 95 |
|
---|
[3] | 96 | ;--------------------------------------------------------------------
|
---|
| 97 | ; Returns segment to RAMVARS.
|
---|
| 98 | ; RAMVARS might be located at the top of interrupt vectors (0030:0000h)
|
---|
| 99 | ; or at the top of system base RAM.
|
---|
| 100 | ;
|
---|
| 101 | ; RamVars_GetSegmentToDS
|
---|
| 102 | ; Parameters:
|
---|
| 103 | ; Nothing
|
---|
| 104 | ; Returns:
|
---|
| 105 | ; DS: RAMVARS segment
|
---|
| 106 | ; Corrupts registers:
|
---|
| 107 | ; DI
|
---|
| 108 | ;--------------------------------------------------------------------
|
---|
| 109 | ALIGN JUMP_ALIGN
|
---|
| 110 | RamVars_GetSegmentToDS:
|
---|
[368] | 111 |
|
---|
| 112 | %ifndef MODULE_ADVANCED_ATA ; Always in Full Mode when using Advanced ATA Module
|
---|
[3] | 113 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
|
---|
[33] | 114 | jnz SHORT .GetStolenSegmentToDS
|
---|
[181] | 115 | %ifndef USE_186
|
---|
[150] | 116 | mov di, LITE_MODE_RAMVARS_SEGMENT
|
---|
[3] | 117 | mov ds, di
|
---|
[181] | 118 | %else
|
---|
| 119 | push LITE_MODE_RAMVARS_SEGMENT
|
---|
| 120 | pop ds
|
---|
| 121 | %endif
|
---|
[3] | 122 | ret
|
---|
[368] | 123 | %endif ; MODULE_ADVANCED_ATA
|
---|
[3] | 124 |
|
---|
| 125 | ALIGN JUMP_ALIGN
|
---|
[33] | 126 | .GetStolenSegmentToDS:
|
---|
[3] | 127 | LOAD_BDA_SEGMENT_TO ds, di
|
---|
| 128 | mov di, [BDA.wBaseMem] ; Load available base memory size in kB
|
---|
[33] | 129 | eSHL_IM di, 6 ; Segment to first stolen kB (*=40h)
|
---|
[3] | 130 | ALIGN JUMP_ALIGN
|
---|
| 131 | .LoopStolenKBs:
|
---|
| 132 | mov ds, di ; EBDA segment to DS
|
---|
| 133 | add di, BYTE 64 ; DI to next stolen kB
|
---|
[150] | 134 | cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE
|
---|
[3] | 135 | jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually)
|
---|
| 136 | ret
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | ;--------------------------------------------------------------------
|
---|
[258] | 140 | ; RamVars_GetHardDiskCountFromBDAtoAX
|
---|
[3] | 141 | ; Parameters:
|
---|
| 142 | ; DS: RAMVARS segment
|
---|
| 143 | ; Returns:
|
---|
[258] | 144 | ; AX: Total hard disk count
|
---|
[3] | 145 | ; Corrupts registers:
|
---|
[258] | 146 | ; CX
|
---|
[116] | 147 | ;--------------------------------------------------------------------
|
---|
[392] | 148 | %ifdef MODULE_BOOT_MENU
|
---|
[258] | 149 | RamVars_GetHardDiskCountFromBDAtoAX:
|
---|
| 150 | call RamVars_GetCountOfKnownDrivesToAX
|
---|
[294] | 151 | push ds
|
---|
| 152 | LOAD_BDA_SEGMENT_TO ds, cx
|
---|
| 153 | mov cl, [BDA.bHDCount]
|
---|
[258] | 154 | MAX_U al, cl
|
---|
[294] | 155 | pop ds
|
---|
[3] | 156 | ret
|
---|
[392] | 157 | %endif
|
---|
[32] | 158 |
|
---|
[392] | 159 |
|
---|
[32] | 160 | ;--------------------------------------------------------------------
|
---|
[258] | 161 | ; RamVars_GetCountOfKnownDrivesToAX
|
---|
[32] | 162 | ; Parameters:
|
---|
| 163 | ; DS: RAMVARS segment
|
---|
| 164 | ; Returns:
|
---|
[258] | 165 | ; AX: Total hard disk count
|
---|
[32] | 166 | ; Corrupts registers:
|
---|
[258] | 167 | ; None
|
---|
[116] | 168 | ;--------------------------------------------------------------------
|
---|
[32] | 169 | ALIGN JUMP_ALIGN
|
---|
[258] | 170 | RamVars_GetCountOfKnownDrivesToAX:
|
---|
| 171 | mov ax, [RAMVARS.wDrvCntAndFirst]
|
---|
| 172 | add al, ah
|
---|
[368] | 173 | and ax, BYTE 7fh
|
---|
[32] | 174 | ret
|
---|
[294] | 175 |
|
---|
[33] | 176 | ;--------------------------------------------------------------------
|
---|
| 177 | ; RamVars_GetIdeControllerCountToCX
|
---|
| 178 | ; Parameters:
|
---|
| 179 | ; Nothing
|
---|
| 180 | ; Returns:
|
---|
| 181 | ; CX: Number of IDE controllers to handle
|
---|
| 182 | ; Corrupts registers:
|
---|
| 183 | ; Nothing
|
---|
[116] | 184 | ;--------------------------------------------------------------------
|
---|
[258] | 185 | ALIGN JUMP_ALIGN
|
---|
[33] | 186 | RamVars_GetIdeControllerCountToCX:
|
---|
[294] | 187 | eMOVZX cx, [cs:ROMVARS.bIdeCnt]
|
---|
[33] | 188 | ret
|
---|
[258] | 189 |
|
---|
| 190 | %ifdef MODULE_SERIAL_FLOPPY
|
---|
| 191 | ;--------------------------------------------------------------------
|
---|
| 192 | ; RamVars_UnpackFlopCntAndFirstToAL
|
---|
| 193 | ; Parameters:
|
---|
| 194 | ; Nothing
|
---|
| 195 | ; Returns:
|
---|
| 196 | ; AL: First floppy drive number supported
|
---|
| 197 | ; CF: Number of floppy drives supported (clear = 1, set = 2)
|
---|
[270] | 198 | ; SF: Emulating drives (clear = yes, set = no)
|
---|
[258] | 199 | ; Corrupts registers:
|
---|
| 200 | ; Nothing
|
---|
[294] | 201 | ;--------------------------------------------------------------------
|
---|
[258] | 202 | ALIGN JUMP_ALIGN
|
---|
| 203 | RamVars_UnpackFlopCntAndFirstToAL:
|
---|
| 204 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst]
|
---|
[294] | 205 | sar al, 1
|
---|
[258] | 206 | ret
|
---|
| 207 | %endif
|
---|