Subversion Repositories Kolibri OS

Rev

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

Rev 2217 Rev 2219
Line 10... Line 10...
10
iglobal
10
iglobal
11
IRQ_COUNT	dd	24
11
IRQ_COUNT    dd 24
12
endg
12
endg
Line 13... Line 13...
13
 
13
 
14
uglobal
14
uglobal
15
APIC         rd  1
15
irq_mode     rd  1
16
IOAPIC_base  rd  1
16
IOAPIC_base  rd  1
17
LAPIC_BASE   rd  1
17
LAPIC_BASE   rd  1
Line 18... Line 18...
18
endg
18
endg
Line 42... Line 42...
42
IOAPIC_ARB      equ 0x2
42
IOAPIC_ARB      equ 0x2
43
IOAPIC_REDTBL   equ 0x10
43
IOAPIC_REDTBL   equ 0x10
Line 44... Line 44...
44
 
44
 
45
align 4
45
align 4
46
APIC_init:
46
APIC_init:
Line 47... Line 47...
47
        mov dword[APIC], 0
47
        mov [irq_mode], IRQ_PIC
-
 
48
 
-
 
49
        cmp [acpi_ioapic_base], 0
-
 
50
        jz .no_apic
-
 
51
 
-
 
52
        cmp [acpi_lapic_base], 0
-
 
53
        jz .no_apic
48
 
54
 
-
 
55
        stdcall load_file, dev_data_path
49
        mov eax, [acpi_ioapic_base]
56
        test eax, eax
Line 50... Line 57...
50
        test eax, eax
57
        mov [acpi_dev_data], eax
Line 51... Line 58...
51
        jz .no_apic
58
        jz .no_apic
Line 96... Line 103...
96
        cmp ecx, [IRQ_COUNT]
103
        cmp ecx, [IRQ_COUNT]
97
        jb  @b
104
        jb  @b
Line 98... Line 105...
98
 
105
 
Line 99... Line 106...
99
        call  LAPIC_init
106
        call  LAPIC_init
Line 100... Line 107...
100
 
107
 
101
        mov dword[APIC], 0xffffffff
108
        mov [irq_mode], IRQ_APIC
102
 
109
 
103
        mov al, 0x70
110
        mov al, 0x70
Line 104... Line -...
104
        out 0x22, al
-
 
105
        mov al, 1
-
 
106
        out 0x23, al
111
        out 0x22, al
Line 107... Line 112...
107
 
112
        mov al, 1
Line 108... Line 113...
108
	; mov	dword[irq_type_to_set], IRQ_TYPE_APIC
113
        out 0x23, al
Line 240... Line 245...
240
        pop esi
245
        pop esi
241
        ret
246
        ret
242
;===========================================================
247
;===========================================================
243
; Remap all IRQ to 0x20+ Vectors
248
; Remap all IRQ to 0x20+ Vectors
244
; IRQ0 to vector 0x20, IRQ1 to vector 0x21....
249
; IRQ0 to vector 0x20, IRQ1 to vector 0x21....
-
 
250
align 4
245
PIC_init:
251
PIC_init:
246
        cli
252
        cli
247
        mov al,0x11   ;  icw4, edge triggered
253
        mov al,0x11   ;  icw4, edge triggered
248
        out 0x20,al
254
        out 0x20,al
249
        out 0xA0,al
255
        out 0xA0,al
Line 266... Line 272...
266
	; mov	dword[irq_type_to_set], IRQ_TYPE_PIC
272
	; mov	dword[irq_type_to_set], IRQ_TYPE_PIC
267
        ret
273
        ret
Line 268... Line 274...
268
 
274
 
269
; -----------------------------------------
275
; -----------------------------------------
-
 
276
; TIMER SET TO 1/100 S
270
; TIMER SET TO 1/100 S
277
align 4
271
PIT_init:
278
PIT_init:
272
        mov   al,0x34      ; set to 100Hz
279
        mov   al,0x34      ; set to 100Hz
273
        out   0x43,al
280
        out   0x43,al
274
        mov   al,0x9b      ; lsb    1193180 / 1193
281
        mov   al,0x9b      ; lsb    1193180 / 1193
275
        out   0x40,al
282
        out   0x40,al
276
        mov   al,0x2e      ; msb
283
        mov   al,0x2e      ; msb
277
        out   0x40,al
284
        out   0x40,al
Line 278... Line 285...
278
        ret
285
        ret
-
 
286
 
279
 
287
; -----------------------------------------
280
; -----------------------------------------
288
align 4
281
unmask_timer:
289
unmask_timer:
-
 
290
        cmp  [irq_mode], IRQ_APIC
282
        test  dword[APIC], 0xffffffff
291
        je @f
283
        jnz @f
292
 
284
        stdcall enable_irq, 0
293
        stdcall enable_irq, 0
285
        ret
294
        ret
286
@@:
295
@@:
Line 304... Line 313...
304
        mov [esi + APIC_LVT_timer], eax
313
        mov [esi + APIC_LVT_timer], eax
305
        ret
314
        ret
Line 306... Line 315...
306
 
315
 
307
; -----------------------------------------
316
; -----------------------------------------
-
 
317
; Disable all IRQ
308
; Disable all IRQ
318
align 4
309
IRQ_mask_all:
319
IRQ_mask_all:
310
        test  dword[APIC], 0xffffffff
320
        cmp [irq_mode], IRQ_APIC
-
 
321
        je .APIC
311
        jnz .APIC
322
 
312
        mov al, 0xFF
323
        mov al, 0xFF
313
        out 0x21, al
324
        out 0x21, al
314
        out 0xA1, al
325
        out 0xA1, al
315
        mov ecx,0x1000
326
        mov ecx,0x1000
Line 329... Line 340...
329
        ret
340
        ret
Line 330... Line 341...
330
 
341
 
331
; -----------------------------------------
342
; -----------------------------------------
332
; End Of Interrupt
343
; End Of Interrupt
333
; cl - IRQ number
344
; cl - IRQ number
334
align 16
345
align 4
335
irq_eoi:         ; __fastcall
346
irq_eoi:         ; __fastcall
336
        test  dword[APIC], 0xffffffff
347
        cmp [irq_mode], IRQ_APIC
Line 337... Line 348...
337
        jnz .APIC
348
        je .APIC
338
 
349
 
339
        cmp cl, 8
350
        cmp cl, 8
340
        mov al, 0x20
351
        mov al, 0x20
Line 352... Line 363...
352
; -----------------------------------------
363
; -----------------------------------------
353
; from dll.inc
364
; from dll.inc
354
align 4
365
align 4
355
proc enable_irq stdcall, irq_line:dword
366
proc enable_irq stdcall, irq_line:dword
356
        mov ebx, [irq_line]
367
        mov ebx, [irq_line]
357
        test  dword[APIC], 0xffffffff
368
        cmp [irq_mode], IRQ_APIC
358
        jnz .APIC
369
        je .APIC
Line 359... Line 370...
359
 
370
 
360
        mov edx, 0x21
371
        mov edx, 0x21
361
        cmp ebx, 8
372
        cmp ebx, 8
Line 377... Line 388...
377
        xchg  eax, ebx
388
        xchg  eax, ebx
378
        call  IOAPIC_write
389
        call  IOAPIC_write
379
        ret
390
        ret
380
endp
391
endp
Line -... Line 392...
-
 
392
 
-
 
393
align 4
-
 
394
pci_irq_fixup:
-
 
395
 
-
 
396
        push ebp
-
 
397
 
-
 
398
        mov esi, [acpi_dev_data]
-
 
399
        mov ebx, [acpi_dev_size]
-
 
400
 
-
 
401
        lea edi, [esi+ebx]
-
 
402
 
-
 
403
.iterate:
-
 
404
 
-
 
405
        cmp esi, edi
-
 
406
        jae .done
-
 
407
 
-
 
408
        mov eax, [esi]
-
 
409
 
-
 
410
        cmp eax, -1
-
 
411
        je .done
-
 
412
 
-
 
413
        movzx ebx, al
-
 
414
        movzx ebp, ah
-
 
415
 
-
 
416
        stdcall pci_read32, ebp, ebx, 0
-
 
417
 
-
 
418
        cmp eax, [esi+4]
-
 
419
        jne .skip
-
 
420
 
-
 
421
        mov eax, [esi+8]
-
 
422
        stdcall pci_write8, ebp, ebx, 0x3C, eax
-
 
423
.skip:
-
 
424
        add esi, 16
-
 
425
        jmp .iterate
-
 
426
 
-
 
427
.done:
-
 
428
.fail:
-
 
429
        pop ebp
Line 381... Line 430...
381
 
430
        ret
382
 
431
 
383
 
432