xref: /freebsd/share/man/man9/bios.9 (revision abf91c46d84b2181b35eaa13854ed2bb29323e73)
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 1, 1997
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/pmap.h
42.In machine/pc/bios.h
43.Ft u_int32_t
44.Fn bios_sigsearch "u_int32_t start" "u_char *sig" "int siglen" "int paralen" "int sigofs"
45.Ft int
46.Fn bios32_SDlookup "struct bios32_SDentry *ent"
47.Ft int
48.Fn bios32 "struct bios_regs *br" "u_int offset" "u_short segment"
49.Fn BIOS_PADDRTOVADDR "addr"
50.Fn BIOS_VADDRTOPADDR "addr"
51.Vt extern struct bios32_SDentry PCIbios ;
52.Vt extern struct SMBIOS_table SMBIOStable ;
53.Vt extern struct DMI_table DMItable ;
54.Ft int
55.Fn bios_oem_strings "struct bios_oem *oem" "u_char *buffer" "size_t maxlen"
56.Bd -literal
57struct bios_oem_signature {
58        char * anchor;          /* search anchor string in BIOS memory */
59        size_t offset;          /* offset from anchor (may be negative) */
60        size_t totlen;          /* total length of BIOS string to copy */
61};
62struct bios_oem_range {
63        u_int from;             /* shouldn't be below 0xe0000 */
64        u_int to;               /* shouldn't be above 0xfffff */
65};
66struct bios_oem {
67        struct bios_oem_range range;
68        struct bios_oem_signature signature[];
69};
70.Ed
71.Sh DESCRIPTION
72These functions provide a general-purpose interface for dealing with
73the BIOS functions and data encountered on x86 PC-architecture systems.
74.Bl -tag -width 20n
75.It Fn bios_sigsearch
76Searches the BIOS address space for a service signature, usually an
77uppercase ASCII sequence surrounded by underscores.
78The search begins at
79.Fa start ,
80or at the beginning of the BIOS if
81.Fa start
82is zero.
83.Fa siglen
84bytes of the BIOS image and
85.Fa sig
86are compared at
87.Fa sigofs
88bytes offset from the current location.
89If no match is found, the
90current location is incremented by
91.Fa paralen
92bytes and the search repeated.
93If the signature is found, its effective
94physical address is returned.
95If no signature is found, zero is returned.
96.It Fn bios_oem_strings
97Searches a given BIOS memory range for one or more strings,
98and composes a printable concatenation of those found.
99The routine expects a structure describing the BIOS address
100.Fa range
101(within 0xe0000 - 0xfffff), and a { NULL, 0, 0 } -terminated array of
102.Fa bios_oem_signature
103structures which define the
104.Fa anchor
105string, an
106.Fa offset
107from the beginning of the match (which may be negative), and
108.Fa totlen
109number of bytes to be collected from BIOS memory starting at that offset.
110Unmatched anchors are ignored, whereas matches are copied from BIOS memory
111starting at their corresponding
112.Fa offset
113with unprintable characters being replaced with space, and consecutive spaces
114being suppressed. This composed string is stored in
115.Fa buffer
116up to the given
117.Fa maxlen
118bytes (including trailing '\\0', and any trailing space surpressed).
119If an error is encountered, i.e. trying to read out of said BIOS range,
120other invalid input, or
121.Fa buffer
122overflow, a negative integer is returned, otherwise the
123length of the composed string is returned. In particular, a return
124value of 0 means that none of the given anchor strings were found in
125the specified BIOS memory range.
126.It Fn BIOS_VADDRTOPADDR
127Returns the effective physical address which corresponds to the kernel
128virtual address
129.Fa addr .
130.It Fn BIOS_PADDRTOVADDR
131Returns the kernel virtual address which corresponds to the effective
132physical address
133.Fa addr .
134.It SMBIOStable
135If not NULL, points to a
136.Ft struct SMBIOS_table
137structure containing information read from the System Management BIOS table
138during system startup.
139.It DMItable
140If not NULL, points to a
141.Ft struct DMI_table
142structure containing information read from the Desktop Management Interface
143parameter table during system startup.
144.El
145.Sh BIOS32
146At system startup, the BIOS is scanned for the BIOS32 Service Directory
147(part of the PCI specification), and the existence of the directory is
148recorded.
149This can then be used to locate other services.
150.Bl -tag -width 20n
151.It Fn bios32_SDlookup
152Attempts to locate the BIOS32 service matching the 4-byte identifier
153passed in the
154.Fa ident
155field of the
156.Fa ent
157argument.
158.It Fn bios32
159Calls a bios32 function.
160This presumes that the function is capable of
161working within the kernel segment (normally the case).
162The virtual address
163of the entrypoint is supplied in
164.Fa entry
165and the register arguments to the function are supplied in
166.Fa args .
167.It PCIbios
168If not NULL, points to a
169.Ft struct bios32_SDentry
170structure describing the PCI BIOS entrypoint which was found during system
171startup.
172.El
173