Decoupling Architectural-specific Code (#35)
[lunaix-os.git] / lunaix-os / arch / i386 / includes / sys / pci_hba.h
1 #ifndef __LUNAIX_PCI_HBA_H
2 #define __LUNAIX_PCI_HBA_H
3
4 #include <hal/pci.h>
5 #include <lunaix/types.h>
6
7 #include "port_io.h"
8
9 #define PCI_CONFIG_ADDR 0xcf8
10 #define PCI_CONFIG_DATA 0xcfc
11
12 static inline pci_reg_t
13 pci_read_cspace(ptr_t base, int offset)
14 {
15     port_wrdword(PCI_CONFIG_ADDR, base | (offset & ~0x3));
16     return port_rddword(PCI_CONFIG_DATA);
17 }
18
19 static inline void
20 pci_write_cspace(ptr_t base, int offset, pci_reg_t data)
21 {
22     port_wrdword(PCI_CONFIG_ADDR, base | (offset & ~0x3));
23     port_wrdword(PCI_CONFIG_DATA, data);
24 }
25
26 static inline u16_t 
27 pci_config_msi_data(int vector) {
28     return vector;
29 }
30
31 static inline ptr_t 
32 pci_get_msi_base() {
33     return 0xFEE00000;
34 }
35
36
37 #endif /* __LUNAIX_PCI_HBA_H */