biospci.c revision 199767f8919635c4928607450d9e0abb932109ce
/*-
* Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
__FBSDID("$FreeBSD$");
/*
* PnP enumerator using the PCI BIOS.
*/
#include <stand.h>
#include <bootstrap.h>
#include <isapnp.h>
#include <btxv86.h>
#include "libi386.h"
/*
* Stupid PCI BIOS interface doesn't let you simply enumerate everything
* that's there, instead you have to ask it if it has something.
*
* So we have to scan by class code, subclass code and sometimes programming
* interface.
*/
struct pci_progif
{
int pi_code;
const char *pi_name;
};
static struct pci_progif progif_null[] = {
{0x0, NULL},
{-1, NULL}
};
static struct pci_progif progif_display[] = {
{0x0, "VGA"},
{0x1, "8514"},
{-1, NULL}
};
static struct pci_progif progif_ide[] = {
{0x00, NULL},
{0x01, NULL},
{0x02, NULL},
{0x03, NULL},
{0x04, NULL},
{0x05, NULL},
{0x06, NULL},
{0x07, NULL},
{0x08, NULL},
{0x09, NULL},
{0x0a, NULL},
{0x0b, NULL},
{0x0c, NULL},
{0x0d, NULL},
{0x0e, NULL},
{0x0f, NULL},
{0x80, NULL},
{0x81, NULL},
{0x82, NULL},
{0x83, NULL},
{0x84, NULL},
{0x85, NULL},
{0x86, NULL},
{0x87, NULL},
{0x88, NULL},
{0x89, NULL},
{0x8a, NULL},
{0x8b, NULL},
{0x8c, NULL},
{0x8d, NULL},
{0x8e, NULL},
{0x8f, NULL},
{-1, NULL}
};
static struct pci_progif progif_serial[] = {
{0x0, "8250"},
{0x1, "16450"},
{0x2, "16550"},
{-1, NULL}
};
static struct pci_progif progif_parallel[] = {
{0x0, "Standard"},
{0x1, "Bidirectional"},
{0x2, "ECP"},
{-1, NULL}
};
static struct pci_progif progif_firewire[] = {
{0x10, "OHCI"},
{-1, NULL}
};
struct pci_subclass
{
int ps_subclass;
const char *ps_name;
};
static struct pci_subclass subclass_old[] = {
};
static struct pci_subclass subclass_mass[] = {
};
static struct pci_subclass subclass_net[] = {
};
static struct pci_subclass subclass_display[] = {
};
static struct pci_subclass subclass_comms[] = {
};
static struct pci_subclass subclass_serial[] = {
};
static struct pci_class
{
int pc_class;
const char *pc_name;
struct pci_subclass *pc_subclass;
} pci_classes[] = {
};
static void biospci_enumerate(void);
static void biospci_addinfo(int devid, struct pci_class *pc, struct pci_subclass *psc, struct pci_progif *ppi);
struct pnphandler biospcihandler =
{
"PCI BIOS",
};
#define PCI_BIOS_PRESENT 0xb101
#define FIND_PCI_DEVICE 0xb102
#define FIND_PCI_CLASS_CODE 0xb103
#define GENERATE_SPECIAL_CYCLE 0xb106
#define READ_CONFIG_BYTE 0xb108
#define READ_CONFIG_WORD 0xb109
#define READ_CONFIG_DWORD 0xb10a
#define WRITE_CONFIG_BYTE 0xb10b
#define WRITE_CONFIG_WORD 0xb10c
#define WRITE_CONFIG_DWORD 0xb10d
#define GET_IRQ_ROUTING_OPTIONS 0xb10e
#define SET_PCI_IRQ 0xb10f
#define PCI_INT 0x1a
void
biospci_detect(void)
{
char buf[24];
/* Find the PCI BIOS */
v86int();
/* Check for OK response */
return;
#if 0
printf("PCI BIOS %d.%d%s%s maxbus %d\n",
maxbus);
#endif
}
static void
biospci_enumerate(void)
{
int device_index, err;
struct pci_subclass *psc;
struct pci_progif *ppi;
/* Iterate over known classes */
/* Iterate over subclasses */
/* Iterate over programming interfaces */
/* Scan for matches */
for (device_index = 0; ; device_index++) {
/* Look for a match */
device_index, &locator);
if (err != 0)
break;
/* Read the device identifier from the nominated device */
if (err != 0)
break;
/* We have the device ID, create a PnP object and save everything */
}
}
}
}
}
static void
{
char desc[80];
/* build the description */
desc[0] = 0;
}
}
pi = pnp_allocinfo();
}
int
{
v86int();
/* error */
return (-1);
return (0);
}
int
{
v86int();
/* error */
return (-1);
return (0);
}
/*
* Configuration space access methods.
* width = 0(byte), 1(word) or 2(dword).
*/
int
{
v86int();
/* error */
return (-1);
return(0);
}
int
{
v86int();
/* error */
return (-1);
return (0);
}
{
}
/*
* Counts the number of instances of devid we have in the system, as least as
* far as the PCI BIOS is able to tell.
*/
int
{
int i;
for (i = 0; 1; i++) {
v86int();
break;
}
return i;
}