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