[90] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for initializing the BIOS.
|
---|
| 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 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 | ;--------------------------------------------------------------------
|
---|
[229] | 35 | Initialize_FromMainBiosRomSearch: ; unused entrypoint ok
|
---|
[3] | 36 | pushf
|
---|
| 37 | push es
|
---|
| 38 | push ds
|
---|
| 39 | ePUSHA
|
---|
| 40 |
|
---|
[90] | 41 | LOAD_BDA_SEGMENT_TO es, ax
|
---|
[229] | 42 | sti ; Enable interrupts
|
---|
| 43 | test BYTE [es:BDA.bKBFlgs1], (1<<2) ; Clears ZF if CTRL is held down
|
---|
[90] | 44 | jnz SHORT .SkipRomInitialization
|
---|
[3] | 45 |
|
---|
[229] | 46 | ; Install INT 19h handler (boot loader) where drives are detected
|
---|
[258] | 47 | mov al, BIOS_BOOT_LOADER_INTERRUPT_19h
|
---|
[243] | 48 | mov si, Int19h_BootLoaderHandler
|
---|
[258] | 49 | call Interrupts_InstallHandlerToVectorInALFromCSSI
|
---|
[229] | 50 |
|
---|
[90] | 51 | .SkipRomInitialization:
|
---|
[3] | 52 | ePOPA
|
---|
| 53 | pop ds
|
---|
| 54 | pop es
|
---|
| 55 | popf
|
---|
| 56 | retf
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | ;--------------------------------------------------------------------
|
---|
| 60 | ; Initializes the BIOS variables and detects IDE drives.
|
---|
| 61 | ;
|
---|
| 62 | ; Initialize_AndDetectDrives
|
---|
| 63 | ; Parameters:
|
---|
[90] | 64 | ; ES: BDA Segment
|
---|
[3] | 65 | ; Returns:
|
---|
[97] | 66 | ; DS: RAMVARS segment
|
---|
[3] | 67 | ; Corrupts registers:
|
---|
[97] | 68 | ; All
|
---|
[3] | 69 | ;--------------------------------------------------------------------
|
---|
| 70 | Initialize_AndDetectDrives:
|
---|
[392] | 71 | call DetectPrint_InitializeDisplayContext
|
---|
[3] | 72 | call DetectPrint_RomFoundAtSegment
|
---|
| 73 | call RamVars_Initialize
|
---|
[392] | 74 | call BootVars_Initialize
|
---|
[33] | 75 | call Interrupts_InitializeInterruptVectors
|
---|
[3] | 76 | call DetectDrives_FromAllIDEControllers
|
---|
[98] | 77 | ; Fall to .StoreDptPointersToIntVectors
|
---|
[97] | 78 |
|
---|
| 79 | ;--------------------------------------------------------------------
|
---|
[98] | 80 | ; .StoreDptPointersToIntVectors
|
---|
[97] | 81 | ; Parameters:
|
---|
| 82 | ; DS: RAMVARS segment
|
---|
| 83 | ; ES: BDA and interrupt vector segment (zero)
|
---|
| 84 | ; Returns:
|
---|
| 85 | ; Nothing
|
---|
| 86 | ; Corrupts registers:
|
---|
| 87 | ; DX, DI
|
---|
| 88 | ;--------------------------------------------------------------------
|
---|
[98] | 89 | .StoreDptPointersToIntVectors:
|
---|
[97] | 90 | mov dl, 80h
|
---|
[262] | 91 | call FindDPT_ForDriveNumberInDL ; DPT to DS:DI
|
---|
[258] | 92 | jc SHORT .FindForDrive81h ; Store nothing if not our drive
|
---|
[152] | 93 | mov [es:HD0_DPT_POINTER_41h*4], di
|
---|
| 94 | mov [es:HD0_DPT_POINTER_41h*4+2], ds
|
---|
[97] | 95 | .FindForDrive81h:
|
---|
| 96 | inc dx
|
---|
[262] | 97 | call FindDPT_ForDriveNumberInDL
|
---|
[258] | 98 | jc SHORT .ResetDetectedDrives
|
---|
[152] | 99 | mov [es:HD1_DPT_POINTER_46h*4], di
|
---|
| 100 | mov [es:HD1_DPT_POINTER_46h*4+2], ds
|
---|
[33] | 101 | ; Fall to .ResetDetectedDrives
|
---|
[3] | 102 |
|
---|
| 103 | ;--------------------------------------------------------------------
|
---|
[97] | 104 | ; .ResetDetectedDrives
|
---|
[3] | 105 | ; Parameters:
|
---|
| 106 | ; DS: RAMVARS segment
|
---|
[243] | 107 | ; ES: BDA and interrupt vector segment (zero)
|
---|
[3] | 108 | ; Returns:
|
---|
| 109 | ; Nothing
|
---|
| 110 | ; Corrupts registers:
|
---|
[243] | 111 | ; All, except DS and ES
|
---|
[3] | 112 | ;--------------------------------------------------------------------
|
---|
[33] | 113 | .ResetDetectedDrives:
|
---|
[150] | 114 | call Idepack_FakeToSSBP
|
---|
[271] | 115 | call AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization
|
---|
[158] | 116 | add sp, BYTE EXTRA_BYTES_FOR_INTPACK
|
---|
[150] | 117 | ret
|
---|