2 Copyright © 1995-2013, 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>
26 #undef HiddPCIDriverBase
27 #define HiddPCIDriverBase (psd->hiddPCIDriverMB)
30 Fetch text descriptions of the different PCI device classes
32 void getPCIClassDesc( UBYTE
class, UBYTE sub
, UBYTE prgif
, STRPTR
*cdesc
, STRPTR
*sdesc
, STRPTR
*pdesc
)
36 *cdesc
= *sdesc
= *pdesc
= "";
38 for (i
=0;i
< PCI_CLASSTABLE_LEN
; i
++)
40 if (PCI_ClassTable
[i
].Baseclass
== class)
44 *cdesc
= PCI_ClassTable
[i
].Basedesc
;
46 if (PCI_ClassTable
[i
].Subclass
== sub
)
50 *sdesc
= PCI_ClassTable
[i
].Subdesc
;
52 if (PCI_ClassTable
[i
].Prgif
== prgif
)
56 *pdesc
= PCI_ClassTable
[i
].Prgifdesc
;
65 * Size a base register
66 * Return size of the base register area
68 ULONG
sizePCIBaseReg(OOP_Object
*driver
, struct pci_staticdata
*psd
, struct DeviceData
*device
, UBYTE bus
, UBYTE dev
, UBYTE func
, UBYTE basenum
)
72 bak
= HIDD_PCIDriver_ReadConfigLong(driver
, (OOP_Object
*)device
, bus
, dev
, func
, PCICS_BAR0
+ (basenum
<< 2));
73 HIDD_PCIDriver_WriteConfigLong(driver
, (OOP_Object
*)device
, bus
, dev
, func
, PCICS_BAR0
+ (basenum
<< 2), ~0);
74 sz
= HIDD_PCIDriver_ReadConfigLong(driver
, (OOP_Object
*)device
, bus
, dev
, func
, PCICS_BAR0
+ (basenum
<< 2));
75 HIDD_PCIDriver_WriteConfigLong(driver
, (OOP_Object
*)device
, bus
, dev
, func
, PCICS_BAR0
+ (basenum
<< 2), bak
);
77 if ((sz
& PCIBAR_MASK_TYPE
) == PCIBAR_TYPE_IO
)
79 /* This is an IO range */
83 /* Upper 16 bits of result is ignored if BAR is for I/O *AND* bits 16-31 returned zero upon read */
84 if(!(bak
>>16)) sz
&= 0xffff;
88 /* This is memory mapped */
89 sz
&= PCIBAR_MASK_MEM
;