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