Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / AHI / Drivers / Envy24HT / pci_wrapper.h
blob46bdb31f7af0a86896ff2f91e696094a91e0beaf
1 /*
2 Copyright © 2004-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef PCI_WRAPPER_H
7 #define PCI_WRAPPER_H
9 #ifndef EXEC_TYPES_H
10 # include <exec/types.h>
11 #endif
13 #include "DriverData.h"
15 #undef PCI_COMMAND
16 #undef PCI_COMMAND_IO
17 #undef PCI_COMMAND_MEMORY
18 #undef PCI_COMMAND_MASTER
19 #undef PCI_BASE_ADDRESS_IO_MASK
20 #undef PCI_REVISION_ID
21 #undef PCI_SUBSYSTEM_ID
22 #undef PCI_DEVICE_ID
23 #undef PCI_SUBSYSTEM_VENDOR_ID
26 #define PCI_COMMAND 4
27 #define PCI_COMMAND_IO 1
28 #define PCI_COMMAND_MEMORY 2
29 #define PCI_COMMAND_MASTER 4
31 #define PCI_BASE_ADDRESS_0 0x10
33 #define PCI_BASE_ADDRESS_IO_MASK (~0x3UL)
35 #define PCI_REVISION_ID 8
36 #define PCI_SUBSYSTEM_ID 0x2e
37 #define PCI_DEVICE_ID 2
38 #define PCI_SUBSYSTEM_VENDOR_ID 0x2c
40 #ifdef __amigaos4__
41 #define ALLOCVEC IExec->AllocVec
42 #define FREEVEC IExec->FreeVec
43 #define DEBUGPRINTF IExec->DebugPrintF
44 #define CAUSE IExec->Cause
45 #define CALLHOOK IUtility->CallHookPkt
46 #define INITSEMAPHORE IExec->InitSemaphore
47 #define OBTAINSEMAPHORE IExec->ObtainSemaphore
48 #define RELEASESEMAPHORE IExec->ReleaseSemaphore
49 #define CREATEPORT(a, b) IExec->CreatePort(a, b)
50 #define CREATEIOREQUEST IExec->CreateIORequest
51 #define OPENDEVICE IExec->OpenDevice
52 #define DOIO IExec->DoIO
53 #define DELETEIOREQUEST IExec->DeleteIORequest
54 #define CLOSEDEVICE IExec->CloseDevice
55 #define DELETEPORT IExec->DeletePort
56 #define GETTAGDATA IUtility->GetTagData
57 #define IRQTYPE INTERRUPT_NODE_TYPE
58 #define DELAY IDOS->Delay
59 #elif __AROS__
60 #include <aros/debug.h>
61 #define ALLOCVEC AllocVec
62 #define FREEVEC FreeVec
63 #define DEBUGPRINTF kprintf
64 #define CAUSE Cause
65 #define CALLHOOK CallHookA
66 #define INITSEMAPHORE InitSemaphore
67 #define OBTAINSEMAPHORE ObtainSemaphore
68 #define RELEASESEMAPHORE ReleaseSemaphore
69 #define CREATEPORT(a, b) CreateMsgPort()
70 #define CREATEIOREQUEST CreateIORequest
71 #define OPENDEVICE OpenDevice
72 #define DOIO DoIO
73 #define DELETEIOREQUEST DeleteIORequest
74 #define CLOSEDEVICE CloseDevice
75 #define DELETEPORT DeleteMsgPort
76 #define GETTAGDATA GetTagData
77 #define IRQTYPE NT_INTERRUPT
78 #define DELAY Delay
79 #else
80 #include <clib/debug_protos.h>
81 #define ALLOCVEC AllocVec
82 #define FREEVEC FreeVec
83 #define DEBUGPRINTF kprintf
84 #define CAUSE Cause
85 #define CALLHOOK CallHookPkt
86 #define INITSEMAPHORE InitSemaphore
87 #define OBTAINSEMAPHORE ObtainSemaphore
88 #define RELEASESEMAPHORE ReleaseSemaphore
89 #define CREATEPORT(a, b) CreateMsgPort()
90 #define CREATEIOREQUEST CreateIORequest
91 #define OPENDEVICE OpenDevice
92 #define DOIO DoIO
93 #define DELETEIOREQUEST DeleteIORequest
94 #define CLOSEDEVICE CloseDevice
95 #define DELETEPORT DeleteMsgPort
96 #define GETTAGDATA GetTagData
97 #define IRQTYPE INTERRUPT_NODE_TYPE
98 #define DELAY Delay
99 #define bug kprintf
100 #endif
102 #ifndef __MORPHOS__
103 #define INBYTE(a) pci_inb((a), card)
104 #define INWORD(a) pci_inw((a), card)
105 #define INLONG(a) pci_inl((a), card)
106 #define OUTBYTE(addr, val) pci_outb((val), (addr), card)
107 #define OUTWORD(addr, val) pci_outw((val), (addr), card)
108 #define OUTLONG(addr, val) pci_outl((val), (addr), card)
109 #else
110 #define INBYTE(a) ahi_pci_inb((a), 0)
111 #define INWORD(a) ahi_pci_inw((a), 0)
112 #define INLONG(a) ahi_pci_inl((a), 0)
113 #define OUTBYTE(addr, val) ahi_pci_outb((val), (addr), 0)
114 #define OUTWORD(addr, val) ahi_pci_outw((val), (addr), 0)
115 #define OUTLONG(addr, val) ahi_pci_outl((val), (addr), 0)
116 #endif
118 #define READCONFIGBYTE(reg) inb_config((reg), dev)
119 #define READCONFIGWORD(reg) inw_config((reg), dev)
121 #define WRITECONFIGWORD(reg, val) outw_config((reg), (val), dev)
123 BOOL ahi_pci_init(struct DriverBase* AHIsubBase);
124 void ahi_pci_exit(void);
126 APTR ahi_pci_find_device(ULONG vendorid, ULONG deviceid, APTR dev);
128 #ifndef __MORPHOS__
129 ULONG pci_inl(ULONG addr, struct CardData *card);
130 UWORD pci_inw(ULONG addr, struct CardData *card);
131 UBYTE pci_inb(ULONG addr, struct CardData *card);
133 void pci_outl(ULONG value, ULONG addr, struct CardData *card);
134 void pci_outw(UWORD value, ULONG addr, struct CardData *card);
135 void pci_outb(UBYTE value, ULONG addr, struct CardData *card);
136 #else
137 ULONG ahi_pci_inl(ULONG addr, APTR dev);
138 UWORD ahi_pci_inw(ULONG addr, APTR dev);
139 UBYTE ahi_pci_inb(ULONG addr, APTR dev);
140 void ahi_pci_outl(ULONG value, ULONG addr, APTR dev);
141 void ahi_pci_outw(UWORD value, ULONG addr, APTR dev);
142 void ahi_pci_outb(UBYTE value, ULONG addr, APTR dev);
143 #endif
145 void outb_setbits(UBYTE value, ULONG addr, struct CardData *card);
146 void outw_setbits(UWORD value, ULONG addr, struct CardData *card);
147 void outl_setbits(ULONG value, ULONG addr, struct CardData *card);
148 void outb_clearbits(UBYTE value, ULONG addr, struct CardData *card);
149 void outw_clearbits(UWORD value, ULONG addr, struct CardData *card);
150 void outl_clearbits(ULONG value, ULONG addr, struct CardData *card);
152 ULONG inl_config(UBYTE reg, APTR dev);
153 UWORD inw_config(UBYTE reg, APTR dev);
154 UBYTE inb_config(UBYTE reg, APTR dev);
156 void outl_config(UBYTE reg, ULONG val, APTR dev);
157 void outw_config(UBYTE reg, UWORD val, APTR dev);
158 void outb_config(UBYTE reg, UBYTE val, APTR dev);
160 ULONG ahi_pci_get_irq(APTR dev);
162 BOOL ahi_pci_add_intserver(struct Interrupt *i, APTR dev);
163 void ahi_pci_rem_intserver(struct Interrupt *i, APTR dev);
165 APTR ahi_pci_logic_to_physic_addr(APTR addr, APTR dev);
167 APTR ahi_pci_get_base_address(WORD which, APTR dev);
168 ULONG ahi_pci_get_base_size(WORD which, APTR dev);
169 ULONG ahi_pci_get_type(WORD which, APTR dev);
170 ULONG ahi_pci_mem_map(APTR addr, APTR dev);
172 #endif