1 /*
2 * The PCI Library -- ID to Name Translation
3 *
4 * Copyright (c) 1997--2014 Martin Mares <[email protected]>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL v2+
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #define MAX_LINE 1024
12
13 /* names-hash.c */
14
15 struct id_entry {
16 struct id_entry *next;
17 u32 id12, id34;
18 byte cat;
19 byte src;
20 char name[1];
21 };
22
23 enum id_entry_type {
24 ID_UNKNOWN,
25 ID_VENDOR,
26 ID_DEVICE,
27 ID_SUBSYSTEM,
28 ID_GEN_SUBSYSTEM,
29 ID_CLASS,
30 ID_SUBCLASS,
31 ID_PROGIF
32 };
33
34 enum id_entry_src {
35 SRC_UNKNOWN,
36 SRC_CACHE,
37 SRC_NET,
38 SRC_HWDB,
39 SRC_LOCAL,
40 };
41
42 #define BUCKET_SIZE 8192
43 #define HASH_SIZE 4099
44
id_pair(unsigned int x,unsigned int y)45 static inline u32 id_pair(unsigned int x, unsigned int y)
46 {
47 return ((x << 16) | y);
48 }
49
pair_first(unsigned int x)50 static inline unsigned int pair_first(unsigned int x)
51 {
52 return (x >> 16) & 0xffff;
53 }
54
pair_second(unsigned int x)55 static inline unsigned int pair_second(unsigned int x)
56 {
57 return x & 0xffff;
58 }
59
60 int pci_id_insert(struct pci_access *a, int cat, int id1, int id2, int id3, int id4, char *text, enum id_entry_src src);
61 char *pci_id_lookup(struct pci_access *a, int flags, int cat, int id1, int id2, int id3, int id4);
62
63 /* names-cache.c */
64
65 int pci_id_cache_load(struct pci_access *a, int flags);
66 void pci_id_cache_dirty(struct pci_access *a);
67 void pci_id_cache_flush(struct pci_access *a);
68 void pci_id_hash_free(struct pci_access *a);
69
70 /* names-dns.c */
71
72 char *pci_id_net_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4);
73
74 /* names-hwdb.c */
75
76 char *pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int id4);
77 void pci_id_hwdb_free(struct pci_access *a);
78