.\" $NetBSD: bioscall.9,v 1.10 2017/07/03 21:31:01 wiz Exp $ .\" .\" Copyright (c) 1998 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by John Kohl. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" .Dd May 5, 2010 .Dt BIOSCALL 9 i386 .Os .Sh NAME .Nm bioscall .Nd call system BIOS function from real mode .Sh SYNOPSIS .In i386/bioscall.h .Ft void .Fn bioscall "int function" "struct bioscallregs *regs" .Sh DESCRIPTION The .Fn bioscall function switches the processor into real mode, calls the .Tn BIOS interrupt numbered .Fa function , and returns to protected mode. .Pp This function is intended to be called during the initial system bootstrap when necessary to probe devices or pseudo-devices. .Pp The register values specified by .Fa *regs (with one exception) are installed before the .Tn BIOS interrupt is called. The processor flags are handled specially. Only the following flags are passed to the .Tn BIOS from the registers in .Fa regs (the remainder come from the processor's flags register at the time of the call): .Ar PSL_C , .Ar PSL_PF , .Ar PSL_AF , .Ar PSL_Z , .Ar PSL_N , .Ar PSL_D , .Ar PSL_V . .Pp The .Va bioscallregs structure is defined to contain structures for each register, to allow access to 32-, 16- or 8-bit wide sections of the registers. Definitions are provided which simplify access to the union members. .Sh RETURN VALUES The .Fn bioscall function fills in .Fa *regs with the processor registers as returned from the .Tn BIOS call. .Sh EXAMPLES The Advanced Power Management driver calls .Fn bioscall by setting up a register structure with the .Tn APM installation check and device types in registers .Fa ax and .Fa bx , then calls the .Tn BIOS to fetch the details for calling the .Tn APM support through a protected-mode interface. The .Tn BIOS returns these details in the registers: .Pp .Bd -literal -offset indent #include #include struct bioscallregs regs; regs.AX = APM_BIOS_FN(APM_INSTALLATION_CHECK); regs.BX = APM_DEV_APM_BIOS; regs.CX = regs.DX = 0; regs.ESI = regs.EDI = regs.EFLAGS = 0; bioscall(APM_SYSTEM_BIOS, ®s); .Ed .Sh CODE REFERENCES .Pa sys/arch/i386/i386/bioscall.s , .Pa sys/arch/i386/bioscall/biostramp.S .Sh REFERENCES .Xr apm 4 .Sh HISTORY The .Fn bioscall function first appeared in .Nx 1.3 . .Sh BUGS Not all .Tn BIOS functions are safe to call through the trampoline, as they may depend on system state which has been disturbed or used for other purposes once the .Nx kernel is running.