-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpci.asm
1891 lines (1555 loc) · 50.3 KB
/
pci.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; DRIVER DE COMUNICAÇÃO PCI
;
; Kernel em Assembly x86
; Criado por Wender Francis
; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%INCLUDE "Hardware/memory.lib"
%INCLUDE "Hardware/kernel.lib"
;[BITS 32]
;[ORG PCI]
ORG 0
ALIGN 4
BITS 32
SECTION protectedmode vstart=0x150000, valign=4
%IFNDEF __CONFPCI_ASM__
%DEFINE __CONFPCI_ASM__
PCI_ADDRESS EQU 0x0CF8
PCI_DATA EQU 0x0CFC
PCI_READ EQU 0x00
PCI_WRITE EQU 0x01
jmp Init_PCI
jmp Get_Class_Name
jmp Get_SubClass_Name
jmp Get_Interface_Name
jmp Get_Device_Name
jmp Get_Vendor_Name
jmp Get_Classes_Number
HeaderMain: ; Main Header for all Devices, Size=16 bytes + 4
.VendorID dw 0
.DeviceID dw 0
.Command dw 0
.Status dw 0
.RevisionID db 0
.ProgIF db 0
.SubClass db 0
.ClassCode db 0
.CacheLSize db 0
.LatTimer db 0
.HeadType db 0
.Bist db 0
.HeadAddress dd 0
HeaderType0: ; (Common Header), size=48 bytes
.BaseBAR0 dd 0
.BaseBAR1 dd 0
.BaseBAR2 dd 0
.BaseBAR3 dd 0
.BaseBAR4 dd 0
.BaseBAR5 dd 0
.CardBusCS dd 0
.SubSysVID dw 0
.SubSysID dw 0
.ExpROM dd 0
.CapPointer db 0
.Reserved0 dw 0
.Reserved1 db 0
.Reserved2 dd 0
.IntLine db 0
.IntPIN db 0
.MinGrant db 0
.MaxLatency db 0
HeaderType1: ; (PCI-to-PCI Bridge Header), Size=48 bytes
.BaseBAR0 dd 0
.BaseBAR1 dd 0
.PrimaryBus db 0
.SecondaryBus db 0
.SubordinaryBus db 0
.SecondLatency db 0
.IOBase db 0
.IOLimit db 0
.SecondStatus dw 0
.MemoryBase dw 0
.MemoryLimit dw 0
.PrefMemBase dw 0
.PrefMemLimit dw 0
.PrefMemBase32 dd 0
.PrefMemLimit32 dd 0
.IOBase16 dw 0
.IOLimit16 dw 0
.CapPointer db 0
.Reserved0 dw 0
.Reserved1 db 0
.ExpROMAddr dd 0
.IntLine db 0
.IntPIN db 0
.BridgeControl dw 0
HeaderType2: ; (PCI-to-CardBus Bridge Header), size=56 bytes
.CardBusSocket dd 0
.OffsetCapList db 0
.Reserved db 0
.SecondaryStatus dw 0
.PCIBusNumber db 0
.CardBusNumber db 0
.SubordBusNumber db 0
.CardBusLatTimer db 0
.MemoryBase0 dd 0
.MemoryLimit0 dd 0
.MemoryBase1 dd 0
.MemoryLimit1 dd 0
.IOBase0 dd 0
.IOLimit0 dd 0
.IOBase1 dd 0
.IOLimit1 dd 0
.InterruptLine db 0
.InterruptPIN db 0
.BridgeControl dw 0
.SubSysDeviceID dw 0
.SubSysVendorID dw 0
.CardLegacy16 dd 0
bus db 0
slot db 0
func db 0
offs db 0
pdata dd 0
PCIEnabled db 0
Init_PCI:
mov eax, 0x80000000 ; Bit 31 set for 'Enabled'
mov ebx, eax
mov dx, PCI_ADDRESS
out dx, eax
in eax, dx
xor edx, edx
cmp eax, ebx
sete dl ; Set byte if equal, otherwise clear
mov byte [PCIEnabled], dl
call PCI_Check_All_Buses
ret
; -----------------------------------------------------------------------------
; PCI_Read_Word - Ler de um registro um dispositivo PCI
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function number
; DL = Offset number
; OUT: EAX = Register information
PCI_Read_Word:
push ebx
push ecx
push edx
and eax, 0xFF
and ebx, 0xFF
and ecx, 0xFF
shl eax, 16
shl ebx, 11
or eax, ebx
shl ecx, 8
or eax, ecx
and edx, 0xFC
or eax, edx
and eax, 0x00FFFFFF
or eax, 0x80000000
mov dx, PCI_ADDRESS
out dx, eax
mov dx, PCI_DATA
in eax, dx
mov [PCI_Reg], eax
pop edx
push edx
and edx, 0x02
shl edx, 3 ; multiplique por 8
mov ecx, edx
shr eax, cl
and eax, 0xFFFF
pop edx
pop ecx
pop ebx
ret
PCI_Reg dd 0x00000000
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Write_Word - Escreve para um registro um dispositivo PCI
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function number
; DL = Offset number
; OUT: None.
PCI_Write_Word:
push ebx
push ecx
push edx
shl eax, 16
shl ebx, 11
or eax, ebx
shl ecx, 8
or eax, ecx
and edx, 0xFC
or eax, edx
and eax, 0x00FFFFFF
or eax, 0x80000000
mov dx, PCI_ADDRESS
out dx, eax
mov dx, PCI_DATA
mov eax, [pdata]
out dx, eax
pop edx
pop ecx
pop ebx
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Check_Device - Verifica um Dispositivo PCI
; IN: AL = Bus number
; BL = Device/Slot number
; OUT: None.
; Registradores preservados
PCI_Check_Device:
pushad
mov cl, 0 ; Função 0
call PCI_Get_VendorID
cmp word[Vendor], 0xFFFF
je ReturnDevice
cmp byte[PCIEnabled], 0
jz Check_Mult_Func1
; EXIBIR INFORMAÇÕES ----------------
;call PCI_Show_Full
call Show_Name_Devices
;call PCI_Get_Info
; -----------------------------------
Check_Mult_Func1:
call PCI_Check_Function
call PCI_Get_HeaderType
and byte[Header], 0x80
cmp byte[Header], 0 ; Se bit 7 não estiver setado então
jz ReturnDevice ; Então não É um dispositivo multi-função
Multi_Func_Dev: ; Se tiver, É um dev multifunção
mov cl, 1
Loop_Check_Functions:
cmp cl, 8
jnb ReturnDevice
call PCI_Get_VendorID
cmp word[Vendor], 0xFFFF
jne CheckFunction
inc cl
jmp Loop_Check_Functions
CheckFunction:
cmp byte[PCIEnabled], 0
jz Check_Mult_Func2
; EXIBIR INFORMAÇÕES ----------------
;call PCI_Show_Full
call Show_Name_Devices
;call PCI_Get_Info
; -----------------------------------
Check_Mult_Func2:
call PCI_Check_Function
inc cl
jmp Loop_Check_Functions
ReturnDevice:
popad
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Check_Function - Verifica aquela função do barramento
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: None.
PCI_Check_Function:
push ax
call PCI_Get_ClassCode
call PCI_Get_SubClass
cmp byte[ClassCode], 0x06
jne ret_check_func
cmp byte[SubClass], 0x04
jne ret_check_func
call PCI_Get_SecondaryBus
mov al, [SecondaryBus]
call PCI_Check_Bus
ret_check_func:
pop ax
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Show_Full - Exibe informações do dispositivo PCI
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: None.
PCI_Show_Full:
push ax
call Print_Dec_Value32
call OffsetSpacesDec
mov ax, bx
call Print_Dec_Value32
call OffsetSpacesDec
mov ax, cx
call Print_Dec_Value32
call OffsetSpacesDec
pop ax
push ax
call PCI_Get_VendorID
call PCI_Get_DeviceID
call PCI_Get_Classes
mov ax, word[Vendor]
call Print_Hexa_Value16
call OffsetSpacesHex
mov ax, word[Device]
call Print_Hexa_Value16
call OffsetSpacesHex
pop ax
call Show_Name_Devices
ret
; -----------------------------------------------------------------------------
; PCI_Show_Full - Exibe Nomes de dispositivos na inicialização
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: None.
Show_Name_Devices:
push bx
push si
mov [bus], al
mov [slot], bl
mov [func], cl
call PCI_Get_Classes
call PCI_Get_ProgIF
mov esi, StrPCI
call Print_String
mov si, ADDRCL
mov bl, byte[ClassCode]
shl bx, 1
mov si, word[si + bx]
call Print_String
cmp byte[SubClass], 0x80
je ShowOther
push bx
mov si, SUBVEC
mov si, word[si + bx]
mov bl, byte[SubClass]
shl bx, 1
mov si, word[si + bx]
call Print_String
pop bx
mov si, PROGCL
mov si, word[si + bx] ; SI = SUBPIFx
cmp si, 0
jz Ret_Names
mov bl, byte[SubClass]
shl bx, 1
mov si, word[si + bx] ; SI = PCISBx
cmp si, 0
jz Ret_Names
mov bl, byte[ProgIF]
shl bx, 1
mov si, word[si + bx] ; SI = PROGIFx.x_x
call Print_String
jmp Return_Name_Device
ShowOther:
mov esi, OTHER
call Print_String
Ret_Names:
mov al, [bus]
mov bl, [slot]
mov cl, [func]
call Get_Device_Name
jc Return_Name_Device
call Print_String
Return_Name_Device:
mov esi, PCIChecked
call Print_String
call Break_Line
;push ax
;xor ax, ax
;int 0x16
;pop ax
pop si
pop bx
ret
; ROTINAS DO USUÁRIO +++++++++
; -----------------------------------------------------------------------------
; Get_Device_Name - Retorna o nome do dispositivo baseado no ID
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: ESI = Endereço da String do Dispositivo.
Get_Device_Name:
pushad
call PCI_Get_VendorID
mov eax, DWORD [PCI_Reg]
mov esi, DevIDs
xor ebx, ebx
xor ecx, ecx
mov cx, WORD [SizeDevID]
shr cx, 2
Loop_DevID:
cmp DWORD [esi], eax
je Get_NameDev
add esi, 4
inc ebx
loop Loop_DevID
stc
jmp Ret_GetDev
Get_NameDev:
shl ebx, 1
mov esi, Array_DevID
mov si, WORD [esi + ebx]
mov DWORD [AddrStr], esi
Ret_GetDev:
popad
mov esi, DWORD [AddrStr]
ret
AddrStr dd 0
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Get_Class_Name - Retorna o nome de Classe do dispositivo
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: ESI = Endereço da String do Dispositivo.
Get_Class_Name:
pushad
call PCI_Get_Classes
xor ebx, ebx
mov bl, BYTE [ClassCode]
shl ebx, 1
mov esi, ADDRCL
mov si, WORD [esi + ebx]
mov DWORD [AddrStr1], esi
popad
mov esi, DWORD [AddrStr1]
ret
AddrStr1 dd 0
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Get_SubClass_Name - Retorna o nome de SubClasse do dispositivo
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: ESI = Endereço da String do Dispositivo.
Get_SubClass_Name:
pushad
call PCI_Get_ClassCode
call PCI_Get_SubClass
xor ebx, ebx
mov bl, BYTE [ClassCode]
shl ebx, 1
mov esi, SUBVEC
mov si, WORD [esi + ebx]
mov bl, BYTE [SubClass]
shl ebx, 1
mov si, WORD [esi + ebx]
mov DWORD [AddrStr2], esi
popad
mov esi, DWORD [AddrStr2]
ret
AddrStr2 dd 0
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Get_Interface_Name - Retorna o nome de Interface do dispositivo
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: ESI = Endereço da String do Dispositivo.
Get_Interface_Name:
pushad
call PCI_Get_ClassCode
call PCI_Get_SubClass
call PCI_Get_ProgIF
xor ebx, ebx
mov bl, BYTE [ClassCode]
shl ebx, 1
mov esi, PROGCL
mov si, WORD [esi + ebx] ; SI = SUBPIFx
cmp si, 0xFFFF
jz Ret_Intr_Error
mov bl, BYTE [SubClass]
shl ebx, 1
mov si, word[esi + ebx] ; SI = PCISBx
cmp si, 0xFFFF
jz Ret_Intr_Error
mov bl, BYTE [ProgIF]
shl ebx, 1
mov si, word[esi + ebx] ; SI = PROGIFx.x_x
jmp Ret_Intr_Name
Ret_Intr_Error:
mov esi, 0xFFFFFFFF
Ret_Intr_Name:
mov DWORD [AddrStr3], esi
popad
mov esi, DWORD [AddrStr3]
ret
AddrStr3 dd 0
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Get_Vendor_Name - Retorna o nome de fabricante do dispositivo
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: ESI = Endereço da String do Fabricante.
Get_Vendor_Name:
pushad
; TODO primeiro fazer todos os nomes de fabricantes,
; Depois vir para esta rotina, igual as rotinas acima.
popad
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; Get_Classes_Number - Retorna o número de Classe e SubClasse
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Function
; OUT: AX = Número de Classe e SubClasse
Get_Classes_Number:
pushad
call PCI_Get_Classes
popad
mov ax, WORD [Classes]
ret
; -----------------------------------------------------------------------------
; Acesso das Strings de Interface -----------
; PROGCL -> Índice das classes
; SUBPIFx -> Índice das subclasses
; PCISBx -> Índice das Interfaces
; PROGIFx.x_x -> Endereço da String
;
; Acesso das Strings de SubClasses
; SUBVEC -> Índice das Classes com vetor de SubClasses
; PCICLx -> Índice das SubClasses dentro de uma Classe
OffsetSpacesDec:
pushad
mov cx, 7
mov bx, 10
OffSpace1:
xor dx, dx
div bx
cmp ax, 0
je RetOff
IncVar:
dec cx
jmp OffSpace1
RetOff:
mov ax, 0x0E20
int 0x10
loop RetOff
mov ah, 0x0E
mov al, "|"
int 0x10
popad
ret
OffsetSpacesHex:
pushad
mov cx, 4
Loop_Off:
mov ax, 0x0E20
int 0x10
loop Loop_Off
mov ah, 0x0E
mov al, "|"
int 0x10
popad
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Check_All_Buses - Brute Force Scan - All bus, All Slots & All Possibly funcs
; IN: None.
; OUT: None.
; Registradores preservados
PCI_Check_All_Buses:
pushad
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
; EXIBIR INFORMAÇÕES ----------------
;mov si, PCIListStr
;call Print_String
; -----------------------------------
mov al, 0
loop_all_buses1:
cmp al, 255
jb init_loop_bus
jmp return_checkb
init_loop_bus:
mov bl, 0
loop_all_buses2:
cmp bl, 32
jnb return_all_buses
call PCI_Check_Device
inc bl
jmp loop_all_buses2
return_all_buses:
inc al
jmp loop_all_buses1
return_checkb:
popad
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Check_Mult_Buses - Recursive Scan - Verificar se há multiplos PCIs
; PCI_Check_All_Buses EXHANCED!
; IN: None.
; OUT: None.
; Registradores preservados
PCI_Check_Mult_Buses:
pushad
xor eax, eax
xor ebx, ebx
xor ecx, ecx
xor edx, edx
; EXIBIR INFORMAÇÕES ----------------
;mov si, PCIListStr
;call Print_String
; -----------------------------------
call PCI_Get_HeaderType
and byte[Header], 0x80
cmp byte[Header], 0
jnz Check_Multiple_PCI
call PCI_Check_Bus
jmp ret_mult_buses
Check_Multiple_PCI:
cmp cl, 8
jnb ret_mult_buses
mov al, 0
call PCI_Get_VendorID
cmp word[Vendor], 0xFFFF
je ret_mult_buses
mov al, cl
call PCI_Check_Bus
inc cl
jmp Check_Multiple_PCI
ret_mult_buses:
popad
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Check_Bus - Recursive Scan
; IN: AL = Bus number.
; OUT: None.
PCI_Check_Bus:
push bx
push cx
mov bx, 0
mov cx, 32
loop_bus:
call PCI_Check_Device
inc bx
loop loop_bus
pop cx
pop bx
ret
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_VendorID - Retorna o ID do fabricante do dispositivo PCI
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AX = ID do Fabricante
PCI_Get_VendorID:
push eax
mov dl, 0 ; Offset 0 -> Fabricante
call PCI_Read_Word ; Efetua a leitura PCI
mov word[Vendor], ax ; Armazene o retorno em Vendor
pop eax
ret
Vendor dw 0x0000
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_DeviceID - Retorna o ID do dispositivo PCI
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AX = ID do Dispositivo
PCI_Get_DeviceID:
push eax
mov dl, 2 ; Offset 2 -> Dispositivo
call PCI_Read_Word ; Efetua a leitura PCI
mov word[Device], ax ; Armazene o retorno em Device
pop eax
ret
Device dw 0x0000
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_Command - Retorna o valor de Comando
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AX = Comando
PCI_Get_Command:
push eax
mov dl, 4 ; Offset 4 -> Command
call PCI_Read_Word ; Efetua a leitura PCI
mov word[Command], ax ; Armazene o retorno em Command
pop eax
ret
Command dw 0x0000
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_Status - Retorna o Status
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AX = Status
PCI_Get_Status:
push eax
mov dl, 6 ; Offset 6 -> Status
call PCI_Read_Word ; Efetua a leitura PCI
mov word[Status], ax ; Armazene o retorno em Status
pop eax
ret
Status dw 0x0000
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_RevisionID - Retorna o ID de Revisão
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AL = ID de Revisão
PCI_Get_RevisionID:
push eax
mov dl, 8 ; Offset 8 -> RevisionID
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[Revision], al ; Armazene o retorno em Revision
pop eax
ret
Revision db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_ProgIF - Retorna o ProgIF
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AH = ProgIF
PCI_Get_ProgIF:
push eax
mov dl, 8 ; Offset 8 -> ProgIF
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[ProgIF], ah ; Armazene o retorno em ProgIF
pop eax
ret
ProgIF db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_SubClass - Retorna a SubClasse
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AL = SubClass
PCI_Get_SubClass:
push eax
mov dl, 10 ; Offset 10 -> SubClasse
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[SubClass], al ; Armazene o retorno em SubClass
pop eax
ret
SubClass db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_ClassCode - Retorna o código de Classe
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AH = Código de Classe
PCI_Get_ClassCode:
push eax
mov dl, 10 ; Offset 10 -> Código de Classe
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[ClassCode], ah ; Armazene o retorno em ClassCode
pop eax
ret
ClassCode db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_CacheSize - Retorna o tamanho de linha de Cache
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AL = Cache Line Size
PCI_Get_CacheSize:
push eax
mov dl, 12 ; Offset 12 -> Cache Line Size
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[CacheSize], al ; Armazene o retorno em CacheSize
pop eax
ret
CacheSize db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_Latency - Retorna o Timer de latência
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AH = Timer de Latência
PCI_Get_Latency:
push eax
mov dl, 12 ; Offset 12 -> Timer de Latência
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[Latency], ah ; Armazene o retorno em Latency
pop eax
ret
Latency db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_HeaderType - Retorna o Tipo de Cabeçalho (Header)
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AL = Tipo de Cabeçalho
PCI_Get_HeaderType:
push eax
mov dl, 14 ; Offset 14 -> Tipo De Cabeçalho
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[Header], al ; Armazene o retorno em Header
pop eax
ret
Header db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_BIST - Retorna o Valor BIST
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AH = valor BIST
PCI_Get_BIST:
push eax
mov dl, 14 ; Offset 14 -> BIST
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[BIST], ah ; Armazene o retorno em BIST
pop eax
ret
BIST db 0x00
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_Classes - Retorna a Classe base & subClasse
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AX = Classe Base e SubClasse
PCI_Get_Classes:
push eax
mov dl, 10 ; Offset 10 -> Base e SubClasse
call PCI_Read_Word ; Efetua a leitura PCI
mov word[Classes], ax ; Armazene o retorno em Classes
mov byte[ClassCode], ah
mov byte[SubClass], al
pop eax
ret
Classes dw 0x0000
; -----------------------------------------------------------------------------
; -----------------------------------------------------------------------------
; PCI_Get_SecondaryBus - Retorna o Barramento Secundário
; IN: AL = Bus number
; BL = Device/Slot number
; CL = Função
; OUT: AX = Barramento Secundário
PCI_Get_SecondaryBus:
push eax
mov dl, 0x18 ; Offset 24 -> Barramento Secundário
call PCI_Read_Word ; Efetua a leitura PCI
mov byte[SecondaryBus], ah ; Armazene o retorno em SecondaryBus
mov byte[PrimaryBus], al
pop eax