// SPDX-License-Identifier: GPL-2.0-only1/* -*- linux-c -*- ------------------------------------------------------- *2*3* Copyright (C) 1991, 1992 Linus Torvalds4* Copyright 2007 rPath, Inc. - All Rights Reserved5* Copyright 2009 Intel Corporation; author H. Peter Anvin6*7* Original APM BIOS checking by Stephen Rothwell, May 19948* ([email protected])9*10* ----------------------------------------------------------------------- */1112/*13* Get APM BIOS information14*/1516#include "boot.h"1718int query_apm_bios(void)19{20struct biosregs ireg, oreg;2122/* APM BIOS installation check */23initregs(&ireg);24ireg.ah = 0x53;25intcall(0x15, &ireg, &oreg);2627if (oreg.flags & X86_EFLAGS_CF)28return -1; /* No APM BIOS */2930if (oreg.bx != 0x504d) /* "PM" signature */31return -1;3233if (!(oreg.cx & 0x02)) /* 32 bits supported? */34return -1;3536/* Disconnect first, just in case */37ireg.al = 0x04;38intcall(0x15, &ireg, NULL);3940/* 32-bit connect */41ireg.al = 0x03;42intcall(0x15, &ireg, &oreg);4344boot_params.apm_bios_info.cseg = oreg.ax;45boot_params.apm_bios_info.offset = oreg.ebx;46boot_params.apm_bios_info.cseg_16 = oreg.cx;47boot_params.apm_bios_info.dseg = oreg.dx;48boot_params.apm_bios_info.cseg_len = oreg.si;49boot_params.apm_bios_info.cseg_16_len = oreg.hsi;50boot_params.apm_bios_info.dseg_len = oreg.di;5152if (oreg.flags & X86_EFLAGS_CF)53return -1;5455/* Redo the installation check as the 32-bit connect;56some BIOSes return different flags this way... */5758ireg.al = 0x00;59intcall(0x15, &ireg, &oreg);6061if ((oreg.eflags & X86_EFLAGS_CF) || oreg.bx != 0x504d) {62/* Failure with 32-bit connect, try to disconnect and ignore */63ireg.al = 0x04;64intcall(0x15, &ireg, NULL);65return -1;66}6768boot_params.apm_bios_info.version = oreg.ax;69boot_params.apm_bios_info.flags = oreg.cx;70return 0;71}72737475