Rev 7132 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
10051 | ace_dent | 3 | ;; Copyright (C) KolibriOS team 2008-2024. All rights reserved. ;; |
2288 | clevermous | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
7 | |||
4850 | mario79 | 8 | |
2288 | clevermous | 9 | ; Detect all BIOS hard drives. |
10 | ; diamond, 2008 |
||
3520 | clevermous | 11 | ; Do not include USB mass storages. CleverMouse, 2013 |
6843 | dunkaist | 12 | ; Read the number of sectors, bytes per sector. dunkaist, 2017 |
2288 | clevermous | 13 | |
14 | xor cx, cx |
||
15 | mov es, cx |
||
7132 | dunkaist | 16 | mov di, BOOT_LO.bios_hd |
2288 | clevermous | 17 | mov byte [es:di-1], cl |
18 | cmp [preboot_biosdisk], 1 |
||
19 | jnz bdde |
||
20 | mov dl, 80h |
||
21 | bdds: |
||
22 | mov ah, 15h |
||
23 | push cx dx di |
||
24 | int 13h |
||
25 | pop di dx cx |
||
26 | jc bddc |
||
27 | test ah, ah |
||
28 | jz bddc |
||
29 | inc cx |
||
3520 | clevermous | 30 | ; We are going to call int 13h/func 48h, Extended get drive parameters. |
31 | ; The latest version of the EDD specification is 3.0. |
||
32 | ; There are two slightly incompatible variants for version 3.0; |
||
33 | ; original one from Phoenix in 1998, see e.g. |
||
34 | ; http://www.t10.org/t13/technical/d98120r0.pdf, and T13 draft, |
||
35 | ; http://www.t13.org/documents/UploadedDocuments/docs2004/d1572r3-EDD3.pdf |
||
36 | ; T13 draft addresses more possible buses, so it gives additional 8 bytes |
||
37 | ; for device path. |
||
38 | ; Most BIOSes follow Phoenix, but T13 version is also known to be used |
||
39 | ; (e.g. systems based on AMD Geode). |
||
40 | ; Fortunately, there is an in/out length field, so |
||
41 | ; it is easy to tell what variant was selected by the BIOS: |
||
42 | ; Phoenix-3.0 has 42h bytes, T13-3.0 has 4Ah bytes. |
||
43 | ; Note that 2.0 has 1Eh bytes, 1.1 has 1Ah bytes; both variants of 3.0 have |
||
44 | ; the same structure for first 1Eh bytes, compatible with previous versions. |
||
45 | ; Note also that difference between Phoenix-3.0 and T13-3.0 starts near the |
||
46 | ; end of the structure, so the current code doesn't even need to distinguish. |
||
47 | ; It needs, however, give at least 4Ah bytes as input and expect that BIOS |
||
48 | ; could return 42h bytes as output while still giving all the information. |
||
2288 | clevermous | 49 | mov ah, 48h |
50 | push ds |
||
51 | push es |
||
52 | pop ds |
||
53 | mov si, 0xA000 |
||
3520 | clevermous | 54 | mov word [si], 4Ah |
2288 | clevermous | 55 | mov ah, 48h |
56 | int 13h |
||
57 | pop ds |
||
58 | jc bddc2 |
||
59 | cmp word [es:si], 1Eh |
||
3520 | clevermous | 60 | jb .noide |
2288 | clevermous | 61 | cmp word [es:si+1Ah], 0xFFFF |
3520 | clevermous | 62 | jz .noide |
7132 | dunkaist | 63 | inc byte [es:BOOT_LO.bios_hd_cnt] |
2288 | clevermous | 64 | mov al, dl |
65 | stosb |
||
66 | push ds |
||
6843 | dunkaist | 67 | push si |
2288 | clevermous | 68 | lds si, [es:si+1Ah] |
69 | mov al, [si+6] |
||
70 | and al, 0xF |
||
71 | stosb |
||
72 | mov al, byte [si+4] |
||
73 | shr al, 4 |
||
74 | and ax, 1 |
||
75 | cmp word [si], 1F0h |
||
76 | jz @f |
||
77 | inc ax |
||
78 | inc ax |
||
79 | cmp word [si], 170h |
||
80 | jz @f |
||
81 | or ax, -1 |
||
82 | ; mov ax, -1 |
||
83 | @@: |
||
84 | stosw |
||
6843 | dunkaist | 85 | pop si |
2288 | clevermous | 86 | pop ds |
6843 | dunkaist | 87 | jmp bddc3 |
3520 | clevermous | 88 | .noide: |
89 | cmp word [es:si], 42h |
||
90 | jb .nousb |
||
91 | cmp word [es:si+28h], 'US' |
||
92 | jnz .nousb |
||
93 | cmp byte [es:si+2Ah], 'B' |
||
94 | jz bddc2 |
||
95 | .nousb: |
||
7132 | dunkaist | 96 | inc byte [es:BOOT_LO.bios_hd_cnt] |
2288 | clevermous | 97 | mov al, dl |
98 | stosb |
||
99 | xor ax, ax |
||
100 | stosb |
||
101 | dec ax |
||
102 | stosw |
||
103 | ; mov al, 0 |
||
104 | ; stosb |
||
105 | ; mov ax, -1 |
||
106 | ; stosw |
||
6843 | dunkaist | 107 | bddc3: |
108 | movzx eax, word[es:si+24] |
||
109 | stosd |
||
110 | mov eax, [es:si+16] |
||
111 | stosd |
||
112 | mov eax, [es:si+20] |
||
113 | stosd |
||
2288 | clevermous | 114 | bddc2: |
115 | cmp cl, [es:0x475] |
||
116 | jae bdde |
||
117 | bddc: |
||
118 | inc dl |
||
119 | jnz bdds |
||
120 | bdde: |