summaryrefslogtreecommitdiff
path: root/sys/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/powerpc')
-rw-r--r--sys/arch/powerpc/pci/macobio.c272
-rw-r--r--sys/arch/powerpc/pci/mpc106reg.h90
-rw-r--r--sys/arch/powerpc/pci/mpcpcibus.c1102
-rw-r--r--sys/arch/powerpc/pci/pchb.c118
-rw-r--r--sys/arch/powerpc/pci/pci_vga.c143
-rw-r--r--sys/arch/powerpc/pci/pcibrvar.h77
-rw-r--r--sys/arch/powerpc/pci/pciide_machdep.c76
-rw-r--r--sys/arch/powerpc/pci/vgafb.c584
-rw-r--r--sys/arch/powerpc/pci/vgafb_pci.c448
-rw-r--r--sys/arch/powerpc/pci/vgafb_pcivar.h43
-rw-r--r--sys/arch/powerpc/pci/vgafbvar.h85
11 files changed, 0 insertions, 3038 deletions
diff --git a/sys/arch/powerpc/pci/macobio.c b/sys/arch/powerpc/pci/macobio.c
deleted file mode 100644
index 56fda5f66f4..00000000000
--- a/sys/arch/powerpc/pci/macobio.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/* $OpenBSD: macobio.c,v 1.16 2001/07/09 02:56:09 mickey Exp $ */
-/* $NetBSD: obio.c,v 1.6 1999/05/01 10:36:08 tsubai Exp $ */
-
-/*-
- * Copyright (C) 1998 Internet Research Institute, Inc.
- * 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by
- * Internet Research Institute, Inc.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcidevs.h>
-
-#include <dev/ofw/openfirm.h>
-
-#include <machine/bus.h>
-#include <machine/autoconf.h>
-
-void macobio_attach __P((struct device *, struct device *, void *));
-int macobio_match __P((struct device *, void *, void *));
-int macobio_print __P((void *, const char *));
-void *undef_mac_establish __P((void * lcv, int irq, int type, int level,
- int (*ih_fun) __P((void *)), void *ih_arg, char *name));
-void mac_intr_disestab __P((void *lcp, void *arg));
-
-struct macobio_softc {
- struct device sc_dev;
- int sc_node;
- struct ppc_bus_space sc_membus_space;
-};
-struct cfdriver macobio_cd = {
- NULL, "macobio", DV_DULL,
-};
-
-
-struct cfattach macobio_ca = {
- sizeof(struct macobio_softc), macobio_match, macobio_attach
-};
-
-int
-macobio_match(parent, cf, aux)
- struct device *parent;
- void *cf;
- void *aux;
-{
- struct pci_attach_args *pa = aux;
-
- if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_APPLE)
- switch (PCI_PRODUCT(pa->pa_id)) {
-
- case PCI_PRODUCT_APPLE_GC:
- case PCI_PRODUCT_APPLE_OHARE:
- case PCI_PRODUCT_APPLE_HEATHROW:
- case PCI_PRODUCT_APPLE_PADDINGTON:
- case PCI_PRODUCT_APPLE_KEYLARGO:
- case PCI_PRODUCT_APPLE_PANGEA_MACIO:
- return 1;
- }
-
- return 0;
-}
-
-#define HEATHROW_FCR_OFFSET 0x38
-u_int32_t *heathrow_FCR = NULL;
-
-/*
- * Attach all the sub-devices we can find
- */
-void
-macobio_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct macobio_softc *sc = (struct macobio_softc *)self;
- struct pci_attach_args *pa = aux;
- struct confargs ca;
- int node, child, namelen;
- u_int32_t reg[20];
- int32_t intr[8];
- char name[32];
- int need_interrupt_controller = 0;
-
- switch (PCI_PRODUCT(pa->pa_id)) {
-
- /* XXX should not use name */
- case PCI_PRODUCT_APPLE_GC:
- node = OF_finddevice("/bandit/gc");
- need_interrupt_controller = 1;
- break;
-
- case PCI_PRODUCT_APPLE_OHARE:
- node = OF_finddevice("/bandit/ohare");
- need_interrupt_controller = 1;
- break;
-
- case PCI_PRODUCT_APPLE_HEATHROW:
- case PCI_PRODUCT_APPLE_PADDINGTON:
- node = OF_finddevice("mac-io");
- if (node == -1)
- node = OF_finddevice("/pci/mac-io");
- if (OF_getprop(node, "assigned-addresses", reg, sizeof(reg))
- == (sizeof (reg[0]) * 5))
- {
- /* always ??? */
- heathrow_FCR = mapiodev(reg[2] + HEATHROW_FCR_OFFSET,
- 4);
- }
- break;
- case PCI_PRODUCT_APPLE_KEYLARGO:
- case PCI_PRODUCT_APPLE_PANGEA_MACIO:
- node = OF_finddevice("mac-io");
- if (node == -1)
- node = OF_finddevice("/pci/mac-io");
-
- break;
- default:
- printf(": unknown macobio controller\n");
- return;
- }
- sc->sc_node = node;
-
- if (OF_getprop(node, "assigned-addresses", reg, sizeof(reg)) < 12)
- return;
-
- ca.ca_baseaddr = reg[2];
-
- sc->sc_membus_space.bus_base = ca.ca_baseaddr;
-
- sc->sc_membus_space.bus_reverse = 1;
-
- ca.ca_iot = &sc->sc_membus_space;
-
- printf("\n");
-
- /*
- * This might be a hack, but it makes the interrupt controller
- * attach as expected if a device node existed in the OF tree.
- */
- if (need_interrupt_controller) {
- /* force attachment of legacy interrupt controllers */
- ca.ca_name = "legacy-interrupt-controller";
- ca.ca_node = 0;
-
- ca.ca_nreg = 0;
- ca.ca_nintr = 0;
-
- ca.ca_reg = 0;
- ca.ca_intr = 0;
-
- config_found(self, &ca, macobio_print);
- }
-
- for (child = OF_child(node); child; child = OF_peer(child)) {
- namelen = OF_getprop(child, "name", name, sizeof(name));
- if (namelen < 0)
- continue;
- if (namelen >= sizeof(name))
- continue;
-
- name[namelen] = 0;
- ca.ca_name = name;
- ca.ca_node = child;
-
- ca.ca_nreg = OF_getprop(child, "reg", reg, sizeof(reg));
- ca.ca_nintr = OF_getprop(child, "AAPL,interrupts", intr,
- sizeof(intr));
- if (ca.ca_nintr == -1)
- ca.ca_nintr = OF_getprop(child, "interrupts", intr,
- sizeof(intr));
-
- ca.ca_reg = reg;
- ca.ca_intr = intr;
-
- config_found(self, &ca, macobio_print);
- }
-}
-
-int
-macobio_print(aux, macobio)
- void *aux;
- const char *macobio;
-{
-#ifdef MACOBIOVERBOSE
- struct confargs *ca = aux;
-
- if (macobio)
- printf("%s at %s", ca->ca_name, macobio);
-
- if (ca->ca_nreg > 0)
- printf(" offset 0x%x", ca->ca_reg[0]);
-
- return UNCONF;
-#else
- return QUIET;
-#endif
-}
-
-void *
-undef_mac_establish(lcv, irq, type, level, ih_fun, ih_arg, name)
- void * lcv;
- int irq;
- int type;
- int level;
- int (*ih_fun) __P((void *));
- void *ih_arg;
- char *name;
-{
- printf("mac_intr_establish called, not yet inited\n");
- return 0;
-}
-
-void
-mac_intr_disestab(lcp, arg)
- void *lcp;
- void *arg;
-{
- printf("mac_intr_disestablish called, not yet inited\n");
-}
-
-intr_establish_t *mac_intr_establish_func = undef_mac_establish;
-intr_disestablish_t *mac_intr_disestablish_func = mac_intr_disestab;
-
-void *
-mac_intr_establish(lcv, irq, type, level, ih_fun, ih_arg, name)
- void * lcv;
- int irq;
- int type;
- int level;
- int (*ih_fun) __P((void *));
- void *ih_arg;
- char *name;
-{
- return (*mac_intr_establish_func)(lcv, irq, type, level, ih_fun,
- ih_arg, name);
-}
-void
-mac_intr_disestablish(lcp, arg)
- void *lcp;
- void *arg;
-{
- (*mac_intr_disestablish_func)(lcp, arg);
-}
diff --git a/sys/arch/powerpc/pci/mpc106reg.h b/sys/arch/powerpc/pci/mpc106reg.h
deleted file mode 100644
index 3a488d2e659..00000000000
--- a/sys/arch/powerpc/pci/mpc106reg.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $OpenBSD: mpc106reg.h,v 1.6 2000/03/20 07:10:50 rahnds Exp $ */
-
-/*
- * Copyright (c) 1997 Per Fogelstrom
- *
- * 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed under OpenBSD for RTMX Inc
- * by Per Fogelstrom, Opsycon AB.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- *
- *
- * mpc106reg.h: PowerPC to PCI bridge controller
- * This code will probably work with the 105 as well.
- */
-
-#ifndef _MACHINE_MPC106REG_H_
-#define _MACHINE_MPC106REG_H_
-
-/* Where we map the PCI memory space - MAP A*/
-#define MPC106_V_PCI_MEM_SPACE 0xc0000000 /* Viritual */
-#define MPC106_P_PCI_MEM_SPACE 0xc0000000 /* Physical */
-
-/* Where we map the PCI I/O space - MAP A*/
-#define MPC106_P_ISA_IO_SPACE 0x80000000
-#define MPC106_V_ISA_IO_SPACE 0x80000000
-#define MPC106_V_PCI_IO_SPACE 0x80000000
-#define MPC106_P_PCI_IO_SPACE 0x80000000
-
-/* Where we map the config space */
-#define MPC106_PCI_CONF_SPACE (MPC106_V_ISA_IO_SPACE + 0x00800000)
-
-/* Where we map the PCI memory space - MAP B*/
-#define MPC106_P_PCI_MEM_SPACE_MAP_B 0x80000000 /* Physical */
-
-/* Where we map the PCI I/O space - MAP B*/
-#define MPC106_P_PCI_IO_SPACE_MAP_B 0xfe000000
-
-/* offsets from base pointer */
-#define MPC106_REGOFFS(x) ((x) | 0x80000000)
-
-/* Where PCI devices sees CPU memory. */
-#define MPC106_PCI_CPUMEM 0x80000000
-
-#define MPC106_PCI_VENDOR 0x00
-#define MPC106_PCI_DEVICE 0x02
-#define MPC106_PCI_CMD 0x04
-#define MPC106_PCI_STAT 0x06
-#define MPC106_PCI_REVID 0x08
-
-#define MPC106_PCI_PMGMT 0x70
-
-void
-mpc_cfg_write_1( struct pcibr_config *cp, u_int32_t reg, u_int8_t val);
-void
-mpc_cfg_write_2( struct pcibr_config *cp, u_int32_t reg, u_int16_t val);
-void
-mpc_cfg_write_4( struct pcibr_config *cp, u_int32_t reg, u_int32_t val);
-
-u_int8_t
-mpc_cfg_read_1( struct pcibr_config *cp, u_int32_t reg);
-
-u_int16_t
-mpc_cfg_read_2( struct pcibr_config *cp, u_int32_t reg);
-
-u_int32_t
-mpc_cfg_read_4( struct pcibr_config *cp, u_int32_t reg);
-
-#endif /* _MACHINE_MPC106REG_H_ */
diff --git a/sys/arch/powerpc/pci/mpcpcibus.c b/sys/arch/powerpc/pci/mpcpcibus.c
deleted file mode 100644
index 6cd085d9ac7..00000000000
--- a/sys/arch/powerpc/pci/mpcpcibus.c
+++ /dev/null
@@ -1,1102 +0,0 @@
-/* $OpenBSD: mpcpcibus.c,v 1.33 2001/08/17 22:26:58 mickey Exp $ */
-
-/*
- * Copyright (c) 1997 Per Fogelstrom
- *
- * 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed under OpenBSD for RTMX Inc
- * by Per Fogelstrom, Opsycon AB.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- *
- */
-
-/*
- * Generic PCI BUS Bridge driver.
- * specialized hooks for different config methods.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/device.h>
-#include <sys/proc.h>
-#include <vm/vm.h>
-
-#include <machine/autoconf.h>
-#include <machine/bat.h>
-#include <machine/powerpc.h>
-
-#if 0
-#include <dev/isa/isareg.h>
-#include <dev/isa/isavar.h>
-#endif
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcidevs.h>
-
-#include <powerpc/pci/pcibrvar.h>
-#include <powerpc/pci/mpc106reg.h>
-
-#include <dev/ofw/openfirm.h>
-extern vm_map_t phys_map;
-
-int mpcpcibrmatch __P((struct device *, void *, void *));
-void mpcpcibrattach __P((struct device *, struct device *, void *));
-
-void mpc_attach_hook __P((struct device *, struct device *,
- struct pcibus_attach_args *));
-int mpc_bus_maxdevs __P((void *, int));
-pcitag_t mpc_make_tag __P((void *, int, int, int));
-void mpc_decompose_tag __P((void *, pcitag_t, int *, int *, int *));
-pcireg_t mpc_conf_read __P((void *, pcitag_t, int));
-void mpc_conf_write __P((void *, pcitag_t, int, pcireg_t));
-
-int mpc_intr_map __P((void *, pcitag_t, int, int, pci_intr_handle_t *));
-const char *mpc_intr_string __P((void *, pci_intr_handle_t));
-int mpc_intr_line __P((void *, pci_intr_handle_t));
-void *mpc_intr_establish __P((void *, pci_intr_handle_t,
- int, int (*func)(void *), void *, char *));
-void mpc_intr_disestablish __P((void *, void *));
-int mpc_ether_hw_addr __P((struct ppc_pci_chipset *, u_int8_t *));
-u_int32_t mpc_gen_config_reg __P((void *cpv, pcitag_t tag, int offset));
-int of_ether_hw_addr __P((struct ppc_pci_chipset *, u_int8_t *));
-int find_node_intr __P((int node, u_int32_t *addr, u_int32_t *intr));
-u_int32_t pci_iack __P((void));
-
-struct cfattach mpcpcibr_ca = {
- sizeof(struct pcibr_softc), mpcpcibrmatch, mpcpcibrattach,
-};
-
-struct cfdriver mpcpcibr_cd = {
- NULL, "mpcpcibr", DV_DULL,
-};
-
-static int mpcpcibrprint __P((void *, const char *pnp));
-
-struct pcibr_config mpc_config;
-
-/*
- * config types
- * bit meanings
- * 0 - standard cf8/cfc type configurations,
- * sometimes the base addresses for these are different
- * 1 - Config Method #2 configuration - uni-north
- *
- * 2 - 64 bit config bus, data for accesses &4 is at daddr+4;
- */
-struct {
- char * compat;
- u_int32_t addr; /* offset */
- u_int32_t data; /* offset */
- int config_type;
-} config_offsets[] = {
- {"grackle", 0x00c00cf8, 0x00e00cfc, 0 },
- {"bandit", 0x00800000, 0x00c00000, 0 },
- {"uni-north", 0x00800000, 0x00c00000, 3 },
- {"legacy", 0x00000cf8, 0x00000cfc, 0 },
- {"IBM,27-82660", 0x00000cf8, 0x00000cfc, 0 },
- {NULL, 0x00000000, 0x00000000, 0 },
-};
-
-struct powerpc_bus_dma_tag pci_bus_dma_tag = {
- NULL,
- _dmamap_create,
- _dmamap_destroy,
- _dmamap_load,
- _dmamap_load_mbuf,
- _dmamap_load_uio,
- _dmamap_load_raw,
- _dmamap_unload,
- _dmamap_sync,
- _dmamem_alloc,
- _dmamem_free,
- _dmamem_map,
- _dmamem_unmap,
- _dmamem_mmap
-};
-
-/*
- * Code from "pci/if_de.c" used to calculate crc32 of ether rom data.
- */
-#define TULIP_CRC32_POLY 0xEDB88320UL
-static __inline__ unsigned
-srom_crc32(
- const unsigned char *databuf,
- size_t datalen)
-{
- u_int idx, bit, data, crc = 0xFFFFFFFFUL;
-
- for (idx = 0; idx < datalen; idx++)
- for (data = *databuf++, bit = 0; bit < 8; bit++, data >>= 1)
- crc = (crc >> 1) ^ (((crc ^ data) & 1) ? TULIP_CRC32_POLY : 0);
- return crc;
-}
-
-int
-mpcpcibrmatch(parent, match, aux)
- struct device *parent;
- void *match, *aux;
-{
- struct confargs *ca = aux;
- int found = 0;
-
- if (strcmp(ca->ca_name, mpcpcibr_cd.cd_name) != 0)
- return (found);
-
- found = 1;
-
- return found;
-}
-
-void fix_node_irq(int node, struct pcibus_attach_args *pba);
-
-int pci_map_a = 0;
-void
-mpcpcibrattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct pcibr_softc *sc = (struct pcibr_softc *)self;
- struct confargs *ca = aux;
- struct pcibr_config *lcp;
- struct pcibus_attach_args pba;
- int map, node;
- char *bridge;
- int of_node = 0;
-
- switch(system_type) {
- case OFWMACH:
- case PWRSTK:
- {
- int handle;
- int err;
- unsigned int val;
- handle = ppc_open_pci_bridge();
- /* if open fails something odd has happened,
- * we did this before during probe...
- */
- err = OF_call_method("config-l@", handle, 1, 1,
- 0x80000000, &val);
- if (err == 0) {
- switch (val) {
- /* supported ppc-pci bridges */
- case (PCI_VENDOR_MOT | ( PCI_PRODUCT_MOT_MPC105 <<16)):
- bridge = "MPC105";
- break;
- case (PCI_VENDOR_MOT | ( PCI_PRODUCT_MOT_MPC106 <<16)):
- bridge = "MPC106";
- break;
- default:
- ;
- }
-
- }
-
- /* read the PICR1 register to find what
- * address map is being used
- */
- err = OF_call_method("config-l@", handle, 1, 1,
- 0x800000a8, &val);
- if (val & 0x00010000) {
- map = 1; /* map A */
- pci_map_a = 1;
- } else {
- map = 0; /* map B */
- pci_map_a = 0;
- }
-
- ppc_close_pci_bridge(handle);
- }
- if (map == 1) {
- sc->sc_membus_space.bus_base = MPC106_P_PCI_MEM_SPACE;
- sc->sc_membus_space.bus_reverse = 1;
- sc->sc_iobus_space.bus_base = MPC106_P_PCI_IO_SPACE;
- sc->sc_iobus_space.bus_reverse = 1;
- if ( bus_space_map(&(sc->sc_iobus_space), 0, NBPG, 0,
- &lcp->ioh_cf8) != 0 )
- {
- panic("mpcpcibus: unable to map self\n");
- }
- lcp->ioh_cfc = lcp->ioh_cf8;
- } else {
- sc->sc_membus_space.bus_base =
- MPC106_P_PCI_MEM_SPACE_MAP_B;
- sc->sc_membus_space.bus_reverse = 1;
- sc->sc_iobus_space.bus_base =
- MPC106_P_PCI_IO_SPACE_MAP_B;
- sc->sc_iobus_space.bus_reverse = 1;
- if ( bus_space_map(&(sc->sc_iobus_space), 0xfec00000,
- NBPG, 0, &lcp->ioh_cf8) != 0 )
- {
- panic("mpcpcibus: unable to map self\n");
- }
- if ( bus_space_map(&(sc->sc_iobus_space), 0xfee00000,
- NBPG, 0, &lcp->ioh_cfc) != 0 )
- {
- panic("mpcpcibus: unable to map self\n");
- }
- }
-
- lcp->lc_pc.pc_conf_v = lcp;
- lcp->lc_pc.pc_attach_hook = mpc_attach_hook;
- lcp->lc_pc.pc_bus_maxdevs = mpc_bus_maxdevs;
- lcp->lc_pc.pc_make_tag = mpc_make_tag;
- lcp->lc_pc.pc_decompose_tag = mpc_decompose_tag;
- lcp->lc_pc.pc_conf_read = mpc_conf_read;
- lcp->lc_pc.pc_conf_write = mpc_conf_write;
- lcp->lc_pc.pc_ether_hw_addr = mpc_ether_hw_addr;
- lcp->lc_iot = &sc->sc_iobus_space;
- lcp->lc_memt = &sc->sc_membus_space;
-
- lcp->lc_pc.pc_intr_v = lcp;
- lcp->lc_pc.pc_intr_map = mpc_intr_map;
- lcp->lc_pc.pc_intr_string = mpc_intr_string;
- lcp->lc_pc.pc_intr_line = mpc_intr_line;
- lcp->lc_pc.pc_intr_establish = mpc_intr_establish;
- lcp->lc_pc.pc_intr_disestablish = mpc_intr_disestablish;
-
-
- printf(": %s, Revision 0x%x, ", bridge,
- mpc_cfg_read_1(lcp, MPC106_PCI_REVID));
- if (map == 1) {
- printf("Using Map A\n");
- } else {
- printf("Using Map B\n");
- }
-#if 0
- /* Reset status */
- mpc_cfg_write_2(lcp, MPC106_PCI_STAT, 0xff80);
-#endif
- break;
-
- case APPL:
- /* scan the children of the root of the openfirmware
- * tree to locate all nodes with device_type of "pci"
- */
-
- if (ca->ca_node == 0) {
- printf("invalid node on mpcpcibr config\n");
- return;
- }
- {
- char compat[32];
- u_int32_t addr_offset;
- u_int32_t data_offset;
-#if 0
- struct pci_reserve_mem null_reserve = {
- 0,
- 0,
- 0
- };
-#endif
- int i;
- int len;
- int rangelen;
-
- struct ranges_new {
- u_int32_t flags;
- u_int32_t pad1;
- u_int32_t pad2;
- u_int32_t base;
- u_int32_t pad3;
- u_int32_t size;
- };
- u_int32_t range_store[32];
- struct ranges_new *prange = (void *)&range_store;
-
- len=OF_getprop(ca->ca_node, "compatible", compat,
- sizeof (compat));
- if (len <= 0 ) {
- len=OF_getprop(ca->ca_node, "name", compat,
- sizeof (compat));
- if (len <= 0) {
- printf(" compatible and name not"
- " found\n");
- return;
- }
- compat[len] = 0;
- if (strcmp (compat, "bandit") != 0) {
- printf(" compatible not found and name"
- " %s found\n", compat);
- return;
- }
- }
- compat[len] = 0;
- if ((rangelen = OF_getprop(ca->ca_node, "ranges",
- range_store,
- sizeof (range_store))) <= 0)
- {
- printf("range lookup failed, node %x\n",
- ca->ca_node);
- }
- /* translate byte(s) into item count*/
- rangelen /= sizeof(struct ranges_new);
-
- lcp = sc->sc_pcibr = &sc->pcibr_config;
-
- {
- int found;
- unsigned int base = 0;
- unsigned int size = 0;
-
- /* mac configs */
-
- sc->sc_membus_space.bus_base = 0;
- sc->sc_membus_space.bus_reverse = 1;
- sc->sc_iobus_space.bus_base = 0;
- sc->sc_iobus_space.bus_reverse = 1;
-
- /* find io(config) base, flag == 0x01000000 */
- found = 0;
- for (i = 0; i < rangelen ; i++)
- {
- if (prange[i].flags == 0x01000000) {
- /* find last? */
- found = i;
- }
- }
- /* found the io space ranges */
- if (prange[found].flags == 0x01000000) {
- sc->sc_iobus_space.bus_base =
- prange[found].base;
- sc->sc_iobus_space.bus_size =
- prange[found].size;
- }
-
- /* the mem space ranges
- * apple openfirmware always puts full
- * addresses in config information,
- * it is not necessary to have correct bus
- * base address, but since 0 is reserved
- * and all IO and device memory will be in
- * upper 2G of address space, set to
- * 0x80000000
- * start with segment 1 not 0, 0 is config.
- */
- for (i = 0; i < rangelen ; i++)
- {
- if (prange[i].flags == 0x02000000) {
-#if 0
- printf("\nfound mem %x %x",
- prange[i].base,
- prange[i].size);
-#endif
-
- if (base != 0) {
- if ((base + size) ==
- prange[i].base)
- {
- size +=
- prange[i].size;
- } else {
- base =
- prange[i].base;
- size =
- prange[i].size;
- }
- } else {
- base = prange[i].base;
- size = prange[i].size;
- }
- }
- }
- sc->sc_membus_space.bus_base = base;
- sc->sc_membus_space.bus_size = size;
-
- }
- addr_offset = 0;
- for (i = 0; config_offsets[i].compat != NULL; i++) {
- if (strcmp(config_offsets[i].compat, compat)
- == 0)
- {
- addr_offset = config_offsets[i].addr;
- data_offset = config_offsets[i].data;
- lcp->config_type =
- config_offsets[i].config_type;
- break;
- }
- }
- if (addr_offset == 0) {
- printf("unable to find match for"
- " compatible %s\n", compat);
- return;
- }
-#ifdef PCI_DEBUG
- printf(" mem base %x sz %x io base %x sz %x\n config addr %x"
- " config data %x\n",
- sc->sc_membus_space.bus_base,
- sc->sc_membus_space.bus_size,
- sc->sc_iobus_space.bus_base,
- sc->sc_iobus_space.bus_size,
- addr_offset, data_offset);
-#endif
-
-
-
- if ( bus_space_map(&(sc->sc_iobus_space), addr_offset,
- NBPG, 0, &lcp->ioh_cf8) != 0 )
- {
- panic("mpcpcibus: unable to map self\n");
- }
- if ( bus_space_map(&(sc->sc_iobus_space), data_offset,
- NBPG, 0, &lcp->ioh_cfc) != 0 )
- {
- panic("mpcpcibus: unable to map self\n");
- }
- of_node = ca->ca_node;
-
-
- lcp->node = ca->ca_node;
- lcp->lc_pc.pc_conf_v = lcp;
- lcp->lc_pc.pc_attach_hook = mpc_attach_hook;
- lcp->lc_pc.pc_bus_maxdevs = mpc_bus_maxdevs;
- lcp->lc_pc.pc_make_tag = mpc_make_tag;
- lcp->lc_pc.pc_decompose_tag = mpc_decompose_tag;
- lcp->lc_pc.pc_conf_read = mpc_conf_read;
- lcp->lc_pc.pc_conf_write = mpc_conf_write;
- lcp->lc_pc.pc_ether_hw_addr = of_ether_hw_addr;
- lcp->lc_iot = &sc->sc_iobus_space;
- lcp->lc_memt = &sc->sc_membus_space;
-
- lcp->lc_pc.pc_intr_v = lcp;
- lcp->lc_pc.pc_intr_map = mpc_intr_map;
- lcp->lc_pc.pc_intr_string = mpc_intr_string;
- lcp->lc_pc.pc_intr_line = mpc_intr_line;
- lcp->lc_pc.pc_intr_establish = mpc_intr_establish;
- lcp->lc_pc.pc_intr_disestablish = mpc_intr_disestablish;
-
- printf(": %s, Revision 0x%x\n", compat,
- mpc_cfg_read_1(lcp, MPC106_PCI_REVID));
-
-#if 0
- pci_addr_fixup(sc, &lcp->lc_pc, 32, &null_reserve);
-#endif
- }
- break;
-
- default:
- printf("unknown system_type %d\n",system_type);
- return;
- }
-
- pba.pba_dmat = &pci_bus_dma_tag;
-
-
- pba.pba_busname = "pci";
- pba.pba_iot = &sc->sc_iobus_space;
- pba.pba_memt = &sc->sc_membus_space;
- pba.pba_pc = &lcp->lc_pc;
- pba.pba_bus = 0;
-
- /* we want to check pci irq settings */
- if (of_node != 0) {
- int nn;
-
- for (node = OF_child(of_node); node; node = nn)
- {
- {
- char name[32];
- int len;
- len = OF_getprop(node, "name", name,
- sizeof(name));
- name[len] = 0;
-#if 0
- printf("checking node %s\n", name);
-#endif
- }
- fix_node_irq(node, &pba);
-
- /* iterate section */
- if ((nn = OF_child(node)) != 0) {
- continue;
- }
- while ((nn = OF_peer(node)) == 0) {
- node = OF_parent(node);
- if (node == of_node) {
- nn = 0; /* done */
- break;
- }
- }
- }
- }
-
- config_found(self, &pba, mpcpcibrprint);
-
-}
-
-#define OFW_PCI_PHYS_HI_BUSMASK 0x00ff0000
-#define OFW_PCI_PHYS_HI_BUSSHIFT 16
-#define OFW_PCI_PHYS_HI_DEVICEMASK 0x0000f800
-#define OFW_PCI_PHYS_HI_DEVICESHIFT 11
-#define OFW_PCI_PHYS_HI_FUNCTIONMASK 0x00000700
-#define OFW_PCI_PHYS_HI_FUNCTIONSHIFT 8
-
-#define pcibus(x) \
- (((x) & OFW_PCI_PHYS_HI_BUSMASK) >> OFW_PCI_PHYS_HI_BUSSHIFT)
-#define pcidev(x) \
- (((x) & OFW_PCI_PHYS_HI_DEVICEMASK) >> OFW_PCI_PHYS_HI_DEVICESHIFT)
-#define pcifunc(x) \
- (((x) & OFW_PCI_PHYS_HI_FUNCTIONMASK) >> OFW_PCI_PHYS_HI_FUNCTIONSHIFT)
-
-/*
- * Find PCI IRQ from OF
- */
-int
-find_node_intr(node, addr, intr)
- int node;
- u_int32_t *addr, *intr;
-{
- int parent, iparent, len, mlen;
- int match, i;
- u_int32_t map[64], *mp;
- u_int32_t imask[8], maskedaddr[8];
- u_int32_t icells;
-
- len = OF_getprop(node, "AAPL,interrupts", intr, 4);
- if (len == 4)
- return 1;
-
- parent = OF_parent(node);
- len = OF_getprop(parent, "interrupt-map", map, sizeof(map));
- mlen = OF_getprop(parent, "interrupt-map-mask", imask, sizeof(imask));
-
- if ((len == -1) || (mlen == -1))
- goto nomap;
- for (i = 0; i < (mlen / 4); i++) {
- maskedaddr[i] = addr[i] & imask[i];
- }
- mp = map;
- while (len > mlen) {
- match = bcmp(maskedaddr, mp, mlen);
- mp += mlen / 4;
- len -= mlen;
- iparent = *mp++;
- if (OF_getprop(iparent, "#interrupt-cells", &icells, 4) != 4)
- return -1;
-
- if (match == 0) {
- /* multiple irqs? */
- *intr = *mp;
- return 1;
- }
- mp += icells;
- len -= icells * 4;
- }
- return -1;
-nomap:
- return -1;
-}
-
-void
-fix_node_irq(node, pba)
- int node;
- struct pcibus_attach_args *pba;
-{
- struct {
- u_int32_t phys_hi, phys_mid, phys_lo;
- u_int32_t size_hi, size_lo;
- } addr [8];
- int len;
- pcitag_t tag;
- u_int32_t irq;
- u_int32_t intr;
-
- pci_chipset_tag_t pc = pba->pba_pc;
-
- len = OF_getprop(node, "assigned-addresses", addr, sizeof(addr));
- if (len < sizeof(addr[0])) {
- return;
- }
- tag = pci_make_tag(pc, pcibus(addr[0].phys_hi),
- pcidev(addr[0].phys_hi),
- pcifunc(addr[0].phys_hi));
- /* program the interrupt line register with the value
- * found in openfirmware
- */
- if (find_node_intr(node, &addr[0].phys_hi, &irq) == -1)
- return;
-
- intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
-#if 0
- printf("changing interrupt from %d to %d\n",
- intr & PCI_INTERRUPT_LINE_MASK,
- irq & PCI_INTERRUPT_LINE_MASK);
-#endif
- intr &= ~PCI_INTERRUPT_LINE_MASK;
- intr |= irq & PCI_INTERRUPT_LINE_MASK;
- pci_conf_write(pc, tag, PCI_INTERRUPT_REG, intr);
-}
-
-static int
-mpcpcibrprint(aux, pnp)
- void *aux;
- const char *pnp;
-{
- struct pcibus_attach_args *pba = aux;
-
- if(pnp)
- printf("%s at %s", pba->pba_busname, pnp);
- printf(" bus %d", pba->pba_bus);
- return(UNCONF);
-}
-
-/*
- * Get PCI physical address from given viritual address.
- * XXX Note that cross page boundarys are *not* guarantee to work!
- */
-
-paddr_t
-vtophys(pa)
- paddr_t pa;
-{
- vaddr_t va = (vaddr_t) pa;
-
- if(va < VM_MIN_KERNEL_ADDRESS)
- pa = va;
- else
- pmap_extract(vm_map_pmap(phys_map), va, &pa);
-
- return (pa | ((pci_map_a == 1) ? MPC106_PCI_CPUMEM : 0 ));
-}
-
-void
-mpc_attach_hook(parent, self, pba)
- struct device *parent, *self;
- struct pcibus_attach_args *pba;
-{
-}
-
-int
-of_ether_hw_addr(struct ppc_pci_chipset *lcpc, u_int8_t *oaddr)
-{
- u_int8_t laddr[6];
- struct pcibr_config *lcp = lcpc->pc_conf_v;
- int of_node = lcp->node;
- int node, nn;
- for (node = OF_child(of_node); node; node = nn)
- {
- char name[32];
- int len;
- len = OF_getprop(node, "name", name,
- sizeof(name));
- name[len] = 0;
- if (sizeof (laddr) ==
- OF_getprop(node, "local-mac-address", laddr,
- sizeof laddr))
- {
- bcopy (laddr, oaddr, sizeof laddr);
- return 1;
-
- }
-
- /* iterate section */
- if ((nn = OF_child(node)) != 0) {
- continue;
- }
- while ((nn = OF_peer(node)) == 0) {
- node = OF_parent(node);
- if (node == of_node) {
- nn = 0; /* done */
- break;
- }
- }
- }
- oaddr[0] = oaddr[1] = oaddr[2] = 0xff;
- oaddr[3] = oaddr[4] = oaddr[5] = 0xff;
- return 0;
-}
-
-int
-mpc_ether_hw_addr(p, s)
- struct ppc_pci_chipset *p;
- u_int8_t *s;
-{
- printf("mpc_ether_hw_addr not supported\n");
- return(0);
-}
-
-int
-mpc_bus_maxdevs(cpv, busno)
- void *cpv;
- int busno;
-{
- return(32);
-}
-
-#define BUS_SHIFT 16
-#define DEVICE_SHIFT 11
-#define FNC_SHIFT 8
-
-pcitag_t
-mpc_make_tag(cpv, bus, dev, fnc)
- void *cpv;
- int bus, dev, fnc;
-{
- return (bus << BUS_SHIFT) | (dev << DEVICE_SHIFT) | (fnc << FNC_SHIFT);
-}
-
-void
-mpc_decompose_tag(cpv, tag, busp, devp, fncp)
- void *cpv;
- pcitag_t tag;
- int *busp, *devp, *fncp;
-{
- if (busp != NULL)
- *busp = (tag >> BUS_SHIFT) & 0xff;
- if (devp != NULL)
- *devp = (tag >> DEVICE_SHIFT) & 0x1f;
- if (fncp != NULL)
- *fncp = (tag >> FNC_SHIFT) & 0x7;
-}
-
-u_int32_t
-mpc_gen_config_reg(cpv, tag, offset)
- void *cpv;
- pcitag_t tag;
- int offset;
-{
- struct pcibr_config *cp = cpv;
- unsigned int bus, dev, fcn;
- u_int32_t reg;
- /*
- static int spin = 0;
- while (spin > 85);
- spin++;
- */
-
- mpc_decompose_tag(cpv, tag, &bus, &dev, &fcn);
-
- if (cp->config_type & 1) {
- /* Config Mechanism #2 */
- if (bus == 0) {
- if (dev < 11) {
- return 0xffffffff;
- }
- /*
- * Need to do config type 0 operation
- * 1 << (11?+dev) | fcn << 8 | reg
- * 11? is because pci spec states
- * that 11-15 is reserved.
- */
- reg = 1 << (dev) | fcn << 8 | offset;
-
- } else {
- if (dev > 15) {
- return 0xffffffff;
- }
- /*
- * config type 1
- */
- reg = tag | offset | 1;
-
- }
- } else {
- /* config mechanism #2, type 0
- * standard cf8/cfc config
- */
- reg = 0x80000000 | tag | offset;
-
- }
- return reg;
-}
-
-/* #define DEBUG_CONFIG */
-pcireg_t
-mpc_conf_read(cpv, tag, offset)
- void *cpv;
- pcitag_t tag;
- int offset;
-{
- struct pcibr_config *cp = cpv;
-
- pcireg_t data;
- u_int32_t reg;
- int s;
- int daddr = 0;
-
- if(offset & 3 || offset < 0 || offset >= 0x100) {
-#ifdef DEBUG_CONFIG
- printf ("pci_conf_read: bad reg %x\n", offset);
-#endif /* DEBUG_CONFIG */
- return(~0);
- }
-
- reg = mpc_gen_config_reg(cpv, tag, offset);
- /* if invalid tag, return -1 */
- if (reg == 0xffffffff) {
- return 0xffffffff;
- }
-
- if ((cp->config_type & 2) && (offset & 0x04)) {
- daddr += 4;
- }
-
- s = splhigh();
-
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, reg);
- bus_space_read_4(cp->lc_iot, cp->ioh_cf8, 0); /* XXX */
- data = bus_space_read_4(cp->lc_iot, cp->ioh_cfc, daddr);
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, 0); /* disable */
- bus_space_read_4(cp->lc_iot, cp->ioh_cf8, 0); /* XXX */
-
- splx(s);
-#ifdef DEBUG_CONFIG
- if (!((offset == 0) && (data == 0xffffffff))) {
- unsigned int bus, dev, fcn;
- mpc_decompose_tag(cpv, tag, &bus, &dev, &fcn);
- printf("mpc_conf_read bus %x dev %x fcn %x offset %x", bus, dev, fcn,
- offset);
- printf(" daddr %x reg %x",daddr, reg);
- printf(" data %x\n", data);
- }
-#endif
-
- return(data);
-}
-
-void
-mpc_conf_write(cpv, tag, offset, data)
- void *cpv;
- pcitag_t tag;
- int offset;
- pcireg_t data;
-{
- struct pcibr_config *cp = cpv;
- u_int32_t reg;
- int s;
- int daddr = 0;
-
- reg = mpc_gen_config_reg(cpv, tag, offset);
-
- /* if invalid tag, return ??? */
- if (reg == 0xffffffff) {
- return;
- }
- if ((cp->config_type & 2) && (offset & 0x04)) {
- daddr += 4;
- }
-#ifdef DEBUG_CONFIG
- {
- unsigned int bus, dev, fcn;
- mpc_decompose_tag(cpv, tag, &bus, &dev, &fcn);
- printf("mpc_conf_write bus %x dev %x fcn %x offset %x", bus,
- dev, fcn, offset);
- printf(" daddr %x reg %x",daddr, reg);
- printf(" data %x\n", data);
- }
-#endif
-
- s = splhigh();
-
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, reg);
- bus_space_read_4(cp->lc_iot, cp->ioh_cf8, 0); /* XXX */
- bus_space_write_4(cp->lc_iot, cp->ioh_cfc, daddr, data);
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, 0); /* disable */
- bus_space_read_4(cp->lc_iot, cp->ioh_cf8, 0); /* XXX */
-
- splx(s);
-}
-
-
-/*ARGSUSED*/
-int
-mpc_intr_map(lcv, bustag, buspin, line, ihp)
- void *lcv;
- pcitag_t bustag;
- int buspin, line;
- pci_intr_handle_t *ihp;
-{
- int error = 0;
-
- *ihp = -1;
- if (buspin == 0) {
- /* No IRQ used. */
- error = 1;
- }
- else if (buspin > 4) {
- printf("mpc_intr_map: bad interrupt pin %d\n", buspin);
- error = 1;
- }
-
- if(!error)
- *ihp = line;
- return error;
-}
-
-const char *
-mpc_intr_string(lcv, ih)
- void *lcv;
- pci_intr_handle_t ih;
-{
- static char str[16];
-
- sprintf(str, "irq %d", ih);
- return(str);
-}
-
-int
-mpc_intr_line(lcv, ih)
- void *lcv;
- pci_intr_handle_t ih;
-{
- return (ih);
-}
-
-void *
-mpc_intr_establish(lcv, ih, level, func, arg, name)
- void *lcv;
- pci_intr_handle_t ih;
- int level;
- int (*func) __P((void *));
- void *arg;
- char *name;
-{
- return (*intr_establish_func)(lcv, ih, IST_LEVEL, level, func, arg,
- name);
-#if 0
- return isabr_intr_establish(NULL, ih, IST_LEVEL, level, func, arg,
- name);
-#endif
-}
-
-void
-mpc_intr_disestablish(lcv, cookie)
- void *lcv, *cookie;
-{
- /* XXX We should probably do something clever here.... later */
-}
-
-#if 0
-void
-mpc_print_pci_stat()
-{
- u_int32_t stat;
-
- stat = mpc_cfg_read_4(cp, MPC106_PCI_CMD);
- printf("pci: status 0x%08x.\n", stat);
- stat = mpc_cfg_read_2(cp, MPC106_PCI_STAT);
- printf("pci: status 0x%04x.\n", stat);
-}
-#endif
-
-u_int32_t
-pci_iack()
-{
- /* do pci IACK cycle */
- /* this should be bus allocated. */
- volatile u_int8_t *iack = (u_int8_t *)0xbffffff0;
- u_int8_t val;
-
- val = *iack;
- return val;
-}
-
-void
-mpc_cfg_write_1(cp, reg, val)
- struct pcibr_config *cp;
- u_int32_t reg;
- u_int8_t val;
-{
- int s;
- s = splhigh();
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0,
- MPC106_REGOFFS(reg));
- bus_space_write_1(cp->lc_iot, cp->ioh_cfc, 0, val);
- splx(s);
-}
-
-void
-mpc_cfg_write_2(cp, reg, val)
- struct pcibr_config *cp;
- u_int32_t reg;
- u_int16_t val;
-{
- int s;
- s = splhigh();
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, MPC106_REGOFFS(reg));
- bus_space_write_2(cp->lc_iot, cp->ioh_cfc, 0, val);
- splx(s);
-}
-
-void
-mpc_cfg_write_4(cp, reg, val)
- struct pcibr_config *cp;
- u_int32_t reg;
- u_int32_t val;
-{
-
- int s;
- s = splhigh();
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, MPC106_REGOFFS(reg));
- bus_space_write_4(cp->lc_iot, cp->ioh_cfc, 0, val);
- splx(s);
-}
-
-u_int8_t
-mpc_cfg_read_1(cp, reg)
- struct pcibr_config *cp;
- u_int32_t reg;
-{
- u_int8_t _v_;
-
- int s;
- s = splhigh();
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, MPC106_REGOFFS(reg));
- _v_ = bus_space_read_1(cp->lc_iot, cp->ioh_cfc, 0);
- splx(s);
- return(_v_);
-}
-
-u_int16_t
-mpc_cfg_read_2(cp, reg)
- struct pcibr_config *cp;
- u_int32_t reg;
-{
- u_int16_t _v_;
-
- int s;
- s = splhigh();
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, MPC106_REGOFFS(reg));
- _v_ = bus_space_read_2(cp->lc_iot, cp->ioh_cfc, 0);
- splx(s);
- return(_v_);
-}
-
-u_int32_t
-mpc_cfg_read_4(cp, reg)
- struct pcibr_config *cp;
- u_int32_t reg;
-{
- u_int32_t _v_;
-
- int s;
- s = splhigh();
- bus_space_write_4(cp->lc_iot, cp->ioh_cf8, 0, MPC106_REGOFFS(reg));
- _v_ = bus_space_read_4(cp->lc_iot, cp->ioh_cfc, 0);
- splx(s);
- return(_v_);
-}
diff --git a/sys/arch/powerpc/pci/pchb.c b/sys/arch/powerpc/pci/pchb.c
deleted file mode 100644
index b64315ceafb..00000000000
--- a/sys/arch/powerpc/pci/pchb.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* $OpenBSD: pchb.c,v 1.5 2001/07/04 08:38:52 niklas Exp $ */
-/* $NetBSD: pchb.c,v 1.4 2000/01/25 07:19:11 tsubai Exp $ */
-
-/*-
- * Copyright (c) 1996 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe.
- *
- * 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 REGENTS 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.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-
-#include <machine/bus.h>
-
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcidevs.h>
-
-int pchbmatch __P((struct device *, void *, void *));
-void pchbattach __P((struct device *, struct device *, void *));
-
-struct cfattach pchb_ca = {
- sizeof(struct device), pchbmatch, pchbattach
-};
-
-struct cfdriver pchb_cd = {
- NULL, "pchb", DV_DULL
-};
-
-int
-pchbmatch(parent, cf, aux)
- struct device *parent;
- void *cf;
- void *aux;
-{
- struct pci_attach_args *pa = aux;
-
- /*
- * Match all known PCI host chipsets.
- */
- switch (PCI_VENDOR(pa->pa_id)) {
- case PCI_VENDOR_APPLE:
- switch (PCI_PRODUCT(pa->pa_id)) {
- case PCI_PRODUCT_APPLE_BANDIT:
- case PCI_PRODUCT_APPLE_UNINORTH:
- case PCI_PRODUCT_APPLE_UNINORTHETH:
- case PCI_PRODUCT_APPLE_UNINORTHAGP:
- case PCI_PRODUCT_APPLE_PANGEA_PCI1:
- case PCI_PRODUCT_APPLE_PANGEA_PCI2:
- case PCI_PRODUCT_APPLE_PANGEA_AGP:
- return (1);
- }
- break;
-
- case PCI_VENDOR_MOT:
- switch (PCI_PRODUCT(pa->pa_id)) {
- case PCI_PRODUCT_MOT_MPC106:
- return (1);
- }
- break;
- }
-
- return (0);
-}
-
-/*ARGSUSED*/
-void
-pchbattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
-
- printf("\n");
-
- /*
- * All we do is print out a description. Eventually, we
- * might want to add code that does something that's
- * possibly chipset-specific.
- */
-
- /*
- pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
- printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
- PCI_REVISION(pa->pa_class));
- */
-}
diff --git a/sys/arch/powerpc/pci/pci_vga.c b/sys/arch/powerpc/pci/pci_vga.c
deleted file mode 100644
index c3fa7ff9c58..00000000000
--- a/sys/arch/powerpc/pci/pci_vga.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* $OpenBSD: pci_vga.c,v 1.1 1997/10/11 11:29:31 pefo Exp $ */
-
-/*
- * Copyright (c) 1997 Per Fogelstrom
- *
- * 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed under OpenBSD by
- * Per Fogelstrom.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- *
- */
-#include <sys/param.h>
-#include <sys/fcntl.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/user.h>
-#include <sys/ioctl.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-
-#include <machine/bus.h>
-
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcidevs.h>
-
-struct pcivga_softc {
- struct device sc_dev;
- void *sc_ih;
- pci_chipset_tag_t sc_pc;
- bus_space_tag_t sc_memt;
- bus_space_handle_t sc_iomem;
- bus_space_handle_t sc_vmem;
-};
-
-int pcivga_probe __P((struct device *, void *, void *));
-void pcivga_attach __P((struct device *, struct device *, void *));
-
-struct cfattach pcivga_ca = {
- sizeof(struct pcivga_softc), pcivga_probe, pcivga_attach
-};
-
-struct cfdriver pcivga_cd = {
- NULL, "pcivga", DV_DULL
-};
-
-/*
- * PCI probe
- */
-int
-pcivga_probe(parent, cf, aux)
- struct device *parent;
- void *cf;
- void *aux;
-{
- struct pci_attach_args *pa = aux;
-
- if(PCI_CLASS(pa->pa_class) != PCI_CLASS_DISPLAY ||
- PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_DISPLAY_VGA) {
- return(0);
- }
- return(1);
-}
-
-
-void
-pcivga_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct pci_attach_args *pa = aux;
- struct pcivga_softc *sc = (void *)self;
- bus_size_t msize;
- bus_addr_t maddr;
- int cacheable;
- int class;
-
- sc->sc_memt = pa->pa_memt;
- sc->sc_pc = pa->pa_pc;
-
- printf(": Generic VGA controller\n");
-
- /* Map Control register aperture (0x10) */
- if(pci_mem_find(pa->pa_pc, pa->pa_tag, 0x10,
- &maddr, &msize, &cacheable) != 0) {
- printf("%s: can't find PCI card memory", self->dv_xname);
- return;
- }
- if(bus_space_map(sc->sc_memt, maddr, msize, 0, &sc->sc_iomem) != 0) {
- printf("%s: couldn't map ioreg region\n", self->dv_xname);
- return;
- }
-
-#if 0
- /* Map Video memory aperture (0x14) */
- if(pci_mem_find(pa->pa_pc, pa->pa_tag, 0x14,
- &maddr, &msize, &cacheable) != 0) {
- printf("%s: can't find PCI card memory", self->dv_xname);
- return;
- }
- if(bus_space_map(sc->sc_memt, maddr, msize, 0, &sc->sc_vmem) != 0) {
- printf("%s: couldn't map video region\n", self->dv_xname);
- return;
- }
-#endif
-
-printf("IO=%x\n", sc->sc_iomem);
-class = pci_conf_read (pa->pa_pc, pa->pa_tag, 0x40);
-pci_conf_write(pa->pa_pc, pa->pa_tag, 0x40, class & ~0x40000100);
-class = pci_conf_read (pa->pa_pc, pa->pa_tag, 0x40);
-printf("Opt=%x\n", class);
-class = pci_conf_read (pa->pa_pc, pa->pa_tag, 0x4);
-printf("Devctl=%x\n", class);
-class = pci_conf_read (pa->pa_pc, pa->pa_tag, 0x30);
-printf("Rombase=%x\n", class);
-
-mdbpanic();
-
-}
diff --git a/sys/arch/powerpc/pci/pcibrvar.h b/sys/arch/powerpc/pci/pcibrvar.h
deleted file mode 100644
index b148b3929d3..00000000000
--- a/sys/arch/powerpc/pci/pcibrvar.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $OpenBSD: pcibrvar.h,v 1.8 2001/06/25 23:30:00 drahn Exp $ */
-
-/*
- * Copyright (c) 1997 Per Fogelstrom
- *
- * 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed under OpenBSD by
- * Per Fogelstrom.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- *
- */
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcidevs.h>
-
-struct pcibr_config {
- bus_space_tag_t lc_memt;
- bus_space_tag_t lc_iot;
- bus_space_handle_t ioh_cf8;
- bus_space_handle_t ioh_cfc;
- struct ppc_pci_chipset lc_pc;
- int config_type;
- int bus;
- int pci_init_done;
- int node;
-};
-
-struct pcibr_softc {
- struct device sc_dev;
- struct pcibr_config *sc_pcibr;
- struct ppc_bus_space sc_membus_space;
- struct ppc_bus_space sc_iobus_space;
- struct powerpc_bus_dma_tag sc_dmatag;
- struct pcibr_config pcibr_config;
- struct extent *extent_mem;
- struct extent *extent_port;
- u_int32_t mem_alloc_start;
- u_int32_t port_alloc_start;
- int nbogus;
-};
-
-struct pci_reserve_mem {
- bus_addr_t start;
- bus_size_t size;
- char *name;
-};
-
-void pci_addr_fixup __P((struct pcibr_softc *, pci_chipset_tag_t, int,
- struct pci_reserve_mem *));
-
-#define PCIADDR_SEARCH_IO 0
-#define PCIADDR_SEARCH_MEM 1
-struct extent *pciaddr_search __P((struct device *, int, bus_addr_t *, bus_size_t));
-
diff --git a/sys/arch/powerpc/pci/pciide_machdep.c b/sys/arch/powerpc/pci/pciide_machdep.c
deleted file mode 100644
index f82b6ee9888..00000000000
--- a/sys/arch/powerpc/pci/pciide_machdep.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* $OpenBSD: pciide_machdep.c,v 1.1 2001/06/26 21:26:45 drahn Exp $ */
-/* $NetBSD: pciide_machdep.c,v 1.2 1999/02/19 18:01:27 mycroft Exp $ */
-
-/*
- * Copyright (c) 1998 Christopher G. Demetriou. 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
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christopher G. Demetriou
- * for the NetBSD Project.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-/*
- * PCI IDE controller driver (i386 machine-dependent portion).
- *
- * Author: Christopher G. Demetriou, March 2, 1998 (derived from NetBSD
- * sys/dev/pci/ppb.c, revision 1.16).
- *
- * See "PCI IDE Controller Specification, Revision 1.0 3/4/94" from the
- * PCI SIG.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pciidereg.h>
-#include <dev/pci/pciidevar.h>
-
-#include <powerpc/autoconf.h>
-
-void *
-pciide_machdep_compat_intr_establish(dev, pa, chan, func, arg)
- struct device *dev;
- struct pci_attach_args *pa;
- int chan;
- int (*func) __P((void *));
- void *arg;
-{
- int irq;
- void *cookie;
-
- irq = PCIIDE_COMPAT_IRQ(chan);
- cookie = mac_intr_establish(NULL, irq, IPL_BIO, IST_EDGE, func, arg, dev->dv_xname);
-
- return (cookie);
-}
-
-void
-pciide_machdep_compat_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
-{
- mac_intr_disestablish(NULL, cookie);
-}
diff --git a/sys/arch/powerpc/pci/vgafb.c b/sys/arch/powerpc/pci/vgafb.c
deleted file mode 100644
index b6ed51b5627..00000000000
--- a/sys/arch/powerpc/pci/vgafb.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/* $OpenBSD: vgafb.c,v 1.14 2001/07/09 03:54:40 mickey Exp $ */
-/* $NetBSD: vga.c,v 1.3 1996/12/02 22:24:54 cgd Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-#include <sys/buf.h>
-
-#include <vm/vm.h>
-#include <uvm/uvm_extern.h>
-
-#include <machine/bus.h>
-
-#include <dev/cons.h>
-#include <dev/ofw/openfirm.h>
-
-#include <dev/wscons/wsconsio.h>
-#include <dev/wscons/wsdisplayvar.h>
-#include <dev/wscons/wscons_raster.h>
-#include <dev/rcons/raster.h>
-
-#include <arch/powerpc/pci/vgafbvar.h>
-
-/* parameters set by OF to detect console */
-extern int cons_displaytype;
-extern bus_space_tag_t cons_membus;
-extern bus_space_handle_t cons_display_mem_h;
-extern bus_space_handle_t cons_display_ctl_h;
-extern int cons_width;
-extern int cons_linebytes;
-extern int cons_height;
-extern int cons_depth;
-extern int cons_display_ofh;
-
-struct cfdriver vgafb_cd = {
- NULL, "vgafb", DV_DULL,
-};
-
-void vgafb_cursor __P((void *, int, int, int));
-void vgafb_putchar __P((void *, int, int, u_int, long));
-void vgafb_copycols __P((void *, int, int, int, int));
-void vgafb_erasecols __P((void *, int, int, int));
-void vgafb_copyrows __P((void *, int, int, int));
-void vgafb_eraserows __P((void *, int, int));
-void vgafb_alloc_attr __P((void *c, int fg, int bg, int flags, long *));
-
-void vgafb_setcolor __P((unsigned int index, u_int8_t r, u_int8_t g, u_int8_t b));
-extern const char fontdata_8x16[];
-
-struct vgafb_devconfig {
- struct rcons dc_ri;
-};
-struct raster vgafb_raster;
-
-
-struct vgafb_devconfig vgafb_console_dc;
-
-struct wsscreen_descr vgafb_stdscreen = {
- "std",
- 0, 0, /* will be filled in -- XXX shouldn't, it's global */
- 0,
- 0, 0,
- WSSCREEN_REVERSE
-};
-const struct wsscreen_descr *vgafb_scrlist[] = {
- &vgafb_stdscreen,
- /* XXX other formats, graphics screen? */
-};
-
-struct wsscreen_list vgafb_screenlist = {
- sizeof(vgafb_scrlist) / sizeof(struct wsscreen_descr *), vgafb_scrlist
-};
-
-
-struct wsdisplay_emulops vgafb_emulops = {
- rcons_cursor,
- rcons_mapchar,
- rcons_putchar,
- rcons_copycols,
- rcons_erasecols,
- rcons_copyrows,
- rcons_eraserows,
- rcons_alloc_attr
-};
-
-struct wsdisplay_accessops vgafb_accessops = {
- vgafb_ioctl,
- vgafb_mmap,
- vgafb_alloc_screen,
- vgafb_free_screen,
- vgafb_show_screen,
- 0 /* load_font */
-};
-
-int vgafb_print __P((void *, const char *));
-int vgafb_getcmap __P((struct vgafb_config *vc, struct wsdisplay_cmap *cm));
-int vgafb_putcmap __P((struct vgafb_config *vc, struct wsdisplay_cmap *cm));
-
-#define FONT_WIDTH 8
-#define FONT_HEIGHT 16
-
-/*
- * The following functions implement back-end configuration grabbing
- * and attachment.
- */
-int
-vgafb_common_probe(iot, memt, iobase, iosize, membase, memsize, mmiobase, mmiosize)
- bus_space_tag_t iot, memt;
- u_int32_t iobase, membase, mmiobase;
- size_t iosize, memsize, mmiosize;
-{
- bus_space_handle_t ioh_b, ioh_c, ioh_d, memh, mmioh;
- int gotio_b, gotio_c, gotio_d, gotmem, gotmmio, rv;
-
- gotio_b = gotio_c = gotio_d = gotmem = gotmmio = rv = 0;
-
- if (iosize != 0) {
- if (bus_space_map(iot, iobase+0x3b0, 0xc, 0, &ioh_b))
- goto bad;
- gotio_b = 1;
- if (bus_space_map(iot, iobase+0x3c0, 0x10, 0, &ioh_c))
- goto bad;
- gotio_c = 1;
- if (bus_space_map(iot, iobase+0x3d0, 0x10, 0, &ioh_d))
- goto bad;
- gotio_d = 1;
- }
- if (mmiosize != 0) {
- printf("vgafb_common_probe, mmio base %x size %x\n",
- mmiobase, mmiosize);
- if (bus_space_map(iot, mmiobase, mmiosize, 0, &mmioh))
- goto bad;
- printf("vgafb_common_probe, mmio done\n");
- gotmmio = 1;
- }
-#if 0
- printf("vgafb_common_probe, mem base %x size %x memt %x\n",
- membase, memsize, memt);
-#endif
-
- if (bus_space_map(memt, membase, memsize, 0, &memh))
- goto bad;
- gotmem = 1;
-
-#if 0
- /* CR1 - Horiz. Display End */
- bus_space_write_1(iot, ioh_d, 4, 0x1);
- width = bus_space_read_1(iot, ioh_d, 5);
- /* this is not bit width yet */
-
- /* use CR17 - mode control for this?? */
- if ((width != 0xff) && (width < 600)) {
- /* not accessable or in graphics mode? */
- goto bad;
- }
-#endif
-
- #if 0
- vgadata = bus_space_read_2(memt, memh, 0);
- bus_space_write_2(memt, memh, 0, 0xa55a);
- rv = (bus_space_read_2(memt, memh, 0) == 0xa55a);
- bus_space_write_2(memt, memh, 0, vgadata);
- #else
- rv = 1;
- #endif
-
-
-bad:
- if (gotio_b)
- bus_space_unmap(iot, ioh_b, 0xc);
- if (gotio_c)
- bus_space_unmap(iot, ioh_c, 0x10);
- if (gotio_d)
- bus_space_unmap(iot, ioh_d, 0x10);
- if (gotmmio)
- bus_space_unmap(memt, mmioh, mmiosize);
- if (gotmem)
- bus_space_unmap(memt, memh, memsize);
-
- return (rv);
-}
-
-void
-vgafb_common_setup(iot, memt, vc, iobase, iosize, membase, memsize, mmiobase, mmiosize)
- bus_space_tag_t iot, memt;
- struct vgafb_config *vc;
- u_int32_t iobase, membase, mmiobase;
- size_t iosize, memsize, mmiosize;
-{
-
- vc->vc_iot = iot;
- vc->vc_memt = memt;
- vc->vc_paddr = membase;
-
- if (iosize != 0) {
- if (bus_space_map(vc->vc_iot, iobase+0x3b0, 0xc, 0, &vc->vc_ioh_b))
- panic("vgafb_common_setup: couldn't map io b");
- if (bus_space_map(vc->vc_iot, iobase+0x3c0, 0x10, 0, &vc->vc_ioh_c))
- panic("vgafb_common_setup: couldn't map io c");
- if (bus_space_map(vc->vc_iot, iobase+0x3d0, 0x10, 0, &vc->vc_ioh_d))
- panic("vgafb_common_setup: couldn't map io d");
- }
- if (mmiosize != 0) {
- if (bus_space_map(vc->vc_memt, mmiobase, mmiosize, 0, &vc->vc_mmioh))
- panic("vgafb_common_setup: couldn't map mmio");
- }
-#if 0
- printf("commons setup mapping mem base %x size %x\n", membase, memsize);
-#endif
- if (bus_space_map(vc->vc_memt, membase, memsize, 0, &vc->vc_memh))
- panic("vgafb_common_setup: couldn't map memory");
- cons_display_mem_h = vc->vc_memh;
- vc->vc_ofh = cons_display_ofh;
-#if 0
- printf("display_mem_h %x\n", cons_display_mem_h );
-#endif
-
-#if 0
- if (iosize != 0) {
- /* CR1 - Horiz. Display End */
- bus_space_write_1(iot, vc->vc_ioh_d, 4, 0x1);
- width = bus_space_read_1(iot, vc->vc_ioh_d, 5);
- /* (stored value + 1) * depth -> pixel width */
- width = ( width + 1 ) * 8;
-
- /* CR1 - Horiz. Display End */
- bus_space_write_1(iot, vc->vc_ioh_d, 4, 0x12);
- {
- u_int8_t t1, t2, t3;
- bus_space_write_1(iot, vc->vc_ioh_d, 4, 0x12);
- t1 = bus_space_read_1(iot, vc->vc_ioh_d, 5);
-
- bus_space_write_1(iot, vc->vc_ioh_d, 4, 0x7);
- t2 = bus_space_read_1(iot, vc->vc_ioh_d, 5);
- height = t1 + ((t2&0x40) << 3)
- + ((t2&0x02) << 7) + 1;
- bus_space_write_1(iot, vc->vc_ioh_d, 4, 0x17);
- t3 = bus_space_read_1(iot, vc->vc_ioh_d, 5);
- if (t3 & 0x04) {
- height *= 2;
- }
- if (t1 == 0xff && t2 == 0xff && t3 == 0xff) {
- /* iospace not working??? */
- /* hope, better guess than 2048x2048 */
- width = 640;
- height = 480;
- }
- }
- vc->vc_ncol = width / FONT_WIDTH;
- vc->vc_nrow = height / FONT_HEIGHT;
- } else {
- /* iosize == 0
- * default to 640x480 and hope
- */
- vc->vc_ncol = 640 / FONT_WIDTH;
- vc->vc_nrow = 480 / FONT_HEIGHT;
- }
- vc->vc_ncol = cons_width / FONT_WIDTH;
- vc->vc_nrow = cons_height / FONT_HEIGHT;
- printf(", %dx%d", vc->vc_ncol, vc->vc_nrow);
-#endif
-
- vc->vc_crow = vc->vc_ccol = 0; /* Has to be some onscreen value */
- vc->vc_so = 0;
-
- /* clear screen, frob cursor, etc.? */
- /*
- */
-
-#if defined(alpha)
- /*
- * XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!!
- * XXX Therefore, though the comments say "blue bg", the code uses
- * XXX the value for a red background!
- */
- vc->vc_at = 0x40 | 0x0f; /* blue bg|white fg */
- vc->vc_so_at = 0x40 | 0x0f | 0x80; /* blue bg|white fg|blink */
-#else
- vc->vc_at = 0x00 | 0xf; /* black bg|white fg */
- vc->vc_so_at = 0x00 | 0xf | 0x80; /* black bg|white fg|blink */
-#endif
-}
-
-void
-vgafb_wsdisplay_attach(parent, vc, console)
- struct device *parent;
- struct vgafb_config *vc;
- int console;
-{
- struct wsemuldisplaydev_attach_args aa;
-
- aa.console = console;
- aa.scrdata = &vgafb_screenlist;
- aa.accessops = &vgafb_accessops;
- aa.accesscookie = vc;
-
- config_found(parent, &aa, wsemuldisplaydevprint);
-}
-
-
-int
-vgafb_print(aux, pnp)
- void *aux;
- const char *pnp;
-{
-
- if (pnp)
- printf("wsdisplay at %s", pnp);
- return (UNCONF);
-}
-
-int
-vgafb_ioctl(v, cmd, data, flag, p)
- void *v;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct vgafb_config *vc = v;
- struct wsdisplay_fbinfo *wdf;
-
- switch (cmd) {
- case WSDISPLAYIO_GTYPE:
- *(u_int *)data = WSDISPLAY_TYPE_PCIVGA;
- return 0;
- case WSDISPLAYIO_GINFO:
- wdf = (void *)data;
- wdf->height = cons_height;
- wdf->width = cons_width;
- wdf->depth = cons_depth;
- wdf->cmsize = 256;
- return 0;
-
- case WSDISPLAYIO_LINEBYTES:
- *(u_int *)data = cons_linebytes;
- return 0;
-
- case WSDISPLAYIO_GETCMAP:
- return vgafb_getcmap(vc, (struct wsdisplay_cmap *)data);
-
- case WSDISPLAYIO_PUTCMAP:
- return vgafb_putcmap(vc, (struct wsdisplay_cmap *)data);
-
- case WSDISPLAYIO_SVIDEO:
- case WSDISPLAYIO_GVIDEO:
- case WSDISPLAYIO_GCURPOS:
- case WSDISPLAYIO_SCURPOS:
- case WSDISPLAYIO_GCURMAX:
- case WSDISPLAYIO_GCURSOR:
- case WSDISPLAYIO_SCURSOR:
- return -1; /* not supported yet */
- }
-
- /* XXX */
- return -1;
-}
-
-paddr_t
-vgafb_mmap(v, offset, prot)
- void *v;
- off_t offset;
- int prot;
-{
- struct vgafb_config *vc = v;
- bus_space_handle_t h;
-
- /* memsize... */
- if (offset >= 0x00000 && offset < 0x800000) /* 8MB of mem??? */
- h = vc->vc_paddr + offset;
- /* XXX the following are probably wrong. we want physical addresses
- here, not virtual ones */
- else if (offset >= 0x10000000 && offset < 0x10040000 )
- /* 256KB of iohb */
- h = vc->vc_ioh_b;
- else if (offset >= 0x10040000 && offset < 0x10080000)
- /* 256KB of iohc */
- h = vc->vc_ioh_c;
- else if (offset >= 0x18880000 && offset < 0x100c0000)
- /* 256KB of iohd */
- h = vc->vc_ioh_d;
- else if (offset >= 0x20000000 && offset < 0x30000000)
- /* mmiosize... */
- h = vc->vc_mmioh + (offset - 0x20000000);
- else {
- /* XXX - allow mapping of the actual physical
- * device address, if the address is read from
- * pci bus config space
- */
-
- /* NEEDS TO BE RESTRICTED to valid addresses for this device */
-
- h = offset;
- }
-
-#ifdef alpha
- port = (u_int32_t *)(h << 5);
- return alpha_btop(port); /* XXX */
-#elif defined(i386)
- port = (u_int32_t *)(h << 5);
- return i386_btop(port);
-#elif defined(__powerpc__)
- {
- /* huh ??? */
- return h;
- /*
- return powerpc_btop(port);
- */
- }
-#endif
-}
-
-
-void
-vgafb_cnprobe(cp)
- struct consdev *cp;
-{
- if (cons_displaytype != 1) {
- cp->cn_pri = CN_DEAD;
- return;
- }
-
- cp->cn_pri = CN_REMOTE;
- #if 0
- for (j = 0; j < 2; j++) {
- for (i = 0; i < cons_width * cons_height; i++) {
- bus_space_write_1(cons_membus,
- cons_display_mem_h, i, j);
-
- }
- }
- #endif
-
-}
-
-extern struct raster_font fontdata8x16;
-void
-vgafb_cnattach(iot, memt, pc, bus, device, function)
- void * pc;
- bus_space_tag_t iot, memt;
- int bus, device, function;
-{
- long defattr;
-
- struct vgafb_devconfig *dc = &vgafb_console_dc;
- struct rcons *ri = &dc->dc_ri;
- ri->rc_sp = &vgafb_raster;
-
- ri->rc_sp->width = cons_width;
- ri->rc_sp->height = cons_height;
- ri->rc_sp->depth = cons_depth;
- ri->rc_sp->linelongs = cons_linebytes /4; /* XXX */
- ri->rc_sp->pixels = (void *)cons_display_mem_h;
- ri->rc_crow = ri->rc_ccol = -1;
- ri->rc_crowp = &ri->rc_crow;
- ri->rc_ccolp = &ri->rc_ccol;
-
- rcons_init(ri, 160, 160);
-
- vgafb_stdscreen.nrows = ri->rc_maxrow;
- vgafb_stdscreen.ncols = ri->rc_maxcol;
- vgafb_stdscreen.textops = &vgafb_emulops;
- rcons_alloc_attr(ri, 0, 0, 0, &defattr);
-
- #if 0
- {
- int i;
- for (i = 0; i < cons_width * cons_height; i++) {
- bus_space_write_1(cons_membus,
- cons_display_mem_h, i, 0x1);
-
- }
- }
- #endif
- {
- int i;
- for (i = 0; i < 256; i++) {
- vgafb_setcolor(i, 255,255,255);
- }
- }
- vgafb_setcolor(WSCOL_BLACK, 0, 0, 0);
- vgafb_setcolor(255, 255, 255, 255);
- vgafb_setcolor(WSCOL_RED, 255, 0, 0);
- vgafb_setcolor(WSCOL_GREEN, 0, 255, 0);
- vgafb_setcolor(WSCOL_BROWN, 154, 85, 46);
- vgafb_setcolor(WSCOL_BLUE, 0, 0, 255);
- vgafb_setcolor(WSCOL_MAGENTA, 255, 255, 0);
- vgafb_setcolor(WSCOL_CYAN, 0, 255, 255);
- vgafb_setcolor(WSCOL_WHITE, 255, 255, 255);
- wsdisplay_cnattach(&vgafb_stdscreen, ri, 0, 0, defattr);
-}
-
-void
-vgafb_setcolor(index, r, g, b)
- unsigned int index;
- u_int8_t r, g, b;
-{
- OF_call_method_1("color!", cons_display_ofh, 4, r, g, b, index);
-}
-
-int
-vgafb_getcmap(vc, cm)
- struct vgafb_config *vc;
- struct wsdisplay_cmap *cm;
-{
- u_int index = cm->index;
- u_int count = cm->count;
- int error;
-
- if (index >= 256 || count > 256 || index + count > 256)
- return EINVAL;
-
- error = copyout(&vc->vc_cmap_red[index], cm->red, count);
- if (error)
- return error;
- error = copyout(&vc->vc_cmap_green[index], cm->green, count);
- if (error)
- return error;
- error = copyout(&vc->vc_cmap_blue[index], cm->blue, count);
- if (error)
- return error;
-
- return 0;
-}
-
-int
-vgafb_putcmap(vc, cm)
- struct vgafb_config *vc;
- struct wsdisplay_cmap *cm;
-{
- int index = cm->index;
- int count = cm->count;
- int i;
- u_char *r, *g, *b;
-
- if (cm->index >= 256 || cm->count > 256 ||
- (cm->index + cm->count) > 256)
- return EINVAL;
- if (!uvm_useracc(cm->red, cm->count, B_READ) ||
- !uvm_useracc(cm->green, cm->count, B_READ) ||
- !uvm_useracc(cm->blue, cm->count, B_READ))
- return EFAULT;
- copyin(cm->red, &(vc->vc_cmap_red[index]), count);
- copyin(cm->green, &(vc->vc_cmap_green[index]), count);
- copyin(cm->blue, &(vc->vc_cmap_blue[index]), count);
-
- r = &(vc->vc_cmap_red[index]);
- g = &(vc->vc_cmap_green[index]);
- b = &(vc->vc_cmap_blue[index]);
-
- for (i = 0; i < count; i++) {
- OF_call_method_1("color!", vc->vc_ofh, 4, *r, *g, *b, index);
- r++, g++, b++, index++;
- }
- return 0;
-}
diff --git a/sys/arch/powerpc/pci/vgafb_pci.c b/sys/arch/powerpc/pci/vgafb_pci.c
deleted file mode 100644
index 6bb4eab89ec..00000000000
--- a/sys/arch/powerpc/pci/vgafb_pci.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/* $OpenBSD: vgafb_pci.c,v 1.5 2001/07/09 03:54:40 mickey Exp $ */
-/* $NetBSD: vga_pci.c,v 1.4 1996/12/05 01:39:38 cgd Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-
-#ifndef i386
-#include <machine/autoconf.h>
-#endif
-#include <machine/pte.h>
-
-#include <dev/cons.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcidevs.h>
-
-#include <dev/rcons/raster.h>
-#include <dev/wscons/wsconsio.h>
-#include <dev/wscons/wsdisplayvar.h>
-#include <dev/wscons/wscons_raster.h>
-
-#include <arch/powerpc/pci/vgafbvar.h>
-#include <arch/powerpc/pci/vgafb_pcivar.h>
-
-#define PCI_VENDORID(x) ((x) & 0xFFFF)
-#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
-
-struct vgafb_pci_softc {
- struct device sc_dev;
-
- pcitag_t sc_pcitag; /* PCI tag, in case we need it. */
- struct vgafb_config *sc_vc; /* VGA configuration */
- int nscreens;
-};
-
-int vgafb_pci_probe __P((struct pci_attach_args *pa, int id, u_int32_t *ioaddr,
- u_int32_t *iosize, u_int32_t *memaddr, u_int32_t *memsize,
- u_int32_t *cacheable, u_int32_t *mmioaddr, u_int32_t *mmiosize));
-#ifdef __BROKEN_INDIRECT_CONFIG
-int vgafb_pci_match __P((struct device *, void *, void *));
-#else
-int vgafb_pci_match __P((struct device *, struct cfdata *, void *));
-#endif
-void vgafb_pci_attach __P((struct device *, struct device *, void *));
-
-int vgafbpcimmap __P((void *, off_t, int));
-int vgafbpciioctl __P((void *, u_long, caddr_t, int, struct proc *));
-
-struct cfattach vgafb_pci_ca = {
- sizeof(struct vgafb_pci_softc), (cfmatch_t)vgafb_pci_match, vgafb_pci_attach,
-};
-
-pcitag_t vgafb_pci_console_tag;
-struct vgafb_config vgafb_pci_console_vc;
-
-#if 0
-#define DEBUG_VGAFB
-#endif
-
-int
-vgafb_pci_probe(pa, id, ioaddr, iosize, memaddr, memsize, cacheable, mmioaddr, mmiosize)
- struct pci_attach_args *pa;
- int id;
- u_int32_t *ioaddr, *iosize;
- u_int32_t *memaddr, *memsize, *cacheable;
- u_int32_t *mmioaddr, *mmiosize;
-{
- u_long addr;
- u_int32_t size, tcacheable;
- pci_chipset_tag_t pc = pa->pa_pc;
- int retval;
- int i;
-
- *iosize = 0x0;
- *memsize = 0x0;
- *mmiosize = 0x0;
- for (i = 0x10; i < 0x18; i += 4) {
-#ifdef DEBUG_VGAFB
- printf("vgafb confread %x %x\n",
- i, pci_conf_read(pc, pa->pa_tag, i));
-#endif
- /* need to check more than just two base addresses? */
- if (0x1 & pci_conf_read(pc, pa->pa_tag, i) ) {
- retval = pci_io_find(pc, pa->pa_tag, i,
- &addr, &size);
- if (retval) {
- printf("vgafb_pci_probe: io %x addr %x size %x\n", i, addr, size);
- return 0;
- }
- if (*iosize == 0) {
- *ioaddr = addr;
- *iosize = size;
- }
-
- } else {
- retval = pci_mem_find(pc, pa->pa_tag, i,
- &addr, &size, &tcacheable);
-#ifdef DEBUG_VGAFB
- printf("vgafb_pci_probe: mem %x addr %x size %x\n", i, addr, size);
-#endif
-
- if (retval) {
- printf("vgafb_pci_probe: mem %x addr %x size %x\n", i, addr, size);
- return 0;
- }
- if (size == 0) {
- /* ignore this entry */
- }else if (size <= (64 * 1024)) {
-#ifdef DEBUG_VGAFB
- printf("vgafb_pci_probe: mem %x addr %x size %x iosize %x\n",
- i, addr, size, *iosize);
-#endif
- if (*mmiosize == 0) {
- /* this is mmio, not memory */
- *mmioaddr = addr;
- *mmiosize = size;
- /* need skew in here for io memspace */
- }
- } else {
- if (*memsize == 0) {
- *memaddr = addr;
- *memsize = size;
- *cacheable = tcacheable;
- }
- }
- }
- }
-#ifdef DEBUG_VGAFB
- printf("vgafb_pci_probe: id %x ioaddr %x, iosize %x, memaddr %x,\n memsize %x, mmioaddr %x, mmiosize %x\n",
- id, *ioaddr, *iosize, *memaddr, *memsize, *mmioaddr, *mmiosize);
-#endif
- if (*iosize == 0) {
- if (id == 0) {
-#ifdef powerpc
- /* this is only used if on openfirmware system and
- * the device does not have a iobase config register,
- * eg CirrusLogic 5434 VGA. (they hardcode iobase to 0
- * thus giving standard PC addresses for the registers)
- */
- int s;
- u_int32_t sizedata;
-
- /*
- * Open Firmware (yuck) shuts down devices before
- * entering a program so we need to bring them back
- * 'online' to respond to bus accesses... so far
- * this is true on the power.4e.
- */
- s = splhigh();
- sizedata = pci_conf_read(pc, pa->pa_tag,
- PCI_COMMAND_STATUS_REG);
- sizedata |= (PCI_COMMAND_MASTER_ENABLE |
- PCI_COMMAND_IO_ENABLE |
- PCI_COMMAND_PARITY_ENABLE |
- PCI_COMMAND_SERR_ENABLE);
- pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
- sizedata);
- splx(s);
-
-#endif
- /* if this is the first card, allow it
- * to be accessed in vga iospace
- */
- *ioaddr = 0;
- *iosize = 0x10000; /* 64k, good as any */
- } else {
- /* iospace not available, assume 640x480, pray */
- *ioaddr = 0;
- *iosize=0;
- }
- }
-#ifdef DEBUG_VGAFB
- printf("vgafb_pci_probe: id %x ioaddr %x, iosize %x, memaddr %x,\n memsize %x, mmioaddr %x, mmiosize %x\n",
- id, *ioaddr, *iosize, *memaddr, *memsize, *mmioaddr, *mmiosize);
-#endif
- return 1;
-}
-int
-vgafb_pci_match(parent, match, aux)
- struct device *parent;
-#ifdef __BROKEN_INDIRECT_CONFIG
- void *match;
-#else
- struct cfdata *match;
-#endif
- void *aux;
-{
- struct pci_attach_args *pa = aux;
- u_int32_t memaddr, memsize, cacheable;
- u_int32_t ioaddr, iosize;
- u_int32_t mmioaddr, mmiosize;
- int potential;
- int retval;
- static int id = 0;
- int myid;
-
- myid = id;
-
- potential = 0;
-
- /*
- * If it's prehistoric/vga or display/vga, we might match.
- * For the console device, this is jut a sanity check.
- */
- if (PCI_CLASS(pa->pa_class) == PCI_CLASS_PREHISTORIC &&
- PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_PREHISTORIC_VGA)
- potential = 1;
- if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY &&
- PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_DISPLAY_VGA)
- potential = 1;
- if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY &&
- PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_DISPLAY_MISC)
- potential = 1;
-
- if (!potential)
- return (0);
-
- /* If it's the console, we have a winner! */
- if (!bcmp(&pa->pa_tag, &vgafb_pci_console_tag, sizeof(pa->pa_tag))) {
- id++;
- return (1);
- }
-
-#ifdef DEBUG_VGAFB
- {
- int i;
- pci_chipset_tag_t pc = pa->pa_pc;
- for (i = 0x10; i < 0x24; i+=4) {
- printf("vgafb confread %x %x\n",
- i, pci_conf_read(pc, pa->pa_tag, i));
- }
- }
-#endif
-
- memaddr=0xb8000; /* default to isa addresses? */
- ioaddr = 0; /* default to isa addresses? */
-
- retval = vgafb_pci_probe(pa, myid, &ioaddr, &iosize,
- &memaddr, &memsize, &cacheable, &mmioaddr, &mmiosize);
- if (retval == 0) {
- return 0;
- }
-#if 1
- printf("ioaddr %x, iosize %x, memaddr %x, memsize %x mmioaddr %x mmiosize %x\n",
- ioaddr, iosize, memaddr, memsize, mmioaddr, mmiosize);
-#endif
-
- if (!vgafb_common_probe(pa->pa_iot, pa->pa_memt, ioaddr, iosize, memaddr, memsize, mmioaddr, mmiosize))
- {
- printf("vgafb_pci_match: common_probe failed\n");
- return (0);
- }
- id++;
-
- return (1);
-}
-
-void
-vgafb_pci_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct pci_attach_args *pa = aux;
- struct vgafb_pci_softc *sc = (struct vgafb_pci_softc *)self;
- struct vgafb_config *vc;
- u_int32_t memaddr, memsize, cacheable;
- u_int32_t ioaddr, iosize;
- u_int32_t mmioaddr, mmiosize;
- int console;
- static int id = 0;
- int myid;
-
- myid = id;
-
- vgafb_pci_probe(pa, myid, &ioaddr, &iosize,
- &memaddr, &memsize, &cacheable, &mmioaddr, &mmiosize);
-
- console = (!bcmp(&pa->pa_tag, &vgafb_pci_console_tag, sizeof(pa->pa_tag)));
- if (console)
- vc = sc->sc_vc = &vgafb_pci_console_vc;
- else {
- vc = sc->sc_vc = (struct vgafb_config *)
- malloc(sizeof(struct vgafb_config), M_DEVBUF, M_WAITOK);
-
- /* set up bus-independent VGA configuration */
- vgafb_common_setup(pa->pa_iot, pa->pa_memt, vc,
- ioaddr, iosize, memaddr, memsize, mmioaddr, mmiosize);
- }
- vc->vc_mmap = vgafbpcimmap;
- vc->vc_ioctl = vgafbpciioctl;
-
- sc->sc_pcitag = pa->pa_tag;
-
- if (iosize == 0) {
- printf (", no io");
- }
- if (mmiosize != 0) {
- printf (", mmio");
- }
- printf("\n");
-
- vgafb_wsdisplay_attach(self, vc, console);
- id++;
-}
-
-void
-vgafb_pci_console(iot, ioaddr, iosize, memt, memaddr, memsize,
- pc, bus, device, function)
- bus_space_tag_t iot, memt;
- u_int32_t memaddr, memsize;
- u_int32_t ioaddr, iosize;
- pci_chipset_tag_t pc;
- int bus, device, function;
-{
- struct vgafb_config *vc = &vgafb_pci_console_vc;
- u_int32_t mmioaddr;
- u_int32_t mmiosize;
- static struct pci_attach_args spa;
- struct pci_attach_args *pa = &spa;
-
- /* for later recognition */
- vgafb_pci_console_tag = pci_make_tag(pc, bus, device, function);
-
- pa->pa_iot = iot;
- pa->pa_memt = memt;
- pa->pa_tag = vgafb_pci_console_tag;
- /*
- pa->pa_pc = XXX;
- */
-
-/* XXX probe pci before pci bus config? */
-
- mmioaddr =0;
- mmiosize =0;
-#if 0
- vgafb_pci_probe(pa, 0, &ioaddr, &iosize,
- &memaddr, &memsize, &cacheable, mmioaddr, mmiosize);
-#endif
-
-
- /* set up bus-independent VGA configuration */
- vgafb_common_setup(iot, memt, vc,
- ioaddr, iosize, memaddr, memsize, mmioaddr, mmiosize);
-
- vgafb_cnattach(iot, memt, pc, bus, device, function);
-}
-
-int
-vgafbpciioctl(v, cmd, data, flag, p)
- void *v;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct vgafb_pci_softc *sc = v;
-
- return (vgafb_ioctl(sc->sc_vc, cmd, data, flag, p));
-}
-
-int
-vgafbpcimmap(v, offset, prot)
- void *v;
- off_t offset;
- int prot;
-{
- struct vgafb_pci_softc *sc = v;
-
- return (vgafb_mmap(sc->sc_vc, offset, prot));
-}
-
-int
-vgafb_alloc_screen(v, type, cookiep, curxp, curyp, attrp)
- void *v;
- const struct wsscreen_descr *type;
- void **cookiep;
- int *curxp, *curyp;
- long *attrp;
-{
- struct vgafb_pci_softc *sc = v;
- long defattr;
-
- if (sc->nscreens > 0)
- return (ENOMEM);
-
- *cookiep = &sc->sc_vc->dc_rcons; /* one and only for now */
- *curxp = 0;
- *curyp = 0;
- rcons_alloc_attr(&sc->sc_vc->dc_rcons, 0, 0, 0, &defattr);
- *attrp = defattr;
- sc->nscreens++;
- return (0);
-}
-
-void
-vgafb_free_screen(v, cookie)
- void *v;
- void *cookie;
-{
- struct vgafb_pci_softc *sc = v;
-
- if (sc->sc_vc == &vgafb_pci_console_vc)
- panic("vgafb_free_screen: console");
-
- sc->nscreens--;
-}
-
-int
-vgafb_show_screen(v, cookie, waitok, cb, cbarg)
- void *v;
- void *cookie;
- int waitok;
- void (*cb) __P((void *, int, int));
- void *cbarg;
-{
-
- return (0);
-}
diff --git a/sys/arch/powerpc/pci/vgafb_pcivar.h b/sys/arch/powerpc/pci/vgafb_pcivar.h
deleted file mode 100644
index feb61954d3a..00000000000
--- a/sys/arch/powerpc/pci/vgafb_pcivar.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: vgafb_pcivar.h,v 1.2 2000/11/21 02:03:45 deraadt Exp $ */
-/* $NetBSD: vga_pcivar.h,v 1.1 1996/11/19 04:38:36 cgd Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-#define DEVICE_IS_VGA_PCI(class, id) \
- (((PCI_CLASS(class) == PCI_CLASS_DISPLAY && \
- PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_VGA) || \
- (((PCI_CLASS(class) == PCI_CLASS_DISPLAY && \
- PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_MISC) || \
- (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \
- PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) ? 1 : 0)
-
-void vgafb_pci_console __P((bus_space_tag_t,
- u_int32_t ioaddr, u_int32_t iosize,
- bus_space_tag_t,
- u_int32_t memaddr, u_int32_t memsize,
- pci_chipset_tag_t, int, int, int));
diff --git a/sys/arch/powerpc/pci/vgafbvar.h b/sys/arch/powerpc/pci/vgafbvar.h
deleted file mode 100644
index 726812e7d76..00000000000
--- a/sys/arch/powerpc/pci/vgafbvar.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* $OpenBSD: vgafbvar.h,v 1.3 2001/07/09 03:54:41 mickey Exp $ */
-/* $NetBSD: vgavar.h,v 1.2 1996/11/23 06:06:43 cgd Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Author: Chris G. Demetriou
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-struct vgafb_config {
- /*
- * Filled in by front-ends.
- */
- int vc_ofh; /* openfirmware handle */
- bus_space_tag_t vc_iot, vc_memt;
- bus_space_handle_t vc_ioh_b, vc_ioh_c, vc_ioh_d, vc_memh, vc_mmioh;
- paddr_t vc_paddr; /* physical address */
- /* Colormap */
- u_char vc_cmap_red[256];
- u_char vc_cmap_green[256];
- u_char vc_cmap_blue[256];
-
- /*
- * Private to back-end.
- */
- int vc_ncol, vc_nrow; /* screen width & height */
- int vc_ccol, vc_crow; /* current cursor position */
-
- char vc_so; /* in standout mode? */
- char vc_at; /* normal attributes */
- char vc_so_at; /* standout attributes */
-
- int (*vc_ioctl) __P((void *, u_long,
- caddr_t, int, struct proc *));
- int (*vc_mmap) __P((void *, off_t, int));
- #if 0
- struct raster dc_raster; /* raster description */
- #endif
- struct rcons dc_rcons; /* raster blitter control info */
-
-
-};
-
-int vgafb_common_probe __P((bus_space_tag_t, bus_space_tag_t,
- u_int32_t, size_t, u_int32_t, size_t, u_int32_t, size_t ));
-void vgafb_common_setup __P((bus_space_tag_t, bus_space_tag_t,
- struct vgafb_config *, u_int32_t, size_t, u_int32_t, size_t,
- u_int32_t, size_t));
-void vgafb_wscons_attach __P((struct device *, struct vgafb_config *, int));
-void vgafb_wscons_console __P((struct vgafb_config *));
-void vgafb_cnprobe __P((struct consdev *cp));
-void vgafb_cnattach __P((bus_space_tag_t iot, bus_space_tag_t memt,
- void *pc, int bus, int device, int function));
-void vgafb_wsdisplay_attach __P((struct device *parent,
- struct vgafb_config *vc, int console));
-int vgafbioctl __P((void *, u_long, caddr_t, int, struct proc *));
-int vgafbmmap __P((void *, off_t, int));
-int vgafb_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
-paddr_t vgafb_mmap __P((void *, off_t, int));
-int vgafb_alloc_screen __P((void *v, const struct wsscreen_descr *type,
- void **cookiep, int *curxp, int *curyp, long *attrp));
-void vgafb_free_screen __P((void *v, void *cookie));
-int vgafb_show_screen __P((void *v, void *cookie, int waitok,
- void (*cb) __P((void *, int, int)), void *cbarg));