Rev 1301 | Rev 1324 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1301 | Rev 1302 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | */ |
21 | */ |
22 | 22 | ||
23 | struct pci_methods; |
23 | struct pci_methods; |
24 | 24 | ||
25 | enum pci_access_type { |
25 | enum pci_access_type { |
26 | /* Known access methods, remember to update access.c as well */ |
26 | /* Known access methods, remember to update access.c as well */ |
27 | PCI_ACCESS_I386_TYPE1, /* i386 ports, type 1 (params: none) */ |
27 | PCI_ACCESS_I386_TYPE1, /* i386 ports, type 1 (params: none) */ |
28 | PCI_ACCESS_I386_TYPE2, /* i386 ports, type 2 (params: none) */ |
28 | PCI_ACCESS_I386_TYPE2, /* i386 ports, type 2 (params: none) */ |
29 | PCI_ACCESS_MAX |
29 | PCI_ACCESS_MAX |
30 | }; |
30 | }; |
31 | 31 | ||
32 | struct pci_access { |
32 | struct pci_access { |
33 | /* Options you can change: */ |
33 | /* Options you can change: */ |
34 | unsigned int method; /* Access method */ |
34 | unsigned int method; /* Access method */ |
35 | char *method_params[PCI_ACCESS_MAX]; /* Parameters for the methods */ |
35 | char *method_params[PCI_ACCESS_MAX]; /* Parameters for the methods */ |
36 | int writeable; /* Open in read/write mode */ |
36 | int writeable; /* Open in read/write mode */ |
37 | int buscentric; /* Bus-centric view of the world */ |
37 | int buscentric; /* Bus-centric view of the world */ |
38 | int numeric_ids; /* Don't resolve device IDs to names */ |
38 | int numeric_ids; /* Don't resolve device IDs to names */ |
39 | int debugging; /* Turn on debugging messages */ |
39 | int debugging; /* Turn on debugging messages */ |
40 | 40 | ||
41 | /* Functions you can override: */ |
41 | /* Functions you can override: */ |
42 | void (*error)(char *msg, ...); /* Write error message and quit */ |
42 | void (*error) (char *msg, ...); /* Write error message and quit */ |
43 | void (*warning)(char *msg, ...); /* Write a warning message */ |
43 | void (*warning) (char *msg, ...); /* Write a warning message */ |
44 | void (*debug)(char *msg, ...); /* Write a debugging message */ |
44 | void (*debug) (char *msg, ...); /* Write a debugging message */ |
45 | 45 | ||
46 | struct pci_dev *devices; /* Devices found on this bus */ |
46 | struct pci_dev *devices; /* Devices found on this bus */ |
47 | 47 | ||
48 | /* Fields used internally: */ |
48 | /* Fields used internally: */ |
49 | struct pci_methods *methods; |
49 | struct pci_methods *methods; |
50 | struct id_entry **id_hash; /* names.c */ |
50 | struct id_entry **id_hash; /* names.c */ |
51 | struct id_bucket *current_id_bucket; |
51 | struct id_bucket *current_id_bucket; |
52 | int fd; /* proc: fd */ |
52 | int fd; /* proc: fd */ |
53 | int fd_rw; /* proc: fd opened read-write */ |
53 | int fd_rw; /* proc: fd opened read-write */ |
54 | struct pci_dev *cached_dev; /* proc: device the fd is for */ |
54 | struct pci_dev *cached_dev; /* proc: device the fd is for */ |
55 | int fd_pos; /* proc: current position */ |
55 | int fd_pos; /* proc: current position */ |
56 | }; |
56 | }; |
57 | 57 | ||
58 | /* Initialize PCI access */ |
58 | /* Initialize PCI access */ |
59 | struct pci_access *pci_alloc(void); |
59 | struct pci_access *pci_alloc(void); |
60 | void pci_init(struct pci_access *); |
60 | void pci_init(struct pci_access *); |
61 | void pci_cleanup(struct pci_access *); |
61 | void pci_cleanup(struct pci_access *); |
62 | 62 | ||
63 | /* Scanning of devices */ |
63 | /* Scanning of devices */ |
64 | void pci_scan_bus(struct pci_access *acc); |
64 | void pci_scan_bus(struct pci_access *acc); |
65 | struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func); /* Raw access to specified device */ |
65 | struct pci_dev *pci_get_dev(struct pci_access *acc, int domain, int bus, int dev, int func); /* Raw access to specified device */ |
66 | void pci_free_dev(struct pci_dev *); |
66 | void pci_free_dev(struct pci_dev *); |
67 | 67 | ||
68 | /* |
68 | /* |
69 | * Devices |
69 | * Devices |
70 | */ |
70 | */ |
71 | 71 | ||
72 | struct pci_dev { |
72 | struct pci_dev { |
73 | struct pci_dev *next; /* Next device in the chain */ |
73 | struct pci_dev *next; /* Next device in the chain */ |
74 | u16 domain; /* PCI domain (host bridge) */ |
74 | u16 domain; /* PCI domain (host bridge) */ |
75 | u8 bus, dev, func; /* Bus inside domain, device and function */ |
75 | u8 bus, dev, func; /* Bus inside domain, device and function */ |
76 | 76 | ||
77 | /* These fields are set by pci_fill_info() */ |
77 | /* These fields are set by pci_fill_info() */ |
78 | int known_fields; /* Set of info fields already known */ |
78 | int known_fields; /* Set of info fields already known */ |
79 | u16 vendor_id, device_id; /* Identity of the device */ |
79 | u16 vendor_id, device_id; /* Identity of the device */ |
80 | int irq; /* IRQ number */ |
80 | int irq; /* IRQ number */ |
81 | pciaddr_t base_addr[6]; /* Base addresses */ |
81 | pciaddr_t base_addr[6]; /* Base addresses */ |
82 | pciaddr_t size[6]; /* Region sizes */ |
82 | pciaddr_t size[6]; /* Region sizes */ |
83 | pciaddr_t rom_base_addr; /* Expansion ROM base address */ |
83 | pciaddr_t rom_base_addr; /* Expansion ROM base address */ |
84 | pciaddr_t rom_size; /* Expansion ROM size */ |
84 | pciaddr_t rom_size; /* Expansion ROM size */ |
85 | 85 | ||
86 | /* Fields used internally: */ |
86 | /* Fields used internally: */ |
87 | struct pci_access *access; |
87 | struct pci_access *access; |
88 | struct pci_methods *methods; |
88 | struct pci_methods *methods; |
89 | u8 *cache; /* Cached config registers */ |
89 | u8 *cache; /* Cached config registers */ |
90 | int cache_len; |
90 | int cache_len; |
91 | int hdrtype; /* Cached low 7 bits of header type, -1 if unknown */ |
91 | int hdrtype; /* Cached low 7 bits of header type, -1 if unknown */ |
92 | void *aux; /* Auxillary data */ |
92 | void *aux; /* Auxillary data */ |
93 | }; |
93 | }; |
94 | 94 | ||
95 | #define PCI_ADDR_IO_MASK (~(pciaddr_t) 0x3) |
95 | #define PCI_ADDR_IO_MASK (~(pciaddr_t) 0x3) |
96 | #define PCI_ADDR_MEM_MASK (~(pciaddr_t) 0xf) |
96 | #define PCI_ADDR_MEM_MASK (~(pciaddr_t) 0xf) |
97 | 97 | ||
98 | u8 pci_read_byte(struct pci_dev *, int pos); /* Access to configuration space */ |
98 | u8 pci_read_byte(struct pci_dev *, int pos); /* Access to configuration space */ |
99 | u16 pci_read_word(struct pci_dev *, int pos); |
99 | u16 pci_read_word(struct pci_dev *, int pos); |
100 | u32 pci_read_long(struct pci_dev *, int pos); |
100 | u32 pci_read_long(struct pci_dev *, int pos); |
101 | int pci_read_block(struct pci_dev *, int pos, u8 *buf, int len); |
101 | int pci_read_block(struct pci_dev *, int pos, u8 * buf, int len); |
102 | int pci_write_byte(struct pci_dev *, int pos, u8 data); |
102 | int pci_write_byte(struct pci_dev *, int pos, u8 data); |
103 | int pci_write_word(struct pci_dev *, int pos, u16 data); |
103 | int pci_write_word(struct pci_dev *, int pos, u16 data); |
104 | int pci_write_long(struct pci_dev *, int pos, u32 data); |
104 | int pci_write_long(struct pci_dev *, int pos, u32 data); |
105 | int pci_write_block(struct pci_dev *, int pos, u8 *buf, int len); |
105 | int pci_write_block(struct pci_dev *, int pos, u8 * buf, int len); |
106 | 106 | ||
107 | int pci_fill_info(struct pci_dev *, int flags); /* Fill in device information */ |
107 | int pci_fill_info(struct pci_dev *, int flags); /* Fill in device information */ |
108 | 108 | ||
109 | #define PCI_FILL_IDENT 1 |
109 | #define PCI_FILL_IDENT 1 |
110 | #define PCI_FILL_IRQ 2 |
110 | #define PCI_FILL_IRQ 2 |
111 | #define PCI_FILL_BASES 4 |
111 | #define PCI_FILL_BASES 4 |
112 | #define PCI_FILL_ROM_BASE 8 |
112 | #define PCI_FILL_ROM_BASE 8 |
113 | #define PCI_FILL_SIZES 16 |
113 | #define PCI_FILL_SIZES 16 |
114 | #define PCI_FILL_RESCAN 0x10000 |
114 | #define PCI_FILL_RESCAN 0x10000 |
115 | 115 | ||
116 | void pci_setup_cache(struct pci_dev *, u8 *cache, int len); |
116 | void pci_setup_cache(struct pci_dev *, u8 * cache, int len); |
117 | 117 | ||
118 | /* |
118 | /* |
119 | * Filters |
119 | * Filters |
120 | */ |
120 | */ |
121 | 121 | ||
122 | struct pci_filter { |
122 | struct pci_filter { |
123 | int domain, bus, slot, func; /* -1 = ANY */ |
123 | int domain, bus, slot, func; /* -1 = ANY */ |
124 | int vendor, device; |
124 | int vendor, device; |
125 | }; |
125 | }; |
126 | 126 | ||
127 | void pci_filter_init(struct pci_access *, struct pci_filter *); |
127 | void pci_filter_init(struct pci_access *, struct pci_filter *); |
128 | char *pci_filter_parse_slot(struct pci_filter *, char *); |
128 | char *pci_filter_parse_slot(struct pci_filter *, char *); |
129 | char *pci_filter_parse_id(struct pci_filter *, char *); |
129 | char *pci_filter_parse_id(struct pci_filter *, char *); |
Line 143... | Line 143... | ||
143 | * SUBSYSTEM | ... (-1, -1, subvendorID, subdevID) -> generic subsystem |
143 | * SUBSYSTEM | ... (-1, -1, subvendorID, subdevID) -> generic subsystem |
144 | * CLASS (classID) -> class |
144 | * CLASS (classID) -> class |
145 | * PROGIF (classID, progif) -> programming interface |
145 | * PROGIF (classID, progif) -> programming interface |
146 | */ |
146 | */ |
147 | 147 | ||
148 | char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, ...); |
148 | char *pci_lookup_name(struct pci_access *a, char *buf, int size, int flags, |
- | 149 | ...); |
|
149 | 150 | ||
150 | int pci_load_name_list(struct pci_access *a); /* Called automatically by pci_lookup_*() when needed; returns success */ |
151 | int pci_load_name_list(struct pci_access *a); /* Called automatically by pci_lookup_*() when needed; returns success */ |
151 | void pci_free_name_list(struct pci_access *a); /* Called automatically by pci_cleanup() */ |
152 | void pci_free_name_list(struct pci_access *a); /* Called automatically by pci_cleanup() */ |
152 | 153 | ||
153 | enum pci_lookup_mode { |
154 | enum pci_lookup_mode { |
154 | PCI_LOOKUP_VENDOR = 1, /* Vendor name (args: vendorID) */ |
155 | PCI_LOOKUP_VENDOR = 1, /* Vendor name (args: vendorID) */ |
155 | PCI_LOOKUP_DEVICE = 2, /* Device name (args: vendorID, deviceID) */ |
156 | PCI_LOOKUP_DEVICE = 2, /* Device name (args: vendorID, deviceID) */ |
156 | PCI_LOOKUP_CLASS = 4, /* Device class (args: classID) */ |
157 | PCI_LOOKUP_CLASS = 4, /* Device class (args: classID) */ |
157 | PCI_LOOKUP_SUBSYSTEM = 8, |
158 | PCI_LOOKUP_SUBSYSTEM = 8, |
158 | PCI_LOOKUP_PROGIF = 16, /* Programming interface (args: classID, prog_if) */ |
159 | PCI_LOOKUP_PROGIF = 16, /* Programming interface (args: classID, prog_if) */ |
159 | PCI_LOOKUP_NUMERIC = 0x10000, /* Want only formatted numbers; default if access->numeric_ids is set */ |
160 | PCI_LOOKUP_NUMERIC = 0x10000, /* Want only formatted numbers; default if access->numeric_ids is set */ |
160 | PCI_LOOKUP_NO_NUMBERS = 0x20000 /* Return NULL if not found in the database; default is to print numerically */ |
161 | PCI_LOOKUP_NO_NUMBERS = 0x20000 /* Return NULL if not found in the database; default is to print numerically */ |
161 | }; |
162 | }; |
162 | 163 | ||
163 | #endif |
164 | #endif |