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 "config.h" // BUILD_BIOS_ADDR
8 #include "farptr.h" // SET_FARVAR
9 #include "output.h" // dprintf
10 #include "std/pnpbios.h" // PNP_SIGNATURE
11 #include "string.h" // checksum
12 #include "util.h" // pnp_init
14 extern struct pnpheader PNPHEADER;
15 extern char pnp_string[];
18 struct pnpheader PNPHEADER __aligned(16) VARFSEG = {
19 .signature = PNP_SIGNATURE,
21 .length = sizeof(PNPHEADER),
23 .prot_base = BUILD_BIOS_ADDR,
25 .prot_database = BUILD_BIOS_ADDR,
28 // We need a copy of this string in the 0xf000 segment, but we are not
29 // actually a PnP BIOS, so make sure it is *not* aligned, so OSes will
30 // not see it if they scan.
31 char pnp_string[] __aligned(2) VARFSEG = " $PnP";
34 // BBS - Get Version and Installation Check
36 handle_pnp60(u16 *args)
38 u16 version_ptr = args[1];
39 u16 version_seg = args[2];
40 SET_FARVAR(version_seg, *(u16*)(version_ptr+0), 0x0101);
45 handle_pnpXX(u16 *args)
47 return FUNCTION_NOT_SUPPORTED;
54 return FUNCTION_NOT_SUPPORTED;
57 dprintf(DEBUG_HDL_pnp, "pnp call arg1=%x\n", arg1);
60 case 0x60: return handle_pnp60(args);
61 default: return handle_pnpXX(args);
69 return (u32)pnp_string + 1 - BUILD_BIOS_ADDR;
70 return (u32)&PNPHEADER - BUILD_BIOS_ADDR;
74 extern void entry_pnp_real(void);
75 extern void entry_pnp_prot(void);
83 dprintf(3, "init PNPBIOS table\n");
85 PNPHEADER.real_ip = (u32)entry_pnp_real - BUILD_BIOS_ADDR;
86 PNPHEADER.prot_ip = (u32)entry_pnp_prot - BUILD_BIOS_ADDR;
87 PNPHEADER.checksum -= checksum(&PNPHEADER, sizeof(PNPHEADER));