From 98098c3edad41d04379bb95076ac6581d99b8a64 Mon Sep 17 00:00:00 2001 From: jkim Date: Thu, 11 Nov 2010 19:20:33 +0000 Subject: [PATCH] Add compat shim for apm(4) to translate APM BIOS function numbers from i386 to PC98-specific ones. Any binaries using apm ioctl(4) commands but built for i386 should also work on PC98 now. Reviewed by: imp, nyan --- sys/i386/bios/apm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index e015cd09f68c..f33bafdeddd6 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -1389,6 +1389,23 @@ apmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td return (EPERM); /* XXX compatibility with the old interface */ args = (struct apm_bios_arg *)addr; +#ifdef PC98 + if (((args->eax >> 8) & 0xff) == 0x53) { + sc->bios.r.eax = args->eax & ~0xffff; + sc->bios.r.eax |= APM_BIOS << 8; + switch (args->eax & 0xff) { + case 0x0a: + sc->bios.r.eax |= APM_GETPWSTATUS; + break; + case 0x0e: + sc->bios.r.eax |= APM_DRVVERSION; + break; + default: + sc->bios.r.eax |= args->eax & 0xff; + break; + } + } else +#endif sc->bios.r.eax = args->eax; sc->bios.r.ebx = args->ebx; sc->bios.r.ecx = args->ecx;