[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 | ;--------------------------------------------------------------------
|
---|
[254] | 9 | ; Creates new BOOTMENUINFO struct for detected hard disk.
|
---|
[3] | 10 | ;
|
---|
[254] | 11 | ; BootMenuInfo_CreateForHardDisk
|
---|
[3] | 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:
|
---|
[254] | 17 | ; ES:BX: Ptr to BOOTMENUINFO (if successful)
|
---|
[3] | 18 | ; Corrupts registers:
|
---|
[364] | 19 | ; AX, BX, CX, DX, DI
|
---|
[3] | 20 | ;--------------------------------------------------------------------
|
---|
[254] | 21 | BootMenuInfo_CreateForHardDisk:
|
---|
| 22 | call BootMenuInfo_ConvertDPTtoBX ; ES:BX now points to new BOOTMENUINFO
|
---|
[3] | 23 |
|
---|
[364] | 24 | ; Store Drive Name
|
---|
| 25 | push ds ; Preserve RAMVARS
|
---|
| 26 | push si
|
---|
[3] | 27 |
|
---|
[364] | 28 | push es ; ES copied to DS
|
---|
| 29 | pop ds
|
---|
[241] | 30 |
|
---|
[254] | 31 | add si, BYTE ATA1.strModel ; DS:SI now points drive name
|
---|
| 32 | lea di, [bx+BOOTMENUINFO.szDrvName] ; ES:DI now points to name destination
|
---|
| 33 | mov cx, MAX_HARD_DISK_NAME_LENGTH / 2 ; Max number of WORDs allowed
|
---|
[121] | 34 | .CopyNextWord:
|
---|
| 35 | lodsw
|
---|
[254] | 36 | xchg al, ah ; Change endianness
|
---|
[121] | 37 | stosw
|
---|
| 38 | loop .CopyNextWord
|
---|
[254] | 39 | xor ax, ax ; Zero AX and clear CF
|
---|
| 40 | stosw ; Terminate with NULL
|
---|
[3] | 41 |
|
---|
| 42 | pop si
|
---|
| 43 | pop ds
|
---|
[364] | 44 |
|
---|
[3] | 45 | ret
|
---|
| 46 |
|
---|
[252] | 47 |
|
---|
[3] | 48 | ;--------------------------------------------------------------------
|
---|
[254] | 49 | ; BootMenuInfo_GetTotalSectorCount
|
---|
[3] | 50 | ; Parameters:
|
---|
[241] | 51 | ; DS:DI: DPT Pointer
|
---|
[3] | 52 | ; Returns:
|
---|
| 53 | ; BX:DX:AX: 48-bit sector count
|
---|
| 54 | ; Corrupts registers:
|
---|
[252] | 55 | ; CX
|
---|
[128] | 56 | ;--------------------------------------------------------------------
|
---|
[364] | 57 | ALIGN JUMP_ALIGN
|
---|
[254] | 58 | BootMenuInfo_GetTotalSectorCount:
|
---|
[252] | 59 | test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
|
---|
| 60 | jnz SHORT .ReturnFullCapacity
|
---|
| 61 | jmp AH15h_GetSectorCountToBXDXAX
|
---|
| 62 | .ReturnFullCapacity:
|
---|
| 63 | jmp AccessDPT_GetLbaSectorCountToBXDXAX
|
---|
[100] | 64 |
|
---|
| 65 |
|
---|
| 66 | ;--------------------------------------------------------------------
|
---|
[254] | 67 | ; Returns offset to BOOTMENUINFO based on DPT pointer.
|
---|
[100] | 68 | ;
|
---|
[254] | 69 | ; BootMenuInfo_ConvertDPTtoBX
|
---|
[100] | 70 | ; Parameters:
|
---|
[241] | 71 | ; DS:DI: DPT Pointer
|
---|
[100] | 72 | ; Returns:
|
---|
[254] | 73 | ; BX: Offset to BOOTMENUINFO struct
|
---|
[100] | 74 | ; Corrupts registers:
|
---|
[365] | 75 | ; AX
|
---|
[100] | 76 | ;--------------------------------------------------------------------
|
---|
[254] | 77 | BootMenuInfo_ConvertDPTtoBX:
|
---|
[241] | 78 | mov ax, di
|
---|
[363] | 79 | sub ax, BYTE RAMVARS_size ; subtract off base of DPTs
|
---|
[254] | 80 | mov bl, DPT_BOOTMENUINFO_SIZE_MULTIPLIER ; BOOTMENUINFO's are a whole number multiple of DPT size
|
---|
[241] | 81 | mul bl
|
---|
[254] | 82 | add ax, BOOTVARS.rgBootNfo ; add base of BOOTMENUINFO
|
---|
[241] | 83 | xchg ax, bx
|
---|
[364] | 84 | ret
|
---|