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