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