1.\" $NetBSD: bioscall.9,v 1.10 2017/07/03 21:31:01 wiz 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 May 5, 2010 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.Fn bioscall 43function switches the processor into real mode, calls the 44.Tn BIOS 45interrupt numbered 46.Fa function , 47and returns to protected mode. 48.Pp 49This function is intended to be called during the initial system 50bootstrap when necessary to probe devices or pseudo-devices. 51.Pp 52The register values specified by 53.Fa *regs 54(with one exception) are installed before the 55.Tn BIOS 56interrupt is called. 57The processor flags are handled specially. 58Only the following flags are passed to the 59.Tn BIOS 60from the registers in 61.Fa regs 62(the remainder come from the processor's flags register at the time 63of the call): 64.Ar PSL_C , 65.Ar PSL_PF , 66.Ar PSL_AF , 67.Ar PSL_Z , 68.Ar PSL_N , 69.Ar PSL_D , 70.Ar PSL_V . 71.Pp 72The 73.Va bioscallregs 74structure is defined to contain structures for each register, to allow 75access to 32-, 16- or 8-bit wide sections of the registers. 76Definitions are provided which simplify access to the union members. 77.Sh RETURN VALUES 78The 79.Fn bioscall 80function fills in 81.Fa *regs 82with the processor registers as returned from the 83.Tn BIOS 84call. 85.Sh EXAMPLES 86The Advanced Power Management driver calls 87.Fn bioscall 88by setting up a register structure with the 89.Tn APM 90installation check and device types in registers 91.Fa ax 92and 93.Fa bx , 94then calls the 95.Tn BIOS 96to fetch the details for calling the 97.Tn APM 98support through a protected-mode interface. 99The 100.Tn BIOS 101returns these details in the registers: 102.Pp 103.Bd -literal -offset indent 104#include <i386/bioscall.h> 105#include <i386/apmvar.h> 106struct bioscallregs regs; 107 108regs.AX = APM_BIOS_FN(APM_INSTALLATION_CHECK); 109regs.BX = APM_DEV_APM_BIOS; 110regs.CX = regs.DX = 0; 111regs.ESI = regs.EDI = regs.EFLAGS = 0; 112bioscall(APM_SYSTEM_BIOS, ®s); 113.Ed 114.Sh CODE REFERENCES 115.Pa sys/arch/i386/i386/bioscall.s , 116.Pa sys/arch/i386/bioscall/biostramp.S 117.Sh REFERENCES 118.Xr apm 4 119.Sh HISTORY 120The 121.Fn bioscall 122function first appeared in 123.Nx 1.3 . 124.Sh BUGS 125Not all 126.Tn BIOS 127functions are safe to call through the trampoline, as they 128may depend on system state which has been disturbed or used for other 129purposes once the 130.Nx 131kernel is running. 132