Subversion Repositories Kolibri OS

Rev

Rev 2899 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2899 Rev 2900
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2012. 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
;; simple AGP driver for KolibriOS                                 ;;
-
 
7
;;                                                                 ;;
-
 
8
;;    Written by hidnplayr@kolibrios.org                           ;;
-
 
9
;;                                                                 ;;
-
 
10
;;          GNU GENERAL PUBLIC LICENSE                             ;;
-
 
11
;;             Version 2, June 1991                                ;;
-
 
12
;;                                                                 ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 14...
7
 
14
 
Line 8... Line 15...
8
 
15
 
-
 
16
format MS COFF
9
format MS COFF
17
 
Line 10... Line 18...
10
 
18
DEBUG                   equ 1
11
DEBUG           equ 1
19
FAST_WRITE              equ 0
Line 12... Line 20...
12
API_VERSION     equ 1
20
SIDE_BAND_ADDRESSING    equ 0
Line 35... Line 43...
35
DRV_EXIT     equ -1
43
DRV_EXIT        equ -1
Line 36... Line 44...
36
 
44
 
37
SRV_GETVERSION  equ 0
45
SRV_GETVERSION  equ 0
Line -... Line 46...
-
 
46
SRV_DETECT      equ 1
-
 
47
 
38
SRV_DETECT      equ 1
48
API_VERSION     equ 1
Line 39... Line 49...
39
 
49
 
Line 40... Line 50...
40
section '.flat' code readable align 16
50
section '.flat' code readable align 16
Line 108... Line 118...
108
        mov     [bus], eax
118
        mov     [bus], eax
109
        inc     eax
119
        inc     eax
110
        call    PciApi          ; get last bus
120
        call    PciApi          ; get last bus
111
        cmp     eax, -1
121
        cmp     eax, -1
112
        je      .error
122
        je      .error
113
 
-
 
114
        mov     [last_bus], eax
123
        mov     [last_bus], eax
Line 115... Line 124...
115
 
124
 
116
  .next_bus:
125
  .next_bus:
117
        and     [devfn], 0
126
        and     [devfn], 0
118
  .next_dev:
127
  .next_dev:
119
        stdcall PciRead16, [bus], [devfn], dword 0x08   ; read class/subclass
-
 
120
        test    eax, eax
-
 
121
        jz      .next
-
 
122
        cmp     eax, -1
-
 
Line 123... Line 128...
123
        je      .next
128
        stdcall PciRead16, [bus], [devfn], dword 0x0a   ; read class/subclass
124
 
129
 
Line 125... Line 130...
125
        cmp     ax, 0x0302      ; display controller - 3d controller
130
        cmp     ax, 0x0302      ; display controller - 3d controller
Line 135... Line 140...
135
        mov     eax, [bus]
140
        mov     eax, [bus]
136
        inc     eax
141
        inc     eax
137
        mov     [bus], eax
142
        mov     [bus], eax
138
        cmp     eax, [last_bus]
143
        cmp     eax, [last_bus]
139
        jna     .next_bus
144
        jna     .next_bus
-
 
145
 
-
 
146
  .error:
-
 
147
     if DEBUG
-
 
148
        mov     esi, msgFail
-
 
149
        call    SysMsgBoardStr
-
 
150
     end if
-
 
151
 
140
        xor     eax, eax
152
        xor     eax, eax
-
 
153
        inc     eax
141
        ret
154
        ret
Line 142... Line 155...
142
 
155
 
143
  .found:
156
  .found:
144
        stdcall PciRead8, [bus], [devfn], dword 0x06    ; read prog IF
157
        stdcall PciRead8, [bus], [devfn], dword 0x06    ; read prog IF
145
        test    al, 1 shl 4                             ; got capabilities list?
158
        test    al, 1 shl 4                             ; got capabilities list?
Line -... Line 159...
-
 
159
        jnz     .got_capabilities_list
-
 
160
 
-
 
161
        ; TODO: Do it the old way: detect device and check with a list of known capabilities
-
 
162
        ; stupid pre PCI 2.2 board....
-
 
163
 
146
        jnz     .got_capabilities_list
164
        jmp     .next
147
 
165
 
148
  .got_capabilities_list:
166
  .got_capabilities_list:
149
        stdcall PciRead8, [bus], [devfn], dword 0x34    ; read capabilities offset
167
        stdcall PciRead8, [bus], [devfn], dword 0x34    ; read capabilities offset
Line 155... Line 173...
155
        cmp     al, 0x02                                ; AGP
173
        cmp     al, 0x02                                ; AGP
156
        je      .got_agp
174
        je      .got_agp
157
        movzx   esi, ah                                 ; pointer to next capability
175
        movzx   esi, ah                                 ; pointer to next capability
158
        test    esi, esi
176
        test    esi, esi
159
        jnz     .read_capability
177
        jnz     .read_capability
160
  .error:
-
 
161
        xor     eax, eax
-
 
162
        inc     eax
178
        jmp     .next
163
        ret
-
 
Line 164... Line 179...
164
 
179
 
165
  .got_agp:
180
  .got_agp:
166
        shl     eax, 16
181
        shl     eax, 16
167
        mov     [revision], al                          ; high nibble = major revision
182
        mov     [revision], al                          ; high nibble = major revision
Line 181... Line 196...
181
 
196
 
182
        test    al, 1b
197
        test    al, 1b
Line 183... Line 198...
183
        jz      .error
198
        jz      .error
184
 
199
 
185
  .001b:
200
  .001b:
Line 186... Line 201...
186
        mov     [speed], 001b
201
        mov     [cmd], 001b
187
        jmp     .agp_go
202
        jmp     .agp_go
188
 
203
 
Line 189... Line 204...
189
  .010b:
204
  .010b:
190
        mov     [speed], 010b
205
        mov     [cmd], 010b
191
        jmp     .agp_go
206
        jmp     .agp_go
Line 192... Line 207...
192
 
207
 
193
  .100b:
208
  .100b:
194
        mov     [speed], 100b
209
        mov     [cmd], 100b
195
        jmp     .agp_go
210
        jmp     .agp_go
196
 
211
 
197
  .agp_3:
212
  .agp_3:
198
        stdcall PciRead32, [bus], [devfn], esi          ; read AGP status
213
        stdcall PciRead32, [bus], [devfn], esi          ; read AGP status
199
        test    al, 1 shl 3
214
        test    al, 1 shl 3
200
        jz      .agp_2
215
        jz      .agp_2
Line 201... Line 216...
201
        and     al, 11b
216
        mov     [cmd], eax
-
 
217
        and     [cmd], 11b
-
 
218
        cmp     [cmd], 11b
-
 
219
        jne     .agp_go
-
 
220
        mov     [cmd], 10b
-
 
221
 
-
 
222
  .agp_go:
-
 
223
 
-
 
224
if FAST_WRITE
-
 
225
        test    ax, 1 shl 4
-
 
226
        jz      @f
-
 
227
        or      [cmd], 1 shl 4
-
 
228
  @@:
-
 
229
end if
202
        mov     [speed], al
230
if SIDE_BAND_ADDRESSING
203
        cmp     al, 11b
-
 
204
        jne     .agp_go
-
 
205
        mov     [speed], 10b
231
        test    ax, 1 shl 9
206
 
232
        jz      @f
207
  .agp_go:
233
        or      [cmd], 1 shl 9
Line -... Line 234...
-
 
234
  @@:
-
 
235
end if
-
 
236
        add     esi, 4
-
 
237
        mov     eax, [cmd]
-
 
238
        or      eax, 1 shl 8                            ; enable AGP
208
        add     esi, 4
239
        stdcall PciWrite32, [bus], [devfn], esi, eax    ; write AGP cmd
Line 209... Line 240...
209
        stdcall PciRead32, [bus], [devfn], esi          ; read AGP cmd
240
 
Line 210... Line 241...
210
        and     al, not 111b                            ; set max speed
241
     if DEBUG
Line 211... Line 242...
211
        or      al, [speed]
242
        mov     esi, msgOK
212
        or      eax, 1 shl 8                            ; enable AGP
243
        call    SysMsgBoardStr
Line 213... Line 244...
213
        stdcall PciWrite32, [bus], [devfn], esi, eax    ; write AGP cmd
244
     end if
Line 214... Line 245...
214
 
245
 
215
        ret
-
 
216
 
246
        ret
-
 
247
 
Line 217... Line 248...
217
endp
248
endp
Line 218... Line 249...
218
 
249
 
Line 219... Line 250...
219
 
250
 
220
;all initialized data place here
251
; initialized data
221
 
252
 
222
align 4
253
align 4