[8c06905] | 1 | /*
|
---|
[663f41c4] | 2 | * Copyright (c) 2010 Lenka Trochtova
|
---|
[8c06905] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /** @addtogroup pciintel
|
---|
| 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[663f41c4] | 35 | #ifndef PCI_H_
|
---|
| 36 | #define PCI_H_
|
---|
[5e598e0] | 37 |
|
---|
| 38 | #include <stdlib.h>
|
---|
[8c06905] | 39 | #include <driver.h>
|
---|
[5e598e0] | 40 | #include <malloc.h>
|
---|
[8c06905] | 41 |
|
---|
[3a5909f] | 42 | #include "pci_regs.h"
|
---|
| 43 |
|
---|
| 44 | #define PCI_MAX_HW_RES 8
|
---|
| 45 |
|
---|
[8b1e15ac] | 46 | typedef struct pci_fun_data {
|
---|
[8c06905] | 47 | int bus;
|
---|
| 48 | int dev;
|
---|
| 49 | int fn;
|
---|
[5e598e0] | 50 | int vendor_id;
|
---|
| 51 | int device_id;
|
---|
| 52 | hw_resource_list_t hw_resources;
|
---|
[8b1e15ac] | 53 | } pci_fun_data_t;
|
---|
[8c06905] | 54 |
|
---|
[8b1e15ac] | 55 | extern void create_pci_match_ids(function_t *);
|
---|
[3a5909f] | 56 |
|
---|
[8b1e15ac] | 57 | extern uint8_t pci_conf_read_8(function_t *, int);
|
---|
| 58 | extern uint16_t pci_conf_read_16(function_t *, int);
|
---|
| 59 | extern uint32_t pci_conf_read_32(function_t *, int);
|
---|
| 60 | extern void pci_conf_write_8(function_t *, int, uint8_t);
|
---|
| 61 | extern void pci_conf_write_16(function_t *, int, uint16_t);
|
---|
| 62 | extern void pci_conf_write_32(function_t *, int, uint32_t);
|
---|
[3a5909f] | 63 |
|
---|
[8b1e15ac] | 64 | extern void pci_add_range(function_t *, uint64_t, size_t, bool);
|
---|
| 65 | extern int pci_read_bar(function_t *, int);
|
---|
| 66 | extern void pci_read_interrupt(function_t *);
|
---|
| 67 | extern void pci_add_interrupt(function_t *, int);
|
---|
[3a5909f] | 68 |
|
---|
[663f41c4] | 69 | extern void pci_bus_scan(device_t *, int);
|
---|
[3a5909f] | 70 |
|
---|
[8b1e15ac] | 71 | extern pci_fun_data_t *create_pci_fun_data(void);
|
---|
| 72 | extern void init_pci_fun_data(pci_fun_data_t *, int, int, int);
|
---|
| 73 | extern void delete_pci_fun_data(pci_fun_data_t *);
|
---|
| 74 | extern void create_pci_fun_name(function_t *);
|
---|
[5e598e0] | 75 |
|
---|
[8b1e15ac] | 76 | extern bool pci_alloc_resource_list(function_t *);
|
---|
| 77 | extern void pci_clean_resource_list(function_t *);
|
---|
[5e598e0] | 78 |
|
---|
[8b1e15ac] | 79 | extern void pci_read_bars(function_t *);
|
---|
[713a4b9] | 80 | extern size_t pci_bar_mask_to_size(uint32_t);
|
---|
[8c06905] | 81 |
|
---|
| 82 | #endif
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
| 85 | * @}
|
---|
| 86 | */ |
---|