summaryrefslogtreecommitdiff
path: root/sys/arch/pegasos/pegasos
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/pegasos/pegasos')
-rw-r--r--sys/arch/pegasos/pegasos/autoconf.c634
-rw-r--r--sys/arch/pegasos/pegasos/clock.c459
-rw-r--r--sys/arch/pegasos/pegasos/conf.c352
-rw-r--r--sys/arch/pegasos/pegasos/cpu.c383
-rw-r--r--sys/arch/pegasos/pegasos/db_interface.c44
-rw-r--r--sys/arch/pegasos/pegasos/disksubr.c450
-rw-r--r--sys/arch/pegasos/pegasos/dma.c601
-rw-r--r--sys/arch/pegasos/pegasos/genassym.cf73
-rw-r--r--sys/arch/pegasos/pegasos/hfsdisksubr.c121
-rw-r--r--sys/arch/pegasos/pegasos/locore.S1246
-rw-r--r--sys/arch/pegasos/pegasos/machdep.c1440
-rw-r--r--sys/arch/pegasos/pegasos/mainbus.c161
-rw-r--r--sys/arch/pegasos/pegasos/mbrdisksubr.c208
-rw-r--r--sys/arch/pegasos/pegasos/mem.c187
-rw-r--r--sys/arch/pegasos/pegasos/ofw_machdep.c723
-rw-r--r--sys/arch/pegasos/pegasos/ofw_machdep.h55
-rw-r--r--sys/arch/pegasos/pegasos/ofwreal.S449
-rw-r--r--sys/arch/pegasos/pegasos/opendev.c318
-rw-r--r--sys/arch/pegasos/pegasos/openfirm.c295
-rw-r--r--sys/arch/pegasos/pegasos/rbus_machdep.c140
-rw-r--r--sys/arch/pegasos/pegasos/rdbdisksubr.c361
-rw-r--r--sys/arch/pegasos/pegasos/wscons_machdep.c136
22 files changed, 0 insertions, 8836 deletions
diff --git a/sys/arch/pegasos/pegasos/autoconf.c b/sys/arch/pegasos/pegasos/autoconf.c
deleted file mode 100644
index 66fc1d3397e..00000000000
--- a/sys/arch/pegasos/pegasos/autoconf.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/* $OpenBSD: autoconf.c,v 1.1 2003/10/31 03:54:33 drahn Exp $ */
-/*
- * Copyright (c) 1996, 1997 Per Fogelstrom
- * Copyright (c) 1995 Theo de Raadt
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department and Ralph Campbell.
- *
- * 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. Neither the name of the University 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 REGENTS 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.
- *
- * from: Utah Hdr: autoconf.c 1.31 91/01/21
- *
- * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93
- * $Id: autoconf.c,v 1.1 2003/10/31 03:54:33 drahn Exp $
- */
-
-/*
- * Setup the system to run on the current machine.
- *
- * cpu_configure() is called at boot time. Available
- * devices are determined (from possibilities mentioned in ioconf.c),
- * and the drivers are initialized.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/disklabel.h>
-#include <sys/conf.h>
-#include <sys/reboot.h>
-#include <sys/device.h>
-#include <dev/cons.h>
-#include <uvm/uvm_extern.h>
-#include <machine/autoconf.h>
-
-struct device *parsedisk(char *, int, int, dev_t *);
-void setroot(void);
-void swapconf(void);
-extern void dumpconf(void);
-int findblkmajor(struct device *);
-char *findblkname(int);
-static struct device * getdisk(char *, int, int, dev_t *);
-struct device * getdevunit(char *, int);
-static struct devmap * findtype(char **);
-void makebootdev(char *cp);
-int getpno(char **);
-void diskconf(void);
-
-/*
- * The following several variables are related to
- * the configuration process, and are used in initializing
- * the machine.
- */
-int cold = 1; /* if 1, still working on cold-start */
-char bootdev[16]; /* to hold boot dev name */
-struct device *bootdv = NULL;
-
-/*
- * Configure all devices found that we know about.
- * This is done at boot time.
- */
-void
-cpu_configure()
-{
- (void)splhigh(); /* To be really sure.. */
- calc_delayconst();
-
- if(config_rootfound("mainbus", "mainbus") == 0)
- panic("no mainbus found");
- (void)spl0();
-
- /*
- * We can not know which is our root disk, defer
- * until we can checksum blocks to figure it out.
- */
- md_diskconf = diskconf;
- cold = 0;
-}
-/*
- * Now that we are fully operational, we can checksum the
- * disks, and using some heuristics, hopefully are able to
- * always determine the correct root disk.
- */
-void
-diskconf()
-{
- /*
- * Configure root, swap, and dump area. This is
- * currently done by running the same checksum
- * algorithm over all known disks, as was done in
- * /boot. Then we basically fixup the *dev vars
- * from the info we gleaned from this.
- dkcsumattach();
- * - XXX
- */
-
-#if 0
- rootconf();
-#endif
- setroot();
- swapconf();
-#if 0
- dumpconf();
-#endif
-}
-
-/*
- * Configure swap space and related parameters.
- */
-void
-swapconf()
-{
- struct swdevt *swp;
- int nblks;
-
- for (swp = swdevt; swp->sw_dev != NODEV; swp++) {
- if (bdevsw[major(swp->sw_dev)].d_psize) {
- nblks =
- (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);
- if (nblks != -1 &&
- (swp->sw_nblks == 0 || swp->sw_nblks > nblks))
- swp->sw_nblks = nblks;
- swp->sw_nblks = ctod(dtoc(swp->sw_nblks));
- }
- }
-#if 0
- dumpconf();
-#endif
-}
-
-/*
- * Crash dump handling.
- */
-u_long dumpmag = 0x8fca0101; /* magic number */
-int dumpsize = 0; /* size of dump in pages */
-long dumplo = -1; /* blocks */
-
-/*
- * This is called by configure to set dumplo and dumpsize.
- * Dumps always skip the first CLBYTES of disk space
- * in case there might be a disk label stored there.
- * If there is extra space, put dump at the end to
- * reduce the chance that swapping trashes it.
- */
-#if 0
-void
-dumpconf()
-{
- int nblks; /* size of dump area */
- int maj;
-
- if (dumpdev == NODEV)
- return;
- maj = major(dumpdev);
- if (maj < 0 || maj >= nblkdev)
- panic("dumpconf: bad dumpdev=0x%x", dumpdev);
- if (bdevsw[maj].d_psize == NULL)
- return;
- nblks = (*bdevsw[maj].d_psize)(dumpdev);
- if (nblks <= ctod(1))
- return;
-
- dumpsize = btoc(IOM_END + ctob(dumpmem_high));
-
- /* Always skip the first CLBYTES, in case there is a label there. */
- if (dumplo < ctod(1))
- dumplo = ctod(1);
-
- /* Put dump at end of partition, and make it fit. */
- if (dumpsize > dtoc(nblks - dumplo))
- dumpsize = dtoc(nblks - dumplo);
- if (dumplo < nblks - ctod(dumpsize))
- dumplo = nblks - ctod(dumpsize);
-}
-#endif
-
-static struct nam2blk {
- char *name;
- int maj;
-} nam2blk[] = {
- { "wd", 0 }, /* 0 = wd */
- { "sd", 2 }, /* 2 = sd */
- { "ofdisk", 4 }, /* 4 = ofdisk */
- { "raid", 19 }, /* 19 = raid */
-};
-
-int
-findblkmajor(struct device *dv)
-{
- char *name = dv->dv_xname;
- int i;
-
- for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); ++i)
- if (strncmp(name, nam2blk[i].name, strlen(nam2blk[i].name)) ==
- 0)
- return (nam2blk[i].maj);
- return (-1);
-}
-
-char *
-findblkname(int maj)
-{
- int i;
-
- for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); i++)
- if (nam2blk[i].maj == maj)
- return (nam2blk[i].name);
- return (NULL);
-}
-
-static struct device *
-getdisk(char *str, int len, int defpart, dev_t *devp)
-{
- struct device *dv;
-
- if ((dv = parsedisk(str, len, defpart, devp)) == NULL) {
- printf("use one of:");
- for (dv = alldevs.tqh_first; dv != NULL;
- dv = dv->dv_list.tqe_next) {
- if (dv->dv_class == DV_DISK)
- printf(" %s[a-p]", dv->dv_xname);
-#ifdef NFSCLIENT
- if (dv->dv_class == DV_IFNET)
- printf(" %s", dv->dv_xname);
-#endif
- }
- printf("\n");
- }
- return (dv);
-}
-
-struct device *
-parsedisk(char *str, int len, int defpart, dev_t *devp)
-{
- struct device *dv;
- char *cp, c;
- int majdev, part;
-
- if (len == 0)
- return (NULL);
- cp = str + len - 1;
- c = *cp;
- if (c >= 'a' && (c - 'a') < MAXPARTITIONS) {
- part = c - 'a';
- *cp = '\0';
- } else
- part = defpart;
-
- for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) {
- if (dv->dv_class == DV_DISK &&
- strcmp(str, dv->dv_xname) == 0) {
- majdev = findblkmajor(dv);
- if (majdev < 0)
- panic("parsedisk");
- *devp = MAKEDISKDEV(majdev, dv->dv_unit, part);
- break;
- }
-#ifdef NFSCLIENT
- if (dv->dv_class == DV_IFNET &&
- strcmp(str, dv->dv_xname) == 0) {
- *devp = NODEV;
- break;
- }
-#endif
- }
-
- *cp = c;
- return (dv);
-}
-
-/*
- * Attempt to find the device from which we were booted.
- * If we can do so, and not instructed not to do so,
- * change rootdev to correspond to the load device.
- */
-void
-setroot()
-{
- int majdev, mindev, unit, part, len;
- dev_t temp;
- struct swdevt *swp;
- struct device *dv;
- dev_t nrootdev, nswapdev = NODEV;
- char buf[128];
- int s;
-
-#if defined(NFSCLIENT)
- extern char *nfsbootdevname;
-#endif
-
- printf("bootpath: '%s'\n", bootpath);
-
- makebootdev(bootpath);
- if(boothowto & RB_DFLTROOT)
- return; /* Boot compiled in */
-
- /*
- * (raid) device auto-configuration could have returned
- * the root device's id in rootdev. Check this case.
- */
- if (rootdev != NODEV) {
- majdev = major(rootdev);
- unit = DISKUNIT(rootdev);
- part = DISKPART(rootdev);
-
- len = snprintf(buf, sizeof buf, "%s%d", findblkname(majdev),
- unit);
- if (len >= sizeof(buf))
- panic("setroot: device name too long");
-
- bootdv = getdisk(buf, len, part, &rootdev);
- }
-
- /* Lookup boot device from boot if not set by configuration */
- if(bootdv == NULL) {
- bootdv = parsedisk(bootdev, strlen(bootdev), 0, &temp);
- }
- if(bootdv == NULL) {
- printf("boot device: lookup '%s' failed.\n", bootdev);
- boothowto |= RB_ASKNAME; /* Don't Panic :-) */
- /* boothowto |= RB_SINGLE; */
- } else
- printf("boot device: %s.\n", bootdv->dv_xname);
-
- if (boothowto & RB_ASKNAME) {
- for (;;) {
- printf("root device ");
- if (bootdv != NULL)
- printf("(default %s%c)",
- bootdv->dv_xname,
- bootdv->dv_class == DV_DISK
- ? 'a' : ' ');
- printf(": ");
- s = splimp();
- cnpollc(TRUE);
- len = getsn(buf, sizeof(buf));
-
- cnpollc(FALSE);
- splx(s);
- if (len == 0 && bootdv != NULL) {
- strlcpy(buf, bootdv->dv_xname, sizeof buf);
- len = strlen(buf);
- }
- if (len > 0 && buf[len - 1] == '*') {
- buf[--len] = '\0';
- dv = getdisk(buf, len, 1, &nrootdev);
- if (dv != NULL) {
- bootdv = dv;
- nswapdev = nrootdev;
- goto gotswap;
- }
- }
- dv = getdisk(buf, len, 0, &nrootdev);
- if (dv != NULL) {
- bootdv = dv;
- break;
- }
- }
- /*
- * because swap must be on same device as root, for
- * network devices this is easy.
- */
- if (bootdv->dv_class == DV_IFNET)
- goto gotswap;
-
- for (;;) {
- printf("swap device ");
- if (bootdv != NULL)
- printf("(default %s%c)",
- bootdv->dv_xname,
- bootdv->dv_class == DV_DISK?'b':' ');
- printf(": ");
- s = splimp();
- cnpollc(TRUE);
- len = getsn(buf, sizeof(buf));
- cnpollc(FALSE);
- splx(s);
- if (len == 0 && bootdv != NULL) {
- switch (bootdv->dv_class) {
- case DV_IFNET:
- nswapdev = NODEV;
- break;
- case DV_DISK:
- nswapdev = MAKEDISKDEV(major(nrootdev),
- DISKUNIT(nrootdev), 1);
- break;
- case DV_TAPE:
- case DV_TTY:
- case DV_DULL:
- case DV_CPU:
- break;
- }
- break;
- }
- dv = getdisk(buf, len, 1, &nswapdev);
- if (dv) {
- if (dv->dv_class == DV_IFNET)
- nswapdev = NODEV;
- break;
- }
- }
-
-gotswap:
- rootdev = nrootdev;
- dumpdev = nswapdev;
- swdevt[0].sw_dev = nswapdev;
- swdevt[1].sw_dev = NODEV;
- }
- else if(mountroot == NULL) {
- /*
- * `swap generic': Use the device the ROM told us to use.
- */
- if (bootdv == NULL)
- panic("boot device not known");
-
- majdev = findblkmajor(bootdv);
-
- if (majdev >= 0) {
- /*
- * Root and Swap are on disk.
- * Boot is always from partition 0.
- */
- rootdev = MAKEDISKDEV(majdev, bootdv->dv_unit, 0);
- nswapdev = MAKEDISKDEV(majdev, bootdv->dv_unit, 1);
- dumpdev = nswapdev;
- } else {
- /*
- * Root and Swap are on net.
- */
- nswapdev = dumpdev = NODEV;
- }
- swdevt[0].sw_dev = nswapdev;
- swdevt[1].sw_dev = NODEV;
-
- } else {
-
- /*
- * `root DEV swap DEV': honour rootdev/swdevt.
- * rootdev/swdevt/mountroot already properly set.
- */
- return;
- }
-
- switch (bootdv->dv_class) {
-#if defined(NFSCLIENT)
- case DV_IFNET:
- mountroot = nfs_mountroot;
- nfsbootdevname = bootdv->dv_xname;
- return;
-#endif
- case DV_DISK:
- mountroot = dk_mountroot;
- majdev = major(rootdev);
- mindev = minor(rootdev);
- unit = DISKUNIT(rootdev);
- part = DISKPART(rootdev);
- printf("root on %s%c\n", bootdv->dv_xname, part + 'a');
- break;
- default:
- printf("can't figure root, hope your kernel is right\n");
- return;
- }
-
- /*
- * XXX: What is this doing?
- */
- temp = NODEV;
- for (swp = swdevt; swp->sw_dev != NODEV; swp++) {
- if (majdev == major(swp->sw_dev) &&
- unit == DISKUNIT(swp->sw_dev)) {
- temp = swdevt[0].sw_dev;
- swdevt[0].sw_dev = swp->sw_dev;
- swp->sw_dev = temp;
- break;
- }
- }
- if (swp->sw_dev == NODEV)
- return;
-
- /*
- * If dumpdev was the same as the old primary swap device, move
- * it to the new primary swap device.
- */
- if (temp == dumpdev)
- dumpdev = swdevt[0].sw_dev;
-}
-
-/*
- * find a device matching "name" and unit number
- */
-struct device *
-getdevunit(char *name, int unit)
-{
- struct device *dev = alldevs.tqh_first;
- char num[10], fullname[16];
- int lunit;
-
- /* compute length of name and decimal expansion of unit number */
- snprintf(num, sizeof num, "%d", unit);
- lunit = strlen(num);
- if (strlen(name) + lunit >= sizeof(fullname) - 1)
- panic("config_attach: device name too long");
-
- strlcpy(fullname, name, sizeof fullname);
- strlcat(fullname, num, sizeof fullname);
-
- while (strcmp(dev->dv_xname, fullname) != 0)
- if ((dev = dev->dv_list.tqe_next) == NULL)
- return NULL;
-
- return dev;
-}
-
-struct devmap {
- char *att;
- char *dev;
- int type;
-};
-#define T_IFACE 0x10
-
-#define T_BUS 0x00
-#define T_SCSI 0x11
-#define T_IDE 0x12
-#define T_DISK 0x21
-
-static struct devmap *
-findtype(char **s)
-{
- static struct devmap devmap[] = {
- { "/pci@", NULL, T_BUS },
- { "/pci", NULL, T_BUS },
- { "/AppleKiwi@",NULL, T_BUS },
- { "/AppleKiwi", NULL, T_BUS },
- { "/mac-io@", NULL, T_BUS },
- { "/mac-io", NULL, T_BUS },
- { "/@", NULL, T_BUS },
- { "/scsi@", "sd", T_SCSI },
- { "/ide", "wd", T_IDE },
- { "/ata", "wd", T_IDE },
- { "/disk@", "sd", T_DISK },
- { "/disk", "wd", T_DISK },
- { NULL, NULL }
- };
- struct devmap *dp = &devmap[0];
-
- while (dp->att) {
- if (strncmp (*s, dp->att, strlen(dp->att)) == 0) {
- *s += strlen(dp->att);
- break;
- }
- dp++;
- }
- if (dp->att == NULL)
- printf("string [%s] not found\n", *s);
-
- return(dp);
-}
-
-/*
- * Look at the string 'bp' and decode the boot device.
- * Boot names look like: '/pci/scsi@c/disk@0,0/bsd'
- * '/pci/mac-io/ide@20000/disk@0,0/bsd
- * '/pci/mac-io/ide/disk/bsd
- */
-void
-makebootdev(char *bp)
-{
- int unit;
- char *dev, *cp;
- struct devmap *dp;
-
- cp = bp;
- do {
- while(*cp && *cp != '/')
- cp++;
-
- dp = findtype(&cp);
- if (!dp->att) {
- printf("Warning: boot device unrecognized: %s\n", bp);
- return;
- }
- } while((dp->type & T_IFACE) == 0);
-
- dev = dp->dev;
- while(*cp && *cp != '/')
- cp++;
- dp = findtype(&cp);
- if (!dp->att || dp->type != T_DISK) {
- printf("Warning: boot device unrecognized: %s\n", bp);
- return;
- }
- unit = getpno(&cp);
- snprintf(bootdev, sizeof bootdev, "%s%d%c", dev, unit, 'a');
-}
-
-int
-getpno(char **cp)
-{
- int val = 0;
- char *cx = *cp;
-
- while(*cx && *cx >= '0' && *cx <= '9') {
- val = val * 10 + *cx - '0';
- cx++;
- }
- *cp = cx;
- return val;
-}
diff --git a/sys/arch/pegasos/pegasos/clock.c b/sys/arch/pegasos/pegasos/clock.c
deleted file mode 100644
index 80593f386c0..00000000000
--- a/sys/arch/pegasos/pegasos/clock.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/* $OpenBSD: clock.c,v 1.2 2003/12/18 20:06:15 drahn Exp $ */
-/* $NetBSD: clock.c,v 1.1 1996/09/30 16:34:40 ws Exp $ */
-
-/*
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/kernel.h>
-#include <sys/systm.h>
-
-#include <machine/autoconf.h>
-#include <machine/pio.h>
-#include <machine/intr.h>
-#include <machine/powerpc.h>
-#include <dev/ofw/openfirm.h>
-
-void resettodr(void);
-
-/* XXX, called from asm code */
-void decr_intr(struct clockframe *frame);
-
-/*
- * Initially we assume a processor with a bus frequency of 12.5 MHz.
- */
-static u_int32_t ticks_per_sec = 3125000;
-static u_int32_t ns_per_tick = 320;
-static int32_t ticks_per_intr;
-static volatile u_int64_t lasttb;
-
-/*
- * BCD to decimal and decimal to BCD.
- */
-#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf))
-#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10))
-
-#define SECDAY (24 * 60 * 60)
-#define SECYR (SECDAY * 365)
-#define LEAPYEAR(y) (((y) & 3) == 0)
-#define YEAR0 1900
-
-#if 0
-typedef int (clock_read_t)(int *sec, int *min, int *hour, int *day,
- int *mon, int *yr);
-typedef int (time_read_t)(u_int32_t *sec);
-typedef int (time_write_t)(u_int32_t sec);
-
-clock_read_t *clock_read = NULL;
-time_read_t *time_read = NULL;
-time_write_t *time_write = NULL;
-
-static u_int32_t chiptotime(int sec, int min, int hour, int day, int mon,
- int year);
-#endif
-
-/* event tracking variables, when the next events of each time should occur */
-u_int64_t nexttimerevent, nextstatevent;
-
-/* vars for stats */
-int statint;
-u_int32_t statvar;
-u_int32_t statmin;
-
-#if 0
-/*
- * For now we let the machine run with boot time, not changing the clock
- * at inittodr at all.
- *
- * We might continue to do this due to setting up the real wall clock with
- * a user level utility in the future.
- */
-
-/* ARGSUSED */
-void
-inittodr(time_t base)
-{
- int sec, min, hour, day, mon, year;
-
- int badbase = 0, waszero = base == 0;
-
- if (base < 5 * SECYR) {
- /*
- * If base is 0, assume filesystem time is just unknown
- * instead of preposterous. Don't bark.
- */
- if (base != 0)
- printf("WARNING: preposterous time in file system\n");
- /* not going to use it anyway, if the chip is readable */
- base = 21*SECYR + 186*SECDAY + SECDAY/2;
- badbase = 1;
- }
-
- if (clock_read != NULL ) {
- (*clock_read)( &sec, &min, &hour, &day, &mon, &year);
- time.tv_sec = chiptotime(sec, min, hour, day, mon, year);
- } else if (time_read != NULL) {
- u_int32_t cursec;
- (*time_read)(&cursec);
- time.tv_sec = cursec;
- } else {
- /* force failure */
- time.tv_sec = 0;
- }
-
- if (time.tv_sec == 0) {
- printf("WARNING: unable to get date/time");
- /*
- * Believe the time in the file system for lack of
- * anything better, resetting the clock.
- */
- time.tv_sec = base;
- if (!badbase)
- resettodr();
- } else {
- int deltat;
-
- time.tv_sec += tz.tz_minuteswest * 60;
- if (tz.tz_dsttime)
- time.tv_sec -= 3600;
-
- deltat = time.tv_sec - base;
-
- if (deltat < 0)
- deltat = -deltat;
- if (waszero || deltat < 2 * SECDAY)
- return;
- printf("WARNING: clock %s %d days",
- time.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
-
- if (time.tv_sec < base && deltat > 1000 * SECDAY) {
- printf(", using FS time");
- time.tv_sec = base;
- }
- }
- printf(" -- CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * This code is defunct after 2068.
- * Will Unix still be here then??
- */
-const short dayyr[12] =
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
-
-static u_int32_t
-chiptotime(int sec, int min, int hour, int day, int mon, int year)
-{
- int days, yr;
-
- sec = FROMBCD(sec);
- min = FROMBCD(min);
- hour = FROMBCD(hour);
- day = FROMBCD(day);
- mon = FROMBCD(mon);
- year = FROMBCD(year) + YEAR0;
-
- /* simple sanity checks */
- if (year < 1970 || mon < 1 || mon > 12 || day < 1 || day > 31)
- return (0);
- days = 0;
- for (yr = 1970; yr < year; yr++)
- days += LEAPYEAR(yr) ? 366 : 365;
- days += dayyr[mon - 1] + day - 1;
- if (LEAPYEAR(yr) && mon > 2)
- days++;
- /* now have days since Jan 1, 1970; the rest is easy... */
- return (days * SECDAY + hour * 3600 + min * 60 + sec);
-}
-
-
-/*
- * Similar to the above
- */
-void
-resettodr(void)
-{
- struct timeval curtime = time;
- if (time_write != NULL) {
- curtime.tv_sec -= tz.tz_minuteswest * 60;
- if (tz.tz_dsttime) {
- curtime.tv_sec += 3600;
- }
- (*time_write)(curtime.tv_sec);
- }
-}
-#endif
-
-volatile int tickspending, statspending;
-
-void
-decr_intr(struct clockframe *frame)
-{
- u_int64_t tb;
- u_int64_t nextevent;
- int nticks;
- int nstats;
- int s;
-
- /*
- * Check whether we are initialized.
- */
- if (!ticks_per_intr)
- return;
-
-
- /*
- * Based on the actual time delay since the last decrementer reload,
- * we arrange for earlier interrupt next time.
- */
-
- tb = ppc_mftb();
- for (nticks = 0; nexttimerevent <= tb; nticks++)
- nexttimerevent += ticks_per_intr;
-
- for (nstats = 0; nextstatevent <= tb; nstats++) {
- int r;
- do {
- r = random() & (statvar -1);
- } while (r == 0); /* random == 0 not allowed */
- nextstatevent += statmin + r;
- }
-
- /* only count timer ticks for CLK_IRQ */
- intrcnt[PPC_CLK_IRQ] += nticks;
- intrcnt[PPC_STAT_IRQ] += nstats;
-
- if (nexttimerevent < nextstatevent)
- nextevent = nexttimerevent;
- else
- nextevent = nextstatevent;
-
- /*
- * Need to work about the near constant skew this introduces???
- * reloading tb here could cause a missed tick.
- */
- ppc_mtdec(nextevent - tb);
-
- if (cpl & SPL_CLOCK) {
- tickspending += nticks;
- statspending += nstats;
- } else {
- do {
- nticks += tickspending;
- nstats += statspending;
- tickspending = 0;
- statspending = 0;
-
- s = splclock();
-
- /*
- * Reenable interrupts
- */
- ppc_intr_enable(1);
-
- /*
- * Do standard timer interrupt stuff.
- * Do softclock stuff only on the last iteration.
- */
- frame->pri = s | SINT_CLOCK;
- if (nticks > 1)
- while (--nticks > 1) {
- /* sync lasttb with hardclock */
- lasttb += ticks_per_intr;
- hardclock(frame);
- }
-
- frame->pri = s;
- if (nticks) {
- /* sync lasttb with hardclock */
- lasttb += ticks_per_intr;
- hardclock(frame);
- }
-
- while (nstats-- > 0)
- statclock(frame);
-
- splx(s);
- (void) ppc_intr_disable();
-
- /* if a tick has occurred while dealing with these,
- * service it now, do not delay until the next tick.
- */
- nstats = 0;
- nticks = 0;
- } while (tickspending != 0 || statspending != 0);
- }
-}
-
-void
-cpu_initclocks()
-{
- int intrstate;
- int r;
- int minint;
- u_int64_t nextevent;
-
- intrstate = ppc_intr_disable();
-
- stathz = 100;
- profhz = 1000; /* must be a multiple of stathz */
-
- /* init secondary clock to stathz */
- statint = ticks_per_sec / stathz;
- statvar = 0x40000000; /* really big power of two */
- /* find largest 2^n which is nearly smaller than statint/2 */
- minint = statint / 2 + 100;
- while (statvar > minint)
- statvar >>= 1;
-
- statmin = statint - (statvar >> 1);
-
-
- lasttb = ppc_mftb();
- nexttimerevent = lasttb + ticks_per_intr;
- do {
- r = random() & (statvar -1);
- } while (r == 0); /* random == 0 not allowed */
- nextstatevent = lasttb + statmin + r;
-
- if (nexttimerevent < nextstatevent)
- nextevent = nexttimerevent;
- else
- nextevent = nextstatevent;
-
- ppc_mtdec(nextevent-lasttb);
- ppc_intr_enable(intrstate);
-}
-
-void
-calc_delayconst(void)
-{
- int qhandle, phandle;
- char name[32];
- int s;
-
- /*
- * Get this info during autoconf? XXX
- */
- for (qhandle = OF_peer(0); qhandle; qhandle = phandle) {
- if (OF_getprop(qhandle, "device_type", name, sizeof name) >= 0
- && !strcmp(name, "cpu")
- && OF_getprop(qhandle, "timebase-frequency",
- &ticks_per_sec, sizeof ticks_per_sec) >= 0) {
- /*
- * Should check for correct CPU here? XXX
- */
- s = ppc_intr_disable();
- ns_per_tick = 1000000000 / ticks_per_sec;
- ticks_per_intr = ticks_per_sec / hz;
- ppc_intr_enable(s);
- break;
- }
- if ((phandle = OF_child(qhandle)))
- continue;
- while (qhandle) {
- if ((phandle = OF_peer(qhandle)))
- break;
- qhandle = OF_parent(qhandle);
- }
- }
-
- if (!phandle)
- panic("no cpu node");
-}
-
-/*
- * Fill in *tvp with current time with microsecond resolution.
- */
-void
-microtime(struct timeval *tvp)
-{
- u_int64_t tb;
- u_int32_t ticks;
- int s;
-
- s = ppc_intr_disable();
- tb = ppc_mftb();
- ticks = (tb - lasttb) * ns_per_tick;
- *tvp = time;
- ppc_intr_enable(s);
- ticks /= 1000;
- tvp->tv_usec += ticks;
- while (tvp->tv_usec >= 1000000) {
- tvp->tv_usec -= 1000000;
- tvp->tv_sec++;
- }
-}
-
-/*
- * Wait for about n microseconds (us) (at least!).
- */
-void
-delay(unsigned n)
-{
- u_int64_t tb;
- u_int32_t tbh, tbl, scratch;
-
- tb = ppc_mftb();
- tb += (n * 1000 + ns_per_tick - 1) / ns_per_tick;
- tbh = tb >> 32;
- tbl = (u_int32_t)tb;
- asm ("1: mftbu %0; cmplw %0,%1; blt 1b; bgt 2f;"
- " mftb %0; cmplw %0,%2; blt 1b; 2:"
- :: "r"(scratch), "r"(tbh), "r"(tbl));
-}
-
-/*
- * Nothing to do.
- */
-void
-setstatclockrate(int newhz)
-{
- int minint;
- int intrstate;
-
- intrstate = ppc_intr_disable();
-
- statint = ticks_per_sec / newhz;
- statvar = 0x40000000; /* really big power of two */
- /* find largest 2^n which is nearly smaller than statint/2 */
- minint = statint / 2 + 100;
- while (statvar > minint)
- statvar >>= 1;
-
- statmin = statint - (statvar >> 1);
- ppc_intr_enable(intrstate);
-
- /*
- * XXX this allows the next stat timer to occur then it switches
- * to the new frequency. Rather than switching instantly.
- */
-}
diff --git a/sys/arch/pegasos/pegasos/conf.c b/sys/arch/pegasos/pegasos/conf.c
deleted file mode 100644
index 4ba95eb33f1..00000000000
--- a/sys/arch/pegasos/pegasos/conf.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/* $OpenBSD: conf.c,v 1.2 2004/02/10 01:31:21 millert Exp $ */
-
-/*
- * Copyright (c) 1997 Per Fogelstrom
- * Copyright (c) 1997 RTMX Inc, North Carolina
- *
- * 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,
- * North Carolina, USA, by Per Fogelstrom, Opsycon AB, Sweden.
- * 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/buf.h>
-#include <sys/ioctl.h>
-#include <sys/systm.h>
-#include <sys/tty.h>
-#include <sys/vnode.h>
-
-#include <machine/conf.h>
-
-#include "sd.h"
-#include "st.h"
-#include "cd.h"
-#include "ss.h"
-#include "uk.h"
-#include "rd.h"
-#include "wd.h"
-bdev_decl(wd);
-cdev_decl(wd);
-
-#include "ofdisk.h"
-bdev_decl(ofd);
-
-#include "vnd.h"
-#include "ccd.h"
-#include "raid.h"
-
-struct bdevsw bdevsw[] = {
- bdev_disk_init(NWD,wd), /* 0: ST506/ESDI/IDE disk */
- bdev_swap_init(1,sw), /* 1 swap pseudo device */
- bdev_disk_init(NSD,sd), /* 2 SCSI Disk */
- bdev_disk_init(NCD,cd), /* 3 SCSI CD-ROM */
- bdev_disk_init(NOFDISK,ofd), /* 4 Openfirmware disk */
- bdev_notdef(), /* 5 unknown*/
- bdev_notdef(), /* 6 unknown*/
- bdev_notdef(), /* 7 unknown*/
- bdev_lkm_dummy(), /* 8 */
- bdev_lkm_dummy(), /* 9 */
- bdev_lkm_dummy(), /* 10 */
- bdev_lkm_dummy(), /* 11 */
- bdev_lkm_dummy(), /* 12 */
- bdev_lkm_dummy(), /* 13 */
- bdev_disk_init(NVND,vnd), /* 14 vnode disk driver*/
- bdev_notdef(), /* 15 unknown*/
- bdev_disk_init(NCCD,ccd), /* 16 concatenated disk driver*/
- bdev_disk_init(NRD,rd), /* 17 ram disk driver*/
- bdev_notdef(), /* 18 unknown*/
- bdev_disk_init(NRAID,raid), /* 19: RAIDframe disk driver */
-};
-int nblkdev = sizeof bdevsw / sizeof bdevsw[0];
-
-#include "pty.h"
-
-#include "ofcons.h"
-cdev_decl(ofc);
-cdev_decl(ofd);
-
-#include "ofrtc.h"
-cdev_decl(ofrtc);
-
-cdev_decl(kbd);
-cdev_decl(ms);
-
-#include "com.h"
-cdev_decl(com);
-
-#include "wsdisplay.h"
-#include "wskbd.h"
-#include "wsmouse.h"
-
-#include "iop.h"
-
-#include "bpfilter.h"
-
-#include "tun.h"
-
-#ifdef XFS
-#include <xfs/nxfs.h>
-cdev_decl(xfs_dev);
-#endif
-
-#ifdef LKM
-#define NLKM 1
-#else
-#define NLKM 0
-#endif
-
-#include "ksyms.h"
-#include "usb.h"
-#include "uhid.h"
-#include "ugen.h"
-#include "ulpt.h"
-#include "urio.h"
-#include "ucom.h"
-#include "uscanner.h"
-
-#include "inet.h"
-
-#include "wsmux.h"
-
-#ifdef USER_PCICONF
-#include "pci.h"
-cdev_decl(pci);
-#endif
-
-#include "audio.h"
-
-#include "pf.h"
-
-#include "systrace.h"
-
-#include "radio.h"
-#include "bktr.h"
-
-struct cdevsw cdevsw[] = {
- cdev_cn_init(1,cn), /* 0: virtual console */
- cdev_ctty_init(1,ctty), /* 1: controlling terminal */
- cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */
- cdev_swap_init(1,sw), /* 3: /dev/drum (swap pseudo-device) */
- cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */
- cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */
- cdev_log_init(1,log), /* 6: /dev/klog */
- cdev_tty_init(NCOM,com), /* 7: Serial ports */
- cdev_disk_init(NSD,sd), /* 8: SCSI disk */
- cdev_disk_init(NCD,cd), /* 9: SCSI CD-ROM */
- cdev_notdef(), /* 10: SCSI changer */
- cdev_disk_init(NWD,wd), /* 11: ST506/ESDI/IDE disk */
- cdev_notdef(), /* 12 */
- cdev_disk_init(NOFDISK,ofd), /* 13 Openfirmware disk */
- cdev_tty_init(NOFCONS,ofc), /* 14 Openfirmware console */
- cdev_notdef(), /* 15 */
- cdev_notdef(), /* 16 */
- cdev_disk_init(NRD,rd), /* 17 ram disk driver*/
- cdev_disk_init(NCCD,ccd), /* 18 concatenated disk driver */
- cdev_disk_init(NVND,vnd), /* 19: vnode disk */
- cdev_tape_init(NST,st), /* 20: SCSI tape */
- cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-dev */
- cdev_bpftun_init(NBPFILTER,bpf),/* 22: berkeley packet filter */
- cdev_bpftun_init(NTUN,tun), /* 23: network tunnel */
- cdev_lkm_init(NLKM,lkm), /* 24: loadable module driver */
- cdev_notdef(), /* 25: APM interface */
- cdev_notdef(), /* 26 */
- cdev_notdef(), /* 27 */
- cdev_notdef(), /* 28 */
- cdev_notdef(), /* 29 */
- cdev_notdef(), /* 30 */
- cdev_notdef(), /* 31 */
- cdev_notdef(), /* 32 */
- cdev_lkm_dummy(), /* 33 */
- cdev_lkm_dummy(), /* 34 */
- cdev_lkm_dummy(), /* 35 */
- cdev_lkm_dummy(), /* 36 */
- cdev_lkm_dummy(), /* 37 */
- cdev_lkm_dummy(), /* 38 */
- cdev_pf_init(NPF,pf), /* 39: packet filter */
- cdev_random_init(1,random), /* 40: random data source */
- cdev_uk_init(NUK,uk), /* 41: unknown SCSI */
- cdev_ss_init(NSS,ss), /* 42: SCSI scanner */
- cdev_ksyms_init(NKSYMS,ksyms), /* 43: Kernel symbols device */
- cdev_audio_init(NAUDIO,audio), /* 44: generic audio I/O */
- cdev_notdef(), /* 45 */
- cdev_notdef(), /* 46 */
- cdev_crypto_init(NCRYPTO,crypto), /* 47: /dev/crypto */
- cdev_notdef(), /* 48 */
- cdev_notdef(), /* 49 */
- cdev_systrace_init(NSYSTRACE,systrace), /* 50 system call tracing */
-#ifdef XFS
- cdev_xfs_init(NXFS,xfs_dev), /* 51: xfs communication device */
-#else
- cdev_notdef(), /* 51 */
-#endif
- cdev_notdef(), /* 52 */
- cdev_notdef(), /* 53 */
- cdev_disk_init(NRAID,raid), /* 54: RAIDframe disk driver */
- cdev_notdef(), /* 55 */
- /* The following slots are reserved for isdn4bsd. */
- cdev_notdef(), /* 56: i4b main device */
- cdev_notdef(), /* 57: i4b control device */
- cdev_notdef(), /* 58: i4b raw b-channel access */
- cdev_notdef(), /* 59: i4b trace device */
- cdev_notdef(), /* 60: i4b phone device */
- /* End of reserved slots for isdn4bsd. */
- cdev_usb_init(NUSB,usb), /* 61: USB controller */
- cdev_usbdev_init(NUHID,uhid), /* 62: USB generic HID */
- cdev_usbdev_init(NUGEN,ugen), /* 63: USB generic driver */
- cdev_ulpt_init(NULPT,ulpt), /* 64: USB printers */
- cdev_urio_init(NURIO,urio), /* 65: USB Diamond Rio 500 */
- cdev_tty_init(NUCOM,ucom), /* 66: USB tty */
- cdev_wsdisplay_init(NWSDISPLAY, /* 67: frame buffers, etc. */
- wsdisplay),
- cdev_mouse_init(NWSKBD, wskbd), /* 68: keyboards */
- cdev_mouse_init(NWSMOUSE, /* 69: mice */
- wsmouse),
- cdev_mouse_init(NWSMUX, wsmux), /* 70: ws multiplexor */
-#ifdef USER_PCICONF
- cdev_pci_init(NPCI,pci), /* 71: PCI user */
-#else
- cdev_notdef(),
-#endif
- cdev_notdef(), /* 72: ALTQ (deprecated) */
- cdev_iop_init(NIOP,iop), /* 73: I2O IOP control interface */
- cdev_usbdev_init(NUSCANNER,uscanner), /* 74: usb scanner */
- cdev_bktr_init(NBKTR,bktr), /* 75: Bt848 video capture device */
- cdev_radio_init(NRADIO, radio), /* 76: generic radio I/O */
- cdev_ptm_init(NPTY,ptm), /* 77: pseudo-tty ptm device */
-};
-int nchrdev = sizeof cdevsw / sizeof cdevsw[0];
-
-int mem_no = 2; /* major number of /dev/mem */
-
-/*
- * Swapdev is a fake device implemented in sw.c.
- * It is used only internally to get to swstrategy.
- */
-dev_t swapdev = makedev(1, 0);
-
-/*
- * Check whether dev is /dev/mem or /dev/kmem.
- */
-int
-iskmemdev(dev_t dev)
-{
- return major(dev) == mem_no && minor(dev) < 2;
-}
-
-/*
- * Check whether dev is /dev/zero.
- */
-int
-iszerodev(dev_t dev)
-{
- return major(dev) == mem_no && minor(dev) == 12;
-}
-
-dev_t
-getnulldev()
-{
- return makedev(mem_no, 2);
-}
-
-int chrtoblktbl[] = {
- /*VCHR*/ /*VBLK*/
- /* 0 */ NODEV,
- /* 1 */ NODEV,
- /* 2 */ NODEV,
- /* 3 */ NODEV,
- /* 4 */ NODEV,
- /* 5 */ NODEV,
- /* 6 */ NODEV,
- /* 7 */ NODEV,
- /* 8 */ 2,
- /* 9 */ NODEV,
- /* 10 */ NODEV,
- /* 11 */ 0,
- /* 12 */ NODEV,
- /* 13 */ 4,
- /* 14 */ NODEV,
- /* 15 */ NODEV,
- /* 16 */ NODEV,
- /* 17 */ 17,
- /* 18 */ NODEV,
- /* 19 */ NODEV,
- /* 20 */ NODEV,
- /* 21 */ NODEV,
- /* 22 */ NODEV,
- /* 23 */ NODEV,
- /* 24 */ NODEV,
- /* 25 */ NODEV,
- /* 26 */ NODEV,
- /* 27 */ NODEV,
- /* 28 */ NODEV,
- /* 29 */ NODEV,
- /* 30 */ NODEV,
- /* 31 */ NODEV,
- /* 32 */ NODEV,
- /* 33 */ NODEV,
- /* 34 */ NODEV,
- /* 35 */ NODEV,
- /* 36 */ NODEV,
- /* 37 */ NODEV,
- /* 38 */ NODEV,
- /* 39 */ NODEV,
- /* 40 */ NODEV,
- /* 41 */ NODEV,
- /* 42 */ NODEV,
- /* 43 */ NODEV,
- /* 44 */ NODEV,
- /* 45 */ NODEV,
- /* 46 */ NODEV,
- /* 47 */ NODEV,
- /* 48 */ NODEV,
- /* 49 */ NODEV,
- /* 50 */ NODEV,
- /* 51 */ NODEV,
- /* 52 */ NODEV,
- /* 53 */ NODEV,
- /* 54 */ 19,
-};
-int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
-
-#include <dev/cons.h>
-#include "vgafb_pci.h"
-
-cons_decl(ws);
-cons_decl(com);
-cons_decl(ofc);
-
-struct consdev constab[] = {
-#if NWSDISPLAY > 0
- cons_init(ws),
-#endif
-#if NCOM > 0
- cons_init(com),
-#endif
-#if NOFCONS > 0
- cons_init(ofc),
-#endif
- { 0 },
-};
diff --git a/sys/arch/pegasos/pegasos/cpu.c b/sys/arch/pegasos/pegasos/cpu.c
deleted file mode 100644
index 9c2b4bb62e2..00000000000
--- a/sys/arch/pegasos/pegasos/cpu.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/* $OpenBSD: cpu.c,v 1.4 2004/02/14 15:09:22 grange Exp $ */
-
-/*
- * Copyright (c) 1997 Per Fogelstrom
- * Copyright (c) 1997 RTMX Inc
- *
- * 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
- * North Carolina, USA, by Per Fogelstrom, Opsycon AB, Sweden.
- * 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/systm.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/device.h>
-
-#include <dev/ofw/openfirm.h>
-
-#include <machine/autoconf.h>
-
-#define MPC601 1
-#define MPC603 3
-#define MPC604 4
-#define MPC603e 6
-#define MPC603ev 7
-#define MPC750 8
-#define MPC604ev 9
-#define MPC7400 12
-#define IBM750FX 0x7000
-#define MPC7410 0x800c
-#define MPC7450 0x8000
-#define MPC7455 0x8001
-#define MPC7454 0x8002
-
-/* only valid on 603(e,ev) and G3, G4 */
-#define HID0_DOZE (1 << (31-8))
-#define HID0_NAP (1 << (31-9))
-#define HID0_SLEEP (1 << (31-10))
-#define HID0_DPM (1 << (31-11))
-#define HID0_SGE (1 << (31-24))
-#define HID0_BTIC (1 << (31-26))
-#define HID0_LRSTK (1 << (31-27))
-#define HID0_FOLD (1 << (31-28))
-#define HID0_BHT (1 << (31-29))
-
-/* L2CR bit definitions */
-#define L2CR_L2E 0x80000000 /* 0: L2 enable */
-#define L2CR_L2PE 0x40000000 /* 1: L2 data parity enable */
-#define L2CR_L2SIZ 0x30000000 /* 2-3: L2 size */
-#define L2SIZ_RESERVED 0x00000000
-#define L2SIZ_256K 0x10000000
-#define L2SIZ_512K 0x20000000
-#define L2SIZ_1M 0x30000000
-#define L2CR_L2CLK 0x0e000000 /* 4-6: L2 clock ratio */
-#define L2CLK_DIS 0x00000000 /* disable L2 clock */
-#define L2CLK_10 0x02000000 /* core clock / 1 */
-#define L2CLK_15 0x04000000 /* / 1.5 */
-#define L2CLK_20 0x08000000 /* / 2 */
-#define L2CLK_25 0x0a000000 /* / 2.5 */
-#define L2CLK_30 0x0c000000 /* / 3 */
-#define L2CR_L2RAM 0x01800000 /* 7-8: L2 RAM type */
-#define L2RAM_FLOWTHRU_BURST 0x00000000
-#define L2RAM_PIPELINE_BURST 0x01000000
-#define L2RAM_PIPELINE_LATE 0x01800000
-#define L2CR_L2DO 0x00400000 /* 9: L2 data-only.
- Setting this bit disables instruction
- caching. */
-#define L2CR_L2I 0x00200000 /* 10: L2 global invalidate. */
-#define L2CR_L2CTL 0x00100000 /* 11: L2 RAM control (ZZ enable).
- Enables automatic operation of the
- L2ZZ (low-power mode) signal. */
-#define L2CR_L2WT 0x00080000 /* 12: L2 write-through. */
-#define L2CR_L2TS 0x00040000 /* 13: L2 test support. */
-#define L2CR_L2OH 0x00030000 /* 14-15: L2 output hold. */
-#define L2CR_L2SL 0x00008000 /* 16: L2 DLL slow. */
-#define L2CR_L2DF 0x00004000 /* 17: L2 differential clock. */
-#define L2CR_L2BYP 0x00002000 /* 18: L2 DLL bypass. */
-#define L2CR_L2IP 0x00000001 /* 31: L2 global invalidate in progress
- (read only). */
-
-/* L3CR bit definitions */
-#define L3CR_L3E 0x80000000 /* 0: L3 enable */
-#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */
-
-#ifdef L2CR_CONFIG
-u_int l2cr_config = L2CR_CONFIG;
-#else
-u_int l2cr_config = 0;
-#endif
-
-char cpu_model[80];
-char machine[] = MACHINE; /* cpu architecture */
-
-/* Definition of the driver for autoconfig. */
-int cpumatch(struct device *, void *, void *);
-void cpuattach(struct device *, struct device *, void *);
-
-struct cfattach cpu_ca = {
- sizeof(struct device), cpumatch, cpuattach
-};
-
-struct cfdriver cpu_cd = {
- NULL, "cpu", DV_DULL, NULL, 0
-};
-
-void config_l2cr(int cpu);
-
-int
-cpumatch(parent, cfdata, aux)
- struct device *parent;
- void *cfdata;
- void *aux;
-{
- struct confargs *ca = aux;
-
- /* make sure that we're looking for a CPU. */
- if (strcmp(ca->ca_name, cpu_cd.cd_name) != 0)
- return (0);
-
- return (1);
-}
-
-static u_int32_t ppc_curfreq;
-
-
-int
-ppc_cpuspeed(int *freq)
-{
- *freq = ppc_curfreq;
-
- return (0);
-}
-
-
-void
-cpuattach(struct device *parent, struct device *dev, void *aux)
-{
- unsigned int cpu, pvr, hid0;
- char name[32];
- int qhandle, phandle;
- unsigned int clock_freq = 0;
-
- pvr = ppc_mfpvr();
- cpu = pvr >> 16;
- switch (cpu) {
- case MPC601:
- snprintf(cpu_model, sizeof(cpu_model), "601");
- break;
- case MPC603:
- snprintf(cpu_model, sizeof(cpu_model), "603");
- break;
- case MPC604:
- snprintf(cpu_model, sizeof(cpu_model), "604");
- break;
- case MPC603e:
- snprintf(cpu_model, sizeof(cpu_model), "603e");
- break;
- case MPC603ev:
- snprintf(cpu_model, sizeof(cpu_model), "603ev");
- break;
- case MPC750:
- snprintf(cpu_model, sizeof(cpu_model), "750");
- break;
- case MPC604ev:
- snprintf(cpu_model, sizeof(cpu_model), "604ev");
- break;
- case MPC7400:
- snprintf(cpu_model, sizeof(cpu_model), "7400");
- break;
- case IBM750FX:
- snprintf(cpu_model, sizeof(cpu_model), "750FX");
- break;
- case MPC7410:
- snprintf(cpu_model, sizeof(cpu_model), "7410");
- break;
- case MPC7450:
- if ((pvr & 0xf) < 3)
- snprintf(cpu_model, sizeof(cpu_model), "7450");
- else
- snprintf(cpu_model, sizeof(cpu_model), "7451");
- break;
- case MPC7454:
- snprintf(cpu_model, sizeof(cpu_model), "7454");
- break;
- case MPC7455:
- snprintf(cpu_model, sizeof(cpu_model), "7455");
- break;
- default:
- snprintf(cpu_model, sizeof(cpu_model), "Version %x", cpu);
- break;
- }
- snprintf(cpu_model + strlen(cpu_model),
- sizeof(cpu_model) - strlen(cpu_model),
- " (Revision %x)", pvr & 0xffff);
- printf(": %s", cpu_model);
-
- /* This should only be executed on openfirmware systems... */
-
- for (qhandle = OF_peer(0); qhandle; qhandle = phandle) {
- if (OF_getprop(qhandle, "device_type", name, sizeof name) >= 0
- && !strcmp(name, "cpu")
- && OF_getprop(qhandle, "clock-frequency",
- &clock_freq , sizeof clock_freq ) >= 0)
- {
- break;
- }
- if ((phandle = OF_child(qhandle)))
- continue;
- while (qhandle) {
- if ((phandle = OF_peer(qhandle)))
- break;
- qhandle = OF_parent(qhandle);
- }
- }
-
- if (clock_freq != 0) {
- /* Openfirmware stores clock in Hz, not MHz */
- clock_freq /= 1000000;
- printf(": %d MHz", clock_freq);
- ppc_curfreq = clock_freq;
- cpu_cpuspeed = ppc_cpuspeed;
- }
- /* power savings mode */
- hid0 = ppc_mfhid0();
- switch (cpu) {
- case MPC603:
- case MPC603e:
- case MPC750:
- case MPC7400:
- case IBM750FX:
- case MPC7410:
- /* select DOZE mode */
- hid0 &= ~(HID0_NAP | HID0_SLEEP);
- hid0 |= HID0_DOZE | HID0_DPM;
- break;
- case MPC7450:
- case MPC7454:
- case MPC7455:
- /* select NAP mode */
- hid0 &= ~(HID0_DOZE | HID0_SLEEP);
- hid0 |= HID0_NAP | HID0_DPM;
- /* try some other flags */
- hid0 |= HID0_SGE | HID0_BTIC;
- hid0 |= HID0_LRSTK | HID0_FOLD | HID0_BHT;
- /* Disable BTIC on 7450 Rev 2.0 or earlier */
- if (cpu == MPC7450 && (pvr & 0xffff) < 0x0200)
- hid0 &= ~HID0_BTIC;
- break;
- }
- ppc_mthid0(hid0);
-
- /* if processor is G3 or G4, configure l2 cache */
- if ( (cpu == MPC750) || (cpu == MPC7400) || (cpu == IBM750FX)
- || (cpu == MPC7410) || (cpu == MPC7450) || (cpu == MPC7454)
- || (cpu == MPC7455)) {
- /* Pegasos doesn't configure L2 in OF,
- * should enable it's size based on OF values, not
- * this G3/G4 switch
- */
- switch (cpu) {
- case MPC750:
- l2cr_config = L2CR_L2E|L2SIZ_512K;
- break;
- case MPC7454:
- l2cr_config = L2CR_L2E|L2SIZ_256K;
- break;
- default:
- ;
- }
- config_l2cr(cpu);
- }
- printf("\n");
-
-
-}
-
-
-void
-config_l2cr(int cpu)
-{
- u_int l2cr, x;
-
- l2cr = ppc_mfl2cr();
-
- /*
- * Configure L2 cache if not enabled.
- */
- if ((l2cr & L2CR_L2E) == 0 && l2cr_config != 0) {
- l2cr = l2cr_config & ~L2CR_L2E;
- __asm __volatile ("sync");
- ppc_mtl2cr(l2cr);
- __asm __volatile ("sync");
-
- /* Wait for L2 clock to be stable (640 L2 clocks). */
- delay(100);
-
- /* Invalidate all L2 contents. */
- l2cr |= L2CR_L2I;
- ppc_mtl2cr(l2cr);
- do {
- x = ppc_mfl2cr();
- } while (x & L2CR_L2IP);
-
- /* Enable L2 cache. */
- l2cr &= ~L2CR_L2I;
- l2cr |= L2CR_L2E;
- ppc_mtl2cr(l2cr);
- }
-
- if (l2cr & L2CR_L2E) {
- if (cpu == MPC7450 || cpu == MPC7454 || cpu == MPC7455) {
- u_int l3cr;
-
- printf(": 256KB L2 cache");
-
- l3cr = ppc_mfl3cr();
- if (l3cr & L3CR_L3E)
- printf(", %cMB L3 cache",
- l3cr & L3CR_L3SIZ ? '2' : '1');
- } else if (cpu == IBM750FX)
- printf(": 512KB L2 cache");
- else {
- switch (l2cr & L2CR_L2SIZ) {
- case L2SIZ_256K:
- printf(": 256KB");
- break;
- case L2SIZ_512K:
- printf(": 512KB");
- break;
- case L2SIZ_1M:
- printf(": 1MB");
- break;
- default:
- printf(": unknown size");
- }
- printf(" backside cache");
- }
-#if 0
- switch (l2cr & L2CR_L2RAM) {
- case L2RAM_FLOWTHRU_BURST:
- printf(" Flow-through synchronous burst SRAM");
- break;
- case L2RAM_PIPELINE_BURST:
- printf(" Pipelined synchronous burst SRAM");
- break;
- case L2RAM_PIPELINE_LATE:
- printf(" Pipelined synchronous late-write SRAM");
- break;
- default:
- printf(" unknown type");
- }
-
- if (l2cr & L2CR_L2PE)
- printf(" with parity");
-#endif
- } else
- printf(": L2 cache not enabled");
-}
diff --git a/sys/arch/pegasos/pegasos/db_interface.c b/sys/arch/pegasos/pegasos/db_interface.c
deleted file mode 100644
index bf3aabe5213..00000000000
--- a/sys/arch/pegasos/pegasos/db_interface.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $OpenBSD: db_interface.c,v 1.1 2003/10/31 03:54:33 drahn Exp $ */
-/* $NetBSD: db_interface.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-
-#include <dev/cons.h>
-
-#include <machine/db_machdep.h>
-#include <ddb/db_extern.h>
-
-int ddb_trap_glue(struct trapframe *frame); /* called from locore */
-
-void
-Debugger()
-{
- ddb_trap();
-}
-
-int
-ddb_trap_glue(struct trapframe *frame)
-{
- if (!(frame->srr1 & PSL_PR)
- && (frame->exc == EXC_TRC
- || (frame->exc == EXC_PGM && (frame->srr1 & 0x20000))
- || frame->exc == EXC_BPT)) {
-
- bcopy(frame->fixreg, DDB_REGS->tf.fixreg,
- 32 * sizeof(u_int32_t));
- DDB_REGS->tf.srr0 = frame->srr0;
- DDB_REGS->tf.srr1 = frame->srr1;
-
- cnpollc(TRUE);
- db_trap(T_BREAKPOINT, 0);
- cnpollc(FALSE);
-
- bcopy(DDB_REGS->tf.fixreg, frame->fixreg,
- 32 * sizeof(u_int32_t));
-
- return 1;
- }
- return 0;
-}
diff --git a/sys/arch/pegasos/pegasos/disksubr.c b/sys/arch/pegasos/pegasos/disksubr.c
deleted file mode 100644
index 4802d37c1ef..00000000000
--- a/sys/arch/pegasos/pegasos/disksubr.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/* $OpenBSD: disksubr.c,v 1.3 2004/03/17 14:16:04 miod Exp $ */
-/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
-
-/*
- * Copyright (c) 1996 Theo de Raadt
- * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
- * 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. Neither the name of the University 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 REGENTS 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.
- *
- * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/disklabel.h>
-#include <sys/syslog.h>
-#include <sys/disk.h>
-
-#define b_cylin b_resid
-
-void
-dk_establish(struct disk *dk, struct device *dev)
-{
-}
-
-int
-try_rdb_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff);
-int
-try_hfs_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff);
-int
-try_mbr_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff);
-
-
-/*
- * Attempt to read a disk label from a device
- * using the indicated strategy routine.
- * The label must be partly set up before this:
- * secpercyl, secsize and anything required for a block i/o read
- * operation in the driver's strategy/start routines
- * must be filled in before calling us.
- *
- * Returns null on success and an error string on failure.
- */
-char *
-readdisklabel(dev_t dev, void (*strat)(struct buf *),
- struct disklabel *lp, struct cpu_disklabel *osdep, int spoofonly)
-{
- struct dkbad *bdp = &DKBAD(osdep);
- struct buf *bp;
- struct disklabel *dlp;
- char *msg = NULL;
- int partoff, i, found;
-
- /* minimal requirements for archtypal disk label */
- if (lp->d_secsize < DEV_BSIZE)
- lp->d_secsize = DEV_BSIZE;
- if (lp->d_secperunit == 0)
- lp->d_secperunit = 0x1fffffff;
- lp->d_npartitions = RAW_PART + 1;
- for (i = 0; i < RAW_PART; i++) {
- lp->d_partitions[i].p_size = 0;
- lp->d_partitions[i].p_offset = 0;
- }
- if (lp->d_partitions[i].p_size == 0)
- lp->d_partitions[i].p_size = 0x1fffffff;
- lp->d_partitions[i].p_offset = 0;
-
- /* get a buffer and initialize it */
- bp = geteblk((int)lp->d_secsize);
- bp->b_dev = dev;
-
- partoff = -1;
-
- /* try hfs */
- found = try_hfs_label(dev, strat, bp, lp, osdep, &msg, &partoff);
- /* if no hfs or mbr, try rdb */
- if (found == 0)
- found = try_rdb_label(dev, strat, bp, lp, osdep, &msg,
- &partoff);
- /* if no hfs, try mbr */
- if (found == 0)
- found = try_mbr_label(dev, strat, bp, lp, osdep, &msg,
- &partoff);
- /* if no partition found, return */
- if (found == 0 || partoff == -1) {
- /* no special partition table found try raw labeled disk. */
- partoff = LABELSECTOR;
- }
-
- /* don't read the on-disk label if we are in spoofed-only mode */
- if (spoofonly)
- goto done;
-
- /* next, dig out disk label */
- bp->b_blkno = partoff;
- bp->b_cylin = partoff/lp->d_secpercyl; /* XXX */
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- (*strat)(bp);
-
- /* if successful, locate disk label within block and validate */
- if (biowait(bp)) {
- /* XXX we return the faked label built so far */
- msg = "disk label I/O error";
- goto done;
- }
-
- for (dlp = (struct disklabel *)bp->b_data;
- dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize -
- sizeof(*dlp));
- dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
- if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
- if (msg == NULL)
- msg = "no disk label";
- } else if (dlp->d_npartitions > MAXPARTITIONS ||
- dkcksum(dlp) != 0)
- msg = "disk label corrupted";
- else {
- *lp = *dlp;
- msg = NULL;
- break;
- }
- }
-
- if (msg) {
-#if defined(CD9660)
- if (iso_disklabelspoof(dev, strat, lp) == 0)
- msg = NULL;
-#endif
- goto done;
- }
-
- /* obtain bad sector table if requested and present */
- if (bdp && (lp->d_flags & D_BADSECT)) {
- struct dkbad *db;
-
- i = 0;
- do {
- /* read a bad sector table */
- bp->b_flags = B_BUSY | B_READ;
- bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i;
- if (lp->d_secsize > DEV_BSIZE)
- bp->b_blkno *= lp->d_secsize / DEV_BSIZE;
- else
- bp->b_blkno /= DEV_BSIZE / lp->d_secsize;
- bp->b_bcount = lp->d_secsize;
- bp->b_cylin = lp->d_ncylinders - 1;
- (*strat)(bp);
-
- /* if successful, validate, otherwise try another */
- if (biowait(bp)) {
- msg = "bad sector table I/O error";
- } else {
- db = (struct dkbad *)(bp->b_data);
-#define DKBAD_MAGIC 0x4321
- if (db->bt_mbz == 0
- && db->bt_flag == DKBAD_MAGIC) {
- msg = NULL;
- *bdp = *db;
- break;
- } else
- msg = "bad sector table corrupted";
- }
- } while ((bp->b_flags & B_ERROR) && (i += 2) < 10 &&
- i < lp->d_nsectors);
- }
-
-done:
- bp->b_flags |= B_INVAL;
- brelse(bp);
- return (msg);
-}
-
-/*
- * Check new disk label for sensibility
- * before setting it.
- */
-int
-setdisklabel(struct disklabel *olp, struct disklabel *nlp, u_long openmask,
- struct cpu_disklabel *osdep)
-{
- int i;
- struct partition *opp, *npp;
-
- /* sanity clause */
- if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
- (nlp->d_secsize % DEV_BSIZE) != 0)
- return(EINVAL);
-
- /* special case to allow disklabel to be invalidated */
- if (nlp->d_magic == 0xffffffff) {
- *olp = *nlp;
- return (0);
- }
-
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
-
- /* XXX missing check if other dos partitions will be overwritten */
-
- while (openmask != 0) {
- i = ffs(openmask) - 1;
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
- return (EBUSY);
- /*
- * Copy internally-set partition information
- * if new label doesn't include it. XXX
- */
- if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
- npp->p_fstype = opp->p_fstype;
- npp->p_fsize = opp->p_fsize;
- npp->p_frag = opp->p_frag;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
-
-
-/*
- * Write disk label back to device after modification.
- * XXX cannot handle OpenBSD partitions in extended partitions!
- */
-int
-writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
- struct cpu_disklabel *osdep)
-{
- struct dos_partition *dp = osdep->dosparts, *dp2;
- struct buf *bp;
- struct disklabel *dlp;
- int error, dospartoff, cyl, i;
- int ourpart = -1;
-
- /* get a buffer and initialize it */
- bp = geteblk((int)lp->d_secsize);
- bp->b_dev = dev;
-
- /* try DPME partition */
- if (osdep->macparts[0].pmSig == PART_ENTRY_MAGIC) {
- /* only write if a valid "OpenBSD" partition type exists */
- if (osdep->macparts[1].pmSig == PART_ENTRY_MAGIC) {
- bp->b_blkno = osdep->macparts[1].pmPyPartStart;
- bp->b_cylin = bp->b_blkno/lp->d_secpercyl;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_WRITE;
- *(struct disklabel *)bp->b_data = *lp;
- (*strat)(bp);
- error = biowait(bp);
- goto done;
- }
-
- /* SHOULD FAIL TO WRITE LABEL IF VALID HFS partition exists
- * and no OpenBSD partition exists
- */
- error = 1; /* EPERM? */
- goto done;
- }
-
- /* label RDB disk */
- if (osdep->rd_bsdlbl != 0) {
- /* we have a location for the BSD label */
- /* Really need to add some validation code here */
- bp->b_blkno = osdep->rd_bsdlbl;
- bp->b_cylin = bp->b_blkno/lp->d_secpercyl;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_WRITE;
- *(struct disklabel *)bp->b_data = *lp;
- (*strat)(bp);
- error = biowait(bp);
- goto done;
- }
-
-
- /* do dos partitions in the process of getting disklabel? */
- dospartoff = 0;
- cyl = LABELSECTOR / lp->d_secpercyl;
- if (dp) {
- /* read master boot record */
- bp->b_blkno = DOSBBSECTOR;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
- (*strat)(bp);
-
- if ((error = biowait(bp)) != 0)
- goto done;
-
- /* XXX how do we check veracity/bounds of this? */
- bcopy(bp->b_data + DOSPARTOFF, dp,
- NDOSPART * sizeof(*dp));
-
- for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++)
- if (get_le(&dp2->dp_size) && dp2->dp_typ ==
- DOSPTYP_OPENBSD)
- ourpart = i;
- for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++)
- if (get_le(&dp2->dp_size) && dp2->dp_typ ==
- DOSPTYP_FREEBSD)
- ourpart = i;
- for (dp2=dp, i=0; i < NDOSPART && ourpart == -1; i++, dp2++)
- if (get_le(&dp2->dp_size) && dp2->dp_typ ==
- DOSPTYP_NETBSD)
- ourpart = i;
-
- if (ourpart != -1) {
- dp2 = &dp[ourpart];
-
- /*
- * need sector address for SCSI/IDE,
- * cylinder for ESDI/ST506/RLL
- */
- dospartoff = get_le(&dp2->dp_start);
- cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
- }
- }
-
- /* next, dig out disk label */
- bp->b_blkno = dospartoff + LABELSECTOR;
- bp->b_cylin = cyl;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- (*strat)(bp);
-
- /* if successful, locate disk label within block and validate */
- if ((error = biowait(bp)) != 0)
- goto done;
- for (dlp = (struct disklabel *)bp->b_data;
- dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize -
- sizeof(*dlp));
- dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
- if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
- dkcksum(dlp) == 0) {
- *dlp = *lp;
- bp->b_flags = B_BUSY | B_WRITE;
- (*strat)(bp);
- error = biowait(bp);
- goto done;
- }
- }
-
- /* Write it in the regular place. */
- *(struct disklabel *)bp->b_data = *lp;
- bp->b_flags = B_BUSY | B_WRITE;
- (*strat)(bp);
- error = biowait(bp);
- goto done;
-
-done:
- bp->b_flags |= B_INVAL;
- brelse(bp);
- return (error);
-}
-
-/*
- * Determine the size of the transfer, and make sure it is
- * within the boundaries of the partition. Adjust transfer
- * if needed, and signal errors or early completion.
- */
-int
-bounds_check_with_label(struct buf *bp, struct disklabel *lp,
- struct cpu_disklabel *osdep, int wlabel)
-{
-#define blockpersec(count, lp) ((count) * (((lp)->d_secsize) / DEV_BSIZE))
- struct partition *p = lp->d_partitions + DISKPART(bp->b_dev);
- int labelsector = blockpersec(lp->d_partitions[RAW_PART].p_offset, lp) +
- LABELSECTOR;
- int sz = howmany(bp->b_bcount, DEV_BSIZE);
-
- /* avoid division by zero */
- if (lp->d_secpercyl == 0) {
- bp->b_error = EINVAL;
- goto bad;
- }
-
- if (bp->b_blkno + sz > blockpersec(p->p_size, lp)) {
- sz = blockpersec(p->p_size, lp) - bp->b_blkno;
- if (sz == 0) {
- /* If exactly at end of disk, return EOF. */
- bp->b_resid = bp->b_bcount;
- goto done;
- }
- if (sz < 0) {
- /* If past end of disk, return EINVAL. */
- bp->b_error = EINVAL;
- goto bad;
- }
- /* Otherwise, truncate request. */
- bp->b_bcount = sz << DEV_BSHIFT;
- }
-
- /* Overwriting disk label? */
- if (bp->b_blkno + blockpersec(p->p_offset, lp) <= labelsector &&
-#if LABELSECTOR != 0
- bp->b_blkno + blockpersec(p->p_offset, lp) + sz > labelsector &&
-#endif
- (bp->b_flags & B_READ) == 0 && !wlabel) {
- bp->b_error = EROFS;
- goto bad;
- }
-
- /* calculate cylinder for disksort to order transfers with */
- bp->b_cylin = (bp->b_blkno + blockpersec(p->p_offset, lp)) /
- lp->d_secpercyl;
- return (1);
-
-bad:
- bp->b_flags |= B_ERROR;
-done:
- return (0);
-}
diff --git a/sys/arch/pegasos/pegasos/dma.c b/sys/arch/pegasos/pegasos/dma.c
deleted file mode 100644
index 22fc5642fef..00000000000
--- a/sys/arch/pegasos/pegasos/dma.c
+++ /dev/null
@@ -1,601 +0,0 @@
-/* $OpenBSD: dma.c,v 1.3 2004/02/04 20:07:18 drahn Exp $ */
-/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 FOUNDATION 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/param.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/extent.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/file.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/mount.h>
-
-#include <uvm/uvm.h>
-#include <uvm/uvm_page.h>
-
-#include <machine/bus.h>
-int _dmamem_alloc_range( bus_dma_tag_t t, bus_size_t size,
- bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs,
- int nsegs, int *rsegs, int flags, vm_offset_t low, vm_offset_t high);
-int _dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,
- struct proc *, int, bus_addr_t *, int *, int);
-/*
- * Common function for DMA map creation. May be called by bus-specific
- * DMA map creation functions.
- */
-int
-_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
- bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
-{
- struct powerpc_bus_dmamap *map;
- void *mapstore;
- size_t mapsize;
-
- /*
- * Allocate and initialize the DMA map. The end of the map
- * is a variable-sized array of segments, so we allocate enough
- * room for them in one shot.
- *
- * Note we don't preserve the WAITOK or NOWAIT flags. Preservation
- * of ALLOCNOW notifies others that we've reserved these resources,
- * and they are not to be freed.
- *
- * The bus_dmamap_t includes one bus_dma_segment_t, hence
- * the (nsegments - 1).
- */
- mapsize = sizeof(struct powerpc_bus_dmamap) +
- (sizeof(bus_dma_segment_t) * (nsegments - 1));
- if ((mapstore = malloc(mapsize, M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
- return (ENOMEM);
-
- bzero(mapstore, mapsize);
- map = (struct powerpc_bus_dmamap *)mapstore;
- map->_dm_size = size;
- map->_dm_segcnt = nsegments;
- map->_dm_maxsegsz = maxsegsz;
- map->_dm_boundary = boundary;
- map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
- map->dm_nsegs = 0; /* no valid mappings */
- map->dm_mapsize = 0;
-
- *dmamp = map;
- return (0);
-}
-
-/*
- * Common function for DMA map destruction. May be called by bus-specific
- * DMA map destruction functions.
- */
-void
-_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)
-{
-
- free(map, M_DEVBUF);
-}
-
-
-int
-_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
- bus_size_t buflen, struct proc *p, int flags, bus_addr_t *lastaddrp,
- int *segp, int first)
-{
- bus_size_t sgsize;
- bus_addr_t curaddr, lastaddr, baddr, bmask;
- vaddr_t vaddr = (vaddr_t)buf;
- pmap_t pmap;
- int seg;
-
- lastaddr = *lastaddrp;
- bmask = ~(map->_dm_boundary - 1);
-
- if (p != NULL)
- pmap = p->p_vmspace->vm_map.pmap;
- else
- pmap = pmap_kernel();
-
- for (seg = *segp; buflen > 0; ) {
- /*
- * Get the physical address for this segment.
- */
- if (pmap_extract(pmap, vaddr, (paddr_t *)&curaddr) != TRUE) {
- panic("dmamap_load_buffer pmap %p vaddr %lx "
- "pmap_extract failed", pmap, vaddr);
- }
-
- /*
- * Compute the segment size, and adjust counts.
- */
- sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
- if (buflen < sgsize)
- sgsize = buflen;
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (map->_dm_boundary > 0) {
- baddr = (curaddr + map->_dm_boundary) & bmask;
- if (sgsize > (baddr - curaddr))
- sgsize = (baddr - curaddr);
- }
-
- /*
- * Insert chunk into a segment, coalescing with the
- * previous segment if possible.
- */
- if (first) {
- map->dm_segs[seg].ds_addr = curaddr;
- map->dm_segs[seg].ds_len = sgsize;
- first = 0;
- } else {
- if (curaddr == lastaddr &&
- (map->dm_segs[seg].ds_len + sgsize) <=
- map->_dm_maxsegsz &&
- (map->_dm_boundary == 0 ||
- (map->dm_segs[seg].ds_addr & bmask) ==
- (curaddr & bmask)))
- map->dm_segs[seg].ds_len += sgsize;
- else {
- if (++seg >= map->_dm_segcnt)
- break;
- map->dm_segs[seg].ds_addr = curaddr;
- map->dm_segs[seg].ds_len = sgsize;
- }
- }
-
- lastaddr = curaddr + sgsize;
- vaddr += sgsize;
- buflen -= sgsize;
- }
-
- *segp = seg;
- *lastaddrp = lastaddr;
-
- /*
- * Did we fit?
- */
- if (buflen != 0)
- return (EFBIG); /* XX better return value here? */
-
- return (0);
-}
-
-/*
- * Common function for loading a DMA map with a linear buffer. May
- * be called by bus-specific DMA map load functions.
- */
-int
-_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen,
- struct proc *p, int flags)
-{
- bus_addr_t lastaddr;
- int seg, error;
-
- /*
- * Make sure that on error condition we return "no valid mappings".
- */
- map->dm_mapsize = 0;
- map->dm_nsegs = 0;
-
- if (buflen > map->_dm_size)
- return (EINVAL);
-
- seg = 0;
- error = _dmamap_load_buffer(t, map, buf, buflen, p, flags,
- &lastaddr, &seg, 1);
- if (error == 0) {
- map->dm_mapsize = buflen;
- map->dm_nsegs = seg + 1;
- }
- return (error);
-}
-
-/*
- * Like _bus_dmamap_load(), but for mbufs.
- */
-int
-_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
- int flags)
-{
- bus_addr_t lastaddr;
- int seg, error, first;
- struct mbuf *m;
-
- /*
- * Make sure that on error condition we return "no valid mappings".
- */
- map->dm_mapsize = 0;
- map->dm_nsegs = 0;
-
-#ifdef DIAGNOSTIC
- if ((m0->m_flags & M_PKTHDR) == 0)
- panic("_bus_dmamap_load_mbuf: no packet header");
-#endif
-
- if (m0->m_pkthdr.len > map->_dm_size)
- return (EINVAL);
-
- first = 1;
- seg = 0;
- error = 0;
- for (m = m0; m != NULL && error == 0; m = m->m_next) {
- error = _dmamap_load_buffer(t, map, m->m_data, m->m_len,
- NULL, flags, &lastaddr, &seg, first);
- first = 0;
- }
- if (error == 0) {
- map->dm_mapsize = m0->m_pkthdr.len;
- map->dm_nsegs = seg + 1;
- }
- return (error);
-}
-
-/*
- * Like _bus_dmamap_load(), but for uios.
- */
-int
-_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio, int flags)
-{
- bus_addr_t lastaddr;
- int seg, i, error, first;
- bus_size_t minlen, resid;
- struct proc *p = NULL;
- struct iovec *iov;
- caddr_t addr;
-
- /*
- * Make sure that on error condition we return "no valid mappings".
- */
- map->dm_mapsize = 0;
- map->dm_nsegs = 0;
-
- resid = uio->uio_resid;
- iov = uio->uio_iov;
-
- if (resid > map->_dm_size)
- return (EINVAL);
-
- if (uio->uio_segflg == UIO_USERSPACE) {
- p = uio->uio_procp;
-#ifdef DIAGNOSTIC
- if (p == NULL)
- panic("_bus_dmamap_load_uio: USERSPACE but no proc");
-#endif
- }
-
- first = 1;
- seg = 0;
- error = 0;
- for (i = 0; i < uio->uio_iovcnt && resid != 0 && error == 0; i++) {
- /*
- * Now at the first iovec to load. Load each iovec
- * until we have exhausted the residual count.
- */
- minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len;
- addr = (caddr_t)iov[i].iov_base;
-
- error = _dmamap_load_buffer(t, map, addr, minlen,
- p, flags, &lastaddr, &seg, first);
- first = 0;
-
- resid -= minlen;
- }
- if (error == 0) {
- map->dm_mapsize = uio->uio_resid;
- map->dm_nsegs = seg + 1;
- }
- return (error);
-}
-
-/*
- * Like _bus_dmamap_load(), but for raw memory allocated with
- * bus_dmamem_alloc().
- */
-int
-_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs,
- int nsegs, bus_size_t size, int flags)
-{
- if (nsegs > map->_dm_segcnt || size > map->_dm_size)
- return (EINVAL);
-
- /*
- * Make sure we don't cross any boundaries.
- */
- if (map->_dm_boundary) {
- bus_addr_t bmask = ~(map->_dm_boundary - 1);
- int i;
-
- for (i = 0; i < nsegs; i++) {
- if (segs[i].ds_len > map->_dm_maxsegsz)
- return (EINVAL);
- if ((segs[i].ds_addr & bmask) !=
- ((segs[i].ds_addr + segs[i].ds_len - 1) & bmask))
- return (EINVAL);
- }
- }
-
- bcopy(segs, map->dm_segs, nsegs * sizeof(*segs));
- map->dm_nsegs = nsegs;
- map->dm_mapsize = size;
- return (0);
-}
-
-/*
- * Common function for unloading a DMA map. May be called by
- * bus-specific DMA map unload functions.
- */
-void
-_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map)
-{
-
- /*
- * No resources to free; just mark the mappings as
- * invalid.
- */
- map->dm_nsegs = 0;
- map->dm_mapsize = 0;
-}
-
-/*
- * Common function for DMA map synchronization. May be called
- * by bus-specific DMA map synchronization functions.
- */
-void
-_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
-bus_size_t len, int op)
-{
- vaddr_t p;
- int l;
- int i;
- extern int pegasos; /* XXX */
-
- /*
- * pegasos 1 (april1) needs to sync before dma from memory to
- * disk drives snooping broken?
- */
-
- /* only flush before DMA to drive */
- if ((pegasos != 0) || (op & BUS_DMASYNC_PREWRITE) == 0)
- return;
-
- for (i = 0; i < map->dm_nsegs; i++) {
- /* flush (not invalidate?) the cache */
-
- p = map->dm_segs[i].ds_addr;
- l = map->dm_segs[i].ds_len;
- do {
- __asm__ __volatile__ ("dcbst 0,%0" :: "r"(p));
- p += CACHELINESIZE;
- } while ((l -= CACHELINESIZE) > 0);
- }
-}
-
-/*
- * Common function for DMA-safe memory allocation. May be called
- * by bus-specific DMA memory allocation functions.
- */
-int
-_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
- bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
- int flags)
-{
- return (_dmamem_alloc_range(t, size, alignment, boundary,
- segs, nsegs, rsegs, flags, 0, 0xf0000000));
-}
-
-/*
- * Common function for freeing DMA-safe memory. May be called by
- * bus-specific DMA memory free functions.
- */
-void
-_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
-{
- struct vm_page *m;
- bus_addr_t addr;
- struct pglist mlist;
- int curseg;
-
- /*
- * Build a list of pages to free back to the VM system.
- */
- TAILQ_INIT(&mlist);
- for (curseg = 0; curseg < nsegs; curseg++) {
- for (addr = segs[curseg].ds_addr;
- addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
- addr += PAGE_SIZE) {
- m = PHYS_TO_VM_PAGE(addr);
- TAILQ_INSERT_TAIL(&mlist, m, pageq);
- }
- }
-
- uvm_pglistfree(&mlist);
-}
-
-/*
- * Common function for mapping DMA-safe memory. May be called by
- * bus-specific DMA memory map functions.
- */
-int
-_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
- caddr_t *kvap, int flags)
-{
- vm_offset_t va;
- bus_addr_t addr;
- int curseg;
-
- size = round_page(size);
- va = uvm_km_valloc(kernel_map, size);
- if (va == 0)
- return (ENOMEM);
-
- *kvap = (caddr_t)va;
-
- for (curseg = 0; curseg < nsegs; curseg++) {
- for (addr = segs[curseg].ds_addr;
- addr < (segs[curseg].ds_addr + segs[curseg].ds_len);
- addr += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) {
- if (size == 0)
- panic("_bus_dmamem_map: size botch");
- pmap_enter(pmap_kernel(), va, addr,
- VM_PROT_READ | VM_PROT_WRITE,
- VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
- }
- }
- pmap_update(pmap_kernel());
-
- return (0);
-}
-
-/*
- * Common function for unmapping DMA-safe memory. May be called by
- * bus-specific DMA memory unmapping functions.
- */
-void
-_dmamem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
-{
-
-#ifdef DIAGNOSTIC
- if ((u_long)kva & PGOFSET)
- panic("_bus_dmamem_unmap");
-#endif
-
- size = round_page(size);
- uvm_km_free(kernel_map, (vm_offset_t)kva, size);
-}
-
-/*
- * Common functin for mmap(2)'ing DMA-safe memory. May be called by
- * bus-specific DMA mmap(2)'ing functions.
- */
-paddr_t
-_dmamem_mmap(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, off_t off,
- int prot, int flags)
-{
- int i;
-
- for (i = 0; i < nsegs; i++) {
-#ifdef DIAGNOSTIC
- if (off & PGOFSET)
- panic("_bus_dmamem_mmap: offset unaligned");
- if (segs[i].ds_addr & PGOFSET)
- panic("_bus_dmamem_mmap: segment unaligned");
- if (segs[i].ds_len & PGOFSET)
- panic("_bus_dmamem_mmap: segment size not multiple"
- " of page size");
-#endif
- if (off >= segs[i].ds_len) {
- off -= segs[i].ds_len;
- continue;
- }
-
- return (powerpc_btop((caddr_t)segs[i].ds_addr + off));
- }
-
- /* Page not found. */
- return (-1);
-}
-
-/**********************************************************************
- * DMA utility functions
- **********************************************************************/
-
-/*
- * Allocate physical memory from the given physical address range.
- * Called by DMA-safe memory allocation methods.
- */
-int
-_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
- bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
- int flags, vm_offset_t low, vm_offset_t high)
-{
- vm_offset_t curaddr, lastaddr;
- struct vm_page *m;
- struct pglist mlist;
- int curseg, error;
-
- /* Always round the size. */
- size = round_page(size);
-
- /*
- * Allocate pages from the VM system.
- */
- TAILQ_INIT(&mlist);
- error = uvm_pglistalloc(size, low, high,
- alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
- if (error)
- return (error);
-
- /*
- * Compute the location, size, and number of segments actually
- * returned by the VM code.
- */
- m = TAILQ_FIRST(&mlist);
- curseg = 0;
- lastaddr = segs[curseg].ds_addr = VM_PAGE_TO_PHYS(m);
- segs[curseg].ds_len = PAGE_SIZE;
- m = TAILQ_NEXT(m, pageq);
-
- for (; m != NULL; m = TAILQ_NEXT(m, pageq)) {
- curaddr = VM_PAGE_TO_PHYS(m);
-#ifdef DIAGNOSTIC
- if (curaddr < low || curaddr >= high) {
- printf("vm_page_alloc_memory returned non-sensical"
- " address 0x%lx\n", curaddr);
- panic("dmamem_alloc_range");
- }
-#endif
- if (curaddr == (lastaddr + PAGE_SIZE))
- segs[curseg].ds_len += PAGE_SIZE;
- else {
- curseg++;
- segs[curseg].ds_addr = curaddr;
- segs[curseg].ds_len = PAGE_SIZE;
- }
- lastaddr = curaddr;
- }
-
- *rsegs = curseg + 1;
-
- return (0);
-}
diff --git a/sys/arch/pegasos/pegasos/genassym.cf b/sys/arch/pegasos/pegasos/genassym.cf
deleted file mode 100644
index 6c6a0f119ba..00000000000
--- a/sys/arch/pegasos/pegasos/genassym.cf
+++ /dev/null
@@ -1,73 +0,0 @@
-# $OpenBSD: genassym.cf,v 1.1 2003/10/31 03:54:33 drahn Exp $
-#
-# Copyright (c) 1982, 1990 The Regents of the University of California.
-# 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. Neither the name of the University 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 REGENTS 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.
-#
-# @(#)genassym.c 7.8 (Berkeley) 5/7/91
-#
-
-include <sys/param.h>
-include <sys/time.h>
-include <sys/proc.h>
-include <uvm/uvm_extern.h>
-
-include <machine/pcb.h>
-include <machine/pmap.h>
-
-export FRAMELEN
-struct trapframe FRAME_
-member 0 fixreg[0]
-member 1 fixreg[1]
-member 2 fixreg[2]
-member 3 fixreg[3]
-member lr
-member cr
-member ctr
-member xer
-member srr0
-member srr1
-member dar
-member dsisr
-member exc
-
-define SFRAMELEN roundup(sizeof(struct switchframe), 16)
-
-struct pcb
-member PCB_PMR pcb_pmreal
-member pcb_sp
-member pcb_spl
-member PCB_FAULT pcb_onfault
-
-struct pmap
-member PM_SR pm_sr[0]
-member PM_USRSR pm_sr[USER_SR]
-member PM_KERNELSR pm_sr[KERNEL_SR]
-
-struct proc
-member p_forw
-member p_back
-member p_addr
diff --git a/sys/arch/pegasos/pegasos/hfsdisksubr.c b/sys/arch/pegasos/pegasos/hfsdisksubr.c
deleted file mode 100644
index 39e26d85588..00000000000
--- a/sys/arch/pegasos/pegasos/hfsdisksubr.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* $OpenBSD: hfsdisksubr.c,v 1.1 2003/11/13 23:00:55 drahn Exp $ */
-/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
-
-/*
- * Copyright (c) 1996 Theo de Raadt
- * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
- * 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. Neither the name of the University 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 REGENTS 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.
- *
- * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/disklabel.h>
-#include <sys/syslog.h>
-#include <sys/disk.h>
-
-#define b_cylin b_resid
-
-int
-try_hfs_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff);
-
-int
-try_hfs_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff)
-{
- int part_cnt, n, i;
- struct part_map_entry *part;
- int hfspartoff = -1;
- char *s;
-
- bp->b_blkno = 1;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- bp->b_cylin = 1 / lp->d_secpercyl;
- (*strat)(bp);
-
- /* if successful, wander through DPME partition table */
- if (biowait(bp)) {
- *pmsg = "DPME partition I/O error";
- return 0;
- }
-
- part = (struct part_map_entry *)bp->b_data;
- /* if first partition is not valid, assume not HFS/DPME partitioned */
- if (part->pmSig != PART_ENTRY_MAGIC) {
- osdep->macparts[0].pmSig = 0; /* make invalid */
- return 0;
- }
- osdep->macparts[0] = *part;
- part_cnt = part->pmMapBlkCnt;
- n = 0;
- for (i = 0; i < part_cnt; i++) {
- struct partition *pp = &lp->d_partitions[8+n];
-
- bp->b_blkno = 1+i;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- bp->b_cylin = 1+i / lp->d_secpercyl;
- (*strat)(bp);
-
- if (biowait(bp)) {
- *pmsg = "DPME partition I/O error";
- return 0;
- }
- part = (struct part_map_entry *)bp->b_data;
- /* toupper the string, in case caps are different... */
- for (s = part->pmPartType; *s; s++)
- if ((*s >= 'a') && (*s <= 'z'))
- *s = (*s - 'a' + 'A');
-
- if (0 == strcmp(part->pmPartType, PART_TYPE_OPENBSD)) {
- hfspartoff = part->pmPyPartStart;
- osdep->macparts[1] = *part;
- }
- /* currently we ignore all but HFS partitions */
- if (0 == strcmp(part->pmPartType, PART_TYPE_MAC)) {
- pp->p_offset = part->pmPyPartStart;
- pp->p_size = part->pmPartBlkCnt;
- pp->p_fstype = FS_HFS;
- n++;
-#if 0
- printf("found DPME HFS partition [%s], adding to fake\n",
- part->pmPartName);
-#endif
- }
- }
- lp->d_npartitions = MAXPARTITIONS;
-
- *bsdpartoff = hfspartoff;
- return 1;
-}
diff --git a/sys/arch/pegasos/pegasos/locore.S b/sys/arch/pegasos/pegasos/locore.S
deleted file mode 100644
index 193c5e51227..00000000000
--- a/sys/arch/pegasos/pegasos/locore.S
+++ /dev/null
@@ -1,1246 +0,0 @@
-/* $OpenBSD: locore.S,v 1.2 2004/01/15 03:26:36 drahn Exp $ */
-/* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */
-
-/*
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 "assym.h"
-
-#include <sys/syscall.h>
-
-#include <machine/asm.h>
-#include <machine/param.h>
-#include <machine/pmap.h>
-#include <machine/psl.h>
-#include <machine/trap.h>
-
-/*
- * Globals
- */
- .globl _C_LABEL(esym),_C_LABEL(proc0paddr)
- .type _C_LABEL(esym),@object
- .type _C_LABEL(proc0paddr),@object
- .data
-_C_LABEL(esym): .long 0 /* end of symbol table */
-_C_LABEL(proc0paddr): .long 0 /* proc0 p_addr */
-idle_u: .long 0 /* fake uarea during idle after exit */
-
-fwargsave:
- .long 0
- .long 0
- .globl _C_LABEL(where)
- .type _C_LABEL(where),@object
-_C_LABEL(where): .long 0
-
-/*
- * Startup entry
- */
-_ENTRY(_C_LABEL(kernel_text))
-_ENTRY(_ASM_LABEL(start))
-/* arguments to start
- * r1 - stack provided by firmware/bootloader
- * r3 - unused
- * r4 - unused
- * r5 - firmware pointer (NULL for PPC1bug)
- * r6 - arg list
- * r7 - length
- */
- .globl start
- .type start,@function
-start:
- lis %r3, fwargsave@ha
- stw %r6, fwargsave@l(%r3)
- stw %r7, fwargsave@l+4(%r3)
- bl ofw_init
- li %r0,0
- mtmsr %r0 /* Disable FPU/MMU/exceptions */
- isync
-
-/* compute end of kernel memory */
- lis %r8,_end@ha
- addi %r8,%r8,_end@l
- lis %r3, fwargsave@ha
- lwz %r6, fwargsave@l(%r3)
- lwz %r7, fwargsave@l+4(%r3)
-#if defined(DDB) || defined(KERNFS)
- cmpwi %r6, 0
- beq 1f
- add %r9,%r6,%r7
- lwz %r9, -4(%r9)
- cmpwi %r9,0
- beq 1f
- lis %r8,_C_LABEL(esym)@ha
- stw %r9,_C_LABEL(esym)@l(%r8)
- mr %r8, %r9
-1:
-#endif
- li %r9,PGOFSET
- add %r8,%r8,%r9
- andc %r8,%r8,%r9
- lis %r9,idle_u@ha
- stw %r8,idle_u@l(%r9)
- addi %r8,%r8,USPACE /* space for idle_u */
- lis %r9,_C_LABEL(proc0paddr)@ha
- stw %r8,_C_LABEL(proc0paddr)@l(%r9)
- addi %r1,%r8,USPACE-FRAMELEN /* stackpointer for proc0 */
- mr %r4,%r1 /* end of mem reserved for kernel */
- li %r0,0
- stwu %r0,-16(%r1) /* end of stack chain */
-
- lis %r3,start@ha
- addi %r3,%r3,start@l
- mr %r5,%r6 /* args string */
- bl _C_LABEL(initppc)
- bl _C_LABEL(main)
- b _C_LABEL(OF_exit)
-
-/*
- * No processes are runnable, so loop waiting for one.
- * Separate label here for accounting purposes.
- */
-_C_LABEL(idle):
- mfmsr %r3
- /* disable interrupts while manipulating runque */
- andi. %r3,%r3,~PSL_EE@l
- mtmsr %r3
-
- lis %r8,_C_LABEL(whichqs)@ha
- lwz %r9,_C_LABEL(whichqs)@l(%r8)
-
- or. %r9,%r9,%r9
- bne- _C_LABEL(sw1) /* at least one queue non-empty */
-
- ori %r3,%r3,PSL_EE /* reenable ints again */
- mtmsr %r3
- isync
- sync
- /* low power mode */
- mfmsr %r3
- oris %r3, %r3, PSL_POW@h
- mtmsr %r3
- isync
-
-/* May do some power saving here? */
-
- b _C_LABEL(idle)
-
-/*
- * switchexit gets called from cpu_exit to free the user structure
- * and kernel stack of the current process.
- */
-_ENTRY(_C_LABEL(switchexit))
-/* First switch to the idle pcb/kernel stack */
- lis %r6,idle_u@ha
- lwz %r6,idle_u@l(%r6)
- lis %r7,_C_LABEL(curpcb)@ha
- stw %r6,_C_LABEL(curpcb)@l(%r7)
- addi %r1,%r6,USPACE-16 /* 16 bytes are reserved at stack top */
- /*
- * Schedule the vmspace and stack to be freed (the proc arg is
- * already in r3).
- */
- bl _C_LABEL(exit2)
-
- /* Fall through to cpu_switch to actually select another proc */
- li %r3,0 /* indicate exited process */
-
-/* Fall through to cpu_switch to actually select another proc */
-
-/*
- * void cpu_switch(struct proc *p)
- * Find a runnable process and switch to it.
- */
-_ENTRY(_C_LABEL(cpu_switch))
- mflr %r0 /* save lr */
- stw %r0,4(%r1)
- stwu %r1,-16(%r1)
- stw %r31,12(%r1)
- stw %r30,8(%r1)
-
- mr %r30,%r3
- lis %r3,_C_LABEL(curproc)@ha
- li %r31,0
- /* Zero to not accumulate cpu time */
- stw %r31,_C_LABEL(curproc)@l(%r3)
- lis %r3,_C_LABEL(curpcb)@ha
- lwz %r31,_C_LABEL(curpcb)@l(%r3)
-
- li %r3,0
- bl _C_LABEL(lcsplx)
- stw %r3,PCB_SPL(%r31) /* save spl */
-
-/* Find a new process */
- mfmsr %r3
- andi. %r3,%r3,~PSL_EE@l /* disable interrupts while
- manipulating runque */
- mtmsr %r3
- isync
-
- lis %r8,_C_LABEL(whichqs)@ha
- lwz %r9,_C_LABEL(whichqs)@l(%r8)
-
- or. %r9,%r9,%r9
- beq- _C_LABEL(idle) /* all queues empty */
-_C_LABEL(sw1):
- cntlzw %r10,%r9
- lis %r4,_C_LABEL(qs)@ha
- addi %r4,%r4,_C_LABEL(qs)@l
- slwi %r3,%r10,3
- add %r3,%r3,%r4 /* select queue */
-
- lwz %r31,P_FORW(%r3) /* unlink first proc from queue */
- lwz %r4,P_FORW(%r31)
- stw %r4,P_FORW(%r3)
- stw %r3,P_BACK(%r4)
-
- cmpl 0,%r3,%r4 /* queue empty? */
- bne 1f
-
- lis %r3,0x80000000@ha
- srw %r3,%r3,%r10
- andc %r9,%r9,%r3
- stw %r9,_C_LABEL(whichqs)@l(%r8) /* mark it empty */
-
-1:
- /* just did this resched thing, clear resched */
- li %r3,0
- lis %r4,_C_LABEL(want_resched)@ha
- stw %r3,_C_LABEL(want_resched)@l(%r4)
-
- stw %r3,P_BACK(%r31) /* probably superfluous */
-
- lis %r4,_C_LABEL(curproc)@ha
- stw %r31,_C_LABEL(curproc)@l(%r4) /* record new process */
-
- mfmsr %r3
- ori %r3,%r3,PSL_EE /* Now we can interrupt again */
- mtmsr %r3
-
- cmpl 0,%r31,%r30 /* is it the same process? */
- beq switch_return
-
- or. %r30,%r30,%r30 /* old process was exiting? */
- beq switch_exited
-
- mfsr %r10,USER_SR /* save USER_SR for copyin/copyout */
- mfcr %r11 /* save cr */
- mr %r12,%r2 /* save r2 */
- stwu %r1,-SFRAMELEN(%r1) /* still running on old stack */
- stmw %r10,8(%r1)
- lwz %r3,P_ADDR(%r30)
- stw %r1,PCB_SP(%r3) /* save SP */
-
-switch_exited:
- /* disable interrupts while actually switching */
- mfmsr %r3
- andi. %r3,%r3,~PSL_EE@l
- mtmsr %r3
-
- lwz %r4,P_ADDR(%r31)
- lis %r5,_C_LABEL(curpcb)@ha
- stw %r4,_C_LABEL(curpcb)@l(%r5) /* indicate new pcb */
-
- lwz %r5,PCB_PMR(%r4)
-
- /* save real pmap pointer for spill fill */
- lis %r6,_C_LABEL(curpm)@ha
- stwu %r5,_C_LABEL(curpm)@l(%r6)
- stwcx. %r5,%r0,%r6 /* clear possible reservation */
-
- addic. %r5,%r5,64
- li %r6,0
- mfsr %r8,KERNEL_SR /* save kernel SR */
-1:
- addis %r6,%r6,-0x10000000@ha /* set new procs segment registers */
- or. %r6,%r6,%r6 /* This is done from the real address pmap */
- lwzu %r7,-4(%r5) /* so we don't have to worry */
- mtsrin %r7,%r6 /* about accessibility */
- bne 1b
- mtsr KERNEL_SR,%r8 /* restore kernel SR */
- isync
-
- lwz %r1,PCB_SP(%r4) /* get new procs SP */
-
- ori %r3,%r3,PSL_EE /* interrupts are okay again */
- mtmsr %r3
-
- lmw %r10,8(%r1) /* get other regs */
- lwz %r1,0(%r1) /* get saved SP */
- mr %r2,%r12 /* get saved r2 */
- mtcr %r11 /* get saved cr */
- isync
- mtsr USER_SR,%r10 /* get saved USER_SR */
- isync
-
-switch_return:
- mr %r30,%r7 /* save proc pointer */
- lwz %r3,PCB_SPL(%r4)
- bl _C_LABEL(lcsplx)
-
- mr %r3,%r30 /* curproc for special fork returns */
-
- lwz %r31,12(%r1)
- lwz %r30,8(%r1)
- addi %r1,%r1,16
- lwz %r0,4(%r1)
- mtlr %r0
- blr
-
-
-/*
- * Data used during primary/secondary traps/interrupts
- */
-#define tempsave 0x2e0 /* primary save area for trap handling */
-#define disisave 0x3e0 /* primary save area for dsi/isi traps */
-#define INTSTK (8*1024) /* 8K interrupt stack */
- .data
-intstk: .space INTSTK /* interrupt stack */
- .global _C_LABEL(intr_depth)
- .type _C_LABEL(intr_depth),@object
-_C_LABEL(intr_depth):
- .long -1 /* in-use marker */
-#define SPILLSTK 1024 /* 1K spill stack */
-.lcomm spillstk,SPILLSTK,8
-
-/*
- * This code gets copied to all the trap vectors
- * (except ISI/DSI, ALI, the interrupts, and possibly the debugging traps
- * when using IPKDB).
- */
- .text
- .globl _C_LABEL(trapcode),_C_LABEL(trapsize)
- .type _C_LABEL(trapcode),@function
- .type _C_LABEL(trapsize),@object
-_C_LABEL(trapcode):
- mtsprg 1,%r1 /* save SP */
- stmw %r28,tempsave(%r0) /* free r28-r31 */
- mflr %r28 /* save LR */
- mfcr %r29 /* save CR */
-
- /* Test whether we already had PR set */
- mfsrr1 %r31
- mtcr %r31
- bc 4,17,1f /* branch if PSL_PR is clear */
- lis %r1,_C_LABEL(curpcb)@ha
- lwz %r1,_C_LABEL(curpcb)@l(%r1)
- addi %r1,%r1,USPACE /* stack is top of user struct */
-1:
- bla s_trap
-_C_LABEL(trapsize) = .-_C_LABEL(trapcode)
-
-/*
- * For ALI: has to save DSISR and DAR
- */
- .globl _C_LABEL(alitrap),_C_LABEL(alisize)
-_C_LABEL(alitrap):
- mtsprg 1,%r1 /* save SP */
- stmw %r28,tempsave(0) /* free r28-r31 */
- mfdar %r30
- mfdsisr %r31
- stmw %r30,tempsave+16(0)
- mflr %r28 /* save LR */
- mfcr %r29 /* save CR */
-
- /* Test whether we already had PR set */
- mfsrr1 %r31
- mtcr %r31
- bc 4,17,1f /* branch if PSL_PR is clear */
- lis %r1,_C_LABEL(curpcb)@ha
- lwz %r1,_C_LABEL(curpcb)@l(%r1)
- addi %r1,%r1,USPACE /* stack is top of user struct */
-1:
- bla s_trap
-_C_LABEL(alisize) = .-_C_LABEL(alitrap)
-
-/*
- * Similar to the above for DSI
- * Has to handle BAT spills
- * and standard pagetable spills
- */
- .globl _C_LABEL(dsitrap),_C_LABEL(dsisize)
- .type _C_LABEL(dsitrap),@function
- .type _C_LABEL(dsisize),@object
-_C_LABEL(dsitrap):
- stmw %r28,disisave(0) /* free r28-r31 */
- mfcr %r29 /* save CR */
- mfxer %r30 /* save XER */
- mtsprg 2,%r30 /* in SPRG2 */
- mfsrr1 %r31 /* test kernel mode */
-#if 0
- mtcr %r31
- bc 12,17,1f /* branch if PSL_PR is set */
- mfdar %r31 /* get fault address */
- rlwinm %r31,%r31,7,25,28 /* get segment * 8 */
- addis %r31,%r31,_C_LABEL(battable)@ha
- lwz %r30,_C_LABEL(battable)@l(31) /* get batu */
- mtcr %r30
- bc 4,30,1f /* branch if supervisor valid is false */
- lwz %r31,_C_LABEL(battable)+4@l(%r31) /* get batl */
-/* We randomly use the highest two bat registers here */
- mftb %r28
- andi. %r28,%r28,1
- bne 2f
- mtdbatu 2,%r30
- mtdbatl 2,%r31
- b 3f
-2:
- mtdbatu 3,%r30
- mtdbatl 3,%r31
-3:
- mfsprg %r30,2 /* restore XER */
- mtxer %r30
- mtcr %r29 /* restore CR */
- lmw %r28,disisave(0) /* restore r28-r31 */
- rfi /* return to trapped code */
-1:
-#endif
- mflr %r28 /* save LR */
- bla s_dsitrap
-_C_LABEL(dsisize) = .-_C_LABEL(dsitrap)
-
-/*
- * Similar to the above for ISI
- */
- .globl _C_LABEL(isitrap),_C_LABEL(isisize)
- .type _C_LABEL(isitrap),@function
- .type _C_LABEL(isisize),@object
-_C_LABEL(isitrap):
- stmw %r28,disisave(0) /* free r28-r31 */
- mflr %r28 /* save LR */
- mfcr %r29 /* save CR */
- mfsrr1 %r31 /* test kernel mode */
-#if 0
- mtcr %r31
- bc 12,17,1f /* branch if PSL_PR is set */
- mfsrr0 %r31 /* get fault address */
- rlwinm %r31,%r31,7,25,28 /* get segment * 8 */
- addis %r31,%r31,_C_LABEL(battable)@ha
- lwz %r30,_C_LABEL(battable)@l(31) /* get batu */
- mtcr %r30
- bc 4,30,1f /* branch if supervisor valid is false */
- mtibatu 3,%r30
- lwz %r30,_C_LABEL(battable)+4@l(31) /* get batl */
- mtibatl 3,%r30
- mtcr %r29 /* restore CR */
- lmw %r28,disisave(0) /* restore r28-r31 */
- rfi /* return to trapped code */
-1:
-#endif
- bla s_isitrap
-_C_LABEL(isisize) = .-_C_LABEL(isitrap)
-
-/*
- * This one for the external interrupt handler.
- */
- .globl _C_LABEL(extint),_C_LABEL(extsize)
- .type _C_LABEL(extint),@function
- .type _C_LABEL(extsize),@object
-_C_LABEL(extint):
- mtsprg 1,%r1 /* save SP */
- stmw %r28,tempsave(0) /* free r28-r31 */
- mflr %r28 /* save LR */
- mfcr %r29 /* save CR */
- mfxer %r30 /* save XER */
- lis %r1,intstk+INTSTK@ha /* get interrupt stack */
- addi %r1,%r1,intstk+INTSTK@l
- lwz %r31,0(%r1) /* were we already running on intstk? */
- addic. %r31,%r31,%r1
- stw %r31,0(%r1)
- beq 1f
- mfsprg %r1,1 /* yes, get old SP */
-1:
- ba extintr
-_C_LABEL(extsize) = .-_C_LABEL(extint)
-
-/*
- * And this one for the decrementer interrupt handler.
- */
- .globl _C_LABEL(decrint),_C_LABEL(decrsize)
- .type _C_LABEL(decrint),@function
- .type _C_LABEL(decrsize),@object
-_C_LABEL(decrint):
- mtsprg 1,%r1 /* save SP */
- stmw %r28,tempsave(0) /* free r28-r31 */
- mflr %r28 /* save LR */
- mfcr %r29 /* save CR */
- mfxer %r30 /* save XER */
- lis %r1,intstk+INTSTK@ha /* get interrupt stack */
- addi %r1,%r1,intstk+INTSTK@l
- lwz %r31,0(%r1) /* were we already running on intstk? */
- addic. %r31,%r31,%r1
- stw %r31,0(%r1)
- beq 1f
- mfsprg %r1,1 /* yes, get old SP */
-1:
- ba decrintr
-_C_LABEL(decrsize) = .-_C_LABEL(decrint)
-
-/*
- * Now the tlb software load for 603 processors:
- * (Code essentially from the 603e User Manual, Chapter 5)
- */
-#define DMISS 976
-#define DCMP 977
-#define HASH1 978
-#define HASH2 979
-#define IMISS 980
-#define ICMP 981
-#define RPA 982
-
-#define bdneq bdnzf 2,
-#define tlbli .long 0x7c0007e4+0x800*
-#define tlbld .long 0x7c0007a4+0x800*
-
- .globl _C_LABEL(tlbimiss),_C_LABEL(tlbimsize)
- .type _C_LABEL(tlbimiss),@function
- .type _C_LABEL(tlbimsize),@object
-_C_LABEL(tlbimiss):
- mfspr %r2,HASH1 /* get first pointer */
- li %r1,8
- mfctr %r0 /* save counter */
- mfspr %r3,ICMP /* get first compare value */
- addi %r2,%r2,-8 /* predec pointer */
-1:
- mtctr %r1 /* load counter */
-2:
- lwzu %r1,8(%r2) /* get next pte */
- cmpl 0,%r1,%r3 /* see if found pte */
- bdneq 2b /* loop if not eq */
- bne 3f /* not found */
- lwz %r1,4(%r2) /* load tlb entry lower word */
- andi. %r3,%r1,8 /* check G-bit */
- bne 4f /* if guarded, take ISI */
- mtctr %r0 /* restore counter */
- mfspr %r0,IMISS /* get the miss address for the tlbli */
- mfsrr1 %r3 /* get the saved cr0 bits */
- mtcrf 0x80,%r3 /* and restore */
- ori %r1,%r1,0x100 /* set the reference bit */
- mtspr RPA,%r1 /* set the pte */
- srwi %r1,%r1,8 /* get byte 7 of pte */
- tlbli 0 /* load the itlb */
- stb %r1,6(%r2) /* update page table */
- rfi
-
-3: /* not found in pteg */
- andi. %r1,%r3,0x40 /* have we already done second hash? */
- bne 5f
- mfspr %r2,HASH2 /* get the second pointer */
- ori %r3,%r3,0x40 /* change the compare value */
- li %r1,8
- addi %r2,%r2,-8 /* predec pointer */
- b 1b
-4: /* guarded */
- mfsrr1 %r3
- andi. %r2,%r3,0xffff /* clean upper srr1 */
- addis %r2,%r2,0x800 /* set srr<4> to flag prot violation */
- b 6f
-5: /* not found anywhere */
- mfsrr1 %r3
- andi. %r2,%r3,0xffff /* clean upper srr1 */
- addis %r2,%r2,0x4000 /* set srr1<1> to flag pte not found */
-6:
- mtctr %r0 /* restore counter */
- mtsrr1 %r2
- mfmsr %r0
- xoris %r0,%r0,2 /* flip the msr<tgpr> bit */
- mtcrf 0x80,%r3 /* restore cr0 */
- mtmsr %r0 /* now with native gprs */
- isync
- ba EXC_ISI
-_C_LABEL(tlbimsize) = .-_C_LABEL(tlbimiss)
-
- .globl _C_LABEL(tlbdlmiss),_C_LABEL(tlbdlmsize)
- .type _C_LABEL(tlbdlmiss),@function
- .type _C_LABEL(tlbdlmsize),@object
-_C_LABEL(tlbdlmiss):
- mfspr %r2,HASH1 /* get first pointer */
- li %r1,8
- mfctr %r0 /* save counter */
- mfspr %r3,DCMP /* get first compare value */
- addi %r2,%r2,-8 /* predec pointer */
-1:
- mtctr %r1 /* load counter */
-2:
- lwzu %r1,8(%r2) /* get next pte */
- cmpl 0,%r1,%r3 /* see if found pte */
- bdneq 2b /* loop if not eq */
- bne 3f /* not found */
- lwz %r1,4(%r2) /* load tlb entry lower word */
- mtctr %r0 /* restore counter */
- mfspr %r0,DMISS /* get the miss address for the tlbld */
- mfsrr1 %r3 /* get the saved cr0 bits */
- mtcrf 0x80,%r3 /* and restore */
- ori %r1,%r1,0x100 /* set the reference bit */
- mtspr RPA,%r1 /* set the pte */
- srwi %r1,%r1,8 /* get byte 7 of pte */
- tlbld 0 /* load the dtlb */
- stb %r1,6(%r2) /* update page table */
- rfi
-
-3: /* not found in pteg */
- andi. %r1,%r3,0x40 /* have we already done second hash? */
- bne 5f
- mfspr %r2,HASH2 /* get the second pointer */
- ori %r3,%r3,0x40 /* change the compare value */
- li %r1,8
- addi %r2,%r2,-8 /* predec pointer */
- b 1b
-5: /* not found anywhere */
- mfsrr1 %r3
- lis %r1,0x4000 /* set dsisr<1> to flag pte not found */
- mtctr %r0 /* restore counter */
- andi. %r2,%r3,0xffff /* clean upper srr1 */
- mtsrr1 %r2
- mtdsisr %r1 /* load the dsisr */
- mfspr %r1,DMISS /* get the miss address */
- mtdar %r1 /* put in dar */
- mfmsr %r0
- xoris %r0,%r0,2 /* flip the msr<tgpr> bit */
- mtcrf 0x80,%r3 /* restore cr0 */
- mtmsr %r0 /* now with native gprs */
- isync
- ba EXC_DSI
-_C_LABEL(tlbdlmsize) = .-_C_LABEL(tlbdlmiss)
-
- .globl _C_LABEL(tlbdsmiss),_C_LABEL(tlbdsmsize)
- .type _C_LABEL(tlbdsmiss),@function
- .type _C_LABEL(tlbdsmsize),@object
-_C_LABEL(tlbdsmiss):
- mfspr %r2,HASH1 /* get first pointer */
- li %r1,8
- mfctr %r0 /* save counter */
- mfspr %r3,DCMP /* get first compare value */
- addi %r2,%r2,-8 /* predec pointer */
-1:
- mtctr %r1 /* load counter */
-2:
- lwzu %r1,8(%r2) /* get next pte */
- cmpl 0,%r1,%r3 /* see if found pte */
- bdneq 2b /* loop if not eq */
- bne 3f /* not found */
- lwz %r1,4(%r2) /* load tlb entry lower word */
- andi. %r3,%r1,0x80 /* check the C-bit */
- beq 4f
-5:
- mtctr %r0 /* restore counter */
- mfspr %r0,DMISS /* get the miss address for the tlbld */
- mfsrr1 %r3 /* get the saved cr0 bits */
- mtcrf 0x80,%r3 /* and restore */
- mtspr RPA,%r1 /* set the pte */
- tlbld 0 /* load the dtlb */
- rfi
-
-3: /* not found in pteg */
- andi. %r1,%r3,0x40 /* have we already done second hash? */
- bne 5f
- mfspr %r2,HASH2 /* get the second pointer */
- ori %r3,%r3,0x40 /* change the compare value */
- li %r1,8
- addi %r2,%r2,-8 /* predec pointer */
- b 1b
-4: /* found, but C-bit = 0 */
- rlwinm. %r3,%r1,30,0,1 /* test PP */
- bge- 7f
- andi. %r3,%r1,1
- beq+ 8f
-9: /* found, but protection violation (PP==00)*/
- mfsrr1 %r3
- lis %r1,0xa00 /* indicate protection violation on store */
- b 1f
-7: /* found, PP=1x */
- mfspr %r3,DMISS /* get the miss address */
- mfsrin %r1,%r3 /* get the segment register */
- mfsrr1 %r3
- rlwinm %r3,%r3,18,31,31 /* get PR-bit */
- rlwnm. %r2,%r2,3,1,1 /* get the key */
- bne- 9b /* protection violation */
-8: /* found, set reference/change bits */
- lwz %r1,4(%r2) /* reload tlb entry */
- ori %r1,%r1,0x180
- sth %r1,6(%r2)
- b 5b
-5: /* not found anywhere */
- mfsrr1 %r3
- lis %r1,0x4200 /* set dsisr<1> to flag pte not found */
- /* dsisr<6> to flag store */
-1:
- mtctr %r0 /* restore counter */
- andi. %r2,%r3,0xffff /* clean upper srr1 */
- mtsrr1 %r2
- mtdsisr %r1 /* load the dsisr */
- mfspr %r1,DMISS /* get the miss address */
- mtdar %r1 /* put in dar */
- mfmsr %r0
- xoris %r0,%r0,2 /* flip the msr<tgpr> bit */
- mtcrf 0x80,%r3 /* restore cr0 */
- mtmsr %r0 /* now with native gprs */
- isync
- ba EXC_DSI
-_C_LABEL(tlbdsmsize) = .-_C_LABEL(tlbdsmiss)
-
-#ifdef DDB
-#define ddbsave 0xde0 /* primary save area for DDB */
-/*
- * In case of DDB we want a separate trap catcher for it
- */
- .local ddbstk
- .comm ddbstk,INTSTK,8 /* ddb stack */
-
- .globl _C_LABEL(ddblow),_C_LABEL(ddbsize)
-_C_LABEL(ddblow):
- mtsprg 1,%r1 /* save SP */
- stmw %r28,ddbsave(0) /* free r28-r31 */
- mflr %r28 /* save LR */
- mfcr %r29 /* save CR */
- lis %r1,ddbstk+INTSTK@ha /* get new SP */
- addi %r1,%r1,ddbstk+INTSTK@l
- bla ddbtrap
-_C_LABEL(ddbsize) = .-_C_LABEL(ddblow)
-#endif /* DDB */
-
-
-/*
- * FRAME_SETUP assumes:
- * SPRG1 SP (1)
- * savearea r28-r31,DAR,DSISR (DAR & DSISR only for DSI traps)
- * 28 LR
- * 29 CR
- * 1 kernel stack
- * LR trap type
- * SRR0/1 as at start of trap
- */
-#define FRAME_SETUP(savearea) \
-/* Have to enable translation to allow access of kernel stack: */ \
- mfsrr0 %r30; \
- mfsrr1 %r31; \
- stmw %r30,savearea+24(0); \
- mfmsr %r30; \
- ori %r30,%r30,(PSL_DR|PSL_IR); \
- mtmsr %r30; \
- isync; \
- mfsprg %r31,1; \
- stwu %r31,-FRAMELEN(%r1); \
- stw %r0,FRAME_0+8(%r1); \
- stw %r31,FRAME_1+8(%r1); \
- stw %r28,FRAME_LR+8(%r1); \
- stw %r29,FRAME_CR+8(%r1); \
- lmw %r28,savearea(0); \
- stmw %r2,FRAME_2+8(%r1); \
- lmw %r28,savearea+16(0); \
- mfxer %r3; \
- mfctr %r4; \
- mflr %r5; \
- andi. %r5,%r5,0xff00; \
- stw %r3,FRAME_XER+8(%r1); \
- stw %r4,FRAME_CTR+8(%r1); \
- stw %r5,FRAME_EXC+8(%r1); \
- stw %r28,FRAME_DAR+8(%r1); \
- stw %r29,FRAME_DSISR+8(%r1); \
- stw %r30,FRAME_SRR0+8(%r1); \
- stw %r31,FRAME_SRR1+8(%r1)
-
-#define FRAME_LEAVE(savearea) \
-/* Now restore regs: */ \
- lwz %r2,FRAME_SRR0+8(%r1); \
- lwz %r3,FRAME_SRR1+8(%r1); \
- lwz %r4,FRAME_CTR+8(%r1); \
- lwz %r5,FRAME_XER+8(%r1); \
- lwz %r6,FRAME_LR+8(%r1); \
- lwz %r7,FRAME_CR+8(%r1); \
- stw %r2,savearea(0); \
- stw %r3,savearea+4(0); \
- mtctr %r4; \
- mtxer %r5; \
- mtlr %r6; \
- mtsprg 1,%r7; /* save cr */ \
- lmw %r2,FRAME_2+8(%r1); \
- lwz %r0,FRAME_0+8(%r1); \
- lwz %r1,FRAME_1+8(%r1); \
- mtsprg 2,%r2; /* save r2 & r3 */ \
- mtsprg 3,%r3; \
-/* Disable translation, machine check and recoverability: */ \
- mfmsr %r2; \
- lis %r3,(PSL_DR|PSL_IR|PSL_ME|PSL_RI)@ha; \
- addi %r3,%r3,(PSL_DR|PSL_IR|PSL_ME|PSL_RI)@l; \
- andc %r2,%r2,%r3; \
- mtmsr %r2; \
- isync; \
-/* Decide whether we return to user mode: */ \
- lwz %r3,savearea+4(0); \
- mtcr %r3; \
- bc 4,17,1f; /* branch if PSL_PR is false */ \
-/* Restore user & kernel access SR: */ \
- lis %r2,_C_LABEL(curpm)@ha; /* get real address of pmap */ \
- lwz %r2,_C_LABEL(curpm)@l(2); \
- lwz %r3,PM_USRSR(%r2); \
- mtsr USER_SR,%r3; \
- lwz %r3,PM_KERNELSR(%r2); \
- mtsr KERNEL_SR,%r3; \
-1: mfsprg %r2,1; /* restore cr */ \
- mtcr %r2; \
- lwz %r2,savearea(0); \
- lwz %r3,savearea+4(0); \
- mtsrr0 %r2; \
- mtsrr1 %r3; \
- mfsprg %r2,2; /* restore r2 & r3 */ \
- mfsprg %r3,3
-
-/*
- * Preamble code for DSI/ISI traps
- */
-disitrap:
- lmw %r30,disisave(0)
- stmw %r30,tempsave(0)
- lmw %r30,disisave+8(0)
- stmw %r30,tempsave+8(0)
- mfdar %r30
- mfdsisr %r31
- stmw %r30,tempsave+16(0)
-realtrap:
- /* Test whether we already had PR set */
- mfsrr1 %r1
- mtcr %r1
- /* restore SP (might have been overwritten) */
- mfsprg %r1,1
- bc 4,17,s_trap /* branch if PSL_PR is false */
- lis %r1,_C_LABEL(curpcb)@ha
- lwz %r1,_C_LABEL(curpcb)@l(%r1)
- addi %r1,%r1,USPACE /* stack is top of user struct */
-/*
- * Now the common trap catching code.
- */
-s_trap:
-/* First have to enable KERNEL mapping */
- lis %r31,KERNEL_SEGMENT@ha
- addi %r31,%r31,KERNEL_SEGMENT@l
- mtsr KERNEL_SR,%r31
- FRAME_SETUP(tempsave)
-/* Now we can recover interrupts again: */
- mfmsr %r7
- mfsrr1 %r31
- andi. %r31,%r31,PSL_EE /* restore EE from previous context */
- or %r7,%r7,%r31
- ori %r7,%r7,(PSL_ME|PSL_RI)
- mtmsr %r7
- isync
-/* Call C trap code: */
-trapagain:
- addi %r3,%r1,8
- bl _C_LABEL(trap)
-trapexit:
-/* Disable interrupts: */
- mfmsr %r3
- andi. %r3,%r3,~PSL_EE@l
- mtmsr %r3
-/* Test AST pending: */
- lwz %r5,FRAME_SRR1+8(%r1)
- mtcr %r5
- bc 4,17,1f /* branch if PSL_PR is false */
- lis %r3,_C_LABEL(astpending)@ha
- lwz %r4,_C_LABEL(astpending)@l(%r3)
- andi. %r4,%r4,1
- beq 1f
- li %r6,EXC_AST
- stw %r6,FRAME_EXC+8(%r1)
- b trapagain
-1:
- FRAME_LEAVE(tempsave)
- rfi
-
-/*
- * Child comes here at the end of a fork.
- * Mostly similar to the above.
- */
- .globl _C_LABEL(fork_trampoline)
- .type _C_LABEL(fork_trampoline),@function
-_C_LABEL(fork_trampoline):
- li %r3,0
- bl _C_LABEL(lcsplx)
- mtlr %r31
- mr %r3,%r30
- blrl /* jump indirect to r31 */
- b trapexit
-
-/*
- * DSI second stage fault handler
- */
-s_dsitrap:
- mfdsisr %r31 /* test if this is spill fault */
- mtcr %r31
- mtsprg 1,%r1 /* save SP */
- bc 4,1,disitrap /* branch if table miss is false */
- lis %r1,spillstk+SPILLSTK@ha
- addi %r1,%r1,spillstk+SPILLSTK@l /* get spill stack */
- stwu %r1,-52(%r1)
- stw %r0,48(%r1) /* save non-volatile registers */
- stw %r3,44(%r1)
- stw %r4,40(%r1)
- stw %r5,36(%r1)
- stw %r6,32(%r1)
- stw %r7,28(%r1)
- stw %r8,24(%r1)
- stw %r9,20(%r1)
- stw %r10,16(%r1)
- stw %r11,12(1)
- stw %r12,8(1)
- mfxer %r30 /* save XER */
- mtsprg 2,%r30
- mflr %r30 /* save trap type */
- mfctr %r31 /* & CTR */
- mfdar %r3
- mfsrr1 %r4
- mfdsisr %r5
- li %r6, 0
-s_pte_spill:
- bl _C_LABEL(pte_spill_r) /* try a spill */
- cmpwi 0,%r3,0
- mtctr %r31 /* restore CTR */
- mtlr %r30 /* and trap type */
- mfsprg %r31,2 /* get saved XER */
- mtxer %r31 /* restore XER */
- lwz %r12,8(%r1) /* restore non-volatile registers */
- lwz %r11,12(%r1)
- lwz %r10,16(%r1)
- lwz %r9,20(%r1)
- lwz %r8,24(%r1)
- lwz %r7,28(%r1)
- lwz %r6,32(%r1)
- lwz %r5,36(%r1)
- lwz %r4,40(%r1)
- lwz %r3,44(%r1)
- lwz %r0,48(%r1)
- beq disitrap
- mfsprg %r1,1 /* restore SP */
- mtcr %r29 /* restore CR */
- mtlr %r28 /* restore LR */
- lmw %r28,disisave(0) /* restore r28-r31 */
- rfi /* return to trapped code */
-
-/*
- * ISI second stage fault handler
- */
-s_isitrap:
- mfsrr1 %r31 /* test if this may be a spill fault */
- mtcr %r31
- mtsprg 1,%r1 /* save SP */
- bc 4,%r1,disitrap /* branch if table miss is false */
- lis %r1,spillstk+SPILLSTK@ha
- addi %r1,%r1,spillstk+SPILLSTK@l /* get spill stack */
- stwu %r1,-52(%r1)
- stw %r0,48(%r1) /* save non-volatile registers */
- stw %r3,44(%r1)
- stw %r4,40(%r1)
- stw %r5,36(%r1)
- stw %r6,32(%r1)
- stw %r7,28(%r1)
- stw %r8,24(%r1)
- stw %r9,20(%r1)
- stw %r10,16(%r1)
- stw %r11,12(%r1)
- stw %r12,8(%r1)
- mfxer %r30 /* save XER */
- mtsprg 2,%r30
- mflr %r30 /* save trap type */
- mfctr %r31 /* & ctr */
- mfsrr0 %r3
- mfsrr1 %r4
- li %r5, 0
- li %r6, 1
- b s_pte_spill /* above */
-
-/*
- * External interrupt second level handler
- */
-#define INTRENTER \
-/* Save non-volatile registers: */ \
- stwu %r1,-88(%r1); /* temporarily */ \
- stw %r0,84(%r1); \
- mfsprg %r0,1; /* get original SP */ \
- stw %r0,0(%r1); /* and store it */ \
- stw %r3,80(%r1); \
- stw %r4,76(%r1); \
- stw %r5,72(%r1); \
- stw %r6,68(%r1); \
- stw %r7,64(%r1); \
- stw %r8,60(%r1); \
- stw %r9,56(%r1); \
- stw %r10,52(%r1); \
- stw %r11,48(%r1); \
- stw %r12,44(%r1); \
- stw %r28,40(%r1); /* saved LR */ \
- stw %r29,36(%r1); /* saved CR */ \
- stw %r30,32(%r1); /* saved XER */ \
- lmw %r28,tempsave(0); /* restore r28-r31 */ \
- mfctr %r6; \
- lis %r5,_C_LABEL(intr_depth)@ha; \
- lwz %r5,_C_LABEL(intr_depth)@l(%r5); \
- mfsrr0 %r4; \
- mfsrr1 %r3; \
- stw %r6,28(%r1); \
- stw %r5,20(%r1); \
- stw %r4,12(%r1); \
- stw %r3,8(%r1); \
-/* interrupts are recoverable here, and enable translation */ \
- lis %r3,(KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY)@ha; \
- addi %r3,%r3,(KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY)@l; \
- mtsr KERNEL_SR,%r3; \
- mfmsr %r5; \
- ori %r5,%r5,(PSL_IR|PSL_DR|PSL_RI); \
- mtmsr %r5; \
- isync
-
- .globl _C_LABEL(extint_call)
- .type _C_LABEL(extint_call),@function
-extintr:
- INTRENTER
-_C_LABEL(extint_call):
- bl _C_LABEL(extint_call) /* to be filled in later */
-intr_exit:
-/* Disable interrupts (should already be disabled) and MMU here: */
- mfmsr %r3
- andi. %r3,%r3,~(PSL_EE|PSL_ME|PSL_RI|PSL_DR|PSL_IR)@l
- mtmsr %r3
- isync
-/* restore possibly overwritten registers: */
- lwz %r12,44(%r1)
- lwz %r11,48(%r1)
- lwz %r10,52(%r1)
- lwz %r9,56(%r1)
- lwz %r8,60(%r1)
- lwz %r7,64(%r1)
- lwz %r6,8(%r1)
- lwz %r5,12(%r1)
- lwz %r4,28(%r1)
- lwz %r3,32(%r1)
- mtsrr1 %r6
- mtsrr0 %r5
- mtctr %r4
- mtxer %r3
-/* Returning to user mode? */
- mtcr %r6 /* saved SRR1 */
- bc 4,17,1f /* branch if PSL_PR is false */
- lis %r3,_C_LABEL(curpm)@ha /* get current pmap real address */
- lwz %r3,_C_LABEL(curpm)@l(%r3)
- lwz %r3,PM_KERNELSR(%r3)
- mtsr KERNEL_SR,%r3 /* Restore kernel SR */
- lis %r3,_C_LABEL(astpending)@ha /* Test AST pending */
- lwz %r4,_C_LABEL(astpending)@l(%r3)
- andi. %r4,%r4,1
- beq 1f
-/* Setup for entry to realtrap: */
- lwz %r3,0(%r1) /* get saved SP */
- mtsprg %r1,3
- li %r6,EXC_AST
- stmw %r28,tempsave(0) /* establish tempsave again */
- mtlr %r6
- lwz %r28,40(%r1) /* saved LR */
- lwz %r29,36(%r1) /* saved CR */
- lwz %r6,68(%r1)
- lwz %r5,72(%r1)
- lwz %r4,76(%r1)
- lwz %r3,80(%r1)
- lwz %r0,84(%r1)
- lis %r30,_C_LABEL(intr_depth)@ha /* adjust reentrancy count */
- lwz %r31,_C_LABEL(intr_depth)@l(%r30)
- addi %r31,%r31,-1
- stw %r31,_C_LABEL(intr_depth)@l(%r30)
- b realtrap
-1:
-/* Here is the normal exit of extintr: */
- lwz %r5,36(%r1)
- lwz %r6,40(%r1)
- mtcr %r5
- mtlr %r6
- lwz %r6,68(%r1)
- lwz %r5,72(%r1)
- lis %r3,_C_LABEL(intr_depth)@ha /* adjust reentrancy count */
- lwz %r4,_C_LABEL(intr_depth)@l(%r3)
- addi %r4,%r4,-1
- stw %r4,_C_LABEL(intr_depth)@l(%r3)
- lwz %r4,76(%r1)
- lwz %r3,80(%r1)
- lwz %r0,84(%r1)
- lwz %r1,0(%r1)
- rfi
-
-/*
- * Decrementer interrupt second level handler
- */
-decrintr:
- INTRENTER
- addi %r3,%r1,8 /* intr frame */
- bl _C_LABEL(decr_intr)
- b intr_exit
-
-
-/*
- * int setfault()
- *
- * Similar to setjmp to setup for handling faults on accesses to user memory.
- * Any routine using this may only call bcopy, either the form below,
- * or the (currently used) C code optimized, so it doesn't use any non-volatile
- * registers.
- */
- .globl _C_LABEL(setfault)
- .type _C_LABEL(setfault),@function
-_C_LABEL(setfault):
- mflr %r0
- mfcr %r12
- mfmsr %r2
- lis %r4,_C_LABEL(curpcb)@ha
- lwz %r4,_C_LABEL(curpcb)@l(%r4)
- stw %r3,PCB_FAULT(%r4)
- stw %r0,0(%r3)
- stw %r2,4(%r3)
- stw %r1,8(%r3)
- stmw %r12,12(%r3)
- li %r3,0
- blr
-
-/*
- * The following code gets copied to the top of the user stack on process
- * execution. It does signal trampolining on signal delivery.
- *
- * On entry r1 points to a struct sigframe at bottom of current stack.
- * All other registers are unchanged.
- */
- .globl _C_LABEL(sigcode),_C_LABEL(esigcode)
- .type _C_LABEL(sigcode),@function
- .type _C_LABEL(esigcode),@function
-_C_LABEL(sigcode):
- addi %r1,%r1,-16 /* reserved space for callee */
- blrl
- addi %r3,%r1,16+8 /* compute &sf_sc */
- li %r0,SYS_sigreturn
- sc /* sigreturn(scp) */
- li %r0,SYS_exit
- sc /* exit(errno) */
-_C_LABEL(esigcode):
-
-
-
- .data
- .globl _C_LABEL(intrnames)
- .type _C_LABEL(intrnames),@object
- .globl _C_LABEL(eintrnames)
- .type _C_LABEL(eintrnames),@object
-_C_LABEL(intrnames):
- .string "irq0" "irq1" "irq2" "irq3"
- .string "irq4" "irq5" "irq6" "irq7"
- .string "irq8" "irq9" "irq10" "irq11"
- .string "irq12" "irq13" "irq14" "irq15"
- .string "irq16" "irq17" "irq18" "irq19"
- .string "irq20" "irq21" "irq22" "irq23"
- .string "irq24" "irq25" "irq26" "irq27"
- .string "irq28" "irq29" "irq30" "irq31"
- .string "irq32" "irq33" "irq34" "irq35"
- .string "irq36" "irq37" "irq38" "irq39"
- .string "irq40" "irq41" "irq42" "irq43"
- .string "irq44" "irq45" "irq46" "irq47"
- .string "irq48" "irq49" "irq50" "irq51"
- .string "irq52" "irq53" "irq54" "irq55"
- .string "irq56" "irq57" "irq58" "irq59"
- .string "irq60" "irq61" "irq62" "irq63"
- .string "clock"
- .string "stat"
- .space 512
-_C_LABEL(eintrnames):
- .align 4
- .globl _C_LABEL(intrcnt)
- .type _C_LABEL(intrcnt),@object
- .globl _C_LABEL(eintrcnt)
- .type _C_LABEL(eintrcnt),@object
-_C_LABEL(intrcnt):
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0,0,0,0
- .long 0
- .long 0
-_C_LABEL(eintrcnt):
-
-#ifdef DDB
-/*
- * Deliberate entry to ddbtrap
- */
- .globl _C_LABEL(ddb_trap)
-_C_LABEL(ddb_trap):
- mtsprg %r1,1
- mfmsr %r3
- mtsrr1 %r3
- andi. %r3,%r3,~(PSL_EE|PSL_ME)@l
- mtmsr %r3 /* disable interrupts */
- isync
- stmw %r28,ddbsave(0)
- mflr %r28
- li %r29,EXC_BPT
- mtlr %r29
- mfcr %r29
- mtsrr0 %r28
-
-/*
- * Now the ddb trap catching code.
- */
-ddbtrap:
- FRAME_SETUP(ddbsave)
-/* Call C trap code: */
- addi %r3,%r1,8
- bl _C_LABEL(ddb_trap_glue)
- or. %r3,%r3,%r3
- bne ddbleave
-/* This wasn't for DDB, so switch to real trap: */
- lwz %r3,FRAME_EXC+8(%r1) /* save exception */
- stw %r3,ddbsave+8(0)
- FRAME_LEAVE(ddbsave)
- mtsprg %r1,1 /* prepare for entrance to realtrap */
- stmw %r28,tempsave(0)
- mflr %r28
- mfcr %r29
- lwz %r31,ddbsave+8(0)
- mtlr %r31
- b realtrap
-ddbleave:
- FRAME_LEAVE(ddbsave)
- rfi
-#endif /* DDB */
-
diff --git a/sys/arch/pegasos/pegasos/machdep.c b/sys/arch/pegasos/pegasos/machdep.c
deleted file mode 100644
index cbc638e032f..00000000000
--- a/sys/arch/pegasos/pegasos/machdep.c
+++ /dev/null
@@ -1,1440 +0,0 @@
-/* $OpenBSD: machdep.c,v 1.5 2004/02/04 20:07:18 drahn Exp $ */
-/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
-
-/*
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/buf.h>
-#include <sys/timeout.h>
-#include <sys/exec.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/mount.h>
-#include <sys/msgbuf.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-#include <sys/reboot.h>
-#include <sys/syscallargs.h>
-#include <sys/syslog.h>
-#include <sys/extent.h>
-#include <sys/systm.h>
-#include <sys/user.h>
-
-#include <uvm/uvm_extern.h>
-
-#ifdef SYSVMSG
-#include <sys/msg.h>
-#endif
-#include <net/netisr.h>
-
-#include <dev/cons.h>
-
-#include <machine/bat.h>
-#include <machine/pmap.h>
-#include <machine/powerpc.h>
-#include <machine/trap.h>
-#include <machine/autoconf.h>
-#include <machine/bus.h>
-#include <machine/pio.h>
-#include <machine/intr.h>
-
-#include <dev/pci/pcivar.h>
-
-#include <arch/pegasos/pegasos/ofw_machdep.h>
-#include <dev/ofw/openfirm.h>
-
-#if 0
-#if KEYBOARD_RESET
-#include <dev/isa/isareg.h>
-#include <dev/isa/isavar.h>
-#include <dev/ic/i8042reg.h>
-#endif
-#endif
-
-#ifdef DDB
-#include <machine/db_machdep.h>
-#include <ddb/db_access.h>
-#include <ddb/db_sym.h>
-#include <ddb/db_extern.h>
-#endif
-
-/*
- * Global variables used here and there
- */
-struct pcb *curpcb;
-struct pmap *curpm;
-struct proc *fpuproc;
-
-extern struct user *proc0paddr;
-struct pool ppc_vecpl;
-
-/*
- * Declare these as initialized data so we can patch them.
- */
-#ifdef NBUF
-int nbuf = NBUF;
-#else
-int nbuf = 0;
-#endif
-
-#ifndef BUFCACHEPERCENT
-#define BUFCACHEPERCENT 5
-#endif
-
-#ifdef BUFPAGES
-int bufpages = BUFPAGES;
-#else
-int bufpages = 0;
-#endif
-int bufcachepercent = BUFCACHEPERCENT;
-
-struct bat battable[16];
-
-struct vm_map *exec_map = NULL;
-struct vm_map *phys_map = NULL;
-
-int ppc_malloc_ok = 0;
-
-#ifndef SYS_TYPE
-/* XXX Hardwire it for now */
-#define SYS_TYPE POWER4e
-#endif
-
-int system_type = SYS_TYPE; /* XXX Hardwire it for now */
-
-char ofw_eth_addr[6]; /* Save address of first network ifc found */
-char *bootpath;
-char bootpathbuf[512];
-
-struct firmware *fw = NULL;
-
-#ifdef DDB
-void * startsym, *endsym;
-#endif
-
-#ifdef APERTURE
-#ifdef INSECURE
-int allowaperture = 1;
-#else
-int allowaperture = 0;
-#endif
-#endif
-
-void ofw_dbg(char *str);
-
-caddr_t allocsys(caddr_t);
-void dumpsys(void);
-void systype(char *name);
-int lcsplx(int ipl); /* called from LCore */
-int power4e_get_eth_addr(void);
-void nameinterrupt(int replace, char *newstr);
-void ppc_intr_setup(intr_establish_t *establish,
- intr_disestablish_t *disestablish);
-void *ppc_intr_establish(void *lcv, pci_intr_handle_t ih, int type,
- int level, int (*func)(void *), void *arg, char *name);
-int bus_mem_add_mapping(bus_addr_t bpa, bus_size_t size, int cacheable,
- bus_space_handle_t *bshp);
-bus_addr_t bus_space_unmap_p(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-
-/*
- * Extent maps to manage I/O. Allocate storage for 8 regions in each,
- * initially. Later devio_malloc_safe will indicate that it's save to
- * use malloc() to dynamically allocate region descriptors.
- */
-static long devio_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof (long)];
-struct extent *devio_ex;
-static int devio_malloc_safe = 0;
-
-extern int OF_stdout;
-
-/* XXX, called from asm */
-void initppc(u_int startkernel, u_int endkernel, char *args);
-
-int pegasos = 0;
-
-void
-initppc(startkernel, endkernel, args)
- u_int startkernel, endkernel;
- char *args;
-{
- extern void *trapcode; extern int trapsize;
- extern void *dsitrap; extern int dsisize;
- extern void *isitrap; extern int isisize;
- extern void *alitrap; extern int alisize;
- extern void *decrint; extern int decrsize;
- extern void *tlbimiss; extern int tlbimsize;
- extern void *tlbdlmiss; extern int tlbdlmsize;
- extern void *tlbdsmiss; extern int tlbdsmsize;
-#ifdef DDB
- extern void *ddblow; extern int ddbsize;
-#endif
- extern void consinit(void);
- extern void callback(void *);
- extern void *msgbuf_addr;
- int exc, scratch;
-
- proc0.p_addr = proc0paddr;
- bzero(proc0.p_addr, sizeof *proc0.p_addr);
-
- curpcb = &proc0paddr->u_pcb;
-
- curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel();
-
- /*
- * Initialize BAT registers to unmapped to not generate
- * overlapping mappings below.
- */
- ppc_mtibat0u(0);
- ppc_mtibat1u(0);
- ppc_mtibat2u(0);
- ppc_mtibat3u(0);
- ppc_mtdbat0u(0);
- ppc_mtdbat1u(0);
- ppc_mtdbat2u(0);
- ppc_mtdbat3u(0);
-
- /*
- * Set up initial BAT table to only map the lowest 256 MB area
- */
- battable[0].batl = BATL(0x00000000, BAT_M);
- battable[0].batu = BATU(0x00000000);
-
- /*
- * Now setup fixed bat registers
- *
- * Note that we still run in real mode, and the BAT
- * registers were cleared above.
- */
- /* IBAT0 used for initial 256 MB segment */
- ppc_mtibat0l(battable[0].batl);
- ppc_mtibat0u(battable[0].batu);
-
- /* DBAT0 used similar */
- ppc_mtdbat0l(battable[0].batl);
- ppc_mtdbat0u(battable[0].batu);
-
- /*
- * Set up trap vectors
- */
- for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100) {
- switch (exc) {
- default:
- bcopy(&trapcode, (void *)exc, (size_t)&trapsize);
- break;
- case EXC_EXI:
- /*
- * This one is (potentially) installed during autoconf
- */
- break;
-
- case EXC_DSI:
- bcopy(&dsitrap, (void *)EXC_DSI, (size_t)&dsisize);
- break;
- case EXC_ISI:
- bcopy(&isitrap, (void *)EXC_ISI, (size_t)&isisize);
- break;
- case EXC_ALI:
- bcopy(&alitrap, (void *)EXC_ALI, (size_t)&alisize);
- break;
- case EXC_DECR:
- bcopy(&decrint, (void *)EXC_DECR, (size_t)&decrsize);
- break;
- case EXC_IMISS:
- bcopy(&tlbimiss, (void *)EXC_IMISS, (size_t)&tlbimsize);
- break;
- case EXC_DLMISS:
- bcopy(&tlbdlmiss, (void *)EXC_DLMISS, (size_t)&tlbdlmsize);
- break;
- case EXC_DSMISS:
- bcopy(&tlbdsmiss, (void *)EXC_DSMISS, (size_t)&tlbdsmsize);
- break;
- case EXC_PGM:
- case EXC_TRC:
- case EXC_BPT:
-#if defined(DDB)
- bcopy(&ddblow, (void *)exc, (size_t)&ddbsize);
-#endif
- break;
- }
- }
-
- /* Grr, ALTIVEC_UNAVAIL is a vector not ~0xff aligned: 0x0f20 */
- bcopy(&trapcode, (void *)0xf20, (size_t)&trapsize);
-
- /*
- * since trapsize is > 0x20, we just overwrote the EXC_PERF handler
- * since we do not use it, we will "share" it with the EXC_VEC,
- * we dont support EXC_VEC either.
- * should be a 'ba 0xf20 written' at address 0xf00, but we
- * do not generate EXC_PERF exceptions...
- */
-
- syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
-
-
- uvmexp.pagesize = 4096;
- uvm_setpagesize();
-
- /*
- * Initialize pmap module.
- */
- pmap_bootstrap(startkernel, endkernel);
-
- /* use BATs to map 1GB memory, no pageable BATs now */
- if (physmem > btoc(0x10000000)) {
- ppc_mtdbat1l(BATL(0x10000000, BAT_M));
- ppc_mtdbat1u(BATU(0x10000000));
- }
- if (physmem > btoc(0x20000000)) {
- ppc_mtdbat2l(BATL(0x20000000, BAT_M));
- ppc_mtdbat2u(BATU(0x20000000));
- }
- if (physmem > btoc(0x30000000)) {
- ppc_mtdbat3l(BATL(0x30000000, BAT_M));
- ppc_mtdbat3u(BATU(0x30000000));
- }
-#if 0
- /* now that we know physmem size, map physical memory with BATs */
- if (physmem > btoc(0x10000000)) {
- battable[0x1].batl = BATL(0x10000000, BAT_M);
- battable[0x1].batu = BATU(0x10000000);
- }
- if (physmem > btoc(0x20000000)) {
- battable[0x2].batl = BATL(0x20000000, BAT_M);
- battable[0x2].batu = BATU(0x20000000);
- }
- if (physmem > btoc(0x30000000)) {
- battable[0x3].batl = BATL(0x30000000, BAT_M);
- battable[0x3].batu = BATU(0x30000000);
- }
- if (physmem > btoc(0x40000000)) {
- battable[0x4].batl = BATL(0x40000000, BAT_M);
- battable[0x4].batu = BATU(0x40000000);
- }
- if (physmem > btoc(0x50000000)) {
- battable[0x5].batl = BATL(0x50000000, BAT_M);
- battable[0x5].batu = BATU(0x50000000);
- }
- if (physmem > btoc(0x60000000)) {
- battable[0x6].batl = BATL(0x60000000, BAT_M);
- battable[0x6].batu = BATU(0x60000000);
- }
- if (physmem > btoc(0x70000000)) {
- battable[0x7].batl = BATL(0x70000000, BAT_M);
- battable[0x7].batu = BATU(0x70000000);
- }
-#endif
-
- /*
- * Now enable translation (and machine checks/recoverable interrupts).
- */
- (fw->vmon)();
-
- __asm__ volatile ("eieio; mfmsr %0; ori %0,%0,%1; mtmsr %0; sync;isync"
- : "=r"(scratch) : "K"(PSL_IR|PSL_DR|PSL_ME|PSL_RI));
-
- /*
- * use the memory provided by pmap_bootstrap for message buffer
- */
- initmsgbuf(msgbuf_addr, MSGBUFSIZE);
-
- /*
- * Look at arguments passed to us and compute boothowto.
- * Default to SINGLE and ASKNAME if no args or
- * SINGLE and DFLTROOT if this is a ramdisk kernel.
- */
-#ifdef RAMDISK_HOOKS
- boothowto = RB_SINGLE | RB_DFLTROOT;
-#else
- boothowto = RB_AUTOBOOT;
-#endif /* RAMDISK_HOOKS */
-
- /*
- * Parse arg string.
- */
-
- /* make a copy of the args! */
- strncpy(bootpathbuf, args, 512);
- bootpath= &bootpathbuf[0];
- while ( *++bootpath && *bootpath != ' ');
- if (*bootpath) {
- *bootpath++ = 0;
- while (*bootpath) {
- switch (*bootpath++) {
- case 'a':
- boothowto |= RB_ASKNAME;
- break;
- case 's':
- boothowto |= RB_SINGLE;
- break;
- case 'd':
- boothowto |= RB_KDB;
- break;
- case 'c':
- boothowto |= RB_CONFIG;
- break;
- default:
- break;
- }
- }
- }
- bootpath= &bootpathbuf[0];
-
-#ifdef DDB
- ddb_init();
-#endif
-
- /*
- * Set up extents for pci mappings
- * Is this too late?
- *
- * what are good start and end values here??
- * 0x0 - 0x80000000 mcu bus
- * MAP A MAP B
- * 0x80000000 - 0xbfffffff io 0x80000000 - 0xefffffff mem
- * 0xc0000000 - 0xffffffff mem 0xf0000000 - 0xffffffff io
- *
- * of course bsd uses 0xe and 0xf
- * So the BSD PPC memory map will look like this
- * 0x0 - 0x80000000 memory (whatever is filled)
- * 0x80000000 - 0xdfffffff (pci space, memory or io)
- * 0xe0000000 - kernel vm segment
- * 0xf0000000 - kernel map segment (user space mapped here)
- */
-
- devio_ex = extent_create("devio", 0x80000000, 0xffffffff, M_DEVBUF,
- (caddr_t)devio_ex_storage, sizeof(devio_ex_storage),
- EX_NOCOALESCE|EX_NOWAIT);
-
- /*
- * Now we can set up the console as mapping is enabled.
- */
- ofwconsinit();
- /* while using openfirmware, run userconfig */
- if (boothowto & RB_CONFIG) {
-#ifdef BOOT_CONFIG
- user_config();
-#else
- printf("kernel does not support -c; continuing..\n");
-#endif
- }
-
- {
- char model[32];
- int node, len;
-
- node = OF_peer(0);
- len = OF_getprop(node, "model", model, sizeof(model));
- model[len] = 0;
-
- /*
- * Different versions of Pegasos:
- * Pegasos I, no April (not supported...)
- * Pegasos I, April I 0
- * Pegasos I, April II 1 (?)
- * Pegasos II 2
- *
- * However, OF does not distingush between
- * April I and April II therefore we must assume it
- * has the April I snoop bug...
- */
-
- if (strcmp(model, "Pegasos2") == 0) {
- pegasos = 2;
- } else {
- pegasos = 0; /* Assume PegI April I */
- }
-
-
- }
- /*
- * Replace with real console.
- */
- ofwconprobe();
- consinit();
-
-#ifdef DDB
- if (boothowto & RB_KDB)
- Debugger();
-#endif
-
- /*
- * Figure out ethernet address.
- */
- (void)power4e_get_eth_addr();
-
- pool_init(&ppc_vecpl, sizeof(struct vreg), 16, 0, 0, "ppcvec", NULL);
-
-}
-void ofw_dbg(char *str)
-{
- int i = strlen (str);
- OF_write(OF_stdout, str, i);
-}
-
-
-void
-install_extint(void (*handler)(void))
-{
- void extint(void);
- void extsize(void);
- extern u_long extint_call;
- u_long offset = (u_long)handler - (u_long)&extint_call;
- int msr;
-
-#ifdef DIAGNOSTIC
- if (offset > 0x1ffffff)
- panic("install_extint: too far away");
-#endif
- msr = ppc_intr_disable();
- extint_call = (extint_call & 0xfc000003) | offset;
- bcopy(&extint, (void *)EXC_EXI, (size_t)&extsize);
- syncicache((void *)&extint_call, sizeof extint_call);
- syncicache((void *)EXC_EXI, (int)&extsize);
- ppc_intr_enable(msr);
-}
-
-/*
- * Machine dependent startup code.
- */
-void
-cpu_startup()
-{
- int sz, i;
- caddr_t v;
- vm_offset_t minaddr, maxaddr;
- int base, residual;
- v = (caddr_t)proc0paddr + USPACE;
-
- proc0.p_addr = proc0paddr;
-
- printf("%s", version);
-
- printf("real mem = %d (%dK)\n", ctob(physmem), ctob(physmem)/1024);
-
- /*
- * Find out how much space we need, allocate it,
- * and then give everything true virtual addresses.
- */
- sz = (int)allocsys((caddr_t)0);
- if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
- panic("startup: no room for tables");
- if (allocsys(v) - v != sz)
- panic("startup: table size inconsistency");
-
- /*
- * Now allocate buffers proper. They are different than the above
- * in that they usually occupy more virtual memory than physical.
- */
- sz = MAXBSIZE * nbuf;
- if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(sz),
- NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE,
- UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)))
- panic("cpu_startup: cannot allocate VM for buffers");
- /*
- addr = (vaddr_t)buffers;
- */
- base = bufpages / nbuf;
- residual = bufpages % nbuf;
- if (base >= MAXBSIZE) {
- /* Don't want to alloc more physical mem than ever needed */
- base = MAXBSIZE;
- residual = 0;
- }
- for (i = 0; i < nbuf; i++) {
- vm_size_t curbufsize;
- vm_offset_t curbuf;
- struct vm_page *pg;
-
- curbuf = (vm_offset_t)buffers + i * MAXBSIZE;
- curbufsize = PAGE_SIZE * (i < residual ? base + 1 : base);
- while (curbufsize) {
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (pg == NULL)
- panic("cpu_startup: not enough memory for"
- " buffer cache");
- pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg),
- VM_PROT_READ|VM_PROT_WRITE);
- curbuf += PAGE_SIZE;
- curbufsize -= PAGE_SIZE;
- }
- }
- pmap_update(pmap_kernel());
-
- /*
- * Allocate a submap for exec arguments. This map effectively
- * limits the number of processes exec'ing at any time.
- */
- minaddr = vm_map_min(kernel_map);
- exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 16 * NCARGS,
- VM_MAP_PAGEABLE, FALSE, NULL);
-
- /*
- * Allocate a submap for physio
- */
- phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
- VM_PHYS_SIZE, 0, FALSE, NULL);
- ppc_malloc_ok = 1;
-
- printf("avail mem = %ld (%ldK)\n", ptoa(uvmexp.free),
- ptoa(uvmexp.free) / 1024);
- printf("using %d buffers containing %d bytes of memory\n", nbuf,
- bufpages * PAGE_SIZE);
-
- /*
- * Set up the buffers.
- */
- bufinit();
-
- devio_malloc_safe = 1;
-}
-
-/*
- * Allocate space for system data structures.
- */
-caddr_t
-allocsys(caddr_t v)
-{
-#define valloc(name, type, num) \
- v = (caddr_t)(((name) = (type *)v) + (num))
-
-#ifdef SYSVMSG
- valloc(msgpool, char, msginfo.msgmax);
- valloc(msgmaps, struct msgmap, msginfo.msgseg);
- valloc(msghdrs, struct msg, msginfo.msgtql);
- valloc(msqids, struct msqid_ds, msginfo.msgmni);
-#endif
-
- /*
- * Decide on buffer space to use.
- */
- if (bufpages == 0)
- bufpages = physmem * bufcachepercent / 100;
- if (nbuf == 0) {
- nbuf = bufpages;
- if (nbuf < 16)
- nbuf = 16;
- }
- /* Restrict to at most 35% filled kvm */
- if (nbuf >
- (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) / MAXBSIZE * 35 / 100)
- nbuf = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) /
- MAXBSIZE * 35 / 100;
-
- /* More buffer pages than fits into the buffers is senseless. */
- if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE)
- bufpages = nbuf * MAXBSIZE / PAGE_SIZE;
-
- valloc(buf, struct buf, nbuf);
-
- return v;
-}
-
-/*
- * consinit
- * Initialize system console.
- */
-void
-consinit()
-{
- static int cons_initted = 0;
-
- if (cons_initted)
- return;
- cninit();
- cons_initted = 1;
-}
-
-/*
- * Clear registers on exec
- */
-void
-setregs(struct proc *p, struct exec_package *pack, u_long stack,
- register_t *retval)
-{
- u_int32_t newstack;
- u_int32_t pargs;
- u_int32_t args[4];
-
- struct trapframe *tf = trapframe(p);
- pargs = -roundup(-stack + 8, 16);
- newstack = (u_int32_t)(pargs - 32);
-
- copyin ((void *)(VM_MAX_ADDRESS-0x10), &args, 0x10);
-
- bzero(tf, sizeof *tf);
- tf->fixreg[1] = newstack;
- tf->fixreg[3] = retval[0] = args[1]; /* XXX */
- tf->fixreg[4] = retval[1] = args[0]; /* XXX */
- tf->fixreg[5] = args[2]; /* XXX */
- tf->fixreg[6] = args[3]; /* XXX */
- tf->srr0 = pack->ep_entry;
- tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT;
- p->p_addr->u_pcb.pcb_flags = 0;
-}
-
-/*
- * Send a signal to process.
- */
-void
-sendsig(sig_t catcher, int sig, int mask, u_long code, int type,
- union sigval val)
-{
- struct proc *p = curproc;
- struct trapframe *tf;
- struct sigframe *fp, frame;
- struct sigacts *psp = p->p_sigacts;
- int oldonstack;
-
- frame.sf_signum = sig;
-
- tf = trapframe(p);
- oldonstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
-
- /*
- * Allocate stack space for signal handler.
- */
- if ((psp->ps_flags & SAS_ALTSTACK)
- && !oldonstack
- && (psp->ps_sigonstack & sigmask(sig))) {
- fp = (struct sigframe *)(psp->ps_sigstk.ss_sp
- + psp->ps_sigstk.ss_size);
- psp->ps_sigstk.ss_flags |= SS_ONSTACK;
- } else
- fp = (struct sigframe *)tf->fixreg[1];
-
- fp = (struct sigframe *)((int)(fp - 1) & ~0xf);
-
- /*
- * Generate signal context for SYS_sigreturn.
- */
- frame.sf_sc.sc_onstack = oldonstack;
- frame.sf_sc.sc_mask = mask;
- frame.sf_sip = NULL;
- bcopy(tf, &frame.sf_sc.sc_frame, sizeof *tf);
- if (psp->ps_siginfo & sigmask(sig)) {
- frame.sf_sip = &fp->sf_si;
- initsiginfo(&frame.sf_si, sig, code, type, val);
- }
- if (copyout(&frame, fp, sizeof frame) != 0)
- sigexit(p, SIGILL);
-
-
- tf->fixreg[1] = (int)fp;
- tf->lr = (int)catcher;
- tf->fixreg[3] = (int)sig;
- tf->fixreg[4] = (psp->ps_siginfo & sigmask(sig)) ? (int)&fp->sf_si : NULL;
- tf->fixreg[5] = (int)&fp->sf_sc;
- tf->srr0 = p->p_sigcode;
-
-#if WHEN_WE_ONLY_FLUSH_DATA_WHEN_DOING_PMAP_ENTER
- pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),tf->srr0, &pa);
- syncicache(pa, (p->p_emul->e_esigcode - p->p_emul->e_sigcode));
-#endif
-}
-
-/*
- * System call to cleanup state after a signal handler returns.
- */
-int
-sys_sigreturn(struct proc *p, void *v, register_t *retval)
-{
- struct sys_sigreturn_args /* {
- syscallarg(struct sigcontext *) sigcntxp;
- } */ *uap = v;
- struct sigcontext sc;
- struct trapframe *tf;
- int error;
-
- if ((error = copyin(SCARG(uap, sigcntxp), &sc, sizeof sc)))
- return error;
- tf = trapframe(p);
- if ((sc.sc_frame.srr1 & PSL_USERSTATIC) != (tf->srr1 & PSL_USERSTATIC))
- return EINVAL;
- bcopy(&sc.sc_frame, tf, sizeof *tf);
- if (sc.sc_onstack & 1)
- p->p_sigacts->ps_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigacts->ps_sigstk.ss_flags &= ~SS_ONSTACK;
- p->p_sigmask = sc.sc_mask & ~sigcantmask;
- return EJUSTRETURN;
-}
-
-/*
- * Machine dependent system variables.
- * None for now.
- */
-int
-cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
- size_t newlen, struct proc *p)
-{
- /* all sysctl names at this level are terminal */
- if (namelen != 1)
- return ENOTDIR;
- switch (name[0]) {
- case CPU_ALLOWAPERTURE:
-#ifdef APERTURE
- if (securelevel > 0)
- return (sysctl_rdint(oldp, oldlenp, newp,
- allowaperture));
- else
- return (sysctl_int(oldp, oldlenp, newp, newlen,
- &allowaperture));
-#else
- return (sysctl_rdint(oldp, oldlenp, newp, 0));
-#endif
- default:
- return EOPNOTSUPP;
- }
-}
-
-void
-dumpsys()
-{
- printf("dumpsys: TBD\n");
-}
-
-volatile int cpl, ipending, astpending;
-int imask[IPL_NUM];
-
-/*
- * this is a hack interface to allow zs to work better until
- * a true soft interrupt mechanism is created.
- */
-void
-softtty()
-{
-}
-
-int netisr;
-
-/*
- * Soft networking interrupts.
- */
-void
-softnet(int isr)
-{
-#define DONETISR(flag, func) \
- if (isr & (1 << flag))\
- func();
-
-#include <net/netisr_dispatch.h>
-}
-
-int
-lcsplx(int ipl)
-{
- int oldcpl;
-
- oldcpl = cpl;
- splx(ipl);
- return oldcpl;
-}
-
-/*
- * Halt or reboot the machine after syncing/dumping according to howto.
- */
-void
-boot(int howto)
-{
- static int syncing;
- static char str[256];
-
- boothowto = howto;
- if (!cold && !(howto & RB_NOSYNC) && !syncing) {
- syncing = 1;
- vfs_shutdown(); /* sync */
-#if 0
- /* resettodr does not currently do anything, address
- * this later
- */
- /*
- * If we've been adjusting the clock, the todr
- * will be out of synch; adjust it now unless
- * the system was sitting in ddb.
- */
- if ((howto & RB_TIMEBAD) == 0) {
- resettodr();
- } else {
- printf("WARNING: not updating battery clock\n");
- }
-#endif
- }
- splhigh();
- if (howto & RB_HALT) {
- doshutdownhooks();
- if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
- /* XXX */
- printf("WARNING: powerdown failed!\n");
- }
-
- printf("halted\n\n");
- (fw->exit)();
- }
- if (!cold && (howto & RB_DUMP))
- dumpsys();
- doshutdownhooks();
- printf("rebooting\n\n");
-
-
- (fw->boot)(str);
- {
- /*UGLY HACK!!! */
- void (*f)(void) = (void *)0xfff00100;
- ppc_mtsrr1(PSL_IP);
- ppc_mtsrr0(0);
- ppc_mtmsr(PSL_IP);
- f();
- }
- printf("boot failed, spinning\n");
- while(1) /* forever */;
-}
-
-/*
- * Get Ethernet address for the onboard ethernet chip.
- */
-int
-power4e_get_eth_addr()
-{
- int qhandle, phandle;
- char name[32];
-
- for (qhandle = OF_peer(0); qhandle; qhandle = phandle) {
- if (OF_getprop(qhandle, "device_type", name, sizeof name) >= 0
- && !strcmp(name, "network")
- && OF_getprop(qhandle, "local-mac-address",
- &ofw_eth_addr, sizeof ofw_eth_addr) >= 0) {
- return(0);
- }
- if ((phandle = OF_child(qhandle)))
- continue;
- while (qhandle) {
- if ((phandle = OF_peer(qhandle)))
- break;
- qhandle = OF_parent(qhandle);
- }
- }
- return(-1);
-}
-
-typedef void (void_f) (void);
-void_f *pending_int_f = NULL;
-
-/* call the bus/interrupt controller specific pending interrupt handler
- * would be nice if the offlevel interrupt code was handled here
- * instead of being in each of the specific handler code
- */
-void
-do_pending_int()
-{
- if (pending_int_f != NULL) {
- (*pending_int_f)();
- }
-}
-
-/*
- * set system type from string
- */
-void
-systype(char *name)
-{
- /* this table may be order specific if substrings match several
- * computers but a longer string matches a specific
- */
- int i;
- struct systyp {
- char *name;
- char *systypename;
- int type;
- } systypes[] = {
- { "MOT", "(PWRSTK) MCG powerstack family", PWRSTK },
- { "V-I Power", "(POWER4e) V-I ppc vme boards ", POWER4e},
- { "iMac", "(APPL) Apple iMac ", APPL},
- { "PowerMac", "(APPL) Apple PowerMac ", APPL},
- { "PowerBook", "(APPL) Apple Powerbook ", APPL},
- { NULL,"",0}
- };
- for (i = 0; systypes[i].name != NULL; i++) {
- if (strncmp( name , systypes[i].name,
- strlen (systypes[i].name)) == 0)
- {
- system_type = systypes[i].type;
- printf("recognized system type of %s as %s\n",
- name, systypes[i].systypename);
- break;
- }
- }
- if (system_type == OFWMACH) {
- printf("System type %snot recognized, good luck\n",
- name);
- }
-}
-
-/*
- * one attempt at interrupt stuff..
- *
- */
-#include <dev/pci/pcivar.h>
-
-int ppc_configed_intr_cnt = 0;
-struct intrhand ppc_configed_intr[MAX_PRECONF_INTR];
-
-void *
-ppc_intr_establish(void *lcv, pci_intr_handle_t ih, int type, int level,
- int (*func)(void *), void *arg, char *name)
-{
- if (ppc_configed_intr_cnt < MAX_PRECONF_INTR) {
- ppc_configed_intr[ppc_configed_intr_cnt].ih_fun = func;
- ppc_configed_intr[ppc_configed_intr_cnt].ih_arg = arg;
- ppc_configed_intr[ppc_configed_intr_cnt].ih_level = level;
- ppc_configed_intr[ppc_configed_intr_cnt].ih_irq = ih;
- ppc_configed_intr[ppc_configed_intr_cnt].ih_what = name;
- ppc_configed_intr_cnt++;
- } else {
- panic("ppc_intr_establish called before interrupt controller"
- " configured: driver %s too many interrupts", name);
- }
- /* disestablish is going to be tricky to supported for these :-) */
- return (void *)ppc_configed_intr_cnt;
-}
-
-intr_establish_t *intr_establish_func = (intr_establish_t *)ppc_intr_establish;
-intr_disestablish_t *intr_disestablish_func;
-
-void
-ppc_intr_setup(intr_establish_t *establish, intr_disestablish_t *disestablish)
-{
- intr_establish_func = establish;
- intr_disestablish_func = disestablish;
-}
-
-/* BUS functions */
-int
-bus_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size,
- int cacheable, bus_space_handle_t *bshp)
-{
- int error;
-
- if (POWERPC_BUS_TAG_BASE(t) == 0) {
- /* if bus has base of 0 fail. */
- return 1;
- }
- bpa |= POWERPC_BUS_TAG_BASE(t);
-#if 0
- if ((error = extent_alloc_region(devio_ex, bpa, size, EX_NOWAIT |
- (ppc_malloc_ok ? EX_MALLOCOK : 0))))
- {
- return error;
- }
-#endif
- if ((error = bus_mem_add_mapping(bpa, size, cacheable, bshp))) {
-#if 0
- if (extent_free(devio_ex, bpa, size, EX_NOWAIT |
- (ppc_malloc_ok ? EX_MALLOCOK : 0)))
- {
- printf("bus_space_map: pa 0x%x, size 0x%x\n",
- bpa, size);
- printf("bus_space_map: can't free region\n");
- }
-#endif
- }
- return 0;
-}
-bus_addr_t bus_space_unmap_p(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-bus_addr_t
-bus_space_unmap_p(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- bus_addr_t paddr;
-
- pmap_extract(pmap_kernel(), bsh, &paddr);
- bus_space_unmap((t), (bsh), (size));
- return paddr ;
-}
-void
-bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size)
-{
- bus_addr_t sva;
- bus_size_t off, len;
- bus_addr_t bpa;
-
- /* should this verify that the proper size is freed? */
- sva = trunc_page(bsh);
- off = bsh - sva;
- len = round_page(size+off);
-
- if (pmap_extract(pmap_kernel(), sva, &bpa) == TRUE) {
-#if 0
- if (extent_free(devio_ex, bpa | (bsh & PAGE_MASK), size,
- EX_NOWAIT | (ppc_malloc_ok ? EX_MALLOCOK : 0)))
- {
- printf("bus_space_map: pa 0x%x, size 0x%x\n",
- bpa, size);
- printf("bus_space_map: can't free region\n");
- }
-#endif
- }
- /* do not free memory which was stolen from the vm system */
- if (ppc_malloc_ok &&
- ((sva >= VM_MIN_KERNEL_ADDRESS) && (sva < VM_MAX_KERNEL_ADDRESS)) )
- {
- uvm_km_free(phys_map, sva, len);
- } else {
- for (; len > 0; len -= PAGE_SIZE) {
- pmap_kremove_pg(sva);
- sva += PAGE_SIZE;
- }
- pmap_update(pmap_kernel());
- }
-}
-
-vm_offset_t ppc_kvm_stolen = VM_KERN_ADDRESS_SIZE;
-
-int
-bus_mem_add_mapping(bus_addr_t bpa, bus_size_t size, int cacheable,
- bus_space_handle_t *bshp)
-{
- bus_addr_t vaddr;
- bus_addr_t spa, epa;
- bus_size_t off;
- int len;
-
- spa = trunc_page(bpa);
- epa = bpa + size;
- off = bpa - spa;
- len = size+off;
-
-#if 0
- if (epa <= spa) {
- panic("bus_mem_add_mapping: overflow");
- }
-#endif
- if (ppc_malloc_ok == 0) {
- bus_size_t alloc_size;
-
- /* need to steal vm space before kernel vm is initialized */
- alloc_size = round_page(len);
-
- vaddr = VM_MIN_KERNEL_ADDRESS + ppc_kvm_stolen;
- ppc_kvm_stolen += alloc_size;
- if (ppc_kvm_stolen > SEGMENT_LENGTH) {
- panic("ppc_kvm_stolen, out of space");
- }
- } else {
- vaddr = uvm_km_valloc_wait(phys_map, len);
- if (vaddr == 0)
- panic("bus_mem_add_mapping: kvm alloc of 0x%x failed",
- len);
- }
- *bshp = vaddr + off;
-#ifdef DEBUG_BUS_MEM_ADD_MAPPING
- printf("mapping %x size %x to %x vbase %x\n",
- bpa, size, *bshp, spa);
-#endif
- for (; len > 0; len -= PAGE_SIZE) {
- pmap_kenter_cache(vaddr, spa,
- VM_PROT_READ | VM_PROT_WRITE,
- cacheable ? PMAP_CACHE_WT : PMAP_CACHE_DEFAULT);
- spa += PAGE_SIZE;
- vaddr += PAGE_SIZE;
- }
- return 0;
-}
-
-int
-bus_space_alloc(bus_space_tag_t tag, bus_addr_t rstart, bus_addr_t rend,
- bus_size_t size, bus_size_t alignment, bus_size_t boundary, int cacheable,
- bus_addr_t *addrp, bus_space_handle_t *handlep)
-{
-
- panic("bus_space_alloc: unimplemented");
-}
-
-void
-bus_space_free(bus_space_tag_t tag, bus_space_handle_t handle, bus_size_t size)
-{
-
- panic("bus_space_free: unimplemented");
-}
-
-void *
-mapiodev(paddr_t pa, psize_t len)
-{
- paddr_t spa;
- vaddr_t vaddr, va;
- int off;
- int size;
-
- spa = trunc_page(pa);
- off = pa - spa;
- size = round_page(off+len);
- if (ppc_malloc_ok == 0) {
- /* need to steal vm space before kernel vm is initialized */
- va = VM_MIN_KERNEL_ADDRESS + ppc_kvm_stolen;
- ppc_kvm_stolen += size;
- if (ppc_kvm_stolen > SEGMENT_LENGTH) {
- panic("ppc_kvm_stolen, out of space");
- }
- } else {
- va = uvm_km_valloc_wait(phys_map, size);
- }
-
- if (va == 0)
- return NULL;
-
- for (vaddr = va; size > 0; size -= PAGE_SIZE) {
- pmap_kenter_cache(vaddr, spa,
- VM_PROT_READ | VM_PROT_WRITE, PMAP_CACHE_DEFAULT);
- spa += PAGE_SIZE;
- vaddr += PAGE_SIZE;
- }
- return (void *) (va+off);
-}
-
-void
-unmapiodev(void *kva, psize_t p_size)
-{
- vaddr_t vaddr;
- int size;
-
- size = p_size;
-
- vaddr = trunc_page((vaddr_t)kva);
-
- uvm_km_free_wakeup(phys_map, vaddr, size);
-
- for (; size > 0; size -= PAGE_SIZE) {
- pmap_remove(pmap_kernel(), vaddr, vaddr+PAGE_SIZE-1);
- vaddr += PAGE_SIZE;
- }
- pmap_update(pmap_kernel());
-}
-
-
-
-/*
- * probably should be ppc_space_copy
- */
-
-#define _CONCAT(A,B) A ## B
-#define __C(A,B) _CONCAT(A,B)
-
-#define BUS_SPACE_COPY_N(BYTES,TYPE) \
-void \
-__C(bus_space_copy_,BYTES)(void *v, bus_space_handle_t h1, \
- bus_size_t o1, bus_space_handle_t h2, bus_size_t o2, \
- bus_size_t c) \
-{ \
- TYPE *src, *dst; \
- int i; \
- \
- src = (TYPE *) (h1+o1); \
- dst = (TYPE *) (h2+o2); \
- \
- if (h1 == h2 && o2 > o1) \
- for (i = c-1; i >= 0; i--) \
- dst[i] = src[i]; \
- else \
- for (i = 0; i < c; i++) \
- dst[i] = src[i]; \
-}
-BUS_SPACE_COPY_N(1,u_int8_t)
-BUS_SPACE_COPY_N(2,u_int16_t)
-BUS_SPACE_COPY_N(4,u_int32_t)
-
-void
-bus_space_set_region_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
- u_int8_t val, bus_size_t c)
-{
- u_int8_t *dst;
- int i;
-
- dst = (u_int8_t *) (h+o);
-
- for (i = 0; i < c; i++)
- dst[i] = val;
-}
-
-void
-bus_space_set_region_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
- u_int16_t val, bus_size_t c)
-{
- u_int16_t *dst;
- int i;
-
- dst = (u_int16_t *) (h+o);
- if (t->bus_reverse)
- val = swap16(val);
-
- for (i = 0; i < c; i++)
- dst[i] = val;
-}
-void
-bus_space_set_region_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,
- u_int32_t val, bus_size_t c)
-{
- u_int32_t *dst;
- int i;
-
- dst = (u_int32_t *) (h+o);
- if (t->bus_reverse)
- val = swap32(val);
-
- for (i = 0; i < c; i++)
- dst[i] = val;
-}
-
-#define BUS_SPACE_READ_RAW_MULTI_N(BYTES,SHIFT,TYPE) \
-void \
-__C(bus_space_read_raw_multi_,BYTES)(bus_space_tag_t bst, \
- bus_space_handle_t h, bus_addr_t o, u_int8_t *dst, bus_size_t size) \
-{ \
- TYPE *src; \
- TYPE *rdst = (TYPE *)dst; \
- int i; \
- int count = size >> SHIFT; \
- \
- src = (TYPE *)(h+o); \
- for (i = 0; i < count; i++) { \
- rdst[i] = *src; \
- __asm__("eieio"); \
- } \
-}
-BUS_SPACE_READ_RAW_MULTI_N(2,1,u_int16_t)
-BUS_SPACE_READ_RAW_MULTI_N(4,2,u_int32_t)
-
-#define BUS_SPACE_WRITE_RAW_MULTI_N(BYTES,SHIFT,TYPE) \
-void \
-__C(bus_space_write_raw_multi_,BYTES)( bus_space_tag_t bst, \
- bus_space_handle_t h, bus_addr_t o, const u_int8_t *src, \
- bus_size_t size) \
-{ \
- int i; \
- TYPE *dst; \
- TYPE *rsrc = (TYPE *)src; \
- int count = size >> SHIFT; \
- \
- dst = (TYPE *)(h+o); \
- for (i = 0; i < count; i++) { \
- *dst = rsrc[i]; \
- __asm__("eieio"); \
- } \
-}
-
-BUS_SPACE_WRITE_RAW_MULTI_N(2,1,u_int16_t)
-BUS_SPACE_WRITE_RAW_MULTI_N(4,2,u_int32_t)
-
-int
-bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)
-{
- *nbshp = bsh + offset;
- return (0);
-}
-
-int
-ppc_open_pci_bridge()
-{
- char *
- pci_bridges[] = {
- "/pci",
- NULL
- };
- int handle;
- int i;
-
- for (i = 0; pci_bridges[i] != NULL; i++) {
- handle = OF_open(pci_bridges[i]);
- if ( handle != -1) {
- return handle;
- }
- }
- return 0;
-}
-void
-ppc_close_pci_bridge(int handle)
-{
- OF_close(handle);
-}
-
-/* bcopy(), error on fault */
-int
-kcopy(const void *from, void *to, size_t size)
-{
- faultbuf env;
- void *oldh = curproc->p_addr->u_pcb.pcb_onfault;
-
- if (setfault(&env)) {
- curproc->p_addr->u_pcb.pcb_onfault = oldh;
- return EFAULT;
- }
- bcopy(from, to, size);
- curproc->p_addr->u_pcb.pcb_onfault = oldh;
-
- return 0;
-}
-
-void
-nameinterrupt(int replace, char *newstr)
-{
-#define NENTRIES 66
- char intrname[NENTRIES][30];
- char *p, *src;
- int i;
- extern char intrnames[];
- extern char eintrnames[];
-
- if (replace >= NENTRIES) {
- return;
- }
- src = intrnames;
-
- for (i = 0; i < NENTRIES; i++) {
- src += strlcpy(intrname[i], src, 30);
- src+=1; /* skip the NUL */
- }
-
- strlcat(intrname[replace], "/", sizeof intrname[replace]);
- strlcat(intrname[replace], newstr, sizeof intrname[replace]);
-
- p = intrnames;
- for (i = 0; i < NENTRIES; i++) {
- p += strlcpy(p, intrname[i], eintrnames - p);
- p += 1; /* skip the NUL */
- }
-}
diff --git a/sys/arch/pegasos/pegasos/mainbus.c b/sys/arch/pegasos/pegasos/mainbus.c
deleted file mode 100644
index 00c9c19e5c3..00000000000
--- a/sys/arch/pegasos/pegasos/mainbus.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* $OpenBSD: mainbus.c,v 1.2 2004/02/04 20:07:18 drahn Exp $ */
-
-/*
- * Copyright (c) 1994, 1995 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/device.h>
-#include <sys/reboot.h>
-
-#include <machine/autoconf.h>
-#include <dev/ofw/openfirm.h>
-
-struct mainbus_softc {
- struct device sc_dv;
- struct bushook sc_bus;
-};
-
-/* Definition of the mainbus driver. */
-static int mbmatch(struct device *, void *, void *);
-static void mbattach(struct device *, struct device *, void *);
-static int mbprint(void *, const char *);
-
-struct cfattach mainbus_ca = {
- sizeof(struct mainbus_softc), mbmatch, mbattach
-};
-struct cfdriver mainbus_cd = {
- NULL, "mainbus", DV_DULL, NULL, 0
-};
-
-void mb_intr_establish(struct confargs *, int (*)(void *), void *);
-void mb_intr_disestablish(struct confargs *);
-caddr_t mb_cvtaddr(struct confargs *);
-int mb_matchname(struct confargs *, char *);
-
-/*ARGSUSED*/
-static int
-mbmatch(struct device *parent, void *cfdata, void *aux)
-{
-
- /*
- * That one mainbus is always here.
- */
- return(1);
-}
-
-static void
-mbattach(struct device *parent, struct device *self, void *aux)
-{
- struct mainbus_softc *sc = (struct mainbus_softc *)self;
- struct confargs nca;
- extern int system_type;
-
- printf("\n");
-
- sc->sc_bus.bh_dv = (struct device *)sc;
- sc->sc_bus.bh_type = BUS_MAIN;
- sc->sc_bus.bh_intr_establish = mb_intr_establish;
- sc->sc_bus.bh_intr_disestablish = mb_intr_disestablish;
- sc->sc_bus.bh_matchname = mb_matchname;
-
- /*
- * Try to find and attach all of the CPUs in the machine.
- * ( Right now only one CPU so code is simple )
- */
-
- nca.ca_name = "cpu";
- nca.ca_bus = &sc->sc_bus;
- config_found(self, &nca, mbprint);
-
- /* Set up Openfirmware.*/
- if (system_type != POWER4e) { /* for now */
- nca.ca_name = "ofroot";
- nca.ca_bus = &sc->sc_bus;
- config_found(self, &nca, mbprint);
- }
-
- /* The following machines have a PCI bus */
- if (system_type == APPL) {
- char name[32];
- int node;
- for (node = OF_child(OF_peer(0)); node; node=OF_peer(node)) {
- bzero (name, sizeof(name));
- if (OF_getprop(node, "device_type", name,
- sizeof(name)) <= 0) {
- if (OF_getprop(node, "name", name,
- sizeof(name)) <= 0)
- printf ("name not found on node %x\n",
- node);
- continue;
- }
- if (strcmp(name, "pci") == 0) {
- nca.ca_name = "mpcpcibr";
- nca.ca_node = node;
- nca.ca_bus = &sc->sc_bus;
- config_found(self, &nca, mbprint);
- }
- }
- } else if (system_type != OFWMACH) {
- nca.ca_name = "mpcpcibr";
- nca.ca_bus = &sc->sc_bus;
- nca.ca_node = OF_finddevice("/pci");
- config_found(self, &nca, mbprint);
- }
-}
-
-static int
-mbprint(void *aux, const char *pnp)
-{
- if (pnp)
- return (QUIET);
- return (UNCONF);
-}
-
-void
-mb_intr_establish(struct confargs *ca, int (*handler)(void *), void *val)
-{
- panic("can never mb_intr_establish");
-}
-
-void
-mb_intr_disestablish(struct confargs *ca)
-{
- panic("can never mb_intr_disestablish");
-}
-
-caddr_t
-mb_cvtaddr(struct confargs *ca)
-{
- return (NULL);
-}
-
-int
-mb_matchname(struct confargs *ca, char *name)
-{
- return (strcmp(name, ca->ca_name) == 0);
-}
diff --git a/sys/arch/pegasos/pegasos/mbrdisksubr.c b/sys/arch/pegasos/pegasos/mbrdisksubr.c
deleted file mode 100644
index b33adf2917a..00000000000
--- a/sys/arch/pegasos/pegasos/mbrdisksubr.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* $OpenBSD: mbrdisksubr.c,v 1.2 2003/12/20 22:40:15 miod Exp $ */
-/* $NetBSD: disksubr.c,v 1.21 1996/05/03 19:42:03 christos Exp $ */
-
-/*
- * Copyright (c) 1996 Theo de Raadt
- * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
- * 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. Neither the name of the University 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 REGENTS 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.
- *
- * @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/disklabel.h>
-#include <sys/syslog.h>
-#include <sys/disk.h>
-
-#define b_cylin b_resid
-
-#define BOOT_MAGIC 0xAA55
-#define BOOT_MAGIC_OFF (DOSPARTOFF+NDOSPART*sizeof(struct dos_partition))
-
-int
-try_mbr_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff);
-int
-try_mbr_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff)
-{
- struct dos_partition *dp = osdep->dosparts, *dp2;
- char *cp;
- int cyl, n = 0, i, ourpart = -1;
- int dospartoff = -1;
-
- /* MBR type disklabel */
- /* do dos partitions in the process of getting disklabel? */
- cyl = LABELSECTOR / lp->d_secpercyl;
- if (dp) {
- daddr_t part_blkno = DOSBBSECTOR;
- unsigned long extoff = 0;
- int wander = 1, loop = 0;
-
- /*
- * Read dos partition table, follow extended partitions.
- * Map the partitions to disklabel entries i-p
- */
- while (wander && n < 8 && loop < 8) {
- loop++;
- wander = 0;
- if (part_blkno < extoff)
- part_blkno = extoff;
-
- /* read boot record */
- bp->b_blkno = part_blkno;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- bp->b_cylin = part_blkno / lp->d_secpercyl;
- (*strat)(bp);
-
- /* if successful, wander through dos partition table */
- if (biowait(bp)) {
- *pmsg = "dos partition I/O error";
- return 0;
- }
- bcopy(bp->b_data + DOSPARTOFF, dp, NDOSPART * sizeof(*dp));
-
- if (ourpart == -1) {
- /* Search for our MBR partition */
- for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
- i++, dp2++)
- if (get_le(&dp2->dp_size) &&
- dp2->dp_typ == DOSPTYP_OPENBSD)
- ourpart = i;
- for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
- i++, dp2++)
- if (get_le(&dp2->dp_size) &&
- dp2->dp_typ == DOSPTYP_FREEBSD)
- ourpart = i;
- for (dp2=dp, i=0; i < NDOSPART && ourpart == -1;
- i++, dp2++)
- if (get_le(&dp2->dp_size) &&
- dp2->dp_typ == DOSPTYP_NETBSD)
- ourpart = i;
- if (ourpart == -1)
- goto donot;
- /*
- * This is our MBR partition. need sector address
- * for SCSI/IDE, cylinder for ESDI/ST506/RLL
- */
- dp2 = &dp[ourpart];
- dospartoff = get_le(&dp2->dp_start) + part_blkno;
- cyl = DPCYL(dp2->dp_scyl, dp2->dp_ssect);
-
- /* XXX build a temporary disklabel */
- lp->d_partitions[0].p_size = get_le(&dp2->dp_size);
- lp->d_partitions[0].p_offset =
- get_le(&dp2->dp_start) + part_blkno;
- if (lp->d_ntracks == 0)
- lp->d_ntracks = dp2->dp_ehd + 1;
- if (lp->d_nsectors == 0)
- lp->d_nsectors = DPSECT(dp2->dp_esect);
- if (lp->d_secpercyl == 0)
- lp->d_secpercyl = lp->d_ntracks *
- lp->d_nsectors;
- }
-donot:
- /*
- * In case the disklabel read below fails, we want to
- * provide a fake label in i-p.
- */
- for (dp2=dp, i=0; i < NDOSPART && n < 8; i++, dp2++) {
- struct partition *pp = &lp->d_partitions[8+n];
-
- if (dp2->dp_typ == DOSPTYP_OPENBSD)
- continue;
- if (get_le(&dp2->dp_size) > lp->d_secperunit)
- continue;
- if (get_le(&dp2->dp_size))
- pp->p_size = get_le(&dp2->dp_size);
- if (get_le(&dp2->dp_start))
- pp->p_offset =
- get_le(&dp2->dp_start) + part_blkno;
-
- switch (dp2->dp_typ) {
- case DOSPTYP_UNUSED:
- for (cp = (char *)dp2;
- cp < (char *)(dp2 + 1); cp++)
- if (*cp)
- break;
- /*
- * Was it all zeroes? If so, it is
- * an unused entry that we don't
- * want to show.
- */
- if (cp == (char *)(dp2 + 1))
- continue;
- lp->d_partitions[8 + n++].p_fstype =
- FS_UNUSED;
- break;
-
- case DOSPTYP_LINUX:
- pp->p_fstype = FS_EXT2FS;
- n++;
- break;
-
- case DOSPTYP_FAT12:
- case DOSPTYP_FAT16S:
- case DOSPTYP_FAT16B:
- case DOSPTYP_FAT16C:
- case DOSPTYP_FAT32:
- pp->p_fstype = FS_MSDOS;
- n++;
- break;
- case DOSPTYP_EXTEND:
- case DOSPTYP_EXTENDL:
- part_blkno = get_le(&dp2->dp_start) + extoff;
- if (!extoff) {
- extoff = get_le(&dp2->dp_start);
- part_blkno = 0;
- }
- wander = 1;
- break;
- default:
- pp->p_fstype = FS_OTHER;
- n++;
- break;
- }
- }
- }
- lp->d_bbsize = 8192;
- lp->d_sbsize = 64*1024; /* XXX ? */
- lp->d_npartitions = MAXPARTITIONS;
- }
-
- /* if not partitions found return failure */
- if (n == 0 && dospartoff == -1)
- return 0;
- *bsdpartoff = dospartoff + LABELSECTOR;
- return 1;
-}
diff --git a/sys/arch/pegasos/pegasos/mem.c b/sys/arch/pegasos/pegasos/mem.c
deleted file mode 100644
index e1cbe87cca4..00000000000
--- a/sys/arch/pegasos/pegasos/mem.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* $OpenBSD: mem.c,v 1.1 2003/10/31 03:54:33 drahn Exp $ */
-/* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
-
-/*
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1982, 1986, 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * the Systems Programming Group of the University of Utah Computer
- * Science Department.
- *
- * 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. Neither the name of the University 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 REGENTS 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.
- *
- * @(#)mem.c 8.3 (Berkeley) 1/12/94
- */
-
-/*
- * Memory special file
- */
-
-#include <sys/param.h>
-#include <sys/buf.h>
-#include <sys/systm.h>
-#include <sys/ioccom.h>
-#include <sys/uio.h>
-#include <sys/malloc.h>
-#include <sys/types.h>
-
-#include <machine/cpu.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <machine/conf.h>
-
-/* open counter for aperture */
-#ifdef APERTURE
-static int ap_open_count = 0;
-extern int allowaperture;
-#endif
-
-/*ARGSUSED*/
-int
-mmopen(dev_t dev, int flag, int mode, struct proc *p)
-{
-
- switch (minor(dev)) {
- case 0:
- case 1:
- case 2:
- case 12:
- break;
-#ifdef APERTURE
- case 4:
- if (suser(p, 0) != 0 || !allowaperture)
- return (EPERM);
-
- /* authorize only one simultaneous open() */
- if (ap_open_count > 0)
- return(EPERM);
- ap_open_count++;
- break;
-#endif
- default:
- return (ENXIO);
- }
- return (0);
-}
-
-/*ARGSUSED*/
-int
-mmclose(dev_t dev, int flag, int mode, struct proc *p)
-{
-#ifdef APERTURE
- if (minor(dev) == 4)
- ap_open_count--;
-#endif
- return 0;
-}
-
-/*ARGSUSED*/
-int
-mmrw(dev_t dev, struct uio *uio, int flags)
-{
- vm_offset_t v;
- vm_size_t c;
- struct iovec *iov;
- int error = 0;
- static caddr_t zeropage;
-
- while (uio->uio_resid > 0 && error == 0) {
- iov = uio->uio_iov;
- if (iov->iov_len == 0) {
- uio->uio_iov++;
- uio->uio_iovcnt--;
- if (uio->uio_iovcnt < 0)
- panic("mmrw");
- continue;
- }
- switch (minor(dev)) {
-
- /* minor device 0 is physical memory */
- case 0:
- v = uio->uio_offset;
- c = uio->uio_resid;
- /* This doesn't allow device mapping! XXX */
- pmap_real_memory(&v, &c);
- error = uiomove((caddr_t)v, c, uio);
- continue;
-
- /* minor device 1 is kernel memory */
- case 1:
- v = uio->uio_offset;
- c = min(iov->iov_len, MAXPHYS);
- error = uiomove((caddr_t)v, c, uio);
- continue;
-
- /* minor device 2 is EOF/RATHOLE */
- case 2:
- if (uio->uio_rw == UIO_WRITE)
- uio->uio_resid = 0;
- return 0;
-
- /* minor device 12 (/dev/zero) is source of nulls on read,
- * rathole on write
- */
- case 12:
- if (uio->uio_rw == UIO_WRITE) {
- c = iov->iov_len;
- break;
- }
- if (zeropage == NULL) {
- zeropage = (caddr_t)malloc(PAGE_SIZE, M_TEMP,
- M_WAITOK);
- bzero(zeropage, PAGE_SIZE);
- }
- c = min(iov->iov_len, PAGE_SIZE);
- error = uiomove(zeropage, c, uio);
- continue;
-
- default:
- return ENXIO;
- }
- if (error)
- break;
- iov->iov_base += c;
- iov->iov_len -= c;
- uio->uio_offset += c;
- uio->uio_resid -= c;
- }
- return error;
-}
-
-paddr_t
-mmmmap(dev_t dev, off_t off, int prot)
-{
- return (-1);
-}
-
-/*ARGSUSED*/
-int
-mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
-{
- return (EOPNOTSUPP);
-}
diff --git a/sys/arch/pegasos/pegasos/ofw_machdep.c b/sys/arch/pegasos/pegasos/ofw_machdep.c
deleted file mode 100644
index 4ae397d2f6b..00000000000
--- a/sys/arch/pegasos/pegasos/ofw_machdep.c
+++ /dev/null
@@ -1,723 +0,0 @@
- /* $OpenBSD: ofw_machdep.c,v 1.2 2004/02/04 20:07:18 drahn Exp $ */
-/* $NetBSD: ofw_machdep.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
-
-/*
- * Copyright (C) 1996 Wolfgang Solfrank.
- * Copyright (C) 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/buf.h>
-#include <sys/conf.h>
-#include <sys/device.h>
-#include <sys/disk.h>
-#include <sys/disklabel.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/malloc.h>
-#include <sys/stat.h>
-#include <sys/systm.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <machine/powerpc.h>
-#include <machine/autoconf.h>
-
-#include <dev/ofw/openfirm.h>
-
-#include <pegasos/pegasos/ofw_machdep.h>
-
-#include <ukbd.h>
-#include <dev/usb/ukbdvar.h>
-
-/* XXX, called from asm */
-int save_ofw_mapping(void);
-int restore_ofw_mapping(void);
-void ofw_remove_mem(struct mem_region *mem, paddr_t base, paddr_t end);
-
-void OF_exit(void) __attribute__((__noreturn__));
-void OF_boot(char *bootspec);
-void ofw_mem_regions(struct mem_region **memp, struct mem_region **availp);
-void ofw_vmon(void);
-
-struct firmware ofw_firmware = {
- ofw_mem_regions,
- OF_exit,
- OF_boot,
- ofw_vmon
-#ifdef FW_HAS_PUTC
- ofwcnputc;
-#endif
-};
-
-#define OFMEM_REGIONS 32
-static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3];
-static struct mem_region OFclaimed[OFMEM_REGIONS + 1];
-
-/*
- * This is called during initppc, before the system is really initialized.
- * It shall provide the total and the available regions of RAM.
- * Both lists must have a zero-size entry as terminator.
- * The available regions need not take the kernel into account, but needs
- * to provide space for two additional entry beyond the terminating one.
- */
-
-/* remove a given region from avail memory */
-void
-ofw_remove_mem(struct mem_region *mem, paddr_t base, paddr_t end)
-{
- struct mem_region *mp;
- int i;
- int mpend;
- int cnt_avail;
-
- cnt_avail = 0;
- for (mp = mem; mp->size; mp++)
- cnt_avail++;
-
- /* remove given region from available */
- for (mp = mem; mp->size; mp++) {
- /*
- * Check if this region hold all of the region
- */
- mpend = mp->start + mp->size;
- if (base > mpend) {
- continue;
- }
- if (base <= mp->start) {
- if (end <= mp->start)
- break; /* region not present -??? */
-
- if (end >= mpend) {
- /* covers whole region */
- /* shorten */
- for (i = mp - mem;
- i < cnt_avail;
- i++) {
- mem[i] = mem[i+1];
- }
- cnt_avail--;
- mem[cnt_avail].size = 0;
- } else {
- mp->start = end;
- mp->size = mpend - end;
- }
- } else {
- /* start after the beginning */
- if (end >= mpend) {
- /* just truncate */
- mp->size = base - mp->start;
- } else {
- /* split */
- for (i = cnt_avail;
- i > (mp - mem);
- i--) {
- mem[i] = mem[i - 1];
- }
- cnt_avail++;
- mp->size = base - mp->start;
- mp++;
- mp->start = end;
- mp->size = mpend - end;
- }
- }
- }
-}
-
-void
-ofw_mem_regions(struct mem_region **memp, struct mem_region **availp)
-{
- int phandle;
- int i;
- void * OF_claim(uint32_t, uint32_t, uint32_t); /* XXX */
- u_int32_t end;
- void *val;
- int b;
-
- /*
- * Get memory.
- */
- if ((phandle = OF_finddevice("/memory")) == -1
- || OF_getprop(phandle, "reg",
- OFmem, sizeof OFmem[0] * OFMEM_REGIONS)
- <= 0
- || OF_getprop(phandle, "available",
- OFavail, sizeof OFavail[0] * OFMEM_REGIONS)
- <= 0)
- panic("no memory?");
- *memp = OFmem;
- *availp = OFavail;
-
- for (i = 0; OFavail[i].size != 0; i++) {
- end = OFavail[i].start + OFavail[i].size;
-
- end &= ~PAGE_MASK;
- OFavail[i].start += PAGE_MASK;
- OFavail[i].start &= ~PAGE_MASK;
- OFavail[i].size = end - OFavail[i].start;
- /* XXX - what if this zeros an entry... */
- }
-
- /*
- * Ok, we dont want to use memory which OFW uses but leaves
- * in avail (Peg I).
- */
- ofw_remove_mem(OFavail, 0, 16 * 1024 * 1024);
- /* the last 3 meg too */
- {
- struct mem_region *mp;
- paddr_t last_avail = 0;
- paddr_t a;
- for (mp = OFavail; mp->size !=0; mp++) {
- a = mp->start + mp->size;
- if (last_avail < a)
- last_avail = a;
- }
- if ((last_avail & 3*1024*1024) == 0)
- ofw_remove_mem(OFavail, last_avail - 3*1024*1024,
- last_avail);
-
- }
-
-
-
- /* claim 'avail' memory from openfirmware */
- b = 0;
- for (i = 0; OFavail[i].size != 0; i++) {
- val = OF_claim(OFavail[i].start, OFavail[i].size, 0);
- if (val == (void *)0xffffffff) {
- /* ugh */
- } else {
- OFclaimed[b] = OFavail[i];
- b++;
- }
- }
- *availp = OFclaimed;
-
-}
-
-typedef void (fwcall_f)(int, int);
-extern fwcall_f *fwcall;
-fwcall_f fwentry;
-extern u_int32_t ofmsr;
-
-void
-ofw_vmon()
-{
- fwcall = &fwentry;
-}
-
-int OF_stdout;
-int OF_stdin;
-
-/* code to save and create the necessary mappings for BSD to handle
- * the vm-setup for OpenFirmware
- */
-static int N_mapping;
-static struct {
- vm_offset_t va;
- int len;
- vm_offset_t pa;
- int mode;
-} ofw_mapping[256];
-int
-save_ofw_mapping()
-{
- int mmui, mmu;
- int chosen;
- int stdout, stdin;
- if ((chosen = OF_finddevice("/chosen")) == -1) {
- return 0;
- }
-
- if (OF_getprop(chosen, "stdin", &stdin, sizeof stdin) != sizeof stdin) {
- return 0;
- }
- OF_stdin = stdin;
- if (OF_getprop(chosen, "stdout", &stdout, sizeof stdout)
- != sizeof stdout) {
- return 0;
- }
- if (stdout == 0) {
- /* If the screen is to be console, but not active, open it */
- stdout = OF_open("screen");
- }
- OF_stdout = stdout;
-
- chosen = OF_finddevice("/chosen");
-
- OF_getprop(chosen, "mmu", &mmui, 4);
- mmu = OF_instance_to_package(mmui);
- bzero(ofw_mapping, sizeof(ofw_mapping));
-
- N_mapping = OF_getprop(mmu, "translations", ofw_mapping,
- sizeof(ofw_mapping));
- N_mapping /= sizeof(ofw_mapping[0]);
-
- fw = &ofw_firmware;
- fwcall = &fwentry;
- return 0;
-}
-
-struct pmap ofw_pmap;
-int
-restore_ofw_mapping()
-{
- int i;
-
- pmap_pinit(&ofw_pmap);
-
- ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
-
- for (i = 0; i < N_mapping; i++) {
- vm_offset_t pa = ofw_mapping[i].pa;
- vm_offset_t va = ofw_mapping[i].va;
- int size = ofw_mapping[i].len;
-
- if (va < 0xf8000000) /* XXX */
- continue;
-
- while (size > 0) {
- pmap_enter(&ofw_pmap, va, pa, VM_PROT_ALL, PMAP_WIRED);
- pa += NBPG;
- va += NBPG;
- size -= NBPG;
- }
- }
- pmap_update(pmap_kernel());
-
- return 0;
-}
-
-typedef void (void_f) (void);
-extern void_f *pending_int_f;
-void ofw_do_pending_int(void);
-extern int system_type;
-
-void ofw_intr_init(void);
-
-void
-ofrootfound()
-{
- int node;
- struct ofprobe probe;
-
- if (!(node = OF_peer(0)))
- panic("No PROM root");
- probe.phandle = node;
- if (!config_rootfound("ofroot", &probe))
- panic("ofroot not configured");
- if (system_type == OFWMACH) {
- pending_int_f = ofw_do_pending_int;
- ofw_intr_init();
- }
-}
-
-void
-ofw_intr_establish()
-{
- if (system_type == OFWMACH) {
- pending_int_f = ofw_do_pending_int;
- ofw_intr_init();
- }
-}
-
-void
-ofw_intr_init()
-{
- /*
- * There are tty, network and disk drivers that use free() at interrupt
- * time, so imp > (tty | net | bio).
- */
- /* with openfirmware drivers all levels block clock
- * (have to block polling)
- */
- imask[IPL_IMP] = SPL_CLOCK;
- imask[IPL_TTY] = SPL_CLOCK | SINT_TTY;
- imask[IPL_NET] = SPL_CLOCK | SINT_NET;
- imask[IPL_BIO] = SPL_CLOCK;
- imask[IPL_IMP] |= imask[IPL_TTY] | imask[IPL_NET] | imask[IPL_BIO];
-
- /*
- * Enforce a hierarchy that gives slow devices a better chance at not
- * dropping data.
- */
- imask[IPL_TTY] |= imask[IPL_NET] | imask[IPL_BIO];
- imask[IPL_NET] |= imask[IPL_BIO];
-
- /*
- * These are pseudo-levels.
- */
- imask[IPL_NONE] = 0x00000000;
- imask[IPL_HIGH] = 0xffffffff;
-
-}
-
-void
-ofw_do_pending_int()
-{
- int pcpl;
- int s;
-
- static int processing;
-
- if(processing)
- return;
-
- processing = 1;
- s = ppc_intr_disable();
-
- pcpl = splhigh(); /* Turn off all */
- if((ipending & SINT_CLOCK) && ((pcpl & imask[IPL_CLOCK]) == 0)) {
- ipending &= ~SINT_CLOCK;
- softclock();
- }
- if((ipending & SINT_NET) && ((pcpl & imask[IPL_NET]) == 0) ) {
- extern int netisr;
- int pisr = netisr;
- netisr = 0;
- ipending &= ~SINT_NET;
- softnet(pisr);
- }
- ipending &= pcpl;
- cpl = pcpl; /* Don't use splx... we are here already! */
- ppc_intr_enable(s);
- processing = 0;
-}
-
-#if NVGAFB_PCI > 0
-#include <dev/pci/pcivar.h>
-#include <arch/macppc/pci/vgafb_pcivar.h>
-static pcitag_t ofw_make_tag( void *cpv, int bus, int dev, int fnc);
-
-/* ARGSUSED */
-static pcitag_t
-ofw_make_tag(void *cpv, int bus, int dev, int fnc)
-{
- return (bus << 16) | (dev << 11) | (fnc << 8);
-}
-#endif
-
-#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)
-
-
-struct ppc_bus_space ppc_membus;
-int cons_displaytype=0;
-bus_space_tag_t cons_membus = &ppc_membus;
-bus_space_handle_t cons_display_mem_h;
-bus_space_handle_t cons_display_ctl_h;
-int cons_height, cons_width, cons_linebytes, cons_depth;
-int cons_display_ofh;
-u_int32_t cons_addr;
-int cons_brightness;
-int cons_backlight_available;
-
-#include "vgafb_pci.h"
-
-struct usb_kbd_ihandles {
- struct usb_kbd_ihandles *next;
- int ihandle;
-};
-
-
-u_int32_t ppc_console_addr;
-struct ppc_bus_space *ppc_isa_iobus_space;
-struct ppc_bus_space *ppc_isa_membus_space;
-struct ppc_bus_space *ppc_display_isa_iobus_space;
-struct ppc_bus_space *ppc_display_isa_membus_space;
-struct ppc_bus_space ppc_agp_isa_iobus_store;
-struct ppc_bus_space ppc_agp_isa_membus_store;
-
-extern int comdefaultrate;
-extern int pegasos;
-int ppc_agpconsole;
-
-void
-ofwconprobe()
-{
- char type[32];
- int stdout_node;
- char path[128];
- int len;
- char name[32];
- int display;
-
- ppc_agpconsole = 0;
-
- stdout_node = OF_instance_to_package(OF_stdout);
-
- ppc_isa_iobus_space = &ppc_isa_io;
- ppc_isa_iobus_space->bus_base = 0xfe000000;
- ppc_isa_iobus_space->bus_reverse = 1;
- ppc_isa_iobus_space->bus_io = 1;
- ppc_isa_iobus_space->bus_size = 0x01000000;
- ppc_isa_membus_space = &ppc_isa_mem;
- ppc_isa_membus_space->bus_base = 0xfd000000;
- ppc_isa_membus_space->bus_size = 0x01000000;
- ppc_isa_membus_space->bus_reverse = 1;
-
-
- /* handle different types of console */
-
- bzero(type, sizeof(type));
- if (OF_getprop(stdout_node, "device_type", type, sizeof(type)) == -1) {
- return; /* XXX */
- }
-
- len = OF_package_to_path(stdout_node, path, sizeof path);
- path[len] = 0;
- printf("console path [%s] type [%s]\n", path, type);
-
- if (strcmp(path, "/failsafe") == 0) {
- ppc_console_addr = 0x2f8;
-
- /* failsafe serial console, at firmware dbg speed */
- comdefaultrate = 115200;
- return;
- }
- if (strcmp(type, "serial") == 0) {
- /* XXX */
- ppc_console_addr = 0x2f8;
- comdefaultrate = 9600;
- return;
- }
-
- len = OF_getprop(stdout_node, "name", name, 20);
- name[len] = 0;
- printf("console out [%s]\n", name);
-
- display = OF_finddevice("/display");
- if (display != -1 && display != 0) {
- len = OF_package_to_path(display, path, sizeof path);
- path[len] = 0;
- printf("display path [%s]\n", path);
- if (strncmp(path, "/pci@C0000000", 12) == 0)
- ppc_agpconsole = 1;
- }
-
- /*
- * Initialize the early bus_space values to
- * correct values for Pegasos I
- */
- if (pegasos == 2 && ppc_agpconsole) {
- ppc_display_isa_iobus_space = &ppc_agp_isa_iobus_store;
- ppc_display_isa_membus_space = &ppc_agp_isa_membus_store;
-
- ppc_display_isa_iobus_space->bus_base = 0xf8000000;
- ppc_display_isa_iobus_space->bus_reverse = 1;
- ppc_display_isa_iobus_space->bus_io = 1;
- ppc_display_isa_iobus_space->bus_size = 0x01000000;
- ppc_display_isa_membus_space->bus_base = 0xf9000000;
- ppc_display_isa_membus_space->bus_size = 0x01000000;
- ppc_display_isa_membus_space->bus_reverse = 1;
- } else {
- ppc_display_isa_iobus_space = &ppc_isa_io;
- ppc_display_isa_membus_space = &ppc_isa_mem;
- }
- if (strcmp(type, "bootconsole") == 0) {
- /* pegasos unknown console, */
- /* which is set up already */
-
- ppc_console_addr = 0x2f8;
- ppc_console_addr = 0;
-
- /* if we end up with serial console, do firmware dbg speed */
- comdefaultrate = 115200;
- return;
- }
-
- /* dunno */
-
- return;
-}
-
-#define DEVTREE_UNKNOWN 0
-#define DEVTREE_USB 1
-#define DEVTREE_ADB 2
-#define DEVTREE_HID 3
-int ofw_devtree = DEVTREE_UNKNOWN;
-
-#define OFW_HAVE_USBKBD 1
-#define OFW_HAVE_ADBKBD 2
-int ofw_have_kbd = 0;
-
-void ofw_recurse_keyboard(int pnode);
-void ofw_find_keyboard(void);
-
-void
-ofw_recurse_keyboard(int pnode)
-{
- char name[32];
- int old_devtree;
- int len;
- int node;
-
- for (node = OF_child(pnode); node != 0; node = OF_peer(node)) {
-
- len = OF_getprop(node, "name", name, 20);
- if (len == 0)
- continue;
- name[len] = 0;
- if (strcmp(name, "keyboard") == 0) {
- /* found a keyboard node, where is it? */
- if (ofw_devtree == DEVTREE_USB) {
- ofw_have_kbd |= OFW_HAVE_USBKBD;
- } else if (ofw_devtree == DEVTREE_ADB) {
- ofw_have_kbd |= OFW_HAVE_ADBKBD;
- } else {
- /* hid or some other keyboard? igore */
- }
- continue;
- }
-
- old_devtree = ofw_devtree;
-
- if (strcmp(name, "adb") == 0) {
- ofw_devtree = DEVTREE_ADB;
- }
- if (strcmp(name, "usb") == 0) {
- ofw_devtree = DEVTREE_USB;
- }
-
- ofw_recurse_keyboard(node);
-
- ofw_devtree = old_devtree; /* nest? */
- }
-}
-
-void
-ofw_find_keyboard()
-{
- int stdin_node;
- char iname[32];
- int len;
-
- stdin_node = OF_instance_to_package(OF_stdin);
- len = OF_getprop(stdin_node, "name", iname, 20);
- iname[len] = 0;
- printf("console in [%s] ", iname);
-
- /* GRR, apple removed the interface once used for keyboard
- * detection walk the OFW tree to find keyboards and what type.
- */
-
- ofw_recurse_keyboard(OF_peer(0));
-
- if (ofw_have_kbd == 0) {
- printf("no keyboard found, hoping USB will be present\n");
-#if NUKBD > 0
- ukbd_cnattach();
-#endif
- }
-
- if (ofw_have_kbd == (OFW_HAVE_USBKBD|OFW_HAVE_ADBKBD)) {
-#if NUKBD > 0
- printf("USB and ADB found, using USB\n");
- ukbd_cnattach();
-#else
- ofw_have_kbd = OFW_HAVE_ADBKBD; /* ??? */
-#endif
- }
- if (ofw_have_kbd == OFW_HAVE_USBKBD) {
-#if NUKBD > 0
- printf("USB found\n");
- ukbd_cnattach();
-#endif
- }
-}
-
-
-#include <dev/cons.h>
-
-cons_decl(ofw);
-
-/*
- * Console support functions
- */
-void
-ofwcnprobe(struct consdev *cd)
-{
- cd->cn_pri = CN_DEAD;
-}
-
-void
-ofwcninit(struct consdev *cd)
-{
-}
-void
-ofwcnputc(dev_t dev, int c)
-{
- char ch = c;
-
- OF_write(OF_stdout, &ch, 1);
-}
-int
-ofwcngetc(dev_t dev)
-{
- unsigned char ch = '\0';
- int l;
-
- while ((l = OF_read(OF_stdin, &ch, 1)) != 1)
- if (l != -2 && l != 0)
- return -1;
- return ch;
-}
-
-void
-ofwcnpollc(dev_t dev, int on)
-{
-}
-
-struct consdev consdev_ofw = {
- ofwcnprobe,
- ofwcninit,
- ofwcngetc,
- ofwcnputc,
- ofwcnpollc,
- NULL,
-};
-
-void
-ofwconsinit()
-{
- struct consdev *cp;
- cp = &consdev_ofw;
- cn_tab = cp;
-}
diff --git a/sys/arch/pegasos/pegasos/ofw_machdep.h b/sys/arch/pegasos/pegasos/ofw_machdep.h
deleted file mode 100644
index a66af7e4b44..00000000000
--- a/sys/arch/pegasos/pegasos/ofw_machdep.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* $OpenBSD: ofw_machdep.h,v 1.1 2003/10/31 03:54:33 drahn Exp $ */
-
-/*
- * Copyright (c) 2002, Miodrag Vallat.
- *
- * 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.
- *
- * 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.
- *
- */
-
-/*
- * Various console variables...
- */
-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_height, cons_width, cons_linebytes, cons_depth;
-extern int cons_display_ofh;
-extern u_int32_t cons_addr;
-extern int cons_backlight_available;
-
-void ofwconprobe(void);
-void ofwconsinit(void);
-
-/*
- * For some reason, setting the brightness under 0x29 from OF switches the
- * backlight off, and it won't be switched on again until you set the
- * brightness above 0x33. All hail hysteresis! -- miod
- */
-#define MIN_BRIGHTNESS 0x34
-#define MAX_BRIGHTNESS 0xff
-#define STEP_BRIGHTNESS 8
-#define DEFAULT_BRIGHTNESS 0x80
-extern int cons_brightness;
-
-void of_setbrightness(int);
diff --git a/sys/arch/pegasos/pegasos/ofwreal.S b/sys/arch/pegasos/pegasos/ofwreal.S
deleted file mode 100644
index ed7cea57b6d..00000000000
--- a/sys/arch/pegasos/pegasos/ofwreal.S
+++ /dev/null
@@ -1,449 +0,0 @@
-/* $OpenBSD: ofwreal.S,v 1.1 2003/10/31 03:54:33 drahn Exp $ */
-/* $NetBSD: ofwreal.S,v 1.1 1996/09/30 16:34:51 ws Exp $ */
-
-/*
- * Copyright (C) 1996 Wolfgang Solfrank.
- * Copyright (C) 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-
-/*
- * This file provides a real-mode client interface on machines, that
- * (incorrectly) only implement virtual mode client interface.
- *
- * It assumes though, that any actual memory in the machine is
- * mapped 1:1 even by the virtual mode OpenFirmware.
- * Furthermore it assumes that addresses returned by OpenFirmware are not
- * accessed by the client.
- *
- */
-#include <machine/asm.h>
-#include <machine/psl.h>
-#include <machine/trap.h>
-#include <machine/param.h>
-
-#define CACHELINE 32 /* Note that this value is really hardwired */
-
- .data
-ofentry: .long 0 /* actual entry to firmware in virtual mode */
-
-#define SRSIZE (16*4+4)
-#define SPRGSIZE (4*4)
-#define SDR1SIZE 4
-#define MSRSIZE 4
-#define SVSIZE (SRSIZE+SPRGSIZE+SDR1SIZE+MSRSIZE)
-#define BATSIZE (16*4)
-
- .global _C_LABEL(fwcall)
-_C_LABEL(fwcall): .long 0
-
-.lcomm fwsave,SVSIZE,8
-.lcomm fwbatsave,BATSIZE,8
-.lcomm clsave,SVSIZE,8
-.lcomm clbatsave,BATSIZE,8
-.lcomm ofsrsave,16*4,4 /* 16 words of 4 bytes to store OF segment registers */
-.lcomm srsave,16*4,4 /* 16 words of 4 bytes to swap OF segment registers*/
- .globl _C_LABEL(ofmsr)
-_C_LABEL(ofmsr): .long 0 /* area to store msr for openfirmware*/
-
- .text
-_ENTRY(_C_LABEL(ofw_init))
- mflr %r31 /* save return address */
-
- mr %r13,%r6 /* save args (only pointer used) */
- lis %r8,ofentry@ha
- stw %r5,ofentry@l(%r8) /* save virtual mode firmware entry */
-
- lis %r4,fwcall@ha /* call ofw directly until vm setup */
- stw %r5,fwcall@l(%r4)
-
- mfmsr %r5
- lis %r4,_C_LABEL(ofmsr)@ha /* save msr from openfirmware */
- stw %r5,_C_LABEL(ofmsr)@l(%r4)
-#if 0
- lis %r0,(0x80001ffe)@ha
- addi %r0,%r0,(0x80001ffe)@l
- mtdbatu 0,%r0
- lis %r0,(0x80000022)@ha
- addi %r0,%r0,(0x80000022)@l
- mtdbatl 0,%r0
-#endif
-
- lis %r3,fwsave@ha /* save the mmu values of the firmware */
- addi %r3,%r3,fwsave@l
- lis %r4,fwbatsave@ha
- addi %r4,%r4,fwbatsave@l
- bl savemmu
-
- /* save openfirmware address mappings */
- bl _C_LABEL(save_ofw_mapping)
-
-#if 0
- /* dont really need the bats from firmware saved, 0 to disable */
- lis %r3,fwbatsave@ha
- addi %r3,%r3,fwbatsave@l
- li %r4,64
- li %r5,0
-1: subi %r4,%r4,%r4
- stwx %r5,%r4,%r3
- cmpi 4,0,0
- bne 1b
-#endif
-
- mr %r6,%r13 /* restore args pointer */
- mtlr %r31 /* restore return address */
- blr
-
-/*
- * Save everyting related to the mmu to the saveare pointed to by r3.
- */
- .type savemmu,@function
-savemmu:
-
- mr %r6,%r4 /* r4 holds pointer to BAT save area */
-
- li %r4,0 /* save SRs */
-1:
- addis %r4,%r4,-0x10000000@ha
- or. %r4,%r4,%r4
- mfsrin %r5,%r4
- stwu %r5,4(%r3)
- bne 1b
-
- mfibatl %r4,0 /* save BATs */
- stw %r4,0(%r6)
- mfibatu %r4,0
- stw %r4,4(%r6)
- mfibatl %r4,1
- stw %r4,8(%r6)
- mfibatu %r4,1
- stw %r4,0xc(%r6)
- mfibatl %r4,2
- stw %r4,0x10(%r6)
- mfibatu %r4,2
- stw %r4,0x14(%r6)
- mfibatl %r4,3
- stw %r4,0x18(%r6)
- mfibatu %r4,3
- stw %r4,0x1c(%r6)
- mfdbatl %r4,0
- stw %r4,0x20(%r6)
- mfdbatu %r4,0
- stw %r4,0x24(%r6)
- mfdbatl %r4,1
- stw %r4,0x28(%r6)
- mfdbatu %r4,1
- stw %r4,0x2c(%r6)
- mfdbatl %r4,2
- stw %r4,0x30(%r6)
- mfdbatu %r4,2
- stw %r4,0x34(%r6)
- mfdbatl %r4,3
- stw %r4,0x38(%r6)
- mfdbatu %r4,3
- stw %r4,0x3c(%r6)
-
- mfsprg %r4,0 /* save SPRGs */
- stw %r4,4(%r3)
- mfsprg %r4,1
- stw %r4,8(%r3)
- mfsprg %r4,2
- stw %r4,12(%r3)
- mfsprg %r4,3
- stw %r4,16(%r3)
-
- mfsdr1 %r4 /* save SDR1 */
- stw %r4,20(%r3)
-
- addi %r4,%r3,24
-
- mfmsr %r4
- stw %r4,24(%r3)
-
- sync
- isync
-
- blr
-
-/*
- * Restore everyting related to the mmu from the savearea pointed to by r3.
- * and bats pointed to by r4.
- */
- .type restoremmu,@function
-restoremmu:
-
- li %r0,0
- mtmsr %r0
- mr %r6,%r4 /* pointer to sr to restore */
- li %r4,0 /* restore SRs */
-1:
- lwzu %r5,4(%r3)
- addis %r4,%r4,-0x10000000@ha
- or. %r4,%r4,%r4
- mtsrin %r5,%r4
- bne 1b
-
- mfmsr %r4
- lis %r5,(PSL_IR|PSL_DR)@h /* turn off MMU */
- ori %r5,%r5,(PSL_IR|PSL_DR)@l /* turn off MMU */
- andc %r4,%r4,%r5 /* turn off MMU */
- mtmsr %r4
- isync
-
- li %r4,0 /* first, invalidate BATs */
- mtibatu 0,%r4
- mtibatu 1,%r4
- mtibatu 2,%r4
- mtibatu 3,%r4
- mtdbatu 0,%r4
- mtdbatu 1,%r4
- mtdbatu 2,%r4
- mtdbatu 3,%r4
-
- lwz %r4,0(%r6)
- mtibatl 0,%r4 /* restore BATs */
- lwz %r4,4(%r6)
- mtibatu 0,%r4
- lwz %r4,8(%r6)
- mtibatl 1,%r4
- lwz %r4,12(%r6)
- mtibatu 1,%r4
- lwz %r4,16(%r6)
- mtibatl 2,%r4
- lwz %r4,20(%r6)
- mtibatu 2,%r4
- lwz %r4,24(%r6)
- mtibatl 3,%r4
- lwz %r4,28(%r6)
- mtibatu 3,%r4
- lwz %r4,32(%r6)
- mtdbatl 0,%r4
- lwz %r4,36(%r6)
- mtdbatu 0,%r4
- lwz %r4,40(%r6)
- mtdbatl 1,%r4
- lwz %r4,44(%r6)
- mtdbatu 1,%r4
- lwz %r4,48(%r6)
- mtdbatl 2,%r4
- lwz %r4,52(%r6)
- mtdbatu 2,%r4
- lwz %r4,56(%r6)
- mtdbatl 3,%r4
- lwz %r4,60(%r6)
- mtdbatu 3,%r4
-
- lwz %r4,4(%r3)
- mtsprg 0,4 /* restore SPRGs */
- lwz %r4,8(%r3)
- mtsprg 1,4
- lwz %r4,12(%r3)
- mtsprg 2,4
- lwz %r4,16(%r3)
- mtsprg 3,4
-
- sync /* remove everything from tlb */
- lis %r4,0x40000@ha
- li %r5,0x1000
-1:
- subf. %r4,%r5,%r4
- tlbie %r4
- bne 1b
-
- sync
- tlbsync
- sync
-
- lwz %r4,20(%r3)
- sync
- mtsdr1 %r4 /* restore SDR1 */
-
-
- /* tlbia */
- sync
- li %r5,0x40
- mtctr %r5
- li %r4,0
- 1:
- tlbie %r4
- addi %r4,%r4,0x1000
- bdnz 1b
- sync
- tlbsync
- sync
-
- lwz %r4,24(%r3)
- mtmsr %r4
- isync
-
- blr
-
-
-_ENTRY(_C_LABEL(fwentry))
- stwu %r1,-16(%r1)
- mflr %r4
- stw %r4,20(%r1)
- stw %r3,12(%r1) /* save arg */
-
- lis %r3,clsave@ha /* save mmu values of client */
- addi %r3,%r3,clsave@l
- lis %r4,clbatsave@ha /* save mmu values of client */
- addi %r4,%r4,clbatsave@l
- bl savemmu
-
- lis %r3,fwsave@ha /* restore mmu values of firmware */
- addi %r3,%r3,fwsave@l
- lis %r4,fwbatsave@ha
- addi %r4,%r4,fwbatsave@l
- bl restoremmu
-
- lis %r3,ofentry@ha
- lwz %r3,ofentry@l(%r3) /* get actual firmware entry */
- mtlr %r3
-
- mfmsr %r4
- ori %r4,%r4,PSL_IR|PSL_DR /* turn on MMU */
- mtmsr %r4
- isync
-
- lwz %r3,12(%r1) /* restore arg */
- blrl /* do actual firmware call */
-
- stw %r3,12(%r1) /* save return value */
-
- lis %r3,fwsave@ha /* save mmu values of firmare */
- addi %r3,%r3,fwsave@l /* (might not be necessary, but... */
- lis %r4,fwbatsave@ha
- addi %r4,%r4,fwbatsave@l
- bl savemmu
-
- lis %r3,clsave@ha /* restore mmu values of client */
- addi %r3,%r3,clsave@l
- lis %r4,clbatsave@ha /* save mmu values of client */
- addi %r4,%r4,clbatsave@l
- bl restoremmu
-
- lwz %r4,20(%r1)
- lwz %r3,12(%r1) /* restore return value */
-
- mtlr %r4
- addi %r1,%r1,16
- blr
-
-/*
- * OpenFirmware entry point
- */
-_ENTRY(_C_LABEL(openfirmware))
- stwu %r1,-16(%r1)
- mflr %r0 /* save return address */
- stw %r0,20(%r1)
-
- lis %r4,fwcall@ha
- lwz %r4,fwcall@l(%r4)
-
- mtlr %r4
- blrl
-
- lwz %r0,20(%r1)
- mtlr %r0
- lwz %r1,0(%r1)
- blr
-
-/*
- * Switch to/from OpenFirmware real mode stack
- *
- * Note: has to be called as the very first thing in OpenFirmware interface routines.
- * E.g.:
- * int
- * OF_xxx(arg1, arg2)
- * type arg1, arg2;
- * {
- * static struct {
- * char *name;
- * int nargs;
- * int nreturns;
- * char *method;
- * int arg1;
- * int arg2;
- * int ret;
- * } args = {
- * "xxx",
- * 2,
- * 1,
- * };
- *
- * ofw_stack();
- * args.arg1 = arg1;
- * args.arg2 = arg2;
- * if (openfirmware(&args) < 0)
- * return -1;
- * return args.ret;
- * }
- */
-.lcomm firmstk,NBPG,16
-.comm _C_LABEL(OF_buf),NBPG,PGOFSET
-
-_ENTRY(_C_LABEL(ofw_stack))
- mfmsr %r8 /* turn off interrupts */
- andi. %r0,%r8,~(PSL_EE|PSL_RI)@l
- mtmsr %r0
- stw %r8,4(%r1) /* abuse return address slot */
-
- lwz %r5,0(%r1) /* get length of stack frame */
- subf %r5,%r1,%r5
-
- lis %r7,firmstk+NBPG-8@ha
- addi %r7,%r7,firmstk+NBPG-8@l
- li %r6,0xf
- andc %r7,%r7,%r6
- lis %r6,ofw_back@ha
- addi %r6,%r6,ofw_back@l
- subf %r4,%r5,%r7 /* make room for stack frame on new stack */
- stwu %r1,-16(%r7)
- stw %r6,4(%r7) /* setup return pointer */
-
- stw %r7,-16(%r4)
-
- addi %r3,%r1,%r8
- addi %r1,%r4,-16
- subi %r5,%r5,%r8
- subi %r4,%r4,%r8
-
- b _C_LABEL(ofbcopy) /* and copy it */
-
- .type ofw_back,@function
-ofw_back:
- lwz %r1,0(%r1) /* get callers original stack pointer */
-
- lwz %r0,4(%r1) /* get saved msr from abused slot */
- mtmsr %r0
-
- lwz %r1,0(%r1) /* return */
- lwz %r0,4(%r1)
- mtlr %r0
- blr
diff --git a/sys/arch/pegasos/pegasos/opendev.c b/sys/arch/pegasos/pegasos/opendev.c
deleted file mode 100644
index 07ca90e505c..00000000000
--- a/sys/arch/pegasos/pegasos/opendev.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* $OpenBSD: opendev.c,v 1.2 2004/01/14 23:27:53 brad Exp $ */
-/* $NetBSD: openfirm.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
-
-/*
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/stdarg.h>
-#include <machine/psl.h>
-
-#include <dev/ofw/openfirm.h>
-#include <lib/libkern/libkern.h>
-
-extern void ofw_stack(void);
-extern void ofbcopy(const void *, void *, size_t);
-
-int
-OF_instance_to_package(int ihandle)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int ihandle;
- int phandle;
- } args = {
- "instance-to-package",
- 1,
- 1,
- };
-
- ofw_stack();
- args.ihandle = ihandle;
- if (openfirmware(&args) == -1)
- return -1;
- return args.phandle;
-}
-
-int
-OF_package_to_path(int phandle, char *buf, int buflen)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int phandle;
- char *buf;
- int buflen;
- int length;
- } args = {
- "package-to-path",
- 3,
- 1,
- };
-
- ofw_stack();
- if (buflen > PAGE_SIZE)
- return -1;
- args.phandle = phandle;
- args.buf = OF_buf;
- args.buflen = buflen;
- if (openfirmware(&args) < 0)
- return -1;
- if (args.length > 0)
- ofbcopy(OF_buf, buf, args.length);
- return args.length;
-}
-
-
-int
-OF_call_method(char *method, int ihandle, int nargs, int nreturns, ...)
-{
- va_list ap;
- static struct {
- char *name;
- int nargs;
- int nreturns;
- char *method;
- int ihandle;
- int args_n_results[12];
- } args = {
- "call-method",
- 2,
- 1,
- };
- int *ip, n;
-
- if (nargs > 6)
- return -1;
- args.nargs = nargs + 2;
- args.nreturns = nreturns + 1;
- args.method = method;
- args.ihandle = ihandle;
- va_start(ap, nreturns);
- for (ip = args.args_n_results + (n = nargs); --n >= 0;)
- *--ip = va_arg(ap, int);
- ofw_stack();
- if (openfirmware(&args) == -1) {
- va_end(ap);
- return -1;
- }
- if (args.args_n_results[nargs]) {
- va_end(ap);
- return args.args_n_results[nargs];
- }
- for (ip = args.args_n_results + nargs + (n = args.nreturns); --n > 0;)
- *va_arg(ap, int *) = *--ip;
- va_end(ap);
- return 0;
-}
-int
-OF_call_method_1(char *method, int ihandle, int nargs, ...)
-{
- va_list ap;
- static struct {
- char *name;
- int nargs;
- int nreturns;
- char *method;
- int ihandle;
- int args_n_results[8];
- } args = {
- "call-method",
- 2,
- 2,
- };
- int *ip, n;
-
- if (nargs > 6)
- return -1;
- args.nargs = nargs + 2;
- args.method = method;
- args.ihandle = ihandle;
- va_start(ap, nargs);
- for (ip = args.args_n_results + (n = nargs); --n >= 0;)
- *--ip = va_arg(ap, int);
- va_end(ap);
- ofw_stack();
- if (openfirmware(&args) == -1)
- return -1;
- if (args.args_n_results[nargs])
- return -1;
- return args.args_n_results[nargs + 1];
-}
-
-int
-OF_open(char *dname)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- char *dname;
- int handle;
- } args = {
- "open",
- 1,
- 1,
- };
- int l;
-
- ofw_stack();
- if ((l = strlen(dname)) >= PAGE_SIZE)
- return -1;
- ofbcopy(dname, OF_buf, l + 1);
- args.dname = OF_buf;
- if (openfirmware(&args) == -1)
- return -1;
- return args.handle;
-}
-
-void
-OF_close(int handle)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int handle;
- } args = {
- "close",
- 1,
- 0,
- };
-
- ofw_stack();
- args.handle = handle;
- openfirmware(&args);
-}
-
-/*
- * This assumes that character devices don't read in multiples of PAGE_SIZE.
- */
-int
-OF_read(int handle, void *addr, int len)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int ihandle;
- void *addr;
- int len;
- int actual;
- } args = {
- "read",
- 3,
- 1,
- };
- int l, act = 0;
-
- ofw_stack();
- args.ihandle = handle;
- args.addr = OF_buf;
- for (; len > 0; len -= l, addr += l) {
- l = min(PAGE_SIZE, len);
- args.len = l;
- if (openfirmware(&args) == -1)
- return -1;
- if (args.actual > 0) {
- ofbcopy(OF_buf, addr, args.actual);
- act += args.actual;
- }
- if (args.actual < l) {
- if (act)
- return act;
- else
- return args.actual;
- }
- }
- return act;
-}
-
-int
-OF_write(int handle, void *addr, int len)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int ihandle;
- void *addr;
- int len;
- int actual;
- } args = {
- "write",
- 3,
- 1,
- };
- int l, act = 0;
-
- ofw_stack();
- args.ihandle = handle;
- args.addr = OF_buf;
- for (; len > 0; len -= l, addr += l) {
- l = min(PAGE_SIZE, len);
- ofbcopy(addr, OF_buf, l);
- args.len = l;
- if (openfirmware(&args) == -1)
- return -1;
- l = args.actual;
- act += l;
- }
- return act;
-}
-
-int
-OF_seek(int handle, u_quad_t pos)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int handle;
- int poshi;
- int poslo;
- int status;
- } args = {
- "seek",
- 3,
- 1,
- };
-
- ofw_stack();
- args.handle = handle;
- args.poshi = (int)(pos >> 32);
- args.poslo = (int)pos;
- if (openfirmware(&args) == -1)
- return -1;
- return args.status;
-}
diff --git a/sys/arch/pegasos/pegasos/openfirm.c b/sys/arch/pegasos/pegasos/openfirm.c
deleted file mode 100644
index 0a8f0d34deb..00000000000
--- a/sys/arch/pegasos/pegasos/openfirm.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/* $OpenBSD: openfirm.c,v 1.2 2004/01/14 23:27:53 brad Exp $ */
-/* $NetBSD: openfirm.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
-
-/*
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/systm.h>
-#include <sys/stdarg.h>
-#include <machine/psl.h>
-
-#include <dev/ofw/openfirm.h>
-
-extern void ofw_stack(void);
-extern void ofbcopy(const void *, void *, size_t);
-
-int
-OF_peer(int phandle)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int phandle;
- int sibling;
- } args = {
- "peer",
- 1,
- 1,
- };
-
- ofw_stack();
- args.phandle = phandle;
- if (openfirmware(&args) == -1)
- return 0;
- return args.sibling;
-}
-
-int
-OF_child(int phandle)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int phandle;
- int child;
- } args = {
- "child",
- 1,
- 1,
- };
-
- ofw_stack();
- args.phandle = phandle;
- if (openfirmware(&args) == -1)
- return 0;
- return args.child;
-}
-
-int
-OF_parent(int phandle)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int phandle;
- int parent;
- } args = {
- "parent",
- 1,
- 1,
- };
-
- ofw_stack();
- args.phandle = phandle;
- if (openfirmware(&args) == -1)
- return 0;
- return args.parent;
-}
-
-int
-OF_getprop(int handle, char *prop, void *buf, int buflen)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- int phandle;
- char *prop;
- void *buf;
- int buflen;
- int size;
- } args = {
- "getprop",
- 4,
- 1,
- };
-
- ofw_stack();
- if (buflen > NBPG)
- return -1;
- args.phandle = handle;
- args.prop = prop;
- args.buf = OF_buf;
- args.buflen = buflen;
- if (openfirmware(&args) == -1)
- return -1;
- if (args.size > 0)
- ofbcopy(OF_buf, buf, args.size);
- return args.size;
-}
-
-int
-OF_interpret(char *cmd, int nreturns, ...)
-{
- va_list ap;
- int i;
- static struct {
- char *name;
- int nargs;
- int nreturns;
- char *cmd;
- int status;
- int results[8];
- } args = {
- "interpret",
- 1,
- 2,
- };
-
- ofw_stack();
- if (nreturns > 8)
- return -1;
- if ((i = strlen(cmd)) >= NBPG)
- return -1;
- ofbcopy(cmd, OF_buf, i + 1);
- args.cmd = OF_buf;
- args.nargs = 1;
- args.nreturns = nreturns + 1;
- if (openfirmware(&args) == -1)
- return -1;
- va_start(ap, nreturns);
- for (i = 0; i < nreturns; i++)
- *va_arg(ap, int *) = args.results[i];
- va_end(ap);
- return args.status;
-}
-
-
-int
-OF_finddevice(char *name)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- char *device;
- int phandle;
- } args = {
- "finddevice",
- 1,
- 1,
- };
-
- ofw_stack();
- args.device = name;
- if (openfirmware(&args) == -1)
- return -1;
- return args.phandle;
-}
-static void OF_rboot(char *bootspec);
-
-static void
-OF_rboot(char *bootspec)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- } args = {
- "reset-all",
- 0,
- 0,
- };
- int l;
-
- if ((l = strlen(bootspec)) >= NBPG)
- panic("OF_boot");
- ofw_stack();
- openfirmware(&args);
- /* will attempt exit in OF_boot */
-}
-
-
-void
-OF_boot(char *bootspec)
-{
- OF_rboot(bootspec);
- printf ("OF_boot returned!"); /* just in case */
- OF_exit();
- while(1);
-}
-
-void
-OF_exit()
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- } args = {
- "exit",
- 0,
- 0,
- };
-
- ofw_stack();
- openfirmware(&args);
- panic ("OF_exit returned!"); /* just in case */
- while (1);
-}
-
-void * OF_claim(void *virt, u_int size, u_int align);
-void *
-OF_claim(void *virt, u_int size, u_int align)
-{
- static struct {
- char *name;
- int nargs;
- int nreturns;
- void *virt;
- u_int size;
- u_int align;
- void *baseaddr;
- } args = {
- "claim",
- 3,
- 1,
- };
-
- ofw_stack();
- args.virt = virt;
- args.size = size;
- args.align = align;
- if (openfirmware(&args) == -1)
- return (void *)-1;
- if (virt != 0) {
- return virt;
- }
- return args.baseaddr;
-}
-
-/* XXX What is the reason to have this instead of bcopy/memcpy? */
-void
-ofbcopy(const void *src, void *dst, size_t len)
-{
- const char *sp = src;
- char *dp = dst;
-
- if (src == dst)
- return;
-
- while (len-- > 0)
- *dp++ = *sp++;
-}
-
diff --git a/sys/arch/pegasos/pegasos/rbus_machdep.c b/sys/arch/pegasos/pegasos/rbus_machdep.c
deleted file mode 100644
index 7ec67683570..00000000000
--- a/sys/arch/pegasos/pegasos/rbus_machdep.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* $OpenBSD: rbus_machdep.c,v 1.1 2003/10/31 03:54:33 drahn Exp $ */
-/* $NetBSD: rbus_machdep.c,v 1.2 1999/10/15 06:43:06 haya Exp $ */
-
-/*
- * Copyright (c) 1999
- * HAYAKAWA Koichi. 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 HAYAKAWA Koichi.
- * 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/systm.h>
-#include <sys/extent.h>
-
-#include <uvm/uvm_extern.h>
-
-#include <sys/sysctl.h>
-
-#include <sys/device.h>
-
-#include <machine/bus.h>
-#include <dev/cardbus/rbus.h>
-
-#include <dev/pci/pcivar.h>
-#include <arch/pegasos/pci/pcibrvar.h>
-
-void rbus_cardbus_init(pci_chipset_tag_t pc, pcitag_t tag);
-
-/**********************************************************************
- * rbus_tag_t rbus_fakeparent_mem(struct pci_attach_args *pa)
- *
- * This function makes an rbus tag for memory space. This rbus tag
- * shares the all memory region of ex_iomem.
- **********************************************************************/
-#define RBUS_MEM_SIZE 0x10000000
-
-rbus_tag_t
-rbus_pccbb_parent_mem(struct device *self, struct pci_attach_args *pa)
-{
- bus_addr_t start;
- bus_size_t size;
- struct extent *ex;
-
- rbus_cardbus_init(pa->pa_pc, pa->pa_tag);
-
- size = RBUS_MEM_SIZE;
- if ((ex = pciaddr_search(PCIADDR_SEARCH_MEM, self, &start, size)) == NULL)
- {
- /* XXX */
- printf("failed\n");
- }
-
- return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
-}
-
-
-/**********************************************************************
- * rbus_tag_t rbus_pccbb_parent_io(struct pci_attach_args *pa)
- **********************************************************************/
-#define RBUS_IO_SIZE 0x1000
-
-rbus_tag_t
-rbus_pccbb_parent_io(struct device *self, struct pci_attach_args *pa)
-{
- struct extent *ex;
- bus_addr_t start;
- bus_size_t size;
-
-
- size = RBUS_IO_SIZE;
- if ((ex = pciaddr_search(PCIADDR_SEARCH_IO, self, &start, size)) == NULL)
- {
- /* XXX */
- printf("failed\n");
- }
-
- return rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
-}
-
-
-/*
- * Big ugly hack to enable bridge/fix interrupts
- */
-void
-rbus_cardbus_init(pci_chipset_tag_t pc, pcitag_t tag)
-{
- u_int x;
- static int initted = 0;
-
- if (initted)
- return;
- initted = 1;
-
- /* XXX What about other bridges? */
-
- x = pci_conf_read(pc, tag, PCI_ID_REG);
- if (PCI_VENDOR(x) == PCI_VENDOR_TI &&
- PCI_PRODUCT(x) == PCI_PRODUCT_TI_PCI1211) {
- /* For CardBus card. */
- pci_conf_write(pc, tag, 0x18, 0x10010100);
-
- /* Route INTA to MFUNC0 */
- x = pci_conf_read(pc, tag, 0x8c);
- x |= 0x02;
- pci_conf_write(pc, tag, 0x8c, x);
-
- tag = pci_make_tag(pc, 0, 0, 0);
- x = pci_conf_read(pc, tag, PCI_ID_REG);
- if (PCI_VENDOR(x) == PCI_VENDOR_MOT &&
- PCI_PRODUCT(x) == PCI_PRODUCT_MOT_MPC106) {
- /* Set subordinate bus number to 1. */
- x = pci_conf_read(pc, tag, 0x40);
- x |= 1 << 8;
- pci_conf_write(pc, tag, 0x40, x);
- }
- }
-}
diff --git a/sys/arch/pegasos/pegasos/rdbdisksubr.c b/sys/arch/pegasos/pegasos/rdbdisksubr.c
deleted file mode 100644
index d18e905bbca..00000000000
--- a/sys/arch/pegasos/pegasos/rdbdisksubr.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* $OpenBSD: rdbdisksubr.c,v 1.2 2003/12/20 22:40:28 miod Exp $ */
-/* $NetBSD: disksubr.c,v 1.27 1996/10/13 03:06:34 christos Exp $ */
-
-/*
- * Copyright (c) 1994 Christian E. Hopps
- * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/disklabel.h>
-#include <sys/syslog.h>
-#include <sys/disk.h>
-
-struct adostype getadostype(u_long dostype);
-
-u_long rdbchksum(void *bdata);
-
-#define b_cylin b_resid
-int
-try_rdb_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *osdep, char **pmsg,
- int *bsdpartoff);
-int
-try_rdb_label(dev_t dev, void (*strat)(struct buf *), struct buf *bp,
- struct disklabel *lp, struct cpu_disklabel *clp, char **pmsg,
- int *bsdpartoff)
-{
- int nextb, i;
- int rdbpartoff = -1;
- struct rdblock *rbp;
- struct partblock *pbp;
- struct partition *pp = NULL;
- struct adostype adt;
- int cindex;
-
- clp->rdblock = RDBNULL;
-
- /* initialize */
- for (i = 0; i < MAXPARTITIONS; i++) {
- clp->pbindex[i] = -1;
- clp->pblist[i] = RDBNULL;
- }
- if (lp->d_partitions[RAW_PART].p_size == 0)
- lp->d_partitions[RAW_PART].p_size = 0x1fffffff;
- lp->d_partitions[RAW_PART].p_offset = 0;
-
- lp->d_npartitions = 'i' - 'a';
-
- bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), RAW_PART);
-
- /* Find RDB block */
-
- for (nextb = 0; nextb < RDB_MAXBLOCKS; nextb++) {
- bp->b_blkno = nextb;
- bp->b_cylin = nextb / lp->d_secpercyl;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- strat(bp);
-
- if (biowait(bp)) {
- *pmsg = "RDB search I/O error";
- goto done;
- }
- rbp = (void *)(bp->b_data);
-
- if (rbp->id == RDBLOCK_ID) {
- if (rdbchksum(rbp) == 0)
- break;
- else
- *pmsg = "bad rdb checksum";
- }
- }
- if (nextb == RDB_MAXBLOCKS)
- goto done; /* no RDB found */
-
- clp->rdblock = nextb;
-
- lp->d_secsize = rbp->nbytes;
- lp->d_nsectors = rbp->nsectors;
- lp->d_ntracks = rbp->nheads;
- /*
- * should be rdb->ncylinders however this is a bogus value
- * sometimes it seems
- */
- if (rbp->highcyl == 0)
- lp->d_ncylinders = rbp->ncylinders;
- else
- lp->d_ncylinders = rbp->highcyl + 1;
- /*
- * I also don't trust rdb->secpercyl
- */
- lp->d_secpercyl = min(rbp->secpercyl, lp->d_nsectors * lp->d_ntracks);
- if (lp->d_secpercyl == 0)
- lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
-
- cindex = 0;
- for (nextb = rbp->partbhead; nextb != RDBNULL; nextb = pbp->next) {
- bp->b_blkno = nextb;
- bp->b_cylin = nextb / lp->d_secpercyl;
- bp->b_bcount = lp->d_secsize;
- bp->b_flags = B_BUSY | B_READ;
- strat(bp);
-
- if (biowait(bp)) {
- *pmsg = "RDB partition scan I/O error";
- goto done;
- }
- pbp = (void *)(bp->b_data);
-
- if (pbp->id != PARTBLOCK_ID) {
- *pmsg = "RDB partition block bad id";
- goto done;
- }
- if (rdbchksum(pbp)) {
- *pmsg = "RDB partition block bad cksum";
- goto done;
- }
- if (pbp->e.tabsize < 11)
- *pmsg = "RDB bad partition info (environ < 11)";
-
- if (pbp->e.dostype == DOST_OBSD) {
- rdbpartoff = pbp->e.lowcyl * pbp->e.secpertrk
- * pbp->e.numheads;
- clp->rd_bsdlbl = rdbpartoff;
- continue;
- }
-
- if (pbp->e.tabsize >= 16)
- adt = getadostype(pbp->e.dostype);
- else {
- adt.archtype = ADT_UNKNOWN;
- adt.fstype = FS_UNUSED;
- }
-
- switch (adt.archtype) {
- case ADT_NETBSDROOT:
- pp = &lp->d_partitions[0];
- if (pp->p_size) {
- printf("WARN: more than one root, ignoring\n");
- clp->rdblock = RDBNULL; /* invlidate cpulab */
- continue;
- }
- break;
- case ADT_NETBSDSWAP:
- pp = &lp->d_partitions[1];
- if (pp->p_size) {
- printf("WARN: more than one swap, ignoring\n");
- clp->rdblock = RDBNULL; /* invlidate cpulab */
- continue;
- }
- break;
- case ADT_NETBSDUSER:
- case ADT_AMIGADOS:
- case ADT_AMIX:
- case ADT_EXT2:
- case ADT_UNKNOWN:
- pp = &lp->d_partitions[lp->d_npartitions];
- break;
- }
-
- if (lp->d_npartitions <= (pp - lp->d_partitions))
- lp->d_npartitions = (pp - lp->d_partitions) + 1;
-
-#if 0
- if (lp->d_secpercyl != (pbp->e.secpertrk * pbp->e.numheads)) {
- if (pbp->partname[0] < sizeof(pbp->partname))
- pbp->partname[pbp->partname[0] + 1] = 0;
- else
- pbp->partname[sizeof(pbp->partname) - 1] = 0;
- printf("Partition '%s' geometry %ld/%ld differs",
- pbp->partname + 1, pbp->e.numheads,
- pbp->e.secpertrk);
- printf(" from RDB %d/%d\n", lp->d_ntracks,
- lp->d_nsectors);
- }
-#endif
-#if 0
- /*
- * insert sort in increasing offset order
- */
- while ((pp - lp->d_partitions) > RAW_PART + 1) {
- daddr_t boff;
-
- boff = pbp->e.lowcyl * pbp->e.secpertrk
- * pbp->e.numheads;
- if (boff > (pp - 1)->p_offset)
- break;
- *pp = *(pp - 1); /* struct copy */
- pp--;
- }
-#endif
- i = (pp - lp->d_partitions);
-
- pp->p_size = (pbp->e.highcyl - pbp->e.lowcyl + 1)
- * pbp->e.secpertrk * pbp->e.numheads;
- pp->p_offset = pbp->e.lowcyl * pbp->e.secpertrk
- * pbp->e.numheads;
- pp->p_fstype = adt.fstype;
- if (adt.archtype == ADT_AMIGADOS) {
- /*
- * Save reserved blocks at begin in cpg and
- * adjust size by reserved blocks at end
- */
- pp->p_fsize = 512;
- pp->p_frag = pbp->e.secperblk;
- pp->p_cpg = pbp->e.resvblocks;
- pp->p_size -= pbp->e.prefac;
- } else if (pbp->e.tabsize > 22 && ISFSARCH_NETBSD(adt)) {
- pp->p_fsize = pbp->e.fsize;
- pp->p_frag = pbp->e.frag;
- pp->p_cpg = pbp->e.cpg;
- } else {
- pp->p_fsize = 1024;
- pp->p_frag = 8;
- pp->p_cpg = 0;
- }
-
- /*
- * store this partitions block number
- */
- clp->pbindex[i] = cindex;
- clp->pblist[cindex] = nextb;
- cindex++;
- }
-done:
- if (clp->rdblock != RDBNULL && rdbpartoff != -1)
- *bsdpartoff = rdbpartoff;
- bp->b_dev = dev;
- return (clp->rdblock != RDBNULL);
-}
-
-struct adostype
-getadostype(u_long dostype)
-{
- struct adostype adt;
- u_long t3, b1;
-
- t3 = dostype & 0xffffff00;
- b1 = dostype & 0x000000ff;
-
- adt.fstype = b1;
-
- switch (t3) {
- case DOST_NBR:
- adt.archtype = ADT_NETBSDROOT;
- return (adt);
- case DOST_NBS:
- adt.archtype = ADT_NETBSDSWAP;
- return (adt);
- case DOST_NBU:
- adt.archtype = ADT_NETBSDUSER;
- return (adt);
- case DOST_MUFS:
- /* check for 'muFS'? */
- adt.archtype = ADT_AMIGADOS;
- adt.fstype = FS_ADOS;
- return (adt);
- case DOST_DOS:
- adt.archtype = ADT_AMIGADOS;
- if (b1 > 5)
-#if 0
- /*
- * XXX at least I, <niklas@appli.se>, have a partition
- * that looks like "DOS\023", wherever that came from,
- * but ADOS accepts it, so should we.
- */
- goto unknown;
- else
-#else
- printf("found dostype: 0x%lx, assuming an ADOS FS "
- "although it's unknown\n", dostype);
-#endif
- adt.fstype = FS_ADOS;
- return (adt);
- case DOST_AMIX:
- adt.archtype = ADT_AMIX;
- if (b1 == 2)
- adt.fstype = FS_BSDFFS;
- else
- goto unknown;
- return (adt);
- case DOST_XXXBSD:
-#ifdef DIAGNOSTIC
- printf("found dostype: 0x%lx which is deprecated", dostype);
-#endif
- if (b1 == 'S') {
- dostype = DOST_NBS;
- dostype |= FS_SWAP;
- } else {
- if (b1 == 'R')
- dostype = DOST_NBR;
- else
- dostype = DOST_NBU;
- dostype |= FS_BSDFFS;
- }
-#ifdef DIAGNOSTIC
- printf(" using: 0x%lx instead\n", dostype);
-#endif
- return (getadostype(dostype));
- case DOST_EXT2:
- adt.archtype = ADT_EXT2;
- adt.fstype = FS_EXT2FS;
- return(adt);
- default:
- unknown:
-#ifdef DIAGNOSTIC
- printf("warning unknown dostype: 0x%lx marking unused\n",
- dostype);
-#endif
- adt.archtype = ADT_UNKNOWN;
- adt.fstype = FS_UNUSED;
- return (adt);
- }
-}
-
-u_long
-rdbchksum(bdata)
- void *bdata;
-{
- u_long *blp, cnt, val;
-
- blp = bdata;
- cnt = blp[1];
- val = 0;
-
- while (cnt--)
- val += *blp++;
- return (val);
-}
diff --git a/sys/arch/pegasos/pegasos/wscons_machdep.c b/sys/arch/pegasos/pegasos/wscons_machdep.c
deleted file mode 100644
index 04e57aa11d6..00000000000
--- a/sys/arch/pegasos/pegasos/wscons_machdep.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* $OpenBSD: wscons_machdep.c,v 1.2 2004/02/04 20:07:18 drahn Exp $ */
-
-/*
- * Copyright (c) 2001 Aaron Campbell
- * 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.
- *
- * 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 OR HIS RELATIVES 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 MIND, 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/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/device.h>
-#include <sys/extent.h>
-
-#include <machine/bus.h>
-
-#include <dev/cons.h>
-
-#include "wsdisplay.h"
-#include "vga.h"
-
-
-#if NVGA_PCI >0
-#include <dev/pci/pcivar.h>
-#include <dev/pci/vga_pcivar.h>
-#endif
-#if NWSDISPLAY > 0
-#include <dev/wscons/wsdisplayvar.h>
-#endif
-#include <dev/wscons/wskbdvar.h>
-
-#include "pckbc.h"
-#if (NPCKBC > 0)
-#include <dev/isa/isareg.h>
-#include <dev/ic/i8042reg.h>
-#include <dev/ic/pckbcvar.h>
-#endif
-#include "pckbd.h" /* for pckbc_machdep_cnattach */
-#include "ukbd.h" /* for pckbc_machdep_cnattach */
-#if (NUKBD > 0)
-#include <dev/usb/ukbdvar.h>
-#endif
-
-void wscnprobe(struct consdev *);
-void wscninit(struct consdev *);
-void wscnputc(dev_t, char);
-int wscngetc(dev_t);
-void wscnpollc(dev_t, int);
-
-void
-wscnprobe(struct consdev *cp)
-{
- int maj;
-
- /* locate the major number */
- for (maj = 0; maj < nchrdev; maj++) {
- if (cdevsw[maj].d_open == wsdisplayopen)
- break;
- }
-
- if (maj == nchrdev) {
- /* we are not in cdevsw[], give up */
- panic("wsdisplay is not in cdevsw[]");
- }
-
- cp->cn_dev = makedev(maj, 0);
- cp->cn_pri = CN_INTERNAL;
-}
-
-void
-wscninit(struct consdev *cp)
-{
- static int inited = 0;
-
- if (inited)
- return;
-
- inited = 1;
-
-
-#if (NVGA_PCI > 0)
- if (!vga_pci_cnattach(MD_DISPLAY_ISA_IOT, MD_DISPLAY_ISA_MEMT,
- NULL, 1, 0, 0));
-#endif
-#if (NPCKBC > 0)
- if (!pckbc_cnattach(MD_ISA_IOT, IO_KBD, KBCMDP, PCKBC_KBD_SLOT))
- return;
-#endif
-#if (NUKBD > 0)
- if (!ukbd_cnattach())
- return;
-#endif
-}
-
-void
-wscnputc(dev_t dev, char i)
-{
-#if NWSDISPLAY > 0
- wsdisplay_cnputc(dev, (int)i);
-#endif
-}
-
-int
-wscngetc(dev_t dev)
-{
- return (wskbd_cngetc(dev));
-}
-
-void
-wscnpollc(dev_t dev, int on)
-{
-#if NWSDISPLAY > 0
- wskbd_cnpollc(dev, on);
-#endif
-}