xref: /freebsd/share/man/man9/bios.9 (revision 9ba47352808d701431f0996993f3e31a9da87887)
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.\"
2778ad5421SRuslan Ermilov.Dd August 9, 2005
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
10178ad5421SRuslan Ermilov(within
10278ad5421SRuslan Ermilov.Li 0xe0000
10378ad5421SRuslan Ermilov-
10478ad5421SRuslan Ermilov.Li 0xfffff ) ,
10578ad5421SRuslan Ermilovand a {
10678ad5421SRuslan Ermilov.Dv NULL , Li 0 , 0
10778ad5421SRuslan Ermilov} -terminated array of
10878ad5421SRuslan Ermilov.Vt bios_oem_signature
109636d90fcSPoul-Henning Kampstructures which define the
11078ad5421SRuslan Ermilov.Va anchor
111636d90fcSPoul-Henning Kampstring, an
11278ad5421SRuslan Ermilov.Va offset
113636d90fcSPoul-Henning Kampfrom the beginning of the match (which may be negative), and
11478ad5421SRuslan Ermilov.Va totlen
115636d90fcSPoul-Henning Kampnumber of bytes to be collected from BIOS memory starting at that offset.
116636d90fcSPoul-Henning KampUnmatched anchors are ignored, whereas matches are copied from BIOS memory
117636d90fcSPoul-Henning Kampstarting at their corresponding
11878ad5421SRuslan Ermilov.Vt offset
119636d90fcSPoul-Henning Kampwith unprintable characters being replaced with space, and consecutive spaces
12078ad5421SRuslan Ermilovbeing suppressed.
12178ad5421SRuslan ErmilovThis composed string is stored in
122636d90fcSPoul-Henning Kamp.Fa buffer
123636d90fcSPoul-Henning Kampup to the given
124636d90fcSPoul-Henning Kamp.Fa maxlen
12578ad5421SRuslan Ermilovbytes (including trailing
12678ad5421SRuslan Ermilov.Ql \e0 ,
127*9ba47352SJoel Dahland any trailing space suppressed).
12878ad5421SRuslan ErmilovIf an error is encountered, i.e.\& trying to read out of said BIOS range,
129636d90fcSPoul-Henning Kampother invalid input, or
130636d90fcSPoul-Henning Kamp.Fa buffer
131636d90fcSPoul-Henning Kampoverflow, a negative integer is returned, otherwise the
13278ad5421SRuslan Ermilovlength of the composed string is returned.
13378ad5421SRuslan ErmilovIn particular, a return
134636d90fcSPoul-Henning Kampvalue of 0 means that none of the given anchor strings were found in
135636d90fcSPoul-Henning Kampthe specified BIOS memory range.
136a1dadd10SMike Smith.It Fn BIOS_VADDRTOPADDR
137a1dadd10SMike SmithReturns the effective physical address which corresponds to the kernel
138a1dadd10SMike Smithvirtual address
139a1dadd10SMike Smith.Fa addr .
140abf91c46SMurray Stokely.It Fn BIOS_PADDRTOVADDR
141a1dadd10SMike SmithReturns the kernel virtual address which corresponds to the effective
142a1dadd10SMike Smithphysical address
143a1dadd10SMike Smith.Fa addr .
144a1dadd10SMike Smith.It SMBIOStable
145a1dadd10SMike SmithIf not NULL, points to a
146a1dadd10SMike Smith.Ft struct SMBIOS_table
147a1dadd10SMike Smithstructure containing information read from the System Management BIOS table
148a1dadd10SMike Smithduring system startup.
149a1dadd10SMike Smith.It DMItable
150a1dadd10SMike SmithIf not NULL, points to a
151a1dadd10SMike Smith.Ft struct DMI_table
152a1dadd10SMike Smithstructure containing information read from the Desktop Management Interface
153a1dadd10SMike Smithparameter table during system startup.
154a1dadd10SMike Smith.El
155a1dadd10SMike Smith.Sh BIOS32
156a1dadd10SMike SmithAt system startup, the BIOS is scanned for the BIOS32 Service Directory
157a1dadd10SMike Smith(part of the PCI specification), and the existence of the directory is
158ce91e62bSHiten Pandyarecorded.
159ce91e62bSHiten PandyaThis can then be used to locate other services.
160a1dadd10SMike Smith.Bl -tag -width 20n
161a1dadd10SMike Smith.It Fn bios32_SDlookup
162a1dadd10SMike SmithAttempts to locate the BIOS32 service matching the 4-byte identifier
163a1dadd10SMike Smithpassed in the
164a1dadd10SMike Smith.Fa ident
165a1dadd10SMike Smithfield of the
166a1dadd10SMike Smith.Fa ent
167a1dadd10SMike Smithargument.
168a1dadd10SMike Smith.It Fn bios32
169ce91e62bSHiten PandyaCalls a bios32 function.
170ce91e62bSHiten PandyaThis presumes that the function is capable of
171ce91e62bSHiten Pandyaworking within the kernel segment (normally the case).
172ce91e62bSHiten PandyaThe virtual address
173a1dadd10SMike Smithof the entrypoint is supplied in
174a1dadd10SMike Smith.Fa entry
175a1dadd10SMike Smithand the register arguments to the function are supplied in
176a1dadd10SMike Smith.Fa args .
177a1dadd10SMike Smith.It PCIbios
178a1dadd10SMike SmithIf not NULL, points to a
179a1dadd10SMike Smith.Ft struct bios32_SDentry
180a1dadd10SMike Smithstructure describing the PCI BIOS entrypoint which was found during system
181a1dadd10SMike Smithstartup.
182a1dadd10SMike Smith.El
183