Less aggressive colour change in the title
[snowy-minesweeper.git] / cdi / cdi-pci.c
blob8107b066fda397ad8267d7eb9cea47be1824b7b6
1 #include <io.h>
2 #include <stdlib.h>
3 #include <cdi/lists.h>
4 #include <cdi/pci.h>
6 #define __pci_inX(w, off_mask) \
7 uint##w##_t pci_in##w(int bus, int device, int function, int offset) \
8 { \
9 uint##w##_t ret; \
10 out32(0xcf8, 0x80000000 | ((bus & 0xff) << 16) | ((device & 0x1f) << 11) | ((function & 0x07) << 8) | (offset & 0xfc)); \
11 ret = in##w(0xcfc + (offset & off_mask)); \
12 return ret; \
15 __pci_inX( 8, 3);
16 __pci_inX(16, 2);
17 __pci_inX(32, 0);
20 #define __pci_outX(w, off_mask) \
21 void pci_out##w(int bus, int device, int function, int offset, uint##w##_t value) \
22 { \
23 out32(0xcf8, 0x80000000 | ((bus & 0xff) << 16) | ((device & 0x1f) << 11) | ((function & 0x07) << 8) | (offset & 0xfc)); \
24 out##w(0xcfc + (offset & off_mask), value); \
27 __pci_outX( 8, 3);
28 __pci_outX(16, 2);
29 __pci_outX(32, 0);
32 void cdi_pci_alloc_ioports(struct cdi_pci_device *device)
34 (void)device;
37 void cdi_pci_free_ioports(struct cdi_pci_device *device)
39 (void)device;
42 uint16_t cdi_pci_config_readw(struct cdi_pci_device *device, uint8_t offset)
44 return pci_in16(device->bus, device->dev, device->function, offset);
47 void cdi_pci_config_writew(struct cdi_pci_device *device, uint8_t offset, uint16_t val)
49 pci_out16(device->bus, device->dev, device->function, offset, val);