Subversion Repositories Kolibri OS

Rev

Rev 7122 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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