2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: PCI utility functions
9 #include <exec/types.h>
10 #include <exec/lists.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
13 #include <proto/oop.h>
15 #include <utility/utility.h>
24 #include <aros/debug.h>
27 Fetch text descriptions of the different PCI device classes
29 void getPCIClassDesc( UBYTE
class, UBYTE sub
, UBYTE prgif
, STRPTR
*cdesc
, STRPTR
*sdesc
, STRPTR
*pdesc
)
33 *cdesc
= *sdesc
= *pdesc
= "";
35 for (i
=0;i
< PCI_CLASSTABLE_LEN
; i
++)
37 if (PCI_ClassTable
[i
].Baseclass
== class)
41 *cdesc
= PCI_ClassTable
[i
].Basedesc
;
43 if (PCI_ClassTable
[i
].Subclass
== sub
)
47 *sdesc
= PCI_ClassTable
[i
].Subdesc
;
49 if (PCI_ClassTable
[i
].Prgif
== prgif
)
53 *pdesc
= PCI_ClassTable
[i
].Prgifdesc
;
62 * Size a base register
63 * Return size of the base register area
65 ULONG
sizePCIBaseReg(OOP_Object
*driver
, struct pci_staticdata
*psd
, UBYTE bus
, UBYTE dev
, UBYTE func
, UBYTE basenum
)
68 struct pHidd_PCIDriver_ReadConfigLong msgr
;
69 struct pHidd_PCIDriver_WriteConfigLong msgw
;
71 if (!psd
->mid_RL
) psd
->mid_RL
72 = OOP_GetMethodID(IID_Hidd_PCIDriver
, moHidd_PCIDriver_ReadConfigLong
);
73 if (!psd
->mid_WL
) psd
->mid_WL
74 = OOP_GetMethodID(IID_Hidd_PCIDriver
, moHidd_PCIDriver_WriteConfigLong
);
76 msgr
.mID
= psd
->mid_RL
;
80 msgr
.reg
= PCICS_BAR0
+ (basenum
<< 2);
82 msgw
.mID
= psd
->mid_WL
;
86 msgw
.reg
= PCICS_BAR0
+ (basenum
<< 2);
88 bak
= OOP_DoMethod(driver
, (OOP_Msg
)&msgr
);
90 OOP_DoMethod(driver
, (OOP_Msg
)&msgw
);
91 sz
= OOP_DoMethod(driver
, (OOP_Msg
)&msgr
);
93 OOP_DoMethod(driver
, (OOP_Msg
)&msgw
);
95 if ((sz
& PCIBAR_MASK_TYPE
) == PCIBAR_TYPE_IO
)
97 /* This is an IO range */
104 /* This is memory mapped */
105 sz
&= PCIBAR_MASK_MEM
;