/* -*- linux-c -*- ------------------------------------------------------- *1*2* Copyright (C) 1991, 1992 Linus Torvalds3* Copyright 2007 rPath, Inc. - All Rights Reserved4* Copyright 2009 Intel Corporation; author H. Peter Anvin5*6* Original APM BIOS checking by Stephen Rothwell, May 19947* ([email protected])8*9* This file is part of the Linux kernel, and is made available under10* the terms of the GNU General Public License version 2.11*12* ----------------------------------------------------------------------- */1314/*15* Get APM BIOS information16*/1718#include "boot.h"1920int query_apm_bios(void)21{22struct biosregs ireg, oreg;2324/* APM BIOS installation check */25initregs(&ireg);26ireg.ah = 0x53;27intcall(0x15, &ireg, &oreg);2829if (oreg.flags & X86_EFLAGS_CF)30return -1; /* No APM BIOS */3132if (oreg.bx != 0x504d) /* "PM" signature */33return -1;3435if (!(oreg.cx & 0x02)) /* 32 bits supported? */36return -1;3738/* Disconnect first, just in case */39ireg.al = 0x04;40intcall(0x15, &ireg, NULL);4142/* 32-bit connect */43ireg.al = 0x03;44intcall(0x15, &ireg, &oreg);4546boot_params.apm_bios_info.cseg = oreg.ax;47boot_params.apm_bios_info.offset = oreg.ebx;48boot_params.apm_bios_info.cseg_16 = oreg.cx;49boot_params.apm_bios_info.dseg = oreg.dx;50boot_params.apm_bios_info.cseg_len = oreg.si;51boot_params.apm_bios_info.cseg_16_len = oreg.hsi;52boot_params.apm_bios_info.dseg_len = oreg.di;5354if (oreg.flags & X86_EFLAGS_CF)55return -1;5657/* Redo the installation check as the 32-bit connect;58some BIOSes return different flags this way... */5960ireg.al = 0x00;61intcall(0x15, &ireg, &oreg);6263if ((oreg.eflags & X86_EFLAGS_CF) || oreg.bx != 0x504d) {64/* Failure with 32-bit connect, try to disconect and ignore */65ireg.al = 0x04;66intcall(0x15, &ireg, NULL);67return -1;68}6970boot_params.apm_bios_info.version = oreg.ax;71boot_params.apm_bios_info.flags = oreg.cx;72return 0;73}74757677