1.\" $NetBSD: bioscall.9,v 1.6 2002/02/13 08:18:59 ross Exp $ 2.\" 3.\" Copyright (c) 1998 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by John Kohl. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd October 1, 1998 38.Dt BIOSCALL 9 i386 39.Os 40.Sh NAME 41.Nm bioscall 42.Nd call system BIOS function from real mode 43.Sh SYNOPSIS 44.Fd #include \*[Lt]i386/bioscall.h\*[Gt] 45.Ft void 46.Fn bioscall "int function" "struct bioscallregs *regs" 47.Sh DESCRIPTION 48The 49.Nm 50function switches the processor into real mode, calls the BIOS interrupt 51numbered 52.Fa function , 53and returns to protected mode. 54.Pp 55This function is intended to be called during the initial system 56bootstrap when necessary to probe devices or pseudo-devices. 57.Pp 58The register values specified by 59.Fa *regs 60(with one exception) are installed before the BIOS interrupt is called. 61The processor flags are handled specially. Only the following flags are 62passed to the 63BIOS from the registers in 64.Fa regs 65(the remainder come from the processor's flags register at the time 66of the call): 67.Ar PSL_C , 68.Ar PSL_PF , 69.Ar PSL_AF , 70.Ar PSL_Z , 71.Ar PSL_N , 72.Ar PSL_D , 73.Ar PSL_V . 74.Pp 75The 76.Va bioscallregs 77structure is defined to contain structures for each register, to allow 78access to 32-, 16- or 8-bit wide sections of the registers. 79Definitions are provided which simplify access to the union members. 80.Sh RETURN VALUES 81.Nm 82fills in 83.Fa *regs 84with the processor registers as returned from the BIOS call. 85.Sh EXAMPLES 86The Advanced Power Management driver calls 87.Nm 88by setting up a register structure with the APM installation check and 89device types in registers 90.Fa ax 91and 92.Fa bx , 93then calls the BIOS to fetch the details for calling the APM support 94through a protected-mode interface. The BIOS returns these details in 95the registers: 96.Pp 97.Bd -literal 98#include \*[Lt]i386/bioscall.h\*[Gt] 99#include \*[Lt]i386/apmvar.h\*[Gt] 100struct bioscallregs regs; 101 102regs.AX = APM_BIOS_FN(APM_INSTALLATION_CHECK); 103regs.BX = APM_DEV_APM_BIOS; 104regs.CX = regs.DX = 0; 105regs.ESI = regs.EDI = regs.EFLAGS = 0; 106bioscall(APM_SYSTEM_BIOS, \*[Am]regs); 107.Ed 108.Sh CODE REFERENCES 109.Pa sys/arch/i386/i386/bioscall.s , 110.Pa sys/arch/i386/bioscall/biostramp.S 111.Sh REFERENCES 112.Xr apm 4 113.Sh HISTORY 114.Nm 115first appeared in 116.Nx 1.3 . 117.Sh BUGS 118Not all BIOS functions are safe to call through the trampoline, as they 119may depend on system state which has been disturbed or used for other 120purposes once the 121.Nx 122kernel is running. 123