17f3dea24SPeter Wemm.\" $FreeBSD$ 2a1dadd10SMike Smith.\" 3a1dadd10SMike Smith.\" Copyright (c) 1997 Michael Smith 4a1dadd10SMike Smith.\" All rights reserved. 5a1dadd10SMike Smith.\" 6a1dadd10SMike Smith.\" Redistribution and use in source and binary forms, with or without 7a1dadd10SMike Smith.\" modification, are permitted provided that the following conditions 8a1dadd10SMike Smith.\" are met: 9a1dadd10SMike Smith.\" 1. Redistributions of source code must retain the above copyright 10a1dadd10SMike Smith.\" notice, this list of conditions and the following disclaimer. 11a1dadd10SMike Smith.\" 2. Redistributions in binary form must reproduce the above copyright 12a1dadd10SMike Smith.\" notice, this list of conditions and the following disclaimer in the 13a1dadd10SMike Smith.\" documentation and/or other materials provided with the distribution. 14a1dadd10SMike Smith.\" 15a1dadd10SMike Smith.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16a1dadd10SMike Smith.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17a1dadd10SMike Smith.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18a1dadd10SMike Smith.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19a1dadd10SMike Smith.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20a1dadd10SMike Smith.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21a1dadd10SMike Smith.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22a1dadd10SMike Smith.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23a1dadd10SMike Smith.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24a1dadd10SMike Smith.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25a1dadd10SMike Smith.\" SUCH DAMAGE. 26a1dadd10SMike Smith.\" 27d7b336c0SRuslan Ermilov.Dd August 1, 1997 286b8d502dSMike Smith.Dt BIOS 9 293d45e180SRuslan Ermilov.Os 30a1dadd10SMike Smith.Sh NAME 31a1dadd10SMike Smith.Nm bios_sigsearch , 32a1dadd10SMike Smith.Nm bios32_SDlookup , 33636d90fcSPoul-Henning Kamp.Nm bios32 , 34636d90fcSPoul-Henning Kamp.Nm bios_oem_strings 35eb083802SRuslan Ermilov.Nd interact with PC BIOS 36a1dadd10SMike Smith.Sh SYNOPSIS 37f16b3c0dSChad David.In sys/param.h 38f16b3c0dSChad David.In vm/vm.h 39f16b3c0dSChad David.In vm/pmap.h 40f16b3c0dSChad David.In machine/param.h 41f16b3c0dSChad David.In machine/pmap.h 4232eef9aeSRuslan Ermilov.In machine/pc/bios.h 43a1dadd10SMike Smith.Ft u_int32_t 44a1dadd10SMike Smith.Fn bios_sigsearch "u_int32_t start" "u_char *sig" "int siglen" "int paralen" "int sigofs" 45a1dadd10SMike Smith.Ft int 46a1dadd10SMike Smith.Fn bios32_SDlookup "struct bios32_SDentry *ent" 47f16b3c0dSChad David.Ft int 48f16b3c0dSChad David.Fn bios32 "struct bios_regs *br" "u_int offset" "u_short segment" 49a1dadd10SMike Smith.Fn BIOS_PADDRTOVADDR "addr" 50a1dadd10SMike Smith.Fn BIOS_VADDRTOPADDR "addr" 51b77b3c00SRuslan Ermilov.Vt extern struct bios32_SDentry PCIbios ; 52b77b3c00SRuslan Ermilov.Vt extern struct SMBIOS_table SMBIOStable ; 53b77b3c00SRuslan Ermilov.Vt extern struct DMI_table DMItable ; 54636d90fcSPoul-Henning Kamp.Ft int 55636d90fcSPoul-Henning Kamp.Fn bios_oem_strings "struct bios_oem *oem" "u_char *buffer" "size_t maxlen" 56636d90fcSPoul-Henning Kamp.Bd -literal 57636d90fcSPoul-Henning Kampstruct bios_oem_signature { 58636d90fcSPoul-Henning Kamp char * anchor; /* search anchor string in BIOS memory */ 59636d90fcSPoul-Henning Kamp size_t offset; /* offset from anchor (may be negative) */ 60636d90fcSPoul-Henning Kamp size_t totlen; /* total length of BIOS string to copy */ 61636d90fcSPoul-Henning Kamp}; 62636d90fcSPoul-Henning Kampstruct bios_oem_range { 63636d90fcSPoul-Henning Kamp u_int from; /* shouldn't be below 0xe0000 */ 64636d90fcSPoul-Henning Kamp u_int to; /* shouldn't be above 0xfffff */ 65636d90fcSPoul-Henning Kamp}; 66636d90fcSPoul-Henning Kampstruct bios_oem { 67636d90fcSPoul-Henning Kamp struct bios_oem_range range; 68636d90fcSPoul-Henning Kamp struct bios_oem_signature signature[]; 69636d90fcSPoul-Henning Kamp}; 70636d90fcSPoul-Henning Kamp.Ed 71a1dadd10SMike Smith.Sh DESCRIPTION 72a1dadd10SMike SmithThese functions provide a general-purpose interface for dealing with 73a1dadd10SMike Smiththe BIOS functions and data encountered on x86 PC-architecture systems. 74a1dadd10SMike Smith.Bl -tag -width 20n 75a1dadd10SMike Smith.It Fn bios_sigsearch 76a1dadd10SMike SmithSearches the BIOS address space for a service signature, usually an 77ce91e62bSHiten Pandyauppercase ASCII sequence surrounded by underscores. 78ce91e62bSHiten PandyaThe search begins at 79a1dadd10SMike Smith.Fa start , 80a1dadd10SMike Smithor at the beginning of the BIOS if 81a1dadd10SMike Smith.Fa start 82a1dadd10SMike Smithis zero. 83a1dadd10SMike Smith.Fa siglen 84a1dadd10SMike Smithbytes of the BIOS image and 85a1dadd10SMike Smith.Fa sig 86a1dadd10SMike Smithare compared at 87a1dadd10SMike Smith.Fa sigofs 88ce91e62bSHiten Pandyabytes offset from the current location. 89ce91e62bSHiten PandyaIf no match is found, the 90a1dadd10SMike Smithcurrent location is incremented by 91a1dadd10SMike Smith.Fa paralen 92ce91e62bSHiten Pandyabytes and the search repeated. 93ce91e62bSHiten PandyaIf the signature is found, its effective 94ce91e62bSHiten Pandyaphysical address is returned. 95ce91e62bSHiten PandyaIf no signature is found, zero is returned. 96636d90fcSPoul-Henning Kamp.It Fn bios_oem_strings 97636d90fcSPoul-Henning KampSearches a given BIOS memory range for one or more strings, 98636d90fcSPoul-Henning Kampand composes a printable concatenation of those found. 99636d90fcSPoul-Henning KampThe routine expects a structure describing the BIOS address 100636d90fcSPoul-Henning Kamp.Fa range 101636d90fcSPoul-Henning Kamp(within 0xe0000 - 0xfffff), and a { NULL, 0, 0 } -terminated array of 102636d90fcSPoul-Henning Kamp.Fa bios_oem_signature 103636d90fcSPoul-Henning Kampstructures which define the 104636d90fcSPoul-Henning Kamp.Fa anchor 105636d90fcSPoul-Henning Kampstring, an 106636d90fcSPoul-Henning Kamp.Fa offset 107636d90fcSPoul-Henning Kampfrom the beginning of the match (which may be negative), and 108636d90fcSPoul-Henning Kamp.Fa totlen 109636d90fcSPoul-Henning Kampnumber of bytes to be collected from BIOS memory starting at that offset. 110636d90fcSPoul-Henning KampUnmatched anchors are ignored, whereas matches are copied from BIOS memory 111636d90fcSPoul-Henning Kampstarting at their corresponding 112636d90fcSPoul-Henning Kamp.Fa offset 113636d90fcSPoul-Henning Kampwith unprintable characters being replaced with space, and consecutive spaces 114636d90fcSPoul-Henning Kampbeing suppressed. This composed string is stored in 115636d90fcSPoul-Henning Kamp.Fa buffer 116636d90fcSPoul-Henning Kampup to the given 117636d90fcSPoul-Henning Kamp.Fa maxlen 118636d90fcSPoul-Henning Kampbytes (including trailing '\\0', and any trailing space surpressed). 119636d90fcSPoul-Henning KampIf an error is encountered, i.e. trying to read out of said BIOS range, 120636d90fcSPoul-Henning Kampother invalid input, or 121636d90fcSPoul-Henning Kamp.Fa buffer 122636d90fcSPoul-Henning Kampoverflow, a negative integer is returned, otherwise the 123636d90fcSPoul-Henning Kamplength of the composed string is returned. In particular, a return 124636d90fcSPoul-Henning Kampvalue of 0 means that none of the given anchor strings were found in 125636d90fcSPoul-Henning Kampthe specified BIOS memory range. 126a1dadd10SMike Smith.It Fn BIOS_VADDRTOPADDR 127a1dadd10SMike SmithReturns the effective physical address which corresponds to the kernel 128a1dadd10SMike Smithvirtual address 129a1dadd10SMike Smith.Fa addr . 130abf91c46SMurray Stokely.It Fn BIOS_PADDRTOVADDR 131a1dadd10SMike SmithReturns the kernel virtual address which corresponds to the effective 132a1dadd10SMike Smithphysical address 133a1dadd10SMike Smith.Fa addr . 134a1dadd10SMike Smith.It SMBIOStable 135a1dadd10SMike SmithIf not NULL, points to a 136a1dadd10SMike Smith.Ft struct SMBIOS_table 137a1dadd10SMike Smithstructure containing information read from the System Management BIOS table 138a1dadd10SMike Smithduring system startup. 139a1dadd10SMike Smith.It DMItable 140a1dadd10SMike SmithIf not NULL, points to a 141a1dadd10SMike Smith.Ft struct DMI_table 142a1dadd10SMike Smithstructure containing information read from the Desktop Management Interface 143a1dadd10SMike Smithparameter table during system startup. 144a1dadd10SMike Smith.El 145a1dadd10SMike Smith.Sh BIOS32 146a1dadd10SMike SmithAt system startup, the BIOS is scanned for the BIOS32 Service Directory 147a1dadd10SMike Smith(part of the PCI specification), and the existence of the directory is 148ce91e62bSHiten Pandyarecorded. 149ce91e62bSHiten PandyaThis can then be used to locate other services. 150a1dadd10SMike Smith.Bl -tag -width 20n 151a1dadd10SMike Smith.It Fn bios32_SDlookup 152a1dadd10SMike SmithAttempts to locate the BIOS32 service matching the 4-byte identifier 153a1dadd10SMike Smithpassed in the 154a1dadd10SMike Smith.Fa ident 155a1dadd10SMike Smithfield of the 156a1dadd10SMike Smith.Fa ent 157a1dadd10SMike Smithargument. 158a1dadd10SMike Smith.It Fn bios32 159ce91e62bSHiten PandyaCalls a bios32 function. 160ce91e62bSHiten PandyaThis presumes that the function is capable of 161ce91e62bSHiten Pandyaworking within the kernel segment (normally the case). 162ce91e62bSHiten PandyaThe virtual address 163a1dadd10SMike Smithof the entrypoint is supplied in 164a1dadd10SMike Smith.Fa entry 165a1dadd10SMike Smithand the register arguments to the function are supplied in 166a1dadd10SMike Smith.Fa args . 167a1dadd10SMike Smith.It PCIbios 168a1dadd10SMike SmithIf not NULL, points to a 169a1dadd10SMike Smith.Ft struct bios32_SDentry 170a1dadd10SMike Smithstructure describing the PCI BIOS entrypoint which was found during system 171a1dadd10SMike Smithstartup. 172a1dadd10SMike Smith.El 173