scripts: add crosstools packages for i386 and armhf
[AROS.git] / rom / hidds / pci / pciutil.c
blob29c104d94e60e864230524dbc7ced452fb9c10e8
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: PCI utility functions
6 Lang: english
7 */
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>
14 #include <oop/oop.h>
15 #include <utility/utility.h>
16 #include <hidd/pci.h>
18 #include "pci.h"
19 #include "pciutil.h"
21 #undef SDEBUG
22 #undef DEBUG
23 #define DEBUG 0
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 )
34 ULONG i;
36 *cdesc = *sdesc = *pdesc = "";
38 for (i=0;i < PCI_CLASSTABLE_LEN; i++)
40 if (PCI_ClassTable[i].Baseclass == class)
42 if ( !(**cdesc))
44 *cdesc = PCI_ClassTable[i].Basedesc;
46 if (PCI_ClassTable[i].Subclass == sub)
48 if ( !(**sdesc))
50 *sdesc = PCI_ClassTable[i].Subdesc;
52 if (PCI_ClassTable[i].Prgif == prgif)
54 if ( !(**pdesc))
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 )
70 ULONG bak,sz;
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 */
80 sz &= PCIBAR_MASK_IO;
81 sz = ~sz;
82 sz++;
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;
86 else
88 /* This is memory mapped */
89 sz &= PCIBAR_MASK_MEM;
90 sz = ~sz;
91 sz++;
93 return (sz);