pci.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Lenka Trochtova
00003  * Copyright (c) 2011 Jiri Svoboda
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * - Redistributions of source code must retain the above copyright
00011  *   notice, this list of conditions and the following disclaimer.
00012  * - Redistributions in binary form must reproduce the above copyright
00013  *   notice, this list of conditions and the following disclaimer in the
00014  *   documentation and/or other materials provided with the distribution.
00015  * - The name of the author may not be used to endorse or promote products
00016  *   derived from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00019  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00020  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00021  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00023  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00024  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00025  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00027  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 

Generated on Thu Jun 2 07:45:43 2011 for HelenOS/USB by  doxygen 1.4.7