[90] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for initializing the BIOS. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[526] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 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. |
---|
[526] | 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 |
---|
[526] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[526] | 18 | ; |
---|
[376] | 19 | |
---|
[3] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; Initializes the BIOS. |
---|
| 25 | ; This function is called from main BIOS ROM search routine. |
---|
| 26 | ; |
---|
| 27 | ; Initialize_FromMainBiosRomSearch |
---|
| 28 | ; Parameters: |
---|
| 29 | ; Nothing |
---|
| 30 | ; Returns: |
---|
| 31 | ; Nothing |
---|
| 32 | ; Corrupts registers: |
---|
| 33 | ; Nothing |
---|
| 34 | ;-------------------------------------------------------------------- |
---|
[413] | 35 | Initialize_FromMainBiosRomSearch: ; unused entrypoint ok |
---|
| 36 | pushf ; To store IF |
---|
[3] | 37 | push ds |
---|
| 38 | |
---|
[413] | 39 | %ifndef USE_186 |
---|
| 40 | push ax |
---|
| 41 | LOAD_BDA_SEGMENT_TO ds, ax |
---|
| 42 | %else |
---|
| 43 | push BYTE 0 |
---|
| 44 | pop ds |
---|
| 45 | %endif |
---|
| 46 | |
---|
| 47 | sti ; Enable interrupts for keystrokes |
---|
| 48 | test BYTE [BDA.bKBFlgs1], (1<<2) ; Clears ZF if CTRL is held down |
---|
[90] | 49 | jnz SHORT .SkipRomInitialization |
---|
[3] | 50 | |
---|
[229] | 51 | ; Install INT 19h handler (boot loader) where drives are detected |
---|
[413] | 52 | mov WORD [BIOS_BOOT_LOADER_INTERRUPT_19h*4], Int19h_BootLoaderHandler |
---|
| 53 | mov [BIOS_BOOT_LOADER_INTERRUPT_19h*4+2], cs |
---|
[551] | 54 | ;mov WORD [BIOS_BOOT_FAILURE_INTERRUPT_18h*4], Int19h_BootLoaderHandler |
---|
| 55 | ;mov [BIOS_BOOT_FAILURE_INTERRUPT_18h*4+2], cs |
---|
[229] | 56 | |
---|
[90] | 57 | .SkipRomInitialization: |
---|
[413] | 58 | %ifndef USE_186 |
---|
| 59 | pop ax |
---|
| 60 | %endif |
---|
[3] | 61 | pop ds |
---|
| 62 | popf |
---|
| 63 | retf |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | ;-------------------------------------------------------------------- |
---|
| 67 | ; Initializes the BIOS variables and detects IDE drives. |
---|
| 68 | ; |
---|
| 69 | ; Initialize_AndDetectDrives |
---|
| 70 | ; Parameters: |
---|
[90] | 71 | ; ES: BDA Segment |
---|
[3] | 72 | ; Returns: |
---|
[97] | 73 | ; DS: RAMVARS segment |
---|
[3] | 74 | ; Corrupts registers: |
---|
[413] | 75 | ; All, except ES |
---|
[3] | 76 | ;-------------------------------------------------------------------- |
---|
| 77 | Initialize_AndDetectDrives: |
---|
[392] | 78 | call DetectPrint_InitializeDisplayContext |
---|
[3] | 79 | call DetectPrint_RomFoundAtSegment |
---|
| 80 | call RamVars_Initialize |
---|
[392] | 81 | call BootVars_Initialize |
---|
[551] | 82 | call Interrupts_InitializeInterruptVectors ; HotkeyBar requires INT 40h so install handlers before drive detection |
---|
[431] | 83 | call DetectDrives_FromAllIDEControllers |
---|
[541] | 84 | ; Fall to .StoreDptPointersToIntVectors |
---|
| 85 | |
---|
| 86 | |
---|
[550] | 87 | %ifdef MODULE_COMPATIBLE_TABLES |
---|
[541] | 88 | ;-------------------------------------------------------------------- |
---|
| 89 | ; .StoreDptPointersToIntVectors |
---|
| 90 | ; Parameters: |
---|
| 91 | ; DS: RAMVARS segment |
---|
| 92 | ; ES: BDA and interrupt vector segment (zero) |
---|
| 93 | ; Returns: |
---|
| 94 | ; Nothing |
---|
| 95 | ; Corrupts registers: |
---|
| 96 | ; AX, CX, DX, SI, DI |
---|
| 97 | ;-------------------------------------------------------------------- |
---|
| 98 | .StoreDptPointersToIntVectors: |
---|
[542] | 99 | %ifndef USE_AT |
---|
| 100 | test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE |
---|
| 101 | jz SHORT .CompatibleDPTsCreated ; Only Full operating mode has extra RAM to spare |
---|
| 102 | %endif |
---|
| 103 | |
---|
[541] | 104 | mov dl, 80h |
---|
| 105 | call FindDPT_ForDriveNumberInDL ; DPT to DS:DI |
---|
| 106 | jc SHORT .FindForDrive81h ; Store nothing if not our drive |
---|
| 107 | |
---|
| 108 | call CompatibleDPT_CreateToAXSIforDriveDL |
---|
| 109 | mov [es:HD0_DPT_POINTER_41h*4], si |
---|
| 110 | mov [es:HD0_DPT_POINTER_41h*4+2], ax |
---|
| 111 | |
---|
| 112 | .FindForDrive81h: |
---|
| 113 | mov dl, 81h |
---|
| 114 | call FindDPT_ForDriveNumberInDL |
---|
| 115 | jc SHORT .CompatibleDPTsCreated |
---|
| 116 | |
---|
| 117 | call CompatibleDPT_CreateToAXSIforDriveDL |
---|
| 118 | mov [es:HD1_DPT_POINTER_46h*4], si |
---|
| 119 | mov [es:HD1_DPT_POINTER_46h*4+2], ax |
---|
| 120 | .CompatibleDPTsCreated: |
---|
[33] | 121 | ; Fall to .ResetDetectedDrives |
---|
[550] | 122 | %endif ; MODULE_COMPATIBLE_TABLES |
---|
[3] | 123 | |
---|
[541] | 124 | |
---|
[3] | 125 | ;-------------------------------------------------------------------- |
---|
[97] | 126 | ; .ResetDetectedDrives |
---|
[3] | 127 | ; Parameters: |
---|
| 128 | ; DS: RAMVARS segment |
---|
[243] | 129 | ; ES: BDA and interrupt vector segment (zero) |
---|
[3] | 130 | ; Returns: |
---|
| 131 | ; Nothing |
---|
| 132 | ; Corrupts registers: |
---|
[243] | 133 | ; All, except DS and ES |
---|
[3] | 134 | ;-------------------------------------------------------------------- |
---|
[33] | 135 | .ResetDetectedDrives: |
---|
[150] | 136 | call Idepack_FakeToSSBP |
---|
[271] | 137 | call AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization |
---|
[443] | 138 | add sp, BYTE SIZE_OF_IDEPACK_WITHOUT_INTPACK |
---|
[150] | 139 | ret |
---|