1 | /*
|
---|
2 | * Copyright (c) 2010 Lenka Trochtova
|
---|
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 |
|
---|
35 | #ifndef PCI_H_
|
---|
36 | #define PCI_H_
|
---|
37 |
|
---|
38 | #include <stdlib.h>
|
---|
39 | #include <driver.h>
|
---|
40 | #include <malloc.h>
|
---|
41 |
|
---|
42 | #include "pci_regs.h"
|
---|
43 |
|
---|
44 | #define PCI_MAX_HW_RES 8
|
---|
45 |
|
---|
46 | typedef struct pci_fun_data {
|
---|
47 | int bus;
|
---|
48 | int dev;
|
---|
49 | int fn;
|
---|
50 | int vendor_id;
|
---|
51 | int device_id;
|
---|
52 | hw_resource_list_t hw_resources;
|
---|
53 | } pci_fun_data_t;
|
---|
54 |
|
---|
55 | extern void create_pci_match_ids(function_t *);
|
---|
56 |
|
---|
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);
|
---|
63 |
|
---|
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);
|
---|
68 |
|
---|
69 | extern void pci_bus_scan(device_t *, int);
|
---|
70 |
|
---|
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 *);
|
---|
75 |
|
---|
76 | extern bool pci_alloc_resource_list(function_t *);
|
---|
77 | extern void pci_clean_resource_list(function_t *);
|
---|
78 |
|
---|
79 | extern void pci_read_bars(function_t *);
|
---|
80 | extern size_t pci_bar_mask_to_size(uint32_t);
|
---|
81 |
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /**
|
---|
85 | * @}
|
---|
86 | */ |
---|