1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2012, Joyent, Inc. All rights reserved. 23 * Copyright 2021 Oxide Computer Company 24 */ 25 26 /* 27 * This header file is private to illumos and should not be shipped. 28 */ 29 30 #ifndef _PCIDB_H 31 #define _PCIDB_H 32 33 #include <stdint.h> 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #define PCIDB_VERSION 1 40 41 typedef struct pcidb_hdl pcidb_hdl_t; 42 typedef struct pcidb_vendor pcidb_vendor_t; 43 typedef struct pcidb_device pcidb_device_t; 44 typedef struct pcidb_subvd pcidb_subvd_t; 45 typedef struct pcidb_class pcidb_class_t; 46 typedef struct pcidb_subclass pcidb_subclass_t; 47 typedef struct pcidb_progif pcidb_progif_t; 48 49 extern pcidb_hdl_t *pcidb_open(int); 50 extern void pcidb_close(pcidb_hdl_t *); 51 52 extern pcidb_vendor_t *pcidb_lookup_vendor(pcidb_hdl_t *, uint16_t); 53 extern pcidb_vendor_t *pcidb_vendor_iter(pcidb_hdl_t *); 54 extern pcidb_vendor_t *pcidb_vendor_iter_next(pcidb_vendor_t *); 55 56 extern const char *pcidb_vendor_name(pcidb_vendor_t *); 57 extern uint16_t pcidb_vendor_id(pcidb_vendor_t *); 58 59 extern pcidb_device_t *pcidb_lookup_device(pcidb_hdl_t *, uint16_t, uint16_t); 60 extern pcidb_device_t *pcidb_lookup_device_by_vendor(pcidb_vendor_t *, 61 uint16_t); 62 extern pcidb_device_t *pcidb_device_iter(pcidb_vendor_t *); 63 extern pcidb_device_t *pcidb_device_iter_next(pcidb_device_t *); 64 65 extern const char *pcidb_device_name(pcidb_device_t *); 66 extern uint16_t pcidb_device_id(pcidb_device_t *); 67 extern pcidb_vendor_t *pcidb_device_vendor(pcidb_device_t *); 68 69 extern pcidb_subvd_t *pcidb_lookup_subvd(pcidb_hdl_t *, uint16_t, uint16_t, 70 uint16_t, uint16_t); 71 extern pcidb_subvd_t *pcidb_lookup_subvd_by_vendor(pcidb_vendor_t *, uint16_t, 72 uint16_t, uint16_t); 73 extern pcidb_subvd_t *pcidb_lookup_subvd_by_device(pcidb_device_t *, uint16_t, 74 uint16_t); 75 extern pcidb_subvd_t *pcidb_subvd_iter(pcidb_device_t *); 76 extern pcidb_subvd_t *pcidb_subvd_iter_next(pcidb_subvd_t *); 77 78 extern const char *pcidb_subvd_name(pcidb_subvd_t *); 79 extern uint16_t pcidb_subvd_svid(pcidb_subvd_t *); 80 extern uint16_t pcidb_subvd_sdid(pcidb_subvd_t *); 81 extern pcidb_device_t *pcidb_subvd_device(pcidb_subvd_t *); 82 extern pcidb_vendor_t *pcidb_subvd_vendor(pcidb_subvd_t *); 83 84 extern pcidb_class_t *pcidb_lookup_class(pcidb_hdl_t *, uint8_t); 85 extern pcidb_class_t *pcidb_class_iter(pcidb_hdl_t *); 86 extern pcidb_class_t *pcidb_class_iter_next(pcidb_class_t *); 87 88 extern const char *pcidb_class_name(pcidb_class_t *); 89 extern uint8_t pcidb_class_code(pcidb_class_t *); 90 91 extern pcidb_subclass_t *pcidb_lookup_subclass(pcidb_hdl_t *, uint8_t, uint8_t); 92 extern pcidb_subclass_t *pcidb_lookup_subclass_by_class(pcidb_class_t *, 93 uint8_t); 94 extern pcidb_subclass_t *pcidb_subclass_iter(pcidb_class_t *); 95 extern pcidb_subclass_t *pcidb_subclass_iter_next(pcidb_subclass_t *); 96 97 extern const char *pcidb_subclass_name(pcidb_subclass_t *); 98 extern uint8_t pcidb_subclass_code(pcidb_subclass_t *); 99 100 extern pcidb_progif_t *pcidb_lookup_progif(pcidb_hdl_t *, uint8_t, uint8_t, 101 uint8_t); 102 extern pcidb_progif_t *pcidb_lookup_progif_by_subclass(pcidb_subclass_t *, 103 uint8_t); 104 extern pcidb_progif_t *pcidb_progif_iter(pcidb_subclass_t *); 105 extern pcidb_progif_t *pcidb_progif_iter_next(pcidb_progif_t *); 106 107 extern const char *pcidb_progif_name(pcidb_progif_t *); 108 extern uint8_t pcidb_progif_code(pcidb_progif_t *); 109 110 #ifdef __cplusplus 111 } 112 #endif 113 114 #endif /* _PCIDB_H */ 115