1 /* $OpenBSD: pciprobe.c,v 1.11 2023/07/24 14:02:36 jsg Exp $ */ 2 3 /* 4 * Copyright (c) 1997 Tobias Weingartner 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 */ 29 30 #include <sys/param.h> 31 #include <stand/boot/bootarg.h> 32 #include <machine/biosvar.h> 33 #include "libsa.h" 34 35 #define PCI_SIG 0x20494350 /* PCI Signature */ 36 37 void 38 pciprobe(void) 39 { 40 bios_pciinfo_t bpi; 41 u_int32_t hw_chars, rev, rc, sig; 42 u_int32_t entry32, lastbus; 43 44 /* PCI BIOS v2.0c+ - Installation Check */ 45 __asm volatile(DOINT(0x1A) 46 : "=a" (hw_chars), "=b" (rev), "=c" (lastbus), 47 "=d" (sig), "=D" (entry32), "=@ccc" (rc) 48 : "0" (0xB101), "4" (0x0) 49 : "cc"); 50 51 if (rc & 0xff || hw_chars & 0xff00) 52 return; 53 if (sig != PCI_SIG) 54 return; 55 56 printf(" pci"); 57 #ifdef DEBUG 58 printf("[V%d.%d, %x 0x%x %d]", (rev>>8)&0xFF, (rev&0xFF), 59 hw_chars, entry32, (rc>>8)&0xFF); 60 #endif 61 62 bpi.pci_chars = hw_chars & 0xFFFF; 63 bpi.pci_rev = rev & 0xFFFF; 64 bpi.pci_entry32 = entry32; 65 bpi.pci_lastbus = lastbus & 0xFF; 66 67 addbootarg(BOOTARG_PCIINFO, sizeof(bios_pciinfo_t), &bpi); 68 } 69