25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * All rights reserved.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Redistribution and use in source and binary forms, with or without
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * modification, are permitted provided that the following conditions
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * 1. Redistributions of source code must retain the above copyright
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * notice, this list of conditions and the following disclaimer.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * 2. Redistributions in binary form must reproduce the above copyright
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * notice, this list of conditions and the following disclaimer in the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * documentation and/or other materials provided with the distribution.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * SUCH DAMAGE.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * PnP BIOS enumerator.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic int biospnp_init(void);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic void biospnp_enumerate(void);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic struct pnp_ICstructure *pnp_Icheck = NULL;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic void biospnp_scanresdata(struct pnpinfo *pi, struct pnp_devNode *dn);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic int biospnp_call(int func, const char *fmt, ...);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#define vsegofs(vptr) (((u_int32_t)VTOPSEG(vptr) << 16) + VTOPOFF(vptr))
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtistypedef void v86bios_t(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#define biospnp_f00(NumNodes, NodeSize) biospnp_call(0x00, "ll", NumNodes, NodeSize)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#define biospnp_f01(Node, devNodeBuffer, Control) biospnp_call(0x01, "llw", Node, devNodeBuffer, Control)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#define biospnp_f40(Configuration) biospnp_call(0x40, "l", Configuration)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/* PnP BIOS return codes */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Initialisation: locate the PnP BIOS, test that we can call it.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Returns nonzero if the PnP BIOS is not usable on this system.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* Search for the $PnP signature */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis for (sigptr = PTOV(0xf0000); sigptr < PTOV(0xfffff); sigptr += 16)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis pnp_Icheck = (struct pnp_ICstructure *)sigptr;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis /* No signature, no BIOS */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Fetch the system table parameters as a test of the BIOS
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis result = biospnp_f00(vsegofs(&pnp_NumNodes), vsegofs(&pnp_NodeSize));
switch (result) {
case PNP_SUCCESS:
if (biospnp_init())
Node = 0;
u_int8_t *p;
tag = p[i];
case COMP_DEVICE_ID:
case END_TAG:
i += sizeof(u_int16_t);
case ID_STRING_ANSI:
u_int32_t i;
for (p = fmt; *p != 0; p++) {