00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00036 #ifndef PCI_H_
00037 #define PCI_H_
00038 
00039 #include <ddf/driver.h>
00040 #include "pci_regs.h"
00041 
00042 #define PCI_MAX_HW_RES 8
00043 
00044 typedef struct pciintel_bus {
00046         ddf_dev_t *dnode;
00047         uint32_t conf_io_addr;
00048         void *conf_data_port;
00049         void *conf_addr_port;
00050         fibril_mutex_t conf_mutex;
00051 } pci_bus_t;
00052 
00053 typedef struct pci_fun_data {
00054         pci_bus_t *busptr;
00055         ddf_fun_t *fnode;
00056 
00057         int bus;
00058         int dev;
00059         int fn;
00060         int vendor_id;
00061         int device_id;
00062         hw_resource_list_t hw_resources;
00063 } pci_fun_t;
00064 
00065 extern void pci_fun_create_match_ids(pci_fun_t *);
00066 
00067 extern uint8_t pci_conf_read_8(pci_fun_t *, int);
00068 extern uint16_t pci_conf_read_16(pci_fun_t *, int);
00069 extern uint32_t pci_conf_read_32(pci_fun_t *, int);
00070 extern void pci_conf_write_8(pci_fun_t *, int, uint8_t);
00071 extern void pci_conf_write_16(pci_fun_t *, int, uint16_t);
00072 extern void pci_conf_write_32(pci_fun_t *, int, uint32_t);
00073 
00074 extern void pci_add_range(pci_fun_t *, uint64_t, size_t, bool);
00075 extern int pci_read_bar(pci_fun_t *, int);
00076 extern void pci_read_interrupt(pci_fun_t *);
00077 extern void pci_add_interrupt(pci_fun_t *, int);
00078 
00079 extern pci_fun_t *pci_fun_new(pci_bus_t *);
00080 extern void pci_fun_init(pci_fun_t *, int, int, int);
00081 extern void pci_fun_delete(pci_fun_t *);
00082 extern char *pci_fun_create_name(pci_fun_t *);
00083 
00084 extern void pci_bus_scan(pci_bus_t *, int);
00085 
00086 extern bool pci_alloc_resource_list(pci_fun_t *);
00087 extern void pci_clean_resource_list(pci_fun_t *);
00088 
00089 extern void pci_read_bars(pci_fun_t *);
00090 extern size_t pci_bar_mask_to_size(uint32_t);
00091 
00092 #endif
00093