[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 |
---|
[625] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2023 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: |
---|
[592] | 33 | ; AX, CX, DX, DI |
---|
[3] | 34 | ;-------------------------------------------------------------------- |
---|
| 35 | RamVars_Initialize: |
---|
[90] | 36 | push es |
---|
[3] | 37 | |
---|
[625] | 38 | mov ax, [cs:ROMVARS.wRamVars] |
---|
| 39 | test ax, ax ; UMB segment or LITE_MODE_RAMVARS_SEGMENT? |
---|
| 40 | jnz SHORT .InitializeRamvars ; No need to steal RAM |
---|
[3] | 41 | |
---|
[625] | 42 | mov ds, ax |
---|
[3] | 43 | mov al, [cs:ROMVARS.bStealSize] |
---|
[33] | 44 | sub [BDA.wBaseMem], ax |
---|
[567] | 45 | %ifdef USE_186 |
---|
[592] | 46 | imul ax, [BDA.wBaseMem], 64 |
---|
[567] | 47 | %else |
---|
[592] | 48 | mov al, 64 |
---|
| 49 | mul WORD [BDA.wBaseMem] |
---|
[567] | 50 | %endif |
---|
[3] | 51 | |
---|
[97] | 52 | .InitializeRamvars: |
---|
[592] | 53 | xor di, di |
---|
[241] | 54 | mov ds, ax |
---|
| 55 | mov es, ax |
---|
[97] | 56 | mov cx, RAMVARS_size |
---|
| 57 | call Memory_ZeroESDIwithSizeInCX |
---|
[444] | 58 | mov WORD [RAMVARS.wDrvDetectSignature], RAMVARS_DRV_DETECT_SIGNATURE |
---|
| 59 | mov WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE |
---|
[556] | 60 | %ifdef MODULE_DRIVEXLATE |
---|
| 61 | call DriveXlate_Reset |
---|
| 62 | %endif |
---|
[505] | 63 | |
---|
[97] | 64 | pop es |
---|
[395] | 65 | ret |
---|
[33] | 66 | |
---|
[625] | 67 | |
---|
[3] | 68 | ;-------------------------------------------------------------------- |
---|
| 69 | ; Returns segment to RAMVARS. |
---|
[625] | 70 | ; RAMVARS might be located at the top of interrupt vectors (0030:0000h), |
---|
| 71 | ; at the top of system base RAM or in a user configured UMB. |
---|
[3] | 72 | ; |
---|
| 73 | ; RamVars_GetSegmentToDS |
---|
| 74 | ; Parameters: |
---|
| 75 | ; Nothing |
---|
| 76 | ; Returns: |
---|
| 77 | ; DS: RAMVARS segment |
---|
| 78 | ; Corrupts registers: |
---|
| 79 | ; DI |
---|
| 80 | ;-------------------------------------------------------------------- |
---|
| 81 | ALIGN JUMP_ALIGN |
---|
| 82 | RamVars_GetSegmentToDS: |
---|
[625] | 83 | mov ds, [cs:ROMVARS.wRamVars] |
---|
| 84 | mov di, ds |
---|
| 85 | test di, di ; UMB segment or LITE_MODE_RAMVARS_SEGMENT? |
---|
| 86 | jnz SHORT .Return |
---|
[368] | 87 | |
---|
[592] | 88 | ;%ifdef USE_186 |
---|
| 89 | ; imul di, [BDA.wBaseMem], 64 ; 2 bytes less but slower, especially on 386/486 processors |
---|
| 90 | ;%else |
---|
[3] | 91 | mov di, [BDA.wBaseMem] ; Load available base memory size in kB |
---|
[33] | 92 | eSHL_IM di, 6 ; Segment to first stolen kB (*=40h) |
---|
[592] | 93 | ;%endif |
---|
[3] | 94 | ALIGN JUMP_ALIGN |
---|
| 95 | .LoopStolenKBs: |
---|
| 96 | mov ds, di ; EBDA segment to DS |
---|
| 97 | add di, BYTE 64 ; DI to next stolen kB |
---|
[444] | 98 | cmp WORD [RAMVARS.wSignature], RAMVARS_RAM_SIGNATURE |
---|
[3] | 99 | jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually) |
---|
[625] | 100 | .Return: |
---|
[3] | 101 | ret |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | ;-------------------------------------------------------------------- |
---|
[258] | 105 | ; RamVars_GetHardDiskCountFromBDAtoAX |
---|
[3] | 106 | ; Parameters: |
---|
| 107 | ; DS: RAMVARS segment |
---|
| 108 | ; Returns: |
---|
[258] | 109 | ; AX: Total hard disk count |
---|
[3] | 110 | ; Corrupts registers: |
---|
[492] | 111 | ; BX |
---|
[116] | 112 | ;-------------------------------------------------------------------- |
---|
[392] | 113 | %ifdef MODULE_BOOT_MENU |
---|
[258] | 114 | RamVars_GetHardDiskCountFromBDAtoAX: |
---|
| 115 | call RamVars_GetCountOfKnownDrivesToAX |
---|
[294] | 116 | push ds |
---|
[505] | 117 | LOAD_BDA_SEGMENT_TO ds, bx |
---|
[492] | 118 | mov bl, [BDA.bHDCount] |
---|
| 119 | MAX_U al, bl |
---|
[294] | 120 | pop ds |
---|
[3] | 121 | ret |
---|
[392] | 122 | %endif |
---|
[32] | 123 | |
---|
[392] | 124 | |
---|
[623] | 125 | %ifdef MODULE_SERIAL_FLOPPY |
---|
[32] | 126 | ;-------------------------------------------------------------------- |
---|
[623] | 127 | ; RamVars_UnpackFlopCntAndFirstToAL |
---|
[32] | 128 | ; Parameters: |
---|
| 129 | ; DS: RAMVARS segment |
---|
| 130 | ; Returns: |
---|
[623] | 131 | ; AL: First floppy drive number supported |
---|
| 132 | ; CF: Number of floppy drives supported (clear = 1, set = 2) |
---|
| 133 | ; SF: Emulating drives (clear = yes, set = no) |
---|
[32] | 134 | ; Corrupts registers: |
---|
[623] | 135 | ; Nothing |
---|
[116] | 136 | ;-------------------------------------------------------------------- |
---|
[32] | 137 | ALIGN JUMP_ALIGN |
---|
[623] | 138 | RamVars_UnpackFlopCntAndFirstToAL: |
---|
| 139 | mov al, [RAMVARS.xlateVars+XLATEVARS.bFlopCntAndFirst] |
---|
| 140 | sar al, 1 |
---|
[32] | 141 | ret |
---|
[623] | 142 | %endif |
---|
[294] | 143 | |
---|
[623] | 144 | |
---|
[33] | 145 | ;-------------------------------------------------------------------- |
---|
| 146 | ; RamVars_GetIdeControllerCountToCX |
---|
| 147 | ; Parameters: |
---|
| 148 | ; Nothing |
---|
| 149 | ; Returns: |
---|
| 150 | ; CX: Number of IDE controllers to handle |
---|
| 151 | ; Corrupts registers: |
---|
| 152 | ; Nothing |
---|
[116] | 153 | ;-------------------------------------------------------------------- |
---|
[258] | 154 | ALIGN JUMP_ALIGN |
---|
[33] | 155 | RamVars_GetIdeControllerCountToCX: |
---|
[294] | 156 | eMOVZX cx, [cs:ROMVARS.bIdeCnt] |
---|
[33] | 157 | ret |
---|
[258] | 158 | |
---|
[473] | 159 | |
---|
[258] | 160 | ;-------------------------------------------------------------------- |
---|
[623] | 161 | ; RamVars_GetCountOfKnownDrivesToAX |
---|
[258] | 162 | ; Parameters: |
---|
[473] | 163 | ; DS: RAMVARS segment |
---|
[258] | 164 | ; Returns: |
---|
[623] | 165 | ; AX: Total hard disk count |
---|
[258] | 166 | ; Corrupts registers: |
---|
[623] | 167 | ; None |
---|
[294] | 168 | ;-------------------------------------------------------------------- |
---|
[258] | 169 | ALIGN JUMP_ALIGN |
---|
[623] | 170 | RamVars_GetCountOfKnownDrivesToAX: |
---|
| 171 | mov ax, [RAMVARS.wFirstDrvAndCount] |
---|
| 172 | add al, ah |
---|
| 173 | and ax, BYTE 7Fh |
---|
[258] | 174 | ret |
---|