0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "boot.h"
0018
0019 int query_apm_bios(void)
0020 {
0021 struct biosregs ireg, oreg;
0022
0023
0024 initregs(&ireg);
0025 ireg.ah = 0x53;
0026 intcall(0x15, &ireg, &oreg);
0027
0028 if (oreg.flags & X86_EFLAGS_CF)
0029 return -1;
0030
0031 if (oreg.bx != 0x504d)
0032 return -1;
0033
0034 if (!(oreg.cx & 0x02))
0035 return -1;
0036
0037
0038 ireg.al = 0x04;
0039 intcall(0x15, &ireg, NULL);
0040
0041
0042 ireg.al = 0x03;
0043 intcall(0x15, &ireg, &oreg);
0044
0045 boot_params.apm_bios_info.cseg = oreg.ax;
0046 boot_params.apm_bios_info.offset = oreg.ebx;
0047 boot_params.apm_bios_info.cseg_16 = oreg.cx;
0048 boot_params.apm_bios_info.dseg = oreg.dx;
0049 boot_params.apm_bios_info.cseg_len = oreg.si;
0050 boot_params.apm_bios_info.cseg_16_len = oreg.hsi;
0051 boot_params.apm_bios_info.dseg_len = oreg.di;
0052
0053 if (oreg.flags & X86_EFLAGS_CF)
0054 return -1;
0055
0056
0057
0058
0059 ireg.al = 0x00;
0060 intcall(0x15, &ireg, &oreg);
0061
0062 if ((oreg.eflags & X86_EFLAGS_CF) || oreg.bx != 0x504d) {
0063
0064 ireg.al = 0x04;
0065 intcall(0x15, &ireg, NULL);
0066 return -1;
0067 }
0068
0069 boot_params.apm_bios_info.version = oreg.ax;
0070 boot_params.apm_bios_info.flags = oreg.cx;
0071 return 0;
0072 }
0073