1.\" $FreeBSD$ 2.\" 3.\" Copyright (c) 1997 Michael Smith 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.Dd August 9, 2005 28.Dt BIOS 9 29.Os 30.Sh NAME 31.Nm bios_sigsearch , 32.Nm bios32_SDlookup , 33.Nm bios32 , 34.Nm bios_oem_strings 35.Nd interact with PC BIOS 36.Sh SYNOPSIS 37.In sys/param.h 38.In vm/vm.h 39.In vm/pmap.h 40.In machine/param.h 41.In machine/pc/bios.h 42.Ft uint32_t 43.Fn bios_sigsearch "uint32_t start" "u_char *sig" "int siglen" "int paralen" "int sigofs" 44.Ft int 45.Fn bios32_SDlookup "struct bios32_SDentry *ent" 46.Ft int 47.Fn bios32 "struct bios_regs *br" "u_int offset" "u_short segment" 48.Fn BIOS_PADDRTOVADDR "addr" 49.Fn BIOS_VADDRTOPADDR "addr" 50.Vt extern struct bios32_SDentry PCIbios ; 51.Vt extern struct SMBIOS_table SMBIOStable ; 52.Vt extern struct DMI_table DMItable ; 53.Ft int 54.Fn bios_oem_strings "struct bios_oem *oem" "u_char *buffer" "size_t maxlen" 55.Bd -literal 56struct bios_oem_signature { 57 char * anchor; /* search anchor string in BIOS memory */ 58 size_t offset; /* offset from anchor (may be negative) */ 59 size_t totlen; /* total length of BIOS string to copy */ 60}; 61struct bios_oem_range { 62 u_int from; /* shouldn't be below 0xe0000 */ 63 u_int to; /* shouldn't be above 0xfffff */ 64}; 65struct bios_oem { 66 struct bios_oem_range range; 67 struct bios_oem_signature signature[]; 68}; 69.Ed 70.Sh DESCRIPTION 71These functions provide a general-purpose interface for dealing with 72the BIOS functions and data encountered on x86 PC-architecture systems. 73.Bl -tag -width 20n 74.It Fn bios_sigsearch 75Searches the BIOS address space for a service signature, usually an 76uppercase ASCII sequence surrounded by underscores. 77The search begins at 78.Fa start , 79or at the beginning of the BIOS if 80.Fa start 81is zero. 82.Fa siglen 83bytes of the BIOS image and 84.Fa sig 85are compared at 86.Fa sigofs 87bytes offset from the current location. 88If no match is found, the 89current location is incremented by 90.Fa paralen 91bytes and the search repeated. 92If the signature is found, its effective 93physical address is returned. 94If no signature is found, zero is returned. 95.It Fn bios_oem_strings 96Searches a given BIOS memory range for one or more strings, 97and composes a printable concatenation of those found. 98The routine expects a structure describing the BIOS address 99.Fa range 100(within 101.Li 0xe0000 102- 103.Li 0xfffff ) , 104and a { 105.Dv NULL , Li 0 , 0 106} -terminated array of 107.Vt bios_oem_signature 108structures which define the 109.Va anchor 110string, an 111.Va offset 112from the beginning of the match (which may be negative), and 113.Va totlen 114number of bytes to be collected from BIOS memory starting at that offset. 115Unmatched anchors are ignored, whereas matches are copied from BIOS memory 116starting at their corresponding 117.Vt offset 118with unprintable characters being replaced with space, and consecutive spaces 119being suppressed. 120This composed string is stored in 121.Fa buffer 122up to the given 123.Fa maxlen 124bytes (including trailing 125.Ql \e0 , 126and any trailing space suppressed). 127If an error is encountered, i.e.\& trying to read out of said BIOS range, 128other invalid input, or 129.Fa buffer 130overflow, a negative integer is returned, otherwise the 131length of the composed string is returned. 132In particular, a return 133value of 0 means that none of the given anchor strings were found in 134the specified BIOS memory range. 135.It Fn BIOS_VADDRTOPADDR 136Returns the effective physical address which corresponds to the kernel 137virtual address 138.Fa addr . 139.It Fn BIOS_PADDRTOVADDR 140Returns the kernel virtual address which corresponds to the effective 141physical address 142.Fa addr . 143.It SMBIOStable 144If not NULL, points to a 145.Ft struct SMBIOS_table 146structure containing information read from the System Management BIOS table 147during system startup. 148.It DMItable 149If not NULL, points to a 150.Ft struct DMI_table 151structure containing information read from the Desktop Management Interface 152parameter table during system startup. 153.El 154.Sh BIOS32 155At system startup, the BIOS is scanned for the BIOS32 Service Directory 156(part of the PCI specification), and the existence of the directory is 157recorded. 158This can then be used to locate other services. 159.Bl -tag -width 20n 160.It Fn bios32_SDlookup 161Attempts to locate the BIOS32 service matching the 4-byte identifier 162passed in the 163.Fa ident 164field of the 165.Fa ent 166argument. 167.It Fn bios32 168Calls a bios32 function. 169This presumes that the function is capable of 170working within the kernel segment (normally the case). 171The virtual address 172of the entrypoint is supplied in 173.Fa entry 174and the register arguments to the function are supplied in 175.Fa args . 176.It PCIbios 177If not NULL, points to a 178.Ft struct bios32_SDentry 179structure describing the PCI BIOS entrypoint which was found during system 180startup. 181.El 182