3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
7 #include "util.h" // checksum
8 #include "config.h" // BUILD_BIOS_ADDR
9 #include "farptr.h" // SET_FARVAR
27 extern struct pnpheader PNPHEADER;
28 extern char pnp_string[];
31 struct pnpheader PNPHEADER __aligned(16) VAR16EXPORT = {
32 .signature = PNP_SIGNATURE,
34 .length = sizeof(PNPHEADER),
36 .prot_base = BUILD_BIOS_ADDR,
38 .prot_database = BUILD_BIOS_ADDR,
41 // We need a copy of this string in the 0xf000 segment, but we are not
42 // actually a PnP BIOS, so make sure it is *not* aligned, so OSes will
43 // not see it if they scan.
44 char pnp_string[] __aligned(2) VAR16VISIBLE = " $PnP";
47 #define FUNCTION_NOT_SUPPORTED 0x82
49 // BBS - Get Version and Installation Check
51 handle_pnp60(u16 *args)
53 u16 version_ptr = args[1];
54 u16 version_seg = args[2];
55 SET_FARVAR(version_seg, *(u16*)(version_ptr+0), 0x0101);
60 handle_pnpXX(u16 *args)
62 return FUNCTION_NOT_SUPPORTED;
69 return FUNCTION_NOT_SUPPORTED;
72 dprintf(DEBUG_HDL_pnp, "pnp call arg1=%x\n", arg1);
75 case 0x60: return handle_pnp60(args);
76 default: return handle_pnpXX(args);
84 return (u32)pnp_string + 1 - BUILD_BIOS_ADDR;
85 return (u32)&PNPHEADER - BUILD_BIOS_ADDR;
89 extern void entry_pnp_real(void);
90 extern void entry_pnp_prot(void);
98 dprintf(3, "init PNPBIOS table\n");
100 PNPHEADER.real_ip = (u32)entry_pnp_real - BUILD_BIOS_ADDR;
101 PNPHEADER.prot_ip = (u32)entry_pnp_prot - BUILD_BIOS_ADDR;
102 PNPHEADER.checksum -= checksum(&PNPHEADER, sizeof(PNPHEADER));