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