1*4cfb78b5Sbluhm /* $OpenBSD: patterns.c,v 1.16 2024/10/30 00:04:46 bluhm Exp $ */ 2901907d1Sderaadt 3901907d1Sderaadt /* 4901907d1Sderaadt * Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved. 5901907d1Sderaadt * Copyright (c) 1994 Charles Hannum. All rights reserved. 6901907d1Sderaadt * 7901907d1Sderaadt * Redistribution and use in source and binary forms, with or without 8901907d1Sderaadt * modification, are permitted provided that the following conditions 9901907d1Sderaadt * are met: 10901907d1Sderaadt * 1. Redistributions of source code must retain the above copyright 11901907d1Sderaadt * notice, this list of conditions and the following disclaimer. 12901907d1Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 13901907d1Sderaadt * notice, this list of conditions and the following disclaimer in the 14901907d1Sderaadt * documentation and/or other materials provided with the distribution. 15901907d1Sderaadt * 3. All advertising materials mentioning features or use of this software 16901907d1Sderaadt * must display the following acknowledgement: 17901907d1Sderaadt * This product includes software developed by Charles Hannum. 18901907d1Sderaadt * 4. The name of the author may not be used to endorse or promote products 19901907d1Sderaadt * derived from this software without specific prior written permission. 20901907d1Sderaadt * 21901907d1Sderaadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22901907d1Sderaadt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23901907d1Sderaadt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24901907d1Sderaadt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25901907d1Sderaadt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26901907d1Sderaadt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27901907d1Sderaadt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28901907d1Sderaadt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29901907d1Sderaadt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30901907d1Sderaadt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31901907d1Sderaadt */ 32901907d1Sderaadt 33901907d1Sderaadt #include <sys/types.h> 34901907d1Sderaadt #include <dev/pci/pcivar.h> 35901907d1Sderaadt #include <dev/pci/pcidevs.h> 36901907d1Sderaadt #include <dev/pci/pcidevs_data.h> 37901907d1Sderaadt 38901907d1Sderaadt #include "amdgpu_devlist.h" 39901907d1Sderaadt #include "i915_devlist.h" 40901907d1Sderaadt #include "radeon_devlist.h" 41901907d1Sderaadt 42901907d1Sderaadt #include <stdio.h> 43901907d1Sderaadt 44901907d1Sderaadt #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 45901907d1Sderaadt 46901907d1Sderaadt const char * 47901907d1Sderaadt pci_findvendor(pci_vendor_id_t vendor) 48901907d1Sderaadt { 49901907d1Sderaadt const struct pci_known_vendor *kdp = pci_known_vendors; 50901907d1Sderaadt 51901907d1Sderaadt while (kdp->vendorname != NULL) { /* all have vendor name */ 52901907d1Sderaadt if (kdp->vendor == vendor) 53901907d1Sderaadt break; 54901907d1Sderaadt kdp++; 55901907d1Sderaadt } 56901907d1Sderaadt return (kdp->vendorname); 57901907d1Sderaadt } 58901907d1Sderaadt 59901907d1Sderaadt const char * 60901907d1Sderaadt pci_findproduct(pci_vendor_id_t vendor, pci_product_id_t product) 61901907d1Sderaadt { 62901907d1Sderaadt const struct pci_known_product *pkp = pci_known_products; 63901907d1Sderaadt 64901907d1Sderaadt while (pkp->productname != NULL) { /* all have product name */ 65901907d1Sderaadt if (pkp->vendor == vendor && pkp->product == product) 66901907d1Sderaadt break; 67901907d1Sderaadt pkp++; 68901907d1Sderaadt } 69901907d1Sderaadt return (pkp->productname); 70901907d1Sderaadt } 71901907d1Sderaadt 72901907d1Sderaadt void 73901907d1Sderaadt print_devices(char driver[], const struct pci_matchid devices[], int items) 74901907d1Sderaadt { 75901907d1Sderaadt const char *v, *p; 76901907d1Sderaadt int i; 77901907d1Sderaadt 78901907d1Sderaadt for (i = 0; i < items; i++) { 79901907d1Sderaadt v = pci_findvendor(devices[i].pm_vid); 80901907d1Sderaadt p = pci_findproduct(devices[i].pm_vid, 81901907d1Sderaadt devices[i].pm_pid); 82901907d1Sderaadt if ( v && p ) 83901907d1Sderaadt printf("%s \"%s %s\"\n", driver, v ? v : "", p ? p : ""); 84901907d1Sderaadt } 85901907d1Sderaadt } 86901907d1Sderaadt 87901907d1Sderaadt int 88901907d1Sderaadt main(void) 89901907d1Sderaadt { 90901907d1Sderaadt printf("%s\n", "acx"); 914837ede3Sjsg printf("%s\n", "amd"); 924837ede3Sjsg printf("%s\n", "amd ^cpu0:* AMD"); 93901907d1Sderaadt printf("%s\n", "amdgpu"); 94901907d1Sderaadt print_devices("amdgpu", amdgpu_devices, nitems(amdgpu_devices)); 959843e5d8Sjsg printf("%s\n", "amdgpu ^vga*vendor \"ATI\", unknown product"); 969843e5d8Sjsg printf("%s\n", "amdgpu ^vendor \"ATI\", unknown product*class display"); 97*4cfb78b5Sbluhm printf("%s\n", "amdsev ^\"AMD*Crypto\""); 98*4cfb78b5Sbluhm printf("%s\n", "amdsev ^\"AMD*PSP\""); 99*4cfb78b5Sbluhm printf("%s\n", "amdsev ccp"); 100*4cfb78b5Sbluhm printf("%s\n", "amdsev psp"); 101ff827b62Stobhe printf("%s\n", "apple-boot ^cpu0*Apple"); 1020b316460Spatrick printf("%s\n", "arm64-qcom-dtb ^qcgpio0"); 103901907d1Sderaadt printf("%s\n", "athn"); 104901907d1Sderaadt printf("%s\n", "bwfm"); 105901907d1Sderaadt printf("%s\n", "bwi"); 106901907d1Sderaadt printf("%s\n", "intel"); 10775837956Sjsg printf("%s\n", "intel ^cpu0:*Intel"); 108901907d1Sderaadt printf("%s\n", "inteldrm"); 109901907d1Sderaadt print_devices("inteldrm", i915_devices, nitems(i915_devices)); 110901907d1Sderaadt printf("%s\n", "ipw"); 111901907d1Sderaadt printf("%s\n", "iwi"); 112901907d1Sderaadt printf("%s\n", "iwm"); 113901907d1Sderaadt printf("%s\n", "iwn"); 114901907d1Sderaadt printf("%s\n", "iwx"); 115901907d1Sderaadt printf("%s\n", "malo"); 116284d833fShastings printf("%s\n", "mtw"); 11705846bc7Sclaudio printf("%s\n", "mwx"); 118901907d1Sderaadt printf("%s\n", "ogx"); 119901907d1Sderaadt printf("%s\n", "otus"); 120901907d1Sderaadt printf("%s\n", "pgt"); 1218b82f7f0Spatrick printf("%s\n", "qcpas"); 122c0030defSderaadt printf("%s\n", "qcpas ^ppb0*\"Qualcomm ^cpu0*\"Qualcomm"); 123f11a88a2Sphessler printf("%s\n", "qwx"); 124917cb6cdSphessler printf("%s\n", "qwz"); 125901907d1Sderaadt printf("%s\n", "radeondrm"); 126901907d1Sderaadt print_devices("radeondrm", radeon_devices, nitems(radeon_devices)); 127901907d1Sderaadt printf("%s\n", "rsu"); 128901907d1Sderaadt printf("%s\n", "uath"); 129901907d1Sderaadt printf("%s\n", "upgt"); 130901907d1Sderaadt printf("%s\n", "uvideo"); 131901907d1Sderaadt printf("%s\n", "vmm"); 132901907d1Sderaadt printf("%s\n", "wpi"); 133901907d1Sderaadt 134901907d1Sderaadt return 0; 135901907d1Sderaadt } 136