bdc8c850073222ddb4474799b2800bc3bb1a786a
[tpg/acess2.git] / KernelLand / Kernel / include / drv_pci.h
1 /**\r
2  * \file drv_pci.h\r
3  * \brief PCI Bus Driver\r
4  * \author John Hodge (thePowersGang)\r
5  */\r
6 #ifndef _DRV_PCI_H\r
7 #define _DRV_PCI_H\r
8 \r
9 /**\r
10  * \brief PCI Class Codes\r
11  */\r
12 enum ePCIClasses\r
13 {\r
14         PCI_CLASS_PRE20 = 0x00,\r
15         PCI_CLASS_STORAGE,\r
16         PCI_CLASS_NETWORK,\r
17         PCI_CLASS_DISPLAY,\r
18         PCI_CLASS_MULTIMEDIA,\r
19         PCI_CLASS_MEMORY,\r
20         PCI_CLASS_BRIDGE,\r
21         PCI_CLASS_COMM,\r
22         PCI_CLASS_PREPH,\r
23         PCI_CLASS_INPUT,\r
24         PCI_CLASS_DOCKING,\r
25         PCI_CLASS_PROCESSORS,\r
26         PCI_CLASS_SERIALBUS,\r
27         PCI_CLASS_MISC = 0xFF\r
28 };\r
29 \r
30 enum ePCIOverClasses\r
31 {\r
32         PCI_OC_PCIBRIDGE = 0x060400,\r
33         PCI_OC_SCSI = 0x010000\r
34 };\r
35 \r
36 typedef enum ePCI_BARTypes      tPCI_BARType;\r
37 \r
38 enum ePCI_BARTypes\r
39 {\r
40         PCI_BARTYPE_IO,\r
41         PCI_BARTYPE_MEM,        // Any memory type\r
42         PCI_BARTYPE_MEMP,       // Prefetchable memory\r
43         PCI_BARTYPE_MEMNP,      // Non-prefetchable memory\r
44         PCI_BARTYPE_MEM32,      // 32-bit memory\r
45         PCI_BARTYPE_MEM64       // 64-bit memory\r
46 };\r
47 \r
48 #define PCI_CMD_IOENABLE        (1 << 0)\r
49 #define PCI_CMD_MEMENABLE       (1 << 1)\r
50 #define PCI_CMD_BUSMASTER       (1 << 2)        // Device can behave as a bus master\r
51 #define PCI_CMD_SPECIALCYCLES   (1 << 3)        // Can monitor 'Special Cycle' operations\r
52 #define PCI_CMD_WRAINVAL        (1 << 4)        // Memory 'Write and Invalidate' can be generated\r
53 #define PCI_CMD_VGAPALSNOOP     (1 << 5)        // VGA Palette Snoop enabled\r
54 #define PCI_CMD_PARITYERRRESP   (1 << 6)        // Pairity Error Response (suppress PERR# generation)\r
55 #define PCI_CMD_SERRENABLE      (1 << 8)        // Enable SERR# Driver\r
56 #define PCI_CMD_FASTBACKBACK    (1 << 9)        // Fast Back-Back Enable\r
57 #define PCI_CMD_INTDISABLE      (1 <<10)        // Disable generation of INTx# signals\r
58 \r
59 typedef int     tPCIDev;\r
60 \r
61 /**\r
62  * \brief Count PCI Devices\r
63  * \r
64  * Counts the number of devices with specified Vendor and Device IDs\r
65  */\r
66 extern int      PCI_CountDevices(Uint16 VendorID, Uint16 DeviceID);\r
67 extern tPCIDev  PCI_GetDevice(Uint16 VendorID, Uint16 DeviceID, int index);\r
68 /**\r
69  * \param ClassCode (Class:SubClass:PI)\r
70  */\r
71 extern tPCIDev  PCI_GetDeviceByClass(Uint32 ClassCode, Uint32 Mask, tPCIDev prev);\r
72 \r
73 extern int      PCI_GetDeviceInfo(tPCIDev id, Uint16 *Vendor, Uint16 *Device, Uint32 *Class);\r
74 extern int      PCI_GetDeviceVersion(tPCIDev id, Uint8 *Revision);\r
75 extern int      PCI_GetDeviceSubsys(tPCIDev id, Uint16 *SubsystemVendor, Uint16 *SubsystemID);\r
76 \r
77 extern Uint32   PCI_ConfigRead(tPCIDev id, int Offset, int Size);\r
78 extern void     PCI_ConfigWrite(tPCIDev id, int Offset, int Size, Uint32 Value);\r
79 \r
80 extern Uint16   PCI_SetCommand(tPCIDev id, Uint16 SBits, Uint16 CBits);\r
81 extern Uint8    PCI_GetIRQ(tPCIDev id);\r
82 extern Uint32   PCI_GetBAR(tPCIDev id, int BAR);\r
83 extern Uint64   PCI_GetValidBAR(tPCIDev id, int BAR, tPCI_BARType BARType);\r
84 //extern Uint16 PCI_AssignPort(tPCIDev id, int bar, int count);\r
85 //extern void*  PCI_MapMemBAR(tPCIDev id, int BAR, tPCI_BARType BARType, size_t* Size, tPAddr* PAddr);\r
86 \r
87 #endif\r

UCC git Repository :: git.ucc.asn.au