[88] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for generating and accessing drive
|
---|
| 3 | ; information to be displayed on boot menu.
|
---|
| 4 |
|
---|
| 5 | ; Section containing code
|
---|
| 6 | SECTION .text
|
---|
| 7 |
|
---|
| 8 | ;--------------------------------------------------------------------
|
---|
| 9 | ; Creates new BOOTNFO struct for detected hard disk.
|
---|
| 10 | ;
|
---|
| 11 | ; BootInfo_CreateForHardDisk
|
---|
| 12 | ; Parameters:
|
---|
| 13 | ; DL: Drive number
|
---|
| 14 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 15 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
| 16 | ; Returns:
|
---|
| 17 | ; ES:BX: Ptr to BOOTNFO (if successful)
|
---|
| 18 | ; CF: Cleared if BOOTNFO created succesfully
|
---|
| 19 | ; Set if any error
|
---|
| 20 | ; Corrupts registers:
|
---|
| 21 | ; AX, BX, CX, DX
|
---|
| 22 | ;--------------------------------------------------------------------
|
---|
| 23 | BootInfo_CreateForHardDisk:
|
---|
| 24 | call BootInfo_GetOffsetToBX ; ES:BX now points to new BOOTNFO
|
---|
[100] | 25 | ; Fall to .StoreSectorCount
|
---|
[3] | 26 |
|
---|
| 27 | ;--------------------------------------------------------------------
|
---|
[100] | 28 | ; .StoreSectorCount
|
---|
[3] | 29 | ; Parameters:
|
---|
| 30 | ; ES:BX: Ptr to BOOTNFO
|
---|
| 31 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
| 32 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 33 | ; Returns:
|
---|
[100] | 34 | ; Nothing
|
---|
[3] | 35 | ; Corrupts registers:
|
---|
| 36 | ; AX, CX, DX
|
---|
| 37 | ;--------------------------------------------------------------------
|
---|
[100] | 38 | .StoreSectorCount:
|
---|
[3] | 39 | push bx
|
---|
| 40 | call AtaID_GetTotalSectorCount ; Get to BX:DX:AX
|
---|
| 41 | mov cx, bx ; Now in CX:DX:AX
|
---|
| 42 | pop bx
|
---|
| 43 | mov [es:bx+BOOTNFO.twSectCnt], ax
|
---|
| 44 | mov [es:bx+BOOTNFO.twSectCnt+2], dx
|
---|
| 45 | mov [es:bx+BOOTNFO.twSectCnt+4], cx
|
---|
[100] | 46 | ; Fall to .StoreDriveName
|
---|
[3] | 47 |
|
---|
| 48 | ;--------------------------------------------------------------------
|
---|
[100] | 49 | ; .StoreDriveName
|
---|
[3] | 50 | ; Parameters:
|
---|
| 51 | ; ES:BX: Ptr to BOOTNFO
|
---|
| 52 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
| 53 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 54 | ; Returns:
|
---|
| 55 | ; CF: Cleared if variables stored succesfully
|
---|
| 56 | ; Set if any error
|
---|
| 57 | ; Corrupts registers:
|
---|
| 58 | ; AX, CX
|
---|
| 59 | ;--------------------------------------------------------------------
|
---|
[100] | 60 | .StoreDriveName:
|
---|
[3] | 61 | push ds
|
---|
| 62 | push si
|
---|
| 63 | push di
|
---|
| 64 |
|
---|
| 65 | push es
|
---|
| 66 | pop ds
|
---|
[100] | 67 | add si, BYTE ATA1.strModel ; DS:SI now points drive name
|
---|
| 68 | lea di, [bx+BOOTNFO.szDrvName] ; ES:DI now points to name destination
|
---|
| 69 | mov cx, LEN_BOOTNFO_DRV
|
---|
| 70 | call Memory_CopyCXbytesFromDSSItoESDI
|
---|
| 71 | xor ax, ax
|
---|
| 72 | stosb ; Terminate with NULL
|
---|
[3] | 73 |
|
---|
| 74 | pop di
|
---|
| 75 | pop si
|
---|
| 76 | pop ds
|
---|
| 77 | clc
|
---|
| 78 | ret
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | ;--------------------------------------------------------------------
|
---|
[100] | 82 | ; Finds BOOTNFO for drive and returns total sector count.
|
---|
[3] | 83 | ;
|
---|
| 84 | ; BootInfo_GetTotalSectorCount
|
---|
| 85 | ; Parameters:
|
---|
| 86 | ; DL: Drive number
|
---|
| 87 | ; DS: RAMVARS segment
|
---|
| 88 | ; Returns:
|
---|
| 89 | ; BX:DX:AX: 48-bit sector count
|
---|
| 90 | ; Corrupts registers:
|
---|
| 91 | ; Nothing
|
---|
| 92 | ;--------------------------------------------------------------------
|
---|
| 93 | ALIGN JUMP_ALIGN
|
---|
| 94 | BootInfo_GetTotalSectorCount:
|
---|
| 95 | push ds
|
---|
| 96 | call BootInfo_GetOffsetToBX
|
---|
| 97 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
| 98 | mov ax, [bx+BOOTNFO.twSectCnt]
|
---|
| 99 | mov dx, [bx+BOOTNFO.twSectCnt+2]
|
---|
| 100 | mov bx, [bx+BOOTNFO.twSectCnt+4]
|
---|
| 101 | pop ds
|
---|
| 102 | ret
|
---|
[100] | 103 |
|
---|
| 104 |
|
---|
| 105 | ;--------------------------------------------------------------------
|
---|
| 106 | ; Returns offset to BOOTNFO for wanted drive.
|
---|
| 107 | ;
|
---|
| 108 | ; BootInfo_GetOffsetToBX
|
---|
| 109 | ; Parameters:
|
---|
| 110 | ; DL: Drive number
|
---|
| 111 | ; DS: RAMVARS segment
|
---|
| 112 | ; Returns:
|
---|
| 113 | ; BX: Offset to BOOTNFO struct
|
---|
| 114 | ; Corrupts registers:
|
---|
| 115 | ; AX
|
---|
| 116 | ;--------------------------------------------------------------------
|
---|
| 117 | ALIGN JUMP_ALIGN
|
---|
| 118 | BootInfo_GetOffsetToBX:
|
---|
| 119 | mov bl, dl ; Copy drive number to BL
|
---|
| 120 | mov al, BOOTNFO_size ; Size of struct
|
---|
| 121 | sub bl, [RAMVARS.bFirstDrv] ; Drive number to index
|
---|
| 122 | mul bl ; AX = Offset inside BOOTNFO array
|
---|
| 123 | add ax, BOOTVARS.rgBootNfo ; Add offset to BOOTNFO array
|
---|
| 124 | xchg bx, ax ; Copy result to BX
|
---|
| 125 | ret
|
---|