diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2001-09-01 15:44:21 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2001-09-01 15:44:21 +0000 |
commit | b0437314cc10bd43e476454d2df24ec3d953247f (patch) | |
tree | 2b9119cda2c7c8e085671492f7694db29d608556 /sys/arch/powerpc | |
parent | 96fe985cf8e20d3f5d9dd24aab20b615da5c5c86 (diff) |
The "powerpc" port which has supported the newer Apple Macintosh powerpc based
is being renamed to macppc. This is to allow sharing of common code
between different powerpc base platforms.
Most of the work involved in the renaming process was performed by miod@
Files moved from powerpc/powerpc to macppc/macppc
This moves hardware specific files from the common directory to the
platform specific directory. This leaves common files.
With this change all of the debugger (db_) files have been moved to
the platform specific directory. The debugger should be reconsidered
and commonized.
Diffstat (limited to 'sys/arch/powerpc')
22 files changed, 0 insertions, 9250 deletions
diff --git a/sys/arch/powerpc/powerpc/autoconf.c b/sys/arch/powerpc/powerpc/autoconf.c deleted file mode 100644 index 519c2f8120e..00000000000 --- a/sys/arch/powerpc/powerpc/autoconf.c +++ /dev/null @@ -1,613 +0,0 @@ -/* $OpenBSD: autoconf.c,v 1.12 2001/06/24 04:49:27 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. 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. - * - * from: Utah Hdr: autoconf.c 1.31 91/01/21 - * - * from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - * $Id: autoconf.c,v 1.12 2001/06/24 04:49:27 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 <machine/autoconf.h> - -struct device *parsedisk __P((char *, int, int, dev_t *)); -void setroot __P((void)); -void swapconf __P((void)); -extern void dumpconf __P((void)); -static int findblkmajor __P((struct device *)); -static struct device * getdisk __P((char *, int, int, dev_t *)); -struct device * getdevunit __P((char *, int)); -static struct devmap * findtype __P((char **)); -void makebootdev __P((char *cp)); -int getpno __P((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(system_type == OFWMACH) { - ofrootfound(); - } - */ - 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() -{ - register struct swdevt *swp; - register 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 */ -}; - -static int -findblkmajor(dv) - struct device *dv; -{ - char *name = dv->dv_xname; - register int i; - - for (i = 0; i < sizeof(nam2blk)/sizeof(nam2blk[0]); ++i) - if (strncmp(name, nam2blk[i].name, strlen(nam2blk[0].name)) == 0) - return (nam2blk[i].maj); - return (-1); -} - -static struct device * -getdisk(str, len, defpart, devp) - char *str; - int len, defpart; - dev_t *devp; -{ - register 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-h]", dv->dv_xname); -#ifdef NFSCLIENT - if (dv->dv_class == DV_IFNET) - printf(" %s", dv->dv_xname); -#endif - } - printf("\n"); - } - return (dv); -} - -struct device * -parsedisk(str, len, defpart, devp) - char *str; - int len, defpart; - dev_t *devp; -{ - register struct device *dv; - register 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]; - -#if defined(NFSCLIENT) - extern char *nfsbootdevname; -#endif - -printf("bootpath: '%s'\n", bootpath); - makebootdev(bootpath); - if(boothowto & RB_DFLTROOT) - return; /* Boot compiled in */ - - /* 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(": "); - len = getsn(buf, sizeof(buf)); - if (len == 0 && bootdv != NULL) { - strcpy(buf, bootdv->dv_xname); - 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(": "); - len = getsn(buf, sizeof(buf)); - 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(name, unit) - 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 */ - sprintf(num, "%d", unit); - lunit = strlen(num); - if (strlen(name) + lunit >= sizeof(fullname) - 1) - panic("config_attach: device name too long"); - - strcpy(fullname, name); - strcat(fullname, num); - - 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(s) - char **s; -{ - static struct devmap devmap[] = { - { "/pci@", NULL, T_BUS }, - { "/pci", 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(bp) - 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); - sprintf(bootdev, "%s%d%c", dev, unit, 'a'); -} - -int -getpno(cp) - 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/powerpc/powerpc/clock.c b/sys/arch/powerpc/powerpc/clock.c deleted file mode 100644 index 15b2ba6a5a9..00000000000 --- a/sys/arch/powerpc/powerpc/clock.c +++ /dev/null @@ -1,377 +0,0 @@ -/* $OpenBSD: clock.c,v 1.14 2001/06/24 04:59:26 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 <dev/ofw/openfirm.h> - -#if 0 -#include <powerpc/pci/mpc106reg.h> -#endif - -void resettodr(void); -static inline u_quad_t mftb(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_long ticks_per_sec = 3125000; -static u_long ns_per_tick = 320; -static long ticks_per_intr; -static volatile u_long 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 - -typedef int (clock_read_t)(int *sec, int *min, int *hour, int *day, - int *mon, int *yr); -typedef int (time_read_t)(u_long *sec); -typedef int (time_write_t)(u_long sec); - -int power4e_getclock(int *, int *, int *, int *, int *, int *); - -clock_read_t *clock_read = NULL; -time_read_t *time_read = NULL; -time_write_t *time_write = NULL; - -static u_long -chiptotime(int sec, int min, int hour, int day, int mon, int year); - -/* - * 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(base) - 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_long 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); - } - 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_long -chiptotime(sec, min, hour, day, mon, year) - int sec, min, hour, day, mon, 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() -{ - 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); - } -} - - -void -decr_intr(frame) - struct clockframe *frame; -{ - int msr; - u_long tb; - long tick; - int nticks; - int pri; - - /* - * Check whether we are initialized. - */ - if (!ticks_per_intr) - return; - - intrcnt[PPC_CLK_IRQ]++; - - /* - * Based on the actual time delay since the last decrementer reload, - * we arrange for earlier interrupt next time. - */ - asm ("mftb %0; mfdec %1" : "=r"(tb), "=r"(tick)); - for (nticks = 0; tick < 0; nticks++) - tick += ticks_per_intr; - asm volatile ("mtdec %0" :: "r"(tick)); - /* - * lasttb is used during microtime. Set it to the virtual - * start of this tick interval. - */ - lasttb = tb + tick - ticks_per_intr; - - pri = splclock(); - - if (pri & SPL_CLOCK) { - tickspending += nticks; - } else { - nticks += tickspending; - tickspending = 0; - /* - * Reenable interrupts - */ - asm volatile ("mfmsr %0; ori %0, %0, %1; mtmsr %0" - : "=r"(msr) : "K"(PSL_EE)); - - /* - * Do standard timer interrupt stuff. - * Do softclock stuff only on the last iteration. - */ - frame->pri = pri | SINT_CLOCK; - while (--nticks > 0) - hardclock(frame); - frame->pri = pri; - hardclock(frame); - } - splx(pri); -} - -void -cpu_initclocks() -{ - int msr, scratch; - asm volatile ("mfmsr %0; andi. %1, %0, %2; mtmsr %1" - : "=r"(msr), "=r"(scratch) : "K"((u_short)~PSL_EE)); - asm volatile ("mftb %0" : "=r"(lasttb)); - asm volatile ("mtdec %0" :: "r"(ticks_per_intr)); - asm volatile ("mtmsr %0" :: "r"(msr)); -} - -void -calc_delayconst() -{ - int qhandle, phandle; - char name[32]; - int msr, scratch; - - /* - * 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 - */ - asm volatile ("mfmsr %0; andi. %1, %0, %2; mtmsr %1" - : "=r"(msr), "=r"(scratch) : "K"((u_short)~PSL_EE)); - ns_per_tick = 1000000000 / ticks_per_sec; - ticks_per_intr = ticks_per_sec / hz; - asm volatile ("mtmsr %0" :: "r"(msr)); - 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"); -} - -static inline u_quad_t -mftb() -{ - u_long scratch; - u_quad_t tb; - - asm ("1: mftbu %0; mftb %0+1; mftbu %1; cmpw 0,%0,%1; bne 1b" - : "=r"(tb), "=r"(scratch)); - return tb; -} - -/* - * Fill in *tvp with current time with microsecond resolution. - */ -void -microtime(tvp) - struct timeval *tvp; -{ - u_long tb; - u_long ticks; - int msr, scratch; - - asm volatile ("mfmsr %0; andi. %1,%0,%2; mtmsr %1" - : "=r"(msr), "=r"(scratch) : "K"((u_short)~PSL_EE)); - asm ("mftb %0" : "=r"(tb)); - ticks = (tb - lasttb) * ns_per_tick; - *tvp = time; - asm volatile ("mtmsr %0" :: "r"(msr)); - 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(n) - unsigned n; -{ - u_quad_t tb; - u_long tbh, tbl, scratch; - - tb = mftb(); - tb += (n * 1000 + ns_per_tick - 1) / ns_per_tick; - tbh = tb >> 32; - tbl = 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)); - - tb = mftb(); -} - -/* - * Nothing to do. - */ -void -setstatclockrate(arg) - int arg; -{ - /* Do nothing */ -} diff --git a/sys/arch/powerpc/powerpc/conf.c b/sys/arch/powerpc/powerpc/conf.c deleted file mode 100644 index 56a8aec2f2f..00000000000 --- a/sys/arch/powerpc/powerpc/conf.c +++ /dev/null @@ -1,392 +0,0 @@ -/* $OpenBSD: conf.c,v 1.26 2001/08/06 22:34:44 mickey 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/conf.h> -#include <sys/ioctl.h> -#include <sys/systm.h> -#include <sys/tty.h> -#include <sys/vnode.h> - -#include "wd.h" -bdev_decl(wd); -#include "sd.h" -bdev_decl(sd); -#include "cd.h" -bdev_decl(cd); - -#include "ofdisk.h" -bdev_decl(ofd); - -#include "rd.h" -bdev_decl(rd); - -#include "vnd.h" -bdev_decl(vnd); -#include "ccd.h" -bdev_decl(ccd); -#include "raid.h" -bdev_decl(raid); - -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]; - -cdev_decl(cn); -cdev_decl(ctty); -#define mmread mmrw -#define mmwrite mmrw -cdev_decl(mm); -#include "pty.h" -#define ptstty ptytty -#define ptsioctl ptyioctl -cdev_decl(pts); -#define ptctty ptytty -#define ptcioctl ptyioctl -cdev_decl(ptc); -cdev_decl(log); -#include "com.h" -cdev_decl(com); - -#include "ofcons.h" -cdev_decl(ofc); -cdev_decl(ofd); - -#include "ofrtc.h" -cdev_decl(ofrtc); - - -cdev_decl(kbd); -cdev_decl(ms); - -#include "wsdisplay.h" -#include "wskbd.h" -#include "wsmouse.h" - -cdev_decl(wsdisplay); -cdev_decl(wskbd); -cdev_decl(wsmouse); - -#include <sd.h> -#include <st.h> -#include <cd.h> -#include <uk.h> -#include <ss.h> -cdev_decl(st); -cdev_decl(sd); -cdev_decl(cd); -cdev_decl(vnd); -cdev_decl(ccd); -cdev_decl(rd); -#include "raid.h" -#include "iop.h" - -#include <wd.h> -cdev_decl(wd); - -dev_decl(filedesc,open); - -#include "bpfilter.h" -cdev_decl(bpf); - -#include "tun.h" -cdev_decl(tun); -cdev_decl(random); - -#ifdef XFS -#include <xfs/nxfs.h> -cdev_decl(xfs_dev); -#endif - -#ifdef LKM -#define NLKM 1 -#else -#define NLKM 0 -#endif - -cdev_decl(lkm); - -#include "ksyms.h" -cdev_decl(ksyms); -#include "usb.h" -cdev_decl(usb); -#include "uhid.h" -cdev_decl(uhid); -#include "ugen.h" -cdev_decl(ugen); -#include "ulpt.h" -cdev_decl(ulpt); -#include "urio.h" -cdev_decl(urio); -#include "ucom.h" -cdev_decl(ucom); - -#include "wsmux.h" -cdev_decl(wsmux); - -#ifdef USER_PCICONF -#include "pci.h" -cdev_decl(pci); -#endif - -#include "audio.h" -cdev_decl(audio); - -#include "pf.h" -cdev_decl(pf); - -#include <altq/altqconf.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 */ - 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_notdef(), /* 47 */ - cdev_notdef(), /* 48 */ - cdev_notdef(), /* 49 */ - cdev_notdef(), /* 50 */ -#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_ugen_init(NUGEN,ugen), /* 63: USB generic driver */ - cdev_ulpt_init(NULPT,ulpt), /* 64: USB printers */ - cdev_usbdev_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_altq_init(NALTQ,altq), /* 72: ALTQ control interface */ - cdev_iop_init(NIOP,iop), /* 73: I2O IOP control interface */ -}; -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) - dev_t dev; -{ - return major(dev) == mem_no && minor(dev) < 2; -} - -/* - * Check whether dev is /dev/zero. - */ -int -iszerodev(dev) - dev_t dev; -{ - return major(dev) == mem_no && minor(dev) == 12; -} - -dev_t -getnulldev() -{ - return makedev(mem_no, 2); -} - -static 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, -}; - -/* - * Return accompanying block dev for a char dev. - */ -int -chrtoblk(dev) - dev_t dev; -{ - int blkmaj; - - if (major(dev) >= nchrdev || - major(dev) > sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0])) - return (NODEV); - blkmaj = chrtoblktbl[major(dev)]; - if (blkmaj == NODEV) - return (NODEV); - return (makedev(blkmaj, minor(dev))); -} - -/* - * Convert a character device number to a block device number. - */ -dev_t -blktochr(dev) - dev_t dev; -{ - int blkmaj = major(dev); - int i; - - if (blkmaj >= nblkdev) - return (NODEV); - for (i = 0; i < sizeof(chrtoblktbl)/sizeof(chrtoblktbl[0]); i++) - if (blkmaj == chrtoblktbl[i]) - return (makedev(i, minor(dev))); - return (NODEV); -} - -#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 NOFCONS > 0 - cons_init(ofc), -#endif -#if NCOM > 0 - cons_init(com), -#endif - { 0 }, -}; diff --git a/sys/arch/powerpc/powerpc/cpu.c b/sys/arch/powerpc/powerpc/cpu.c deleted file mode 100644 index fa908134ec7..00000000000 --- a/sys/arch/powerpc/powerpc/cpu.c +++ /dev/null @@ -1,304 +0,0 @@ -/* $OpenBSD: cpu.c,v 1.12 2001/07/09 04:41:28 mickey 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 MPC7410 0x800c -#define MPC7450 0x8000 - -/* 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)) - -char cpu_model[80]; -char machine[] = "powerpc"; /* 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 __P((void)); - -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); -} - -void -cpuattach(parent, dev, aux) - struct device *parent; - struct device *dev; - void *aux; -{ - unsigned int cpu, pvr, hid0; - char name[32]; - int qhandle, phandle; - unsigned int clock_freq = 0; - - __asm__ ("mfpvr %0" : "=r"(pvr)); - cpu = pvr >> 16; - switch (cpu) { - case MPC601: - sprintf(cpu_model, "601"); - break; - case MPC603: - sprintf(cpu_model, "603"); - break; - case MPC604: - sprintf(cpu_model, "604"); - break; - case MPC603e: - sprintf(cpu_model, "603e"); - break; - case MPC603ev: - sprintf(cpu_model, "603ev"); - break; - case MPC750: - sprintf(cpu_model, "750"); - break; - case MPC604ev: - sprintf(cpu_model, "604ev"); - break; - case MPC7400: - sprintf(cpu_model, "7400"); - break; - case MPC7410: - sprintf(cpu_model, "7410"); - break; - case MPC7450: - sprintf(cpu_model, "7450"); - break; - default: - sprintf(cpu_model, "Version %x", cpu); - break; - } - sprintf(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); - - } - /* power savings mode */ - asm ("mfspr %0,1008" : "=r" (hid0)); - switch (cpu) { - case MPC603: - case MPC603e: - case MPC750: - case MPC7400: - case MPC7410: - case MPC7450: - /* select DOZE mode */ - hid0 &= ~(HID0_NAP | HID0_SLEEP); - hid0 |= HID0_DOZE | HID0_DPM; - } - asm ("mtspr %0,1008" : "=r" (hid0)); - - /* if processor is G3 or G4, configure l2 cache */ - if ( (cpu == MPC750) || (cpu == MPC7400) - || (cpu == MPC7410)) - { - config_l2cr(); - } - printf("\n"); - - -} - -#define L2CR 1017 - -#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). */ -#ifdef L2CR_CONFIG -u_int l2cr_config = L2CR_CONFIG; -#else -u_int l2cr_config = 0; -#endif - -void -config_l2cr() -{ - u_int l2cr, x; - - __asm __volatile ("mfspr %0, 1017" : "=r"(l2cr)); - - /* - * Configure L2 cache if not enabled. - */ - if ((l2cr & L2CR_L2E) == 0 && l2cr_config != 0) { - l2cr = l2cr_config; - asm volatile ("mtspr 1017,%0" :: "r"(l2cr)); - - /* Wait for L2 clock to be stable (640 L2 clocks). */ - delay(100); - - /* Invalidate all L2 contents. */ - l2cr |= L2CR_L2I; - asm volatile ("mtspr 1017,%0" :: "r"(l2cr)); - do { - asm volatile ("mfspr %0, 1017" : "=r"(x)); - } while (x & L2CR_L2IP); - - /* Enable L2 cache. */ - l2cr &= ~L2CR_L2I; - l2cr |= L2CR_L2E; - asm volatile ("mtspr 1017,%0" :: "r"(l2cr)); - } - - if (l2cr & L2CR_L2E) { - 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"); - } -#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 - printf(" backside cache"); - } else - printf(": L2 cache not enabled"); - -} diff --git a/sys/arch/powerpc/powerpc/db_disasm.c b/sys/arch/powerpc/powerpc/db_disasm.c deleted file mode 100644 index 9bf13a99f25..00000000000 --- a/sys/arch/powerpc/powerpc/db_disasm.c +++ /dev/null @@ -1,891 +0,0 @@ -/* $NetBSD: db_disasm.c,v 1.8 2001/06/12 05:31:44 simonb Exp $ */ -/* $OpenBSD: db_disasm.c,v 1.7 2001/08/21 02:49:14 drahn Exp $ */ -/* - * Copyright (c) 1996 Dale Rahn. 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 Dale Rahn. - * 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/proc.h> -#include <sys/systm.h> - -#include <machine/db_machdep.h> - -#include <ddb/db_access.h> -#include <ddb/db_sym.h> -#include <ddb/db_variables.h> -#include <ddb/db_interface.h> -#include <ddb/db_output.h> - -enum function_mask { - Op_A = 0x00000001, - Op_B = 0x00000002, - Op_BI = 0x00000004, - Op_BO = 0x00000008, - Op_CRM = 0x00000010, - Op_D = 0x00000020, /* yes, Op_S and Op_D are the same */ - Op_S = 0x00000020, - Op_FM = 0x00000040, - Op_IMM = 0x00000080, - Op_LK = 0x00000100, - Op_Rc = 0x00000200, - Op_AA = Op_LK | Op_Rc, /* kludge (reduce Op_s) */ - Op_LKM = Op_AA, - Op_RcM = Op_AA, - Op_OE = 0x00000400, - Op_SR = 0x00000800, - Op_TO = 0x00001000, - Op_sign = 0x00002000, - Op_const = 0x00004000, - Op_SIMM = Op_const | Op_sign, - Op_UIMM = Op_const, - Op_d = Op_const | Op_sign, - Op_crbA = 0x00008000, - Op_crbB = 0x00010000, - Op_crbD = 0x00020000, - Op_crfD = 0x00040000, - Op_crfS = 0x00080000, - Op_ds = 0x00100000, - Op_me = 0x00200000, - Op_spr = 0x00400000, - Op_tbr = 0x00800000, - - Op_L = 0x01000000, - Op_BD = 0x02000000, - Op_LI = 0x04000000, - Op_C = 0x08000000, - - Op_NB = 0x10000000, - - Op_sh_mb_sh = 0x20000000, - Op_sh = 0x40000000, - Op_SH = Op_sh | Op_sh_mb_sh, - Op_mb = 0x80000000, - Op_MB = Op_mb | Op_sh_mb_sh, - Op_ME = Op_MB, - -}; - -struct opcode { - char *name; - u_int32_t mask; - u_int32_t code; - enum function_mask func; -}; - -typedef u_int32_t instr_t; -typedef void (op_class_func) (instr_t); - -u_int32_t extract_field(u_int32_t value, u_int32_t base, u_int32_t width); -void disasm_fields(const struct opcode *popcode, instr_t instr, - char *disasm_str); -void dis_ppc(const struct opcode *opcodeset, instr_t instr); - -op_class_func op_ill, op_base; -op_class_func op_cl_x13, op_cl_x1e, op_cl_x1f; -op_class_func op_cl_x3a, op_cl_x3b; -op_class_func op_cl_x3e, op_cl_x3f; - -op_class_func *opcodes_base[] = { -/*x00*/ op_ill, op_ill, op_base, op_ill, -/*x04*/ op_ill, op_ill, op_ill, op_base, -/*x08*/ op_base, op_base, op_ill, op_base, -/*x0C*/ op_base, op_base, op_base/*XXX*/, op_base/*XXX*/, -/*x10*/ op_base, op_base, op_base, op_cl_x13, -/*x14*/ op_base, op_base, op_ill, op_base, -/*x18*/ op_base, op_base, op_base, op_base, -/*x1C*/ op_base, op_base, op_cl_x1e, op_cl_x1f, -/*x20*/ op_base, op_base, op_base, op_base, -/*x24*/ op_base, op_base, op_base, op_base, -/*x28*/ op_base, op_base, op_base, op_base, -/*x2C*/ op_base, op_base, op_base, op_base, -/*x30*/ op_base, op_base, op_base, op_base, -/*x34*/ op_base, op_base, op_base, op_base, -/*x38*/ op_ill, op_ill, op_cl_x3a, op_cl_x3b, -/*x3C*/ op_ill, op_ill, op_cl_x3e, op_cl_x3f -}; - - -/* This table could be modified to make significant the "reserved" fields - * of the opcodes, But I didn't feel like it when typing in the table, - * I would recommend that this table be looked over for errors, - * This was derived from the table in Appendix A.2 of (Mot part # MPCFPE/AD) - * PowerPC Microprocessor Family: The Programming Environments - */ - -const struct opcode opcodes[] = { - { "tdi", 0xfc000000, 0x08000000, Op_TO | Op_A | Op_SIMM }, - { "twi", 0xfc000000, 0x0c000000, Op_TO | Op_A | Op_SIMM }, - { "mulli", 0xfc000000, 0x1c000000, Op_D | Op_A | Op_SIMM }, - { "subfic", 0xfc000000, 0x20000000, Op_D | Op_A | Op_SIMM }, - { "cmpli", 0xfc000000, 0x28000000, Op_crfD | Op_L | Op_A | Op_SIMM }, - { "cmpi", 0xfc000000, 0x2c000000, Op_crfD | Op_L | Op_A | Op_SIMM }, - { "addic", 0xfc000000, 0x30000000, Op_D | Op_A | Op_SIMM }, - { "addic.", 0xfc000000, 0x34000000, Op_D | Op_A | Op_SIMM }, - { "addi", 0xfc000000, 0x38000000, Op_D | Op_A | Op_SIMM }, - { "addis", 0xfc000000, 0x3c000000, Op_D | Op_A | Op_SIMM }, - { "bc", 0xfc000000, 0x40000000, Op_BO | Op_BI | Op_BD | Op_AA | Op_LK }, - { "sc", 0xffffffff, 0x44000002, Op_BO | Op_BI | Op_BD | Op_AA | Op_LK }, - { "b", 0xfc000000, 0x48000000, Op_LI | Op_AA | Op_LK }, - - { "rlwimi", 0xfc000000, 0x50000000, Op_S | Op_A | Op_SH | Op_MB | Op_ME | Op_Rc }, - { "rlwinm", 0xfc000000, 0x54000000, Op_S | Op_A | Op_SH | Op_MB | Op_ME | Op_Rc }, - { "rlwnm", 0xfc000000, 0x5c000000, Op_S | Op_A | Op_SH | Op_MB | Op_ME | Op_Rc }, - - { "ori", 0xfc000000, 0x60000000, Op_S | Op_A | Op_UIMM }, - { "oris", 0xfc000000, 0x64000000, Op_S | Op_A | Op_UIMM }, - { "xori", 0xfc000000, 0x68000000, Op_S | Op_A | Op_UIMM }, - { "xoris", 0xfc000000, 0x6c000000, Op_S | Op_A | Op_UIMM }, - - { "andi.", 0xfc000000, 0x70000000, Op_S | Op_A | Op_UIMM }, - { "andis.", 0xfc000000, 0x74000000, Op_S | Op_A | Op_UIMM }, - - { "lwz", 0xfc000000, 0x80000000, Op_D | Op_A | Op_d }, - { "lwzu", 0xfc000000, 0x84000000, Op_D | Op_A | Op_d }, - { "lbz", 0xfc000000, 0x88000000, Op_D | Op_A | Op_d }, - { "lbzu", 0xfc000000, 0x8c000000, Op_D | Op_A | Op_d }, - { "stw", 0xfc000000, 0x90000000, Op_S | Op_A | Op_d }, - { "stwu", 0xfc000000, 0x94000000, Op_S | Op_A | Op_d }, - { "stb", 0xfc000000, 0x98000000, Op_S | Op_A | Op_d }, - { "stbu", 0xfc000000, 0x9c000000, Op_S | Op_A | Op_d }, - - { "lhz", 0xfc000000, 0xa0000000, Op_D | Op_A | Op_d }, - { "lhzu", 0xfc000000, 0xa4000000, Op_D | Op_A | Op_d }, - { "lha", 0xfc000000, 0xa8000000, Op_D | Op_A | Op_d }, - { "lhau", 0xfc000000, 0xac000000, Op_D | Op_A | Op_d }, - { "sth", 0xfc000000, 0xb0000000, Op_S | Op_A | Op_d }, - { "sthu", 0xfc000000, 0xb4000000, Op_S | Op_A | Op_d }, - { "lmw", 0xfc000000, 0xb8000000, Op_D | Op_A | Op_d }, - { "stmw", 0xfc000000, 0xbc000000, Op_S | Op_A | Op_d }, - - { "lfs", 0xfc000000, 0xc0000000, Op_D | Op_A | Op_d }, - { "lfsu", 0xfc000000, 0xc4000000, Op_D | Op_A | Op_d }, - { "lfd", 0xfc000000, 0xc8000000, Op_D | Op_A | Op_d }, - { "lfdu", 0xfc000000, 0xcc000000, Op_D | Op_A | Op_d }, - - { "stfs", 0xfc000000, 0xd0000000, Op_S | Op_A | Op_d }, - { "stfsu", 0xfc000000, 0xd4000000, Op_S | Op_A | Op_d }, - { "stfd", 0xfc000000, 0xd8000000, Op_S | Op_A | Op_d }, - { "stfdu", 0xfc000000, 0xdc000000, Op_S | Op_A | Op_d }, - { "", 0x0, 0x0, 0 } - -}; -/* 13 * 4 = 4c */ -const struct opcode opcodes_13[] = { -/* 0x13 << 2 */ - { "mcrf", 0xfc0007fe, 0x4c000000, Op_crfD | Op_crfS }, - { "bclr", 0xfc0007fe, 0x4c000020, Op_BO | Op_BI | Op_LK }, - { "crnor", 0xfc0007fe, 0x4c000042, Op_crbD | Op_crbA | Op_crbB }, - { "rfi", 0xfc0007fe, 0x4c000064, 0 }, - { "crandc", 0xfc0007fe, 0x4c000102, Op_BO | Op_BI | Op_LK }, - { "isync", 0xfc0007fe, 0x4c00012c, 0 }, - { "crxor", 0xfc0007fe, 0x4c000182, Op_crbD | Op_crbA | Op_crbB }, - { "crnand", 0xfc0007fe, 0x4c0001c2, Op_crbD | Op_crbA | Op_crbB }, - { "crand", 0xfc0007fe, 0x4c000202, Op_crbD | Op_crbA | Op_crbB }, - { "creqv", 0xfc0007fe, 0x4c000242, Op_crbD | Op_crbA | Op_crbB }, - { "crorc", 0xfc0007fe, 0x4c000342, Op_crbD | Op_crbA | Op_crbB }, - { "cror", 0xfc0007fe, 0x4c000382, Op_crbD | Op_crbA | Op_crbB }, - { "bcctr", 0xfc0007fe, 0x4c000420, Op_BO | Op_BI | Op_LK }, - { "", 0x0, 0x0, 0 } -}; - -/* 1e * 4 = 78 */ -const struct opcode opcodes_1e[] = { - { "rldicl", 0xfc00001c, 0x78000000, Op_S | Op_A | Op_sh | Op_mb | Op_Rc }, - { "rldicr", 0xfc00001c, 0x78000004, Op_S | Op_A | Op_sh | Op_me | Op_Rc }, - { "rldic", 0xfc00001c, 0x78000008, Op_S | Op_A | Op_sh | Op_mb | Op_Rc }, - { "rldimi", 0xfc00001c, 0x7800000c, Op_S | Op_A | Op_sh | Op_mb | Op_Rc }, - { "rldcl", 0xfc00003e, 0x78000010, Op_S | Op_A | Op_B | Op_mb | Op_Rc }, - { "rldcr", 0xfc00003e, 0x78000012, Op_S | Op_A | Op_B | Op_me | Op_Rc }, - { "", 0x0, 0x0, 0 } -}; - -/* 1f * 4 = 7c */ -const struct opcode opcodes_1f[] = { -/* 1f << 2 */ - { "cmp", 0xfc0007fe, 0x7c000000, Op_S | Op_A | Op_B | Op_me | Op_Rc }, - { "tw", 0xfc0007fe, 0x7c000008, Op_TO | Op_A | Op_B }, - { "subfc", 0xfc0003fe, 0x7c000010, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "mulhdu", 0xfc0007fe, 0x7c000012, Op_D | Op_A | Op_B | Op_Rc }, - { "addc", 0xfc0003fe, 0x7c000014, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "mulhwu", 0xfc0007fe, 0x7c000016, Op_D | Op_A | Op_B | Op_Rc }, - - { "mfcr", 0xfc0007fe, 0x7c000026, Op_D }, - { "lwarx", 0xfc0007fe, 0x7c000028, Op_D | Op_A | Op_B }, - { "ldx", 0xfc0007fe, 0x7c00002a, Op_D | Op_A | Op_B }, - { "lwzx", 0xfc0007fe, 0x7c00002e, Op_D | Op_A | Op_B }, - { "slw", 0xfc0007fe, 0x7c000030, Op_D | Op_A | Op_B | Op_Rc }, - { "cntlzw", 0xfc0007fe, 0x7c000034, Op_D | Op_A | Op_Rc }, - { "sld", 0xfc0007fe, 0x7c000036, Op_D | Op_A | Op_B | Op_Rc }, - { "and", 0xfc0007fe, 0x7c000038, Op_D | Op_A | Op_B | Op_Rc }, - { "cmpl", 0xfc0007fe, 0x7c000040, Op_crfD | Op_L | Op_A | Op_B }, - { "subf", 0xfc0003fe, 0x7c000050, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "ldux", 0xfc0007fe, 0x7c00006a, Op_D | Op_A | Op_B }, - { "dcbst", 0xfc0007fe, 0x7c00006c, Op_A | Op_B }, - { "lwzux", 0xfc0007fe, 0x7c00006e, Op_D | Op_A | Op_B }, - { "cntlzd", 0xfc0007fe, 0x7c000074, Op_S | Op_A | Op_Rc }, - { "andc", 0xfc0007fe, 0x7c000078, Op_S | Op_A | Op_B | Op_Rc }, - { "td", 0xfc0007fe, 0x7c000088, Op_TO | Op_A | Op_B }, - { "mulhd", 0xfc0007fe, 0x7c000092, Op_D | Op_A | Op_B | Op_Rc }, - { "mulhw", 0xfc0007fe, 0x7c000096, Op_D | Op_A | Op_B | Op_Rc }, - { "mfmsr", 0xfc0007fe, 0x7c0000a6, Op_D }, - { "ldarx", 0xfc0007fe, 0x7c0000a8, Op_D | Op_A | Op_B }, - { "dcbf", 0xfc0007fe, 0x7c0000ac, Op_A | Op_B }, - { "lbzx", 0xfc0007fe, 0x7c0000ae, Op_D | Op_A | Op_B }, - { "neg", 0xfc0003fe, 0x7c0000d0, Op_D | Op_A | Op_OE | Op_Rc }, - { "lbzux", 0xfc0007fe, 0x7c0000ee, Op_D | Op_A | Op_B }, - { "nor", 0xfc0007fe, 0x7c0000f8, Op_S | Op_A | Op_B | Op_Rc }, - { "subfe", 0xfc0003fe, 0x7c000110, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "adde", 0xfc0003fe, 0x7c000114, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "mtcrf", 0xfc0007fe, 0x7c000120, Op_S | Op_CRM }, - { "mtmsr", 0xfc0007fe, 0x7c000124, Op_S }, - { "stdx", 0xfc0007fe, 0x7c00012a, Op_S | Op_A | Op_B }, - { "stwcx.", 0xfc0007ff, 0x7c00012d, Op_S | Op_A | Op_B }, - { "stwx", 0xfc0007fe, 0x7c00012e, Op_S | Op_A | Op_B }, - { "stdux", 0xfc0007fe, 0x7c00016a, Op_S | Op_A | Op_B }, - { "stwux", 0xfc0007fe, 0x7c00016e, Op_S | Op_A | Op_B }, - { "subfze", 0xfc0003fe, 0x7c000190, Op_D | Op_A | Op_OE | Op_Rc }, - { "addze", 0xfc0003fe, 0x7c000194, Op_D | Op_A | Op_OE | Op_Rc }, - { "mtsr", 0xfc0007fe, 0x7c0001a4, Op_S | Op_SR }, - { "stdcx.", 0xfc0007ff, 0x7c0001ad, Op_S | Op_A | Op_B }, - { "stbx", 0xfc0007fe, 0x7c0001ae, Op_S | Op_A | Op_B }, - { "subfme", 0xfc0003fe, 0x7c0001d0, Op_D | Op_A | Op_OE | Op_Rc }, - { "mulld", 0xfc0003fe, 0x7c0001d2, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "addme", 0xfc0003fe, 0x7c0001d4, Op_D | Op_A | Op_OE | Op_Rc }, - { "mullw", 0xfc0003fe, 0x7c0001d6, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "mtsrin", 0xfc0007fe, 0x7c0001e4, Op_S | Op_B }, - { "dcbtst", 0xfc0007fe, 0x7c0001ec, Op_A | Op_B }, - { "stbux", 0xfc0007fe, 0x7c0001ee, Op_S | Op_A | Op_B }, - { "add", 0xfc0003fe, 0x7c000214, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "dcbt", 0xfc0007fe, 0x7c00022c, Op_A | Op_B }, - { "lhzx", 0xfc0007ff, 0x7c00022e, Op_D | Op_A | Op_B }, - { "eqv", 0xfc0007fe, 0x7c000238, Op_S | Op_A | Op_B | Op_Rc }, - { "tlbie", 0xfc0007fe, 0x7c000264, Op_B }, - { "eciwx", 0xfc0007fe, 0x7c00026c, Op_D | Op_A | Op_B }, - { "lhzux", 0xfc0007fe, 0x7c00026e, Op_D | Op_A | Op_B }, - { "xor", 0xfc0007fe, 0x7c000278, Op_S | Op_A | Op_B | Op_Rc }, - { "mfspr", 0xfc0007fe, 0x7c0002a6, Op_D | Op_spr }, - { "lwax", 0xfc0007fe, 0x7c0002aa, Op_D | Op_A | Op_B }, - { "lhax", 0xfc0007fe, 0x7c0002ae, Op_D | Op_A | Op_B }, - { "tlbia", 0xfc0007fe, 0x7c0002e4, 0 }, - { "mftb", 0xfc0007fe, 0x7c0002e6, Op_D | Op_tbr }, - { "lwaux", 0xfc0007fe, 0x7c0002ea, Op_D | Op_A | Op_B }, - { "lhaux", 0xfc0007fe, 0x7c0002ee, Op_D | Op_A | Op_B }, - { "sthx", 0xfc0007fe, 0x7c00032e, Op_S | Op_A | Op_B }, - { "orc", 0xfc0007fe, 0x7c000338, Op_S | Op_A | Op_B | Op_Rc }, - { "ecowx", 0xfc0007fe, 0x7c00036c, Op_S | Op_A | Op_B | Op_Rc }, - { "slbie", 0xfc0007fc, 0x7c000364, Op_B }, - { "sthux", 0xfc0007fe, 0x7c00036e, Op_S | Op_A | Op_B }, - { "or", 0xfc0007fe, 0x7c000378, Op_S | Op_A | Op_B | Op_Rc }, - { "divdu", 0xfc0003fe, 0x7c000392, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "divwu", 0xfc0003fe, 0x7c000396, Op_D | Op_A | Op_B | Op_OE | Op_Rc }, - { "mtspr", 0xfc0007fe, 0x7c0003a6, Op_S | Op_spr }, - { "dcbi", 0xfc0007fe, 0x7c0003ac, Op_A | Op_B }, - { "nand", 0xfc0007fe, 0x7c0003b8, Op_S | Op_A | Op_B | Op_Rc }, - { "divd", 0xfc0003fe, 0x7c0003d2, Op_S | Op_A | Op_B | Op_OE | Op_Rc }, - { "divw", 0xfc0003fe, 0x7c0003d6, Op_S | Op_A | Op_B | Op_OE | Op_Rc }, - { "slbia", 0xfc0003fe, 0x7c0003e4, Op_S | Op_A | Op_B | Op_OE | Op_Rc }, - { "mcrxr", 0xfc0007fe, 0x7c000400, Op_crfD }, - { "lswx", 0xfc0007fe, 0x7c00042a, Op_D | Op_A | Op_B }, - { "lwbrx", 0xfc0007fe, 0x7c00042c, Op_D | Op_A | Op_B }, - { "lfsx", 0xfc0007fe, 0x7c00042e, Op_D | Op_A | Op_B }, - { "srw", 0xfc0007fe, 0x7c000430, Op_S | Op_A | Op_B | Op_Rc }, - { "srd", 0xfc0007fe, 0x7c000436, Op_S | Op_A | Op_B | Op_Rc }, - { "tlbsync", 0xfc0007fe, 0x7c00046c, 0 }, - { "lfsux", 0xfc0007fe, 0x7c00046e, Op_D | Op_A | Op_B }, - { "mfsr", 0xfc0007fe, 0x7c0004a6, Op_D | Op_SR }, - { "lswi", 0xfc0007fe, 0x7c0004aa, Op_D | Op_A | Op_NB }, - { "sync", 0xfc0007fe, 0x7c0004ac, 0 }, - { "lfdx", 0xfc0007fe, 0x7c0004ae, Op_D | Op_A | Op_B }, - { "lfdux", 0xfc0007fe, 0x7c0004ee, Op_D | Op_A | Op_B }, - { "mfsrin", 0xfc0007fe, 0x7c000526, Op_D | Op_B }, - { "stswx", 0xfc0007fe, 0x7c00052a, Op_S | Op_A | Op_B }, - { "stwbrx", 0xfc0007fe, 0x7c00052c, Op_S | Op_A | Op_B }, - { "stfsx", 0xfc0007fe, 0x7c00052e, Op_S | Op_A | Op_B }, - { "stfsux", 0xfc0007fe, 0x7c00056e, Op_S | Op_A | Op_B }, - { "stswi", 0xfc0007fe, 0x7c0005aa, Op_S | Op_A | Op_NB }, - { "stfdx", 0xfc0007fe, 0x7c0005ae, Op_S | Op_A | Op_B }, - { "stfdux", 0xfc0007fe, 0x7c0005ee, Op_S | Op_A | Op_B }, - { "lhbrx", 0xfc0007fe, 0x7c00062c, Op_D | Op_A | Op_B }, - { "sraw", 0xfc0007fe, 0x7c000630, Op_S | Op_A | Op_B }, - { "srad", 0xfc0007fe, 0x7c000634, Op_S | Op_A | Op_B | Op_Rc}, - { "srawi", 0xfc0007fe, 0x7c000670, Op_S | Op_A | Op_B | Op_Rc}, - { "sradi", 0xfc0007fc, 0x7c000674, Op_S | Op_A | Op_sh }, - { "eieio", 0xfc0007fe, 0x7c0006ac, 0 }, - { "sthbrx", 0xfc0007fe, 0x7c00072c, Op_S | Op_A | Op_B }, - { "extsh", 0xfc0007fe, 0x7c000734, Op_S | Op_A | Op_B | Op_Rc }, - { "extsb", 0xfc0007fe, 0x7c000774, Op_S | Op_A | Op_Rc }, - { "icbi", 0xfc0007fe, 0x7c0007ac, Op_A | Op_B }, - - { "stfiwx", 0xfc0007fe, 0x7c0007ae, Op_S | Op_A | Op_B }, - { "extsw", 0xfc0007fe, 0x7c0007b4, Op_S | Op_A | Op_Rc }, - { "dcbz", 0xfc0007fe, 0x7c0007ec, Op_A | Op_B }, - { "", 0x0, 0x0, 0 } -}; - -/* 3a * 4 = e8 */ -const struct opcode opcodes_3a[] = { - { "ld", 0xfc000003, 0xe8000000, Op_D | Op_A | Op_ds }, - { "ldu", 0xfc000003, 0xe8000001, Op_D | Op_A | Op_ds }, - { "lwa", 0xfc000003, 0xe8000002, Op_D | Op_A | Op_ds }, - { "", 0x0, 0x0, 0 } -}; -/* 3b * 4 = ec */ -const struct opcode opcodes_3b[] = { - { "fdivs", 0xfc00003e, 0xec000024, Op_D | Op_A | Op_B | Op_Rc }, - { "fsubs", 0xfc00003e, 0xec000028, Op_D | Op_A | Op_B | Op_Rc }, - - { "fadds", 0xfc00003e, 0xec00002a, Op_D | Op_A | Op_B | Op_Rc }, - { "fsqrts", 0xfc00003e, 0xec00002c, Op_D | Op_B | Op_Rc }, - { "fres", 0xfc00003e, 0xec000030, Op_D | Op_B | Op_Rc }, - { "fmuls", 0xfc00003e, 0xec000032, Op_D | Op_A | Op_C | Op_Rc }, - { "fmsubs", 0xfc00003e, 0xec000038, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fmadds", 0xfc00003e, 0xec00003a, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fnmsubs", 0xfc00003e, 0xec00003c, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fnmadds", 0xfc00003e, 0xec00003e, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "", 0x0, 0x0, 0 } -}; -/* 3e * 4 = f8 */ -const struct opcode opcodes_3e[] = { - { "std", 0xfc000003, 0xf8000000, Op_S | Op_A | Op_ds }, - { "stdu", 0xfc000003, 0xf8000001, Op_S | Op_A | Op_ds }, - { "", 0x0, 0x0, 0 } -}; - -/* 3f * 4 = fc */ -const struct opcode opcodes_3f[] = { - { "fcmpu", 0xfc0007fe, 0xfc000000, Op_crfD | Op_A | Op_B }, - { "frsp", 0xfc0007fe, 0xfc000018, Op_D | Op_B | Op_Rc }, - { "fctiw", 0xfc0007fe, 0xfc00001c, Op_D | Op_B | Op_Rc }, - { "fctiwz", 0xfc0007fe, 0xfc00001e, Op_D | Op_B | Op_Rc }, - - { "fdiv", 0xfc00003e, 0xfc000024, Op_D | Op_A | Op_B | Op_Rc }, - { "fsub", 0xfc00003e, 0xfc000028, Op_D | Op_A | Op_B | Op_Rc }, - { "fadd", 0xfc00003e, 0xfc00002a, Op_D | Op_A | Op_B | Op_Rc }, - { "fsqrt", 0xfc00003e, 0xfc00002c, Op_D | Op_B | Op_Rc }, - { "fsel", 0xfc00003e, 0xfc00002e, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fmul", 0xfc00003e, 0xfc000032, Op_D | Op_A | Op_C | Op_Rc }, - { "frsqrte", 0xfc00003e, 0xfc000034, Op_D | Op_B | Op_Rc }, - { "fmsub", 0xfc00003e, 0xfc000038, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fmadd", 0xfc00003e, 0xfc00003a, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fnmsub", 0xfc00003e, 0xfc00003c, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - { "fnmadd", 0xfc00003e, 0xfc00003e, Op_D | Op_A | Op_B | Op_C | Op_Rc }, - - { "fcmpo", 0xfc0007fe, 0xfc000040, Op_crfD | Op_A | Op_B }, - { "mtfsb1", 0xfc0007fe, 0xfc00004c, Op_crfD | Op_Rc }, - { "fneg", 0xfc0007fe, 0xfc000050, Op_D | Op_B | Op_Rc }, - { "mcrfs", 0xfc0007fe, 0xfc000080, Op_D | Op_B | Op_Rc }, - { "mtfsb0", 0xfc0007fe, 0xfc00008c, Op_crfD | Op_Rc }, - { "fmr", 0xfc0007fe, 0xfc000090, Op_D | Op_B | Op_Rc }, - { "mtfsfi", 0xfc0007fe, 0xfc00010c, Op_crfD | Op_IMM | Op_Rc }, - - { "fnabs", 0xfc0007fe, 0xfc000110, Op_D | Op_B | Op_Rc }, - { "fabs", 0xfc0007fe, 0xfc000210, Op_D | Op_B | Op_Rc }, - { "mffs", 0xfc0007fe, 0xfc00048e, Op_D | Op_B | Op_Rc }, - { "mtfsf", 0xfc0007fe, 0xfc00058e, Op_FM | Op_B | Op_Rc }, - { "fctid", 0xfc0007fe, 0xfc00065c, Op_D | Op_B | Op_Rc }, - { "fctidz", 0xfc0007fe, 0xfc00065e, Op_D | Op_B | Op_Rc }, - { "fcfid", 0xfc0007fe, 0xfc00069c, Op_D | Op_B | Op_Rc }, - { "", 0x0, 0x0, 0 } -}; - -/* -typedef void (op_class_func) (instr_t); -*/ -void -op_ill(instr_t instr) -{ - db_printf("illegal instruction %x\n", instr); -} - -u_int32_t -extract_field(u_int32_t value, u_int32_t base, u_int32_t width) -{ - u_int32_t mask = (1 << width) - 1; - return ((value >> base) & mask); -} - -const struct opcode * search_op(const struct opcode *); - -void -disasm_fields(const struct opcode *popcode, instr_t instr, char *disasm_str) -{ - char * pstr; - enum function_mask func; - - pstr = disasm_str; - - func = popcode->func; - if (func & Op_OE) { - u_int OE; - /* also for Op_S (they are the same) */ - OE = extract_field(instr, 31 - 21, 1); - if (OE) { - pstr += sprintf (pstr, "o"); - } - func &= ~Op_D; - } - switch (func & Op_LKM) { - case Op_Rc: - if (instr & 0x1) { - pstr += sprintf (pstr,". "); - } - break; - case Op_AA: - if (instr & 0x2) { - pstr += sprintf (pstr,"a"); - } - case Op_LK: - if (instr & 0x1) { - pstr += sprintf (pstr,"l "); - } - break; - default: - func &= ~Op_LKM; - } - pstr += sprintf (pstr, " "); - if (func & Op_D) { - u_int D; - /* also for Op_S (they are the same) */ - D = extract_field(instr, 31 - 10, 5); - pstr += sprintf (pstr, "r%d, ", D); - func &= ~Op_D; - } - if (func & Op_crbD) { - u_int crbD; - crbD = extract_field(instr, 31 - 10, 5); - pstr += sprintf (pstr, "crb%d, ", crbD); - func &= ~Op_crbD; - } - if (func & Op_crfD) { - u_int crfD; - crfD = extract_field(instr, 31 - 8, 3); - pstr += sprintf (pstr, "crf%d, ", crfD); - func &= ~Op_crfD; - } - if (func & Op_L) { - u_int L; - L = extract_field(instr, 31 - 10, 1); - if (L) { - pstr += sprintf (pstr, "L, "); - } - func &= ~Op_L; - } - if (func & Op_FM) { - u_int FM; - FM = extract_field(instr, 31 - 10, 8); - pstr += sprintf (pstr, "%d, ", FM); - func &= ~Op_FM; - } - if (func & Op_TO) { - u_int TO; - TO = extract_field(instr, 31 - 10, 1); - pstr += sprintf (pstr, "%d, ", TO); - func &= ~Op_TO; - } - if (func & Op_crfS) { - u_int crfS; - crfS = extract_field(instr, 31 - 13, 3); - pstr += sprintf (pstr, "%d, ", crfS); - func &= ~Op_crfS; - } - if (func & Op_BO) { - u_int BO; - BO = extract_field(instr, 31 - 10, 5); - pstr += sprintf (pstr ,"%d, ", BO); - func &= ~Op_BO; - } - if (func & Op_A) { - u_int A; - A = extract_field(instr, 31 - 15, 5); - pstr += sprintf (pstr, "r%d, ", A); - func &= ~Op_A; - } - if (func & Op_B) { - u_int B; - B = extract_field(instr, 31 - 20, 5); - pstr += sprintf (pstr, "r%d, ", B); - func &= ~Op_B; - } - if (func & Op_C) { - u_int C; - C = extract_field(instr, 31 - 25, 5); - pstr += sprintf (pstr, "r%d, ", C); - func &= ~Op_C; - } - if (func & Op_BI) { - u_int BI; - BI = extract_field(instr, 31 - 10, 5); - pstr += sprintf (pstr, "%d, ", BI); - func &= ~Op_BI; - } - if (func & Op_crbA) { - u_int crbA; - crbA = extract_field(instr, 31 - 15, 5); - pstr += sprintf (pstr, "%d, ", crbA); - func &= ~Op_crbA; - } - if (func & Op_crbB) { - u_int crbB; - crbB = extract_field(instr, 31 - 20, 5); - pstr += sprintf (pstr, "%d, ", crbB); - func &= ~Op_crbB; - } - if (func & Op_CRM) { - u_int CRM; - CRM = extract_field(instr, 31 - 19, 8); - pstr += sprintf (pstr, "0x%x, ", CRM); - func &= ~Op_CRM; - } - if (func & Op_LI) { - u_int LI; - LI = extract_field(instr, 31 - 29, 24); - pstr += sprintf (pstr, "0x%x, ", LI); - func &= ~Op_LI; - } - switch (func & Op_SIMM) { - u_int IMM; - case Op_SIMM: /* same as Op_d */ - IMM = extract_field(instr, 31 - 31, 16); - if (IMM & 0x8000) { - pstr += sprintf (pstr, "-"); - } - /* no break */ - func &= ~Op_SIMM; - case Op_UIMM: - IMM = extract_field(instr, 31 - 31, 16); - pstr += sprintf (pstr, "0x%x, ", IMM); - func &= ~Op_UIMM; - break; - default: - } - if (func & Op_BD ) { - u_int BD; - BD = extract_field(instr, 31 - 29, 14); - pstr += sprintf (pstr, "0x%x, ", BD); - func &= ~Op_BD; - } - if (func & Op_ds ) { - u_int ds; - ds = extract_field(instr, 31 - 29, 14) << 2; - pstr += sprintf (pstr, "0x%x, ", ds); - func &= ~Op_ds; - } - if (func & Op_spr ) { - u_int spr; - u_int sprl; - u_int sprh; - char *reg; - sprl = extract_field(instr, 31 - 15, 5); - sprh = extract_field(instr, 31 - 20, 5); - spr = sprh << 5 | sprl; - - /* this table could be written better */ - switch (spr) { - case 1: - reg = "xer"; - break; - case 8: - reg = "lr"; - break; - case 9: - reg = "ctr"; - break; - case 18: - reg = "dsisr"; - break; - case 19: - reg = "dar"; - break; - case 22: - reg = "dec"; - break; - case 25: - reg = "sdr1"; - break; - case 26: - reg = "srr0"; - break; - case 27: - reg = "srr1"; - break; - case 272: - reg = "SPRG0"; - break; - case 273: - reg = "SPRG1"; - break; - case 274: - reg = "SPRG3"; - break; - case 275: - reg = "SPRG3"; - break; - case 280: - reg = "asr"; - break; - case 282: - reg = "aer"; - break; - case 287: - reg = "pvr"; - break; - case 528: - reg = "ibat0u"; - break; - case 529: - reg = "ibat0l"; - break; - case 530: - reg = "ibat1u"; - break; - case 531: - reg = "ibat1l"; - break; - case 532: - reg = "ibat2u"; - break; - case 533: - reg = "ibat2l"; - break; - case 534: - reg = "ibat3u"; - break; - case 535: - reg = "ibat3l"; - break; - case 536: - reg = "dbat0u"; - break; - case 537: - reg = "dbat0l"; - break; - case 538: - reg = "dbat1u"; - break; - case 539: - reg = "dbat1l"; - break; - case 540: - reg = "dbat2u"; - break; - case 541: - reg = "dbat2l"; - break; - case 542: - reg = "dbat3u"; - break; - case 543: - reg = "dbat3l"; - break; - case 1013: - reg = "dabr"; - break; - default: - reg = 0; - } - if (reg == 0) { - pstr += sprintf (pstr, ", [unknown spr (%d)]", spr); - } else { - pstr += sprintf (pstr, ", %s", reg); - } - func &= ~Op_spr; - } - - if (func & Op_me) { - u_int me, mel, meh; - mel = extract_field(instr, 31 - 25, 4); - meh = extract_field(instr, 31 - 26, 1); - me = meh << 4 | mel; - pstr += sprintf (pstr, ", 0x%x", me); - func &= ~Op_me; - } - if ((func & Op_MB ) && (func & Op_sh_mb_sh)) { - u_int MB; - u_int ME; - MB = extract_field(instr, 31 - 20, 5); - pstr += sprintf (pstr, ", %d", MB); - ME = extract_field(instr, 31 - 25, 5); - pstr += sprintf (pstr, ", %d", ME); - } - if ((func & Op_SH ) && (func & Op_sh_mb_sh)) { - u_int SH; - SH = extract_field(instr, 31 - 20, 5); - pstr += sprintf (pstr, ", %d", SH); - } - if ((func & Op_sh ) && ! (func & Op_sh_mb_sh)) { - u_int sh, shl, shh; - shl = extract_field(instr, 31 - 19, 4); - shh = extract_field(instr, 31 - 20, 1); - sh = shh << 4 | shl; - pstr += sprintf (pstr, ", %d", sh); - } - if ((func & Op_mb ) && ! (func & Op_sh_mb_sh)) { - u_int mb, mbl, mbh; - mbl = extract_field(instr, 31 - 25, 4); - mbh = extract_field(instr, 31 - 26, 1); - mb = mbh << 4 | mbl; - pstr += sprintf (pstr, ", %d", mb); - } - if ((func & Op_me ) && ! (func & Op_sh_mb_sh)) { - u_int me, mel, meh; - mel = extract_field(instr, 31 - 25, 4); - meh = extract_field(instr, 31 - 26, 1); - me = meh << 4 | mel; - pstr += sprintf (pstr, ", %d", me); - } - if (func & Op_tbr ) { - u_int tbr; - u_int tbrl; - u_int tbrh; - char *reg; - tbrl = extract_field(instr, 31 - 15, 5); - tbrh = extract_field(instr, 31 - 20, 5); - tbr = tbrh << 5 | tbrl; - - switch (tbr) { - case 268: - reg = "tbl"; - break; - case 269: - reg = "tbu"; - break; - default: - reg = 0; - } - if (reg == 0) { - pstr += sprintf (pstr, ", [unknown tbr %d ]", tbr); - } else { - pstr += sprintf (pstr, ", %s", reg); - } - func &= ~Op_tbr; - } - if (func & Op_SR) { - u_int SR; - SR = extract_field(instr, 31 - 15, 3); - pstr += sprintf (pstr, ", sr%d", SR); - func &= ~Op_SR; - } - if (func & Op_NB) { - u_int NB; - NB = extract_field(instr, 31 - 20, 5); - if (NB == 0 ) { - NB=32; - } - pstr += sprintf (pstr, ", %d", NB); - func &= ~Op_SR; - } - if (func & Op_IMM) { - u_int IMM; - IMM = extract_field(instr, 31 - 19, 4); - pstr += sprintf (pstr, ", %d", IMM); - func &= ~Op_SR; - } -} - -void -op_base(instr_t instr) -{ - dis_ppc (opcodes,instr); -} - -void -op_cl_x13(instr_t instr) -{ - dis_ppc (opcodes_13,instr); -} - -void -op_cl_x1e(instr_t instr) -{ - dis_ppc (opcodes_1e,instr); -} - -void -op_cl_x1f(instr_t instr) -{ - dis_ppc (opcodes_1f,instr); -} - -void -op_cl_x3a(instr_t instr) -{ - dis_ppc (opcodes_3a,instr); -} - -void -op_cl_x3b(instr_t instr) -{ - dis_ppc (opcodes_3b,instr); -} - -void -op_cl_x3e(instr_t instr) -{ - dis_ppc (opcodes_3e,instr); -} - -void -op_cl_x3f(instr_t instr) -{ - dis_ppc (opcodes_3f,instr); -} - -void -dis_ppc(const struct opcode *opcodeset, instr_t instr) -{ - const struct opcode *op; - int found = 0; - int i; - char disasm_str[30]; - - for ( i=0, op = &opcodeset[0]; - found == 0 && op->mask != 0; - i++, op= &opcodeset[i] ) - { - if ((instr & op->mask) == op->code) { - found = 1; - disasm_fields(op, instr, disasm_str); - db_printf("%s%s",op->name, disasm_str); - return; - } - } - op_ill(instr); -} - -db_addr_t -db_disasm(db_addr_t loc, boolean_t extended) -{ - int class; - instr_t opcode; - opcode = *(instr_t *)(loc); - class = opcode >> 26; - (opcodes_base[class])(opcode); - - return loc + 4; -} diff --git a/sys/arch/powerpc/powerpc/db_interface.c b/sys/arch/powerpc/powerpc/db_interface.c deleted file mode 100644 index fc66b2c08f2..00000000000 --- a/sys/arch/powerpc/powerpc/db_interface.c +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: db_interface.c,v 1.7 2001/08/21 02:58:35 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 <machine/db_machdep.h> -#include <ddb/db_extern.h> - -int ddb_trap_glue __P((struct trapframe *frame)); /* called from locore */ - -void -Debugger() -{ - ddb_trap(); -} - -int -ddb_trap_glue(frame) - 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; - - db_trap(T_BREAKPOINT, 0); - - bcopy(DDB_REGS->tf.fixreg, frame->fixreg, - 32 * sizeof(u_int32_t)); - - return 1; - } - return 0; -} diff --git a/sys/arch/powerpc/powerpc/db_memrw.c b/sys/arch/powerpc/powerpc/db_memrw.c deleted file mode 100644 index 576b50ddf90..00000000000 --- a/sys/arch/powerpc/powerpc/db_memrw.c +++ /dev/null @@ -1,105 +0,0 @@ -/* $NetBSD: db_memrw.c,v 1.4 2001/05/18 20:38:27 matt Exp $ */ -/* $OpenBSD: db_memrw.c,v 1.3 2001/06/24 22:00:13 drahn Exp $ */ - -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * 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 Mellon - * the rights to redistribute these changes. - */ - -/* - * Interface to the debugger for virtual memory read/write. - * This is a simple version for kernels with writable text. - * For an example of read-only kernel text, see the file: - * sys/arch/sun3/sun3/db_memrw.c - * - * ALERT! If you want to access device registers with a - * specific size, then the read/write functions have to - * make sure to do the correct sized pointer access. - */ - -#include <sys/param.h> -#include <sys/proc.h> -#include <sys/systm.h> - -#include <vm/vm.h> - -#include <machine/db_machdep.h> - -#include <ddb/db_access.h> - -/* - * Read bytes from kernel address space for debugger. - */ -void -db_read_bytes(addr, size, data) - vaddr_t addr; - register size_t size; - register char *data; -{ - register char *src = (char*)addr; - - if (size == 4) { - *((int*)data) = *((int*)src); - return; - } - - if (size == 2) { - *((short*)data) = *((short*)src); - return; - } - - while (size > 0) { - --size; - *data++ = *src++; - } -} - -/* - * Write bytes to kernel address space for debugger. - */ -void -db_write_bytes(addr, size, data) - vaddr_t addr; - register size_t size; - register char *data; -{ - register char *dst = (char *)addr; - - if (size == 4) { - *((int*)dst) = *((int*)data); - return; - } - - if (size == 2) { - *((short*)dst) = *((short*)data); - return; - } - - while (size > 0) { - --size; - *dst++ = *data++; - } - syncicache((void *)addr, size); -} - diff --git a/sys/arch/powerpc/powerpc/db_trace.c b/sys/arch/powerpc/powerpc/db_trace.c deleted file mode 100644 index 3a7cad5e9a1..00000000000 --- a/sys/arch/powerpc/powerpc/db_trace.c +++ /dev/null @@ -1,139 +0,0 @@ -/* $OpenBSD: db_trace.c,v 1.11 2001/08/25 05:00:26 drahn Exp $ */ -/* $NetBSD: db_trace.c,v 1.15 1996/02/22 23:23:41 gwr Exp $ */ - -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * 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 Mellon - * the rights to redistribute these changes. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/proc.h> - -#include <machine/db_machdep.h> -#include <machine/signal.h> - -#include <ddb/db_access.h> -#include <ddb/db_sym.h> -#include <ddb/db_variables.h> -#include <ddb/db_interface.h> -#include <ddb/db_output.h> - -struct db_variable db_regs[] = { - { "r0", (long *)&(DDB_REGS->tf.fixreg[0]), FCN_NULL }, - { "r1", (long *)&(DDB_REGS->tf.fixreg[1]), FCN_NULL }, - { "r2", (long *)&(DDB_REGS->tf.fixreg[2]), FCN_NULL }, - { "r3", (long *)&(DDB_REGS->tf.fixreg[3]), FCN_NULL }, - { "r4", (long *)&(DDB_REGS->tf.fixreg[4]), FCN_NULL }, - { "r5", (long *)&(DDB_REGS->tf.fixreg[5]), FCN_NULL }, - { "r6", (long *)&(DDB_REGS->tf.fixreg[6]), FCN_NULL }, - { "r7", (long *)&(DDB_REGS->tf.fixreg[7]), FCN_NULL }, - { "r8", (long *)&(DDB_REGS->tf.fixreg[8]), FCN_NULL }, - { "r9", (long *)&(DDB_REGS->tf.fixreg[9]), FCN_NULL }, - { "r10", (long *)&(DDB_REGS->tf.fixreg[10]), FCN_NULL }, - { "r11", (long *)&(DDB_REGS->tf.fixreg[11]), FCN_NULL }, - { "r12", (long *)&(DDB_REGS->tf.fixreg[12]), FCN_NULL }, - { "r13", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL }, - { "r14", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL }, - { "r15", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL }, - { "r16", (long *)&(DDB_REGS->tf.fixreg[13]), FCN_NULL }, - { "r17", (long *)&(DDB_REGS->tf.fixreg[17]), FCN_NULL }, - { "r18", (long *)&(DDB_REGS->tf.fixreg[18]), FCN_NULL }, - { "r19", (long *)&(DDB_REGS->tf.fixreg[19]), FCN_NULL }, - { "r20", (long *)&(DDB_REGS->tf.fixreg[20]), FCN_NULL }, - { "r21", (long *)&(DDB_REGS->tf.fixreg[21]), FCN_NULL }, - { "r22", (long *)&(DDB_REGS->tf.fixreg[22]), FCN_NULL }, - { "r23", (long *)&(DDB_REGS->tf.fixreg[23]), FCN_NULL }, - { "r24", (long *)&(DDB_REGS->tf.fixreg[24]), FCN_NULL }, - { "r25", (long *)&(DDB_REGS->tf.fixreg[25]), FCN_NULL }, - { "r26", (long *)&(DDB_REGS->tf.fixreg[26]), FCN_NULL }, - { "r27", (long *)&(DDB_REGS->tf.fixreg[27]), FCN_NULL }, - { "r28", (long *)&(DDB_REGS->tf.fixreg[28]), FCN_NULL }, - { "r29", (long *)&(DDB_REGS->tf.fixreg[29]), FCN_NULL }, - { "r30", (long *)&(DDB_REGS->tf.fixreg[30]), FCN_NULL }, - { "r31", (long *)&(DDB_REGS->tf.fixreg[31]), FCN_NULL }, - { "lr", (long *)&(DDB_REGS->tf.lr), FCN_NULL }, - { "cr", (long *)&(DDB_REGS->tf.cr), FCN_NULL }, - { "xer", (long *)&(DDB_REGS->tf.xer), FCN_NULL }, - { "ctr", (long *)&(DDB_REGS->tf.ctr), FCN_NULL }, - { "iar", (long *)&(DDB_REGS->tf.srr0), FCN_NULL }, - { "msr", (long *)&(DDB_REGS->tf.srr1), FCN_NULL }, -}; -struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); - -extern label_t *db_recover; - -/* - * this is probably hackery. - */ -void -db_save_regs(struct trapframe *frame) -{ - bcopy(frame, &(ddb_regs.tf), sizeof (struct trapframe)); -} - - -db_expr_t -db_dumpframe(u_int32_t pframe) -{ - u_int32_t nextframe; - u_int32_t lr; - u_int32_t *access; - char *name; - db_expr_t offset; - - access = (u_int32_t *)(pframe); - nextframe = *access; - - access = (u_int32_t *)(pframe+4); - lr = *access; - - db_find_sym_and_offset(lr-4, &name, &offset); - if (!name) { - name = "?"; - offset = 65536; - } - db_printf("%x %s+0x%x fp %x nfp %x\n", - lr-4, name, offset, pframe, nextframe); - - return nextframe; -} -/* - * Frame tracing. - */ -void -db_stack_trace_cmd(addr, have_addr, count, modif) - db_expr_t addr; - int have_addr; - db_expr_t count; - char *modif; -{ - - if (have_addr == 0){ - addr = ddb_regs.tf.fixreg[1]; - } - while (addr != 0) { - addr = db_dumpframe(addr); - } -} diff --git a/sys/arch/powerpc/powerpc/disksubr.c b/sys/arch/powerpc/powerpc/disksubr.c deleted file mode 100644 index 423cd75ef48..00000000000 --- a/sys/arch/powerpc/powerpc/disksubr.c +++ /dev/null @@ -1,656 +0,0 @@ -/* $OpenBSD: disksubr.c,v 1.16 2001/06/24 05:06:13 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. 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. - * - * @(#)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)) - -void -dk_establish(dk, dev) - struct disk *dk; - struct device *dev; -{ -} - -/* - * 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. - * - * If dos partition table requested, attempt to load it and - * find disklabel inside a DOS partition. Also, if bad block - * table needed, attempt to extract it as well. Return buffer - * for use in signalling errors if requested. - * - * We would like to check if each MBR has a valid BOOT_MAGIC, but - * we cannot because it doesn't always exist. So.. we assume the - * MBR is valid. - * - * Returns null on success and an error string on failure. - */ -char * -readdisklabel(dev, strat, lp, osdep, spoofonly) - dev_t dev; - void (*strat) __P((struct buf *)); - register struct disklabel *lp; - struct cpu_disklabel *osdep; - int spoofonly; -{ - struct dos_partition *dp = osdep->dosparts, *dp2; - struct dkbad *bdp = &DKBAD(osdep); - struct buf *bp; - struct disklabel *dlp; - char *msg = NULL, *cp; - char *s; - int dospartoff, cyl, i, ourpart = -1; - /* HFS variables */ - int part_cnt, n, hfspartoff; - struct part_map_entry *part; - - - /* minimal requirements for archtypal disk label */ - if (lp->d_secsize == 0) - 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; - - /* DPME (HFS) disklabel */ - - 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)) { - msg = "DPME partition I/O error"; - goto hfs_done; - } - - 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) { - msg = "DPME partition invalid"; - osdep->macparts[0].pmSig = 0; /* make invalid */ - goto hfs_done; - } - 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)) { - msg = "DPME partition I/O error"; - goto hfs_done; - } - 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; - - /* 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 = hfspartoff; - bp->b_cylin = hfspartoff/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; - } - goto found_disklabel; - - -hfs_done: - /* MBR type disklabel */ - /* do dos partitions in the process of getting disklabel? */ - dospartoff = 0; - cyl = LABELSECTOR / lp->d_secpercyl; - if (dp) { - daddr_t part_blkno = DOSBBSECTOR; - unsigned long extoff = 0; - int wander = 1, loop = 0; - n = 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; - - /* 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)) { - msg = "dos partition I/O error"; - goto done; - } - 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); - 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; - } - - /* 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 = 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 (biowait(bp)) { - /* XXX we return the faked label built so far */ - msg = "disk label I/O error"; - goto done; - } - -found_disklabel: - 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(olp, nlp, openmask, osdep) - register struct disklabel *olp, *nlp; - u_long openmask; - struct cpu_disklabel *osdep; -{ - register int i; - register 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, strat, lp, osdep) - dev_t dev; - void (*strat) __P((struct buf *)); - register 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; - } - - /* 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(bp, lp, osdep, wlabel) - 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/powerpc/powerpc/dma.c b/sys/arch/powerpc/powerpc/dma.c deleted file mode 100644 index cd417021b47..00000000000 --- a/sys/arch/powerpc/powerpc/dma.c +++ /dev/null @@ -1,510 +0,0 @@ -/* $OpenBSD: dma.c,v 1.10 2001/08/18 21:59:48 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 <vm/vm.h> -#include <vm/vm_kern.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); - -/* - * Common function for DMA map creation. May be called by bus-specific - * DMA map creation functions. - */ -int -_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp) - 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 */ - - *dmamp = map; - return (0); -} - -/* - * Common function for DMA map destruction. May be called by bus-specific - * DMA map destruction functions. - */ -void -_dmamap_destroy(t, map) - bus_dma_tag_t t; - bus_dmamap_t map; -{ - - free(map, M_DEVBUF); -} - -/* - * Common function for loading a DMA map with a linear buffer. May - * be called by bus-specific DMA map load functions. - */ -int -_dmamap_load(t, map, buf, buflen, p, flags) - bus_dma_tag_t t; - bus_dmamap_t map; - void *buf; - bus_size_t buflen; - struct proc *p; - int flags; -{ - bus_size_t sgsize; - bus_addr_t curaddr, lastaddr, baddr, bmask; - caddr_t vaddr = buf; - int first, seg; - pmap_t pmap; - - /* - * Make sure that on error condition we return "no valid mappings". - */ - map->dm_nsegs = 0; - - if (buflen > map->_dm_size) - return (EINVAL); - - if (p != NULL) - pmap = p->p_vmspace->vm_map.pmap; - else - pmap = pmap_kernel(); - - lastaddr = ~0; /* XXX gcc */ - bmask = ~(map->_dm_boundary - 1); - - for (first = 1, seg = 0; buflen > 0; ) { - /* - * Get the physical address for this segment. - */ - pmap_extract(pmap, (vm_offset_t)vaddr, (paddr_t *)&curaddr); - - /* - * 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 - * 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; - } - - /* - * Did we fit? - */ - if (buflen != 0) - return (EFBIG); /* XXX better return value here? */ - - map->dm_nsegs = seg + 1; - return (0); -} - -/* - * Like _bus_dmamap_load(), but for mbufs. - */ -int -_dmamap_load_mbuf(t, map, m, flags) - bus_dma_tag_t t; - bus_dmamap_t map; - struct mbuf *m; - int flags; -{ - - panic("_bus_dmamap_load: not implemented"); -} - -/* - * Like _bus_dmamap_load(), but for uios. - */ -int -_dmamap_load_uio(t, map, uio, flags) - bus_dma_tag_t t; - bus_dmamap_t map; - struct uio *uio; - int flags; -{ - - panic("_bus_dmamap_load_uio: not implemented"); -} - -/* - * Like _bus_dmamap_load(), but for raw memory allocated with - * bus_dmamem_alloc(). - */ -int -_dmamap_load_raw(t, map, segs, nsegs, size, flags) - bus_dma_tag_t t; - bus_dmamap_t map; - bus_dma_segment_t *segs; - int nsegs; - bus_size_t size; - int flags; -{ - - panic("_bus_dmamap_load_raw: not implemented"); -} - -/* - * Common function for unloading a DMA map. May be called by - * bus-specific DMA map unload functions. - */ -void -_dmamap_unload(t, map) - bus_dma_tag_t t; - bus_dmamap_t map; -{ - - /* - * No resources to free; just mark the mappings as - * invalid. - */ - map->dm_nsegs = 0; -} - -/* - * Common function for DMA map synchronization. May be called - * by bus-specific DMA map synchronization functions. - */ -void -_dmamap_sync(t, map, op) - bus_dma_tag_t t; - bus_dmamap_t map; - bus_dmasync_op_t op; -{ - - /* Nothing to do here. */ -} - -/* - * Common function for DMA-safe memory allocation. May be called - * by bus-specific DMA memory allocation functions. - */ -int -_dmamem_alloc(t, size, alignment, boundary, segs, nsegs, rsegs, flags) - bus_dma_tag_t t; - bus_size_t size, alignment, 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(t, segs, nsegs) - bus_dma_tag_t t; - bus_dma_segment_t *segs; - int nsegs; -{ - vm_page_t 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(t, segs, nsegs, size, kvap, flags) - 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(kmem_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); - } - } - - return (0); -} - -/* - * Common function for unmapping DMA-safe memory. May be called by - * bus-specific DMA memory unmapping functions. - */ -void -_dmamem_unmap(t, kva, size) - 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(kmem_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(t, segs, nsegs, off, prot, flags) - bus_dma_tag_t t; - bus_dma_segment_t *segs; - int nsegs; - off_t off; - int prot, 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(t, size, alignment, boundary, segs, nsegs, rsegs, - flags, low, high) - bus_dma_tag_t t; - bus_size_t size, alignment, 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; - vm_page_t 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 = mlist.tqh_first; - curseg = 0; - lastaddr = segs[curseg].ds_addr = VM_PAGE_TO_PHYS(m); - segs[curseg].ds_len = PAGE_SIZE; - m = m->pageq.tqe_next; - - for (; m != NULL; m = m->pageq.tqe_next) { - 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/powerpc/powerpc/genassym.cf b/sys/arch/powerpc/powerpc/genassym.cf deleted file mode 100644 index 02fc36242a8..00000000000 --- a/sys/arch/powerpc/powerpc/genassym.cf +++ /dev/null @@ -1,77 +0,0 @@ -# $OpenBSD: genassym.cf,v 1.2 1997/10/13 13:42:57 pefo 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. 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. -# -# @(#)genassym.c 7.8 (Berkeley) 5/7/91 -# - -include <sys/param.h> -include <sys/time.h> -include <sys/proc.h> -include <vm/vm.h> -include <vm/vm_kern.h> - - -include <machine/pcb.h> -include <machine/pmap.h> - - - -define FRAMELEN FRAMELEN -define FRAME_0 offsetof(struct trapframe, fixreg[0]) -define FRAME_1 offsetof(struct trapframe, fixreg[1]) -define FRAME_2 offsetof(struct trapframe, fixreg[2]) -define FRAME_3 offsetof(struct trapframe, fixreg[3]) -define FRAME_LR offsetof(struct trapframe, lr) -define FRAME_CR offsetof(struct trapframe, cr) -define FRAME_CTR offsetof(struct trapframe, ctr) -define FRAME_XER offsetof(struct trapframe, xer) -define FRAME_SRR0 offsetof(struct trapframe, srr0) -define FRAME_SRR1 offsetof(struct trapframe, srr1) -define FRAME_DAR offsetof(struct trapframe, dar) -define FRAME_DSISR offsetof(struct trapframe, dsisr) -define FRAME_EXC offsetof(struct trapframe, exc) - -define SFRAMELEN roundup(sizeof(struct switchframe), 16) - -define PCB_PMR offsetof(struct pcb, pcb_pmreal) -define PCB_SP offsetof(struct pcb, pcb_sp) -define PCB_SPL offsetof(struct pcb, pcb_spl) -define PCB_FAULT offsetof(struct pcb, pcb_onfault) - -define PM_USRSR offsetof(struct pmap, pm_sr[USER_SR]) -define PM_KERNELSR offsetof(struct pmap, pm_sr[KERNEL_SR]) - -define P_FORW offsetof(struct proc, p_forw) -define P_BACK offsetof(struct proc, p_back) -define P_ADDR offsetof(struct proc, p_addr) - diff --git a/sys/arch/powerpc/powerpc/locore.S b/sys/arch/powerpc/powerpc/locore.S deleted file mode 100644 index 710c9992dfb..00000000000 --- a/sys/arch/powerpc/powerpc/locore.S +++ /dev/null @@ -1,1409 +0,0 @@ -/* $OpenBSD: locore.S,v 1.18 2001/06/24 22:00:12 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 "machine/ipkdb.h" - -#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 3, fwargsave@ha - stw 6, fwargsave@l(3) - stw 7, fwargsave@l+4(3) -#ifdef SUPPORT_PPC1BUG - mr 0,5 - cmpwi 0,0,0 - bne 1f - /* need additional tests for other systems??? */ - bl ppc1bug_init - b 2f -#endif /* SUPPORT_PPC1BUG -1: /* support openfirmware for Apple and PowerStack w/OFW, ... */ - bl ofw_init -2: - li 0,0 - mtmsr 0 /* Disable FPU/MMU/exceptions */ - isync - -/* compute end of kernel memory */ - lis 8,_end@ha - addi 8,8,_end@l - lis 3, fwargsave@ha - lwz 6, fwargsave@l(3) - lwz 7, fwargsave@l+4(3) -#if defined(DDB) || defined(KERNFS) - cmpwi 6, 0 - beq 1f - add 9,6,7 - lwz 9, -4(9) - cmpwi 9,0 - beq 1f - lis 8,_C_LABEL(esym)@ha - stw 9,_C_LABEL(esym)@l(8) - mr 8, 9 -1: -#endif - li 9,PGOFSET - add 8,8,9 - andc 8,8,9 - lis 9,idle_u@ha - stw 8,idle_u@l(9) - addi 8,8,USPACE /* space for idle_u */ - lis 9,_C_LABEL(proc0paddr)@ha - stw 8,_C_LABEL(proc0paddr)@l(9) - addi 1,8,USPACE-FRAMELEN /* stackpointer for proc0 */ - mr 4,1 /* end of mem reserved for kernel */ - xor 0,0,0 - stwu 0,-16(1) /* end of stack chain */ - - li 0, 2 - lis 9,_C_LABEL(where)@ha - stw 0,_C_LABEL(where)@l(9) - - lis 3,start@ha - addi 3,3,start@l - mr 5,6 /* args string */ - bl _C_LABEL(initppc) - bl _C_LABEL(main) - b _C_LABEL(OF_exit) - -#define LED_ADDR 0x800008c0 -_ENTRY(_C_LABEL(led_dbg)) - stwu 1,-32(1) - mflr 0 - stw 0,36(1) - - stw 4,8(1) - stw 5,12(1) - stw 6,16(1) - stw 7,20(1) - mfmsr 5 - - mr 6,5 - ori 6,6,(PSL_IR|PSL_DR)@l /* turn on MMU */ - mtmsr 6 - sync - isync - - lis 4,LED_ADDR@ha - addi 4,4,LED_ADDR@l - li 7,0 - ori 3,3,0x2000 - sthbrx 3,7,4 - - sync - mtmsr 5 - isync - lwz 4,8(1) - lwz 5,12(1) - lwz 6,16(1) - lwz 7,20(1) - - lwz 0,36(1) - mtlr 0 - addi 1,1,32 - blr - -/* - * No processes are runnable, so loop waiting for one. - * Separate label here for accounting purposes. - */ -_C_LABEL(idle): - mfmsr 3 - andi. 3,3,~PSL_EE@l /* disable interrupts while manipulating runque */ - mtmsr 3 - - lis 8,_C_LABEL(whichqs)@ha - lwz 9,_C_LABEL(whichqs)@l(8) - - or. 9,9,9 - bne- _C_LABEL(sw1) /* at least one queue non-empty */ - - ori 3,3,PSL_EE /* reenable ints again */ - mtmsr 3 - isync - sync - /* low power mode */ - mfmsr 3 - oris 3, 3, PSL_POW@h - mtmsr 3 - 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 6,idle_u@ha - lwz 6,idle_u@l(6) - lis 7,_C_LABEL(curpcb)@ha - stw 6,_C_LABEL(curpcb)@l(7) - addi 1,6,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 3,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 0 /* save lr */ - stw 0,4(1) - stwu 1,-16(1) - stw 31,12(1) - stw 30,8(1) - - mr 30,3 - lis 3,_C_LABEL(curproc)@ha - xor 31,31,31 - stw 31,_C_LABEL(curproc)@l(3) /* Zero to not accumulate cpu time */ - lis 3,_C_LABEL(curpcb)@ha - lwz 31,_C_LABEL(curpcb)@l(3) - - xor 3,3,3 - bl _C_LABEL(lcsplx) - stw 3,PCB_SPL(31) /* save spl */ - -/* Find a new process */ - mfmsr 3 - andi. 3,3,~PSL_EE@l /* disable interrupts while - manipulating runque */ - mtmsr 3 - isync - - lis 8,_C_LABEL(whichqs)@ha - lwz 9,_C_LABEL(whichqs)@l(8) - - or. 9,9,9 - beq- _C_LABEL(idle) /* all queues empty */ -_C_LABEL(sw1): - cntlzw 10,9 - lis 4,_C_LABEL(qs)@ha - addi 4,4,_C_LABEL(qs)@l - slwi 3,10,3 - add 3,3,4 /* select queue */ - - lwz 31,P_FORW(3) /* unlink first proc from queue */ - lwz 4,P_FORW(31) - stw 4,P_FORW(3) - stw 3,P_BACK(4) - - cmpl 0,3,4 /* queue empty? */ - bne 1f - - lis 3,0x80000000@ha - srw 3,3,10 - andc 9,9,3 - stw 9,_C_LABEL(whichqs)@l(8) /* mark it empty */ - -1: - xor 3,3,3 - lis 4,_C_LABEL(want_resched)@ha - stw 3,_C_LABEL(want_resched)@l(4) /* just did this resched thing */ - - stw 3,P_BACK(31) /* probably superfluous */ - - lis 4,_C_LABEL(curproc)@ha - stw 31,_C_LABEL(curproc)@l(4) /* record new process */ - - mfmsr 3 - ori 3,3,PSL_EE /* Now we can interrupt again */ - mtmsr 3 - - cmpl 0,31,30 /* is it the same process? */ - beq switch_return - - or. 30,30,30 /* old process was exiting? */ - beq switch_exited - - mfsr 10,USER_SR /* save USER_SR for copyin/copyout */ - mfcr 11 /* save cr */ - mr 12,2 /* save r2 */ - stwu 1,-SFRAMELEN(1) /* still running on old stack */ - stmw 10,8(1) - lwz 3,P_ADDR(30) - stw 1,PCB_SP(3) /* save SP */ - -switch_exited: - mfmsr 3 - andi. 3,3,~PSL_EE@l /* disable interrupts while actually switching */ - mtmsr 3 - - lwz 4,P_ADDR(31) - lis 5,_C_LABEL(curpcb)@ha - stw 4,_C_LABEL(curpcb)@l(5) /* indicate new pcb */ - - lwz 5,PCB_PMR(4) - lis 6,_C_LABEL(curpm)@ha - stwu 5,_C_LABEL(curpm)@l(6) /* save real pmap pointer for spill fill */ - stwcx. 5,0,6 /* clear possible reservation */ - - addic. 5,5,64 - li 6,0 - mfsr 8,KERNEL_SR /* save kernel SR */ -1: - addis 6,6,-0x10000000@ha /* set new procs segment registers */ - or. 6,6,6 /* This is done from the real address pmap */ - lwzu 7,-4(5) /* so we don't have to worry */ - mtsrin 7,6 /* about accessibility */ - bne 1b - mtsr KERNEL_SR,8 /* restore kernel SR */ - isync - - lwz 1,PCB_SP(4) /* get new procs SP */ - - ori 3,3,PSL_EE /* interrupts are okay again */ - mtmsr 3 - - lmw 10,8(1) /* get other regs */ - lwz 1,0(1) /* get saved SP */ - mr 2,12 /* get saved r2 */ - mtcr 11 /* get saved cr */ - isync - mtsr USER_SR,10 /* get saved USER_SR */ - isync - -switch_return: - mr 30,7 /* save proc pointer */ - lwz 3,PCB_SPL(4) - bl _C_LABEL(lcsplx) - - mr 3,30 /* get curproc for special fork returns */ - - lwz 31,12(1) - lwz 30,8(1) - addi 1,1,16 - lwz 0,4(1) - mtlr 0 - 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,1 /* save SP */ - stmw 28,tempsave(0) /* free r28-r31 */ - mflr 28 /* save LR */ - mfcr 29 /* save CR */ -/* Test whether we already had PR set */ - mfsrr1 31 - mtcr 31 - bc 4,17,1f /* branch if PSL_PR is clear */ - lis 1,_C_LABEL(curpcb)@ha - lwz 1,_C_LABEL(curpcb)@l(1) - addi 1,1,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,1 /* save SP */ - stmw 28,tempsave(0) /* free r28-r31 */ - mfdar 30 - mfdsisr 31 - stmw 30,tempsave+16(0) - mflr 28 /* save LR */ - mfcr 29 /* save CR */ -/* Test whether we already had PR set */ - mfsrr1 31 - mtcr 31 - bc 4,17,1f /* branch if PSL_PR is clear */ - lis 1,_C_LABEL(curpcb)@ha - lwz 1,_C_LABEL(curpcb)@l(1) - addi 1,1,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 28,disisave(0) /* free r28-r31 */ - mfcr 29 /* save CR */ - mfxer 30 /* save XER */ - mtsprg 2,30 /* in SPRG2 */ - mfsrr1 31 /* test kernel mode */ - mtcr 31 - bc 12,17,1f /* branch if PSL_PR is set */ - mfdar 31 /* get fault address */ - rlwinm 31,31,7,25,28 /* get segment * 8 */ - addis 31,31,_C_LABEL(battable)@ha - lwz 30,_C_LABEL(battable)@l(31) /* get batu */ - mtcr 30 - bc 4,30,1f /* branch if supervisor valid is false */ - lwz 31,_C_LABEL(battable)+4@l(31) /* get batl */ -/* We randomly use the highest two bat registers here */ - mftb 28 - andi. 28,28,1 - bne 2f - mtdbatu 2,30 - mtdbatl 2,31 - b 3f -2: - mtdbatu 3,30 - mtdbatl 3,31 -3: - mfsprg 30,2 /* restore XER */ - mtxer 30 - mtcr 29 /* restore CR */ - lmw 28,disisave(0) /* restore r28-r31 */ - rfi /* return to trapped code */ -1: - mflr 28 /* 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 28,disisave(0) /* free r28-r31 */ - mflr 28 /* save LR */ - mfcr 29 /* save CR */ - mfsrr1 31 /* test kernel mode */ - mtcr 31 - bc 12,17,1f /* branch if PSL_PR is set */ - mfsrr0 31 /* get fault address */ - rlwinm 31,31,7,25,28 /* get segment * 8 */ - addis 31,31,_C_LABEL(battable)@ha - lwz 30,_C_LABEL(battable)@l(31) /* get batu */ - mtcr 30 - bc 4,30,1f /* branch if supervisor valid is false */ - mtibatu 3,30 - lwz 30,_C_LABEL(battable)+4@l(31) /* get batl */ - mtibatl 3,30 - mtcr 29 /* restore CR */ - lmw 28,disisave(0) /* restore r28-r31 */ - rfi /* return to trapped code */ -1: - 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,1 /* save SP */ - stmw 28,tempsave(0) /* free r28-r31 */ - mflr 28 /* save LR */ - mfcr 29 /* save CR */ - mfxer 30 /* save XER */ - lis 1,intstk+INTSTK@ha /* get interrupt stack */ - addi 1,1,intstk+INTSTK@l - lwz 31,0(1) /* were we already running on intstk? */ - addic. 31,31,1 - stw 31,0(1) - beq 1f - mfsprg 1,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,1 /* save SP */ - stmw 28,tempsave(0) /* free r28-r31 */ - mflr 28 /* save LR */ - mfcr 29 /* save CR */ - mfxer 30 /* save XER */ - lis 1,intstk+INTSTK@ha /* get interrupt stack */ - addi 1,1,intstk+INTSTK@l - lwz 31,0(1) /* were we already running on intstk? */ - addic. 31,31,1 - stw 31,0(1) - beq 1f - mfsprg 1,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 2,HASH1 /* get first pointer */ - li 1,8 - mfctr 0 /* save counter */ - mfspr 3,ICMP /* get first compare value */ - addi 2,2,-8 /* predec pointer */ -1: - mtctr 1 /* load counter */ -2: - lwzu 1,8(2) /* get next pte */ - cmpl 0,1,3 /* see if found pte */ - bdneq 2b /* loop if not eq */ - bne 3f /* not found */ - lwz 1,4(2) /* load tlb entry lower word */ - andi. 3,1,8 /* check G-bit */ - bne 4f /* if guarded, take ISI */ - mtctr 0 /* restore counter */ - mfspr 0,IMISS /* get the miss address for the tlbli */ - mfsrr1 3 /* get the saved cr0 bits */ - mtcrf 0x80,3 /* and restore */ - ori 1,1,0x100 /* set the reference bit */ - mtspr RPA,1 /* set the pte */ - srwi 1,1,8 /* get byte 7 of pte */ - tlbli 0 /* load the itlb */ - stb 1,6(2) /* update page table */ - rfi - -3: /* not found in pteg */ - andi. 1,3,0x40 /* have we already done second hash? */ - bne 5f - mfspr 2,HASH2 /* get the second pointer */ - ori 3,3,0x40 /* change the compare value */ - li 1,8 - addi 2,2,-8 /* predec pointer */ - b 1b -4: /* guarded */ - mfsrr1 3 - andi. 2,3,0xffff /* clean upper srr1 */ - addis 2,2,0x800 /* set srr<4> to flag prot violation */ - b 6f -5: /* not found anywhere */ - mfsrr1 3 - andi. 2,3,0xffff /* clean upper srr1 */ - addis 2,2,0x4000 /* set srr1<1> to flag pte not found */ -6: - mtctr 0 /* restore counter */ - mtsrr1 2 - mfmsr 0 - xoris 0,0,2 /* flip the msr<tgpr> bit */ - mtcrf 0x80,3 /* restore cr0 */ - mtmsr 0 /* 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 2,HASH1 /* get first pointer */ - li 1,8 - mfctr 0 /* save counter */ - mfspr 3,DCMP /* get first compare value */ - addi 2,2,-8 /* predec pointer */ -1: - mtctr 1 /* load counter */ -2: - lwzu 1,8(2) /* get next pte */ - cmpl 0,1,3 /* see if found pte */ - bdneq 2b /* loop if not eq */ - bne 3f /* not found */ - lwz 1,4(2) /* load tlb entry lower word */ - mtctr 0 /* restore counter */ - mfspr 0,DMISS /* get the miss address for the tlbld */ - mfsrr1 3 /* get the saved cr0 bits */ - mtcrf 0x80,3 /* and restore */ - ori 1,1,0x100 /* set the reference bit */ - mtspr RPA,1 /* set the pte */ - srwi 1,1,8 /* get byte 7 of pte */ - tlbld 0 /* load the dtlb */ - stb 1,6(2) /* update page table */ - rfi - -3: /* not found in pteg */ - andi. 1,3,0x40 /* have we already done second hash? */ - bne 5f - mfspr 2,HASH2 /* get the second pointer */ - ori 3,3,0x40 /* change the compare value */ - li 1,8 - addi 2,2,-8 /* predec pointer */ - b 1b -5: /* not found anywhere */ - mfsrr1 3 - lis 1,0x4000 /* set dsisr<1> to flag pte not found */ - mtctr 0 /* restore counter */ - andi. 2,3,0xffff /* clean upper srr1 */ - mtsrr1 2 - mtdsisr 1 /* load the dsisr */ - mfspr 1,DMISS /* get the miss address */ - mtdar 1 /* put in dar */ - mfmsr 0 - xoris 0,0,2 /* flip the msr<tgpr> bit */ - mtcrf 0x80,3 /* restore cr0 */ - mtmsr 0 /* 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 2,HASH1 /* get first pointer */ - li 1,8 - mfctr 0 /* save counter */ - mfspr 3,DCMP /* get first compare value */ - addi 2,2,-8 /* predec pointer */ -1: - mtctr 1 /* load counter */ -2: - lwzu 1,8(2) /* get next pte */ - cmpl 0,1,3 /* see if found pte */ - bdneq 2b /* loop if not eq */ - bne 3f /* not found */ - lwz 1,4(2) /* load tlb entry lower word */ - andi. 3,1,0x80 /* check the C-bit */ - beq 4f -5: - mtctr 0 /* restore counter */ - mfspr 0,DMISS /* get the miss address for the tlbld */ - mfsrr1 3 /* get the saved cr0 bits */ - mtcrf 0x80,3 /* and restore */ - mtspr RPA,1 /* set the pte */ - tlbld 0 /* load the dtlb */ - rfi - -3: /* not found in pteg */ - andi. 1,3,0x40 /* have we already done second hash? */ - bne 5f - mfspr 2,HASH2 /* get the second pointer */ - ori 3,3,0x40 /* change the compare value */ - li 1,8 - addi 2,2,-8 /* predec pointer */ - b 1b -4: /* found, but C-bit = 0 */ - rlwinm. 3,1,30,0,1 /* test PP */ - bge- 7f - andi. 3,1,1 - beq+ 8f -9: /* found, but protection violation (PP==00)*/ - mfsrr1 3 - lis 1,0xa00 /* indicate protection violation on store */ - b 1f -7: /* found, PP=1x */ - mfspr 3,DMISS /* get the miss address */ - mfsrin 1,3 /* get the segment register */ - mfsrr1 3 - rlwinm 3,3,18,31,31 /* get PR-bit */ - rlwnm. 2,2,3,1,1 /* get the key */ - bne- 9b /* protection violation */ -8: /* found, set reference/change bits */ - lwz 1,4(2) /* reload tlb entry */ - ori 1,1,0x180 - sth 1,6(2) - b 5b -5: /* not found anywhere */ - mfsrr1 3 - lis 1,0x4200 /* set dsisr<1> to flag pte not found */ - /* dsisr<6> to flag store */ -1: - mtctr 0 /* restore counter */ - andi. 2,3,0xffff /* clean upper srr1 */ - mtsrr1 2 - mtdsisr 1 /* load the dsisr */ - mfspr 1,DMISS /* get the miss address */ - mtdar 1 /* put in dar */ - mfmsr 0 - xoris 0,0,2 /* flip the msr<tgpr> bit */ - mtcrf 0x80,3 /* restore cr0 */ - mtmsr 0 /* 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,1 /* save SP */ - stmw 28,ddbsave(0) /* free r28-r31 */ - mflr 28 /* save LR */ - mfcr 29 /* save CR */ - lis 1,ddbstk+INTSTK@ha /* get new SP */ - addi 1,1,ddbstk+INTSTK@l - bla ddbtrap -_C_LABEL(ddbsize) = .-_C_LABEL(ddblow) -#endif /* DDB */ - - -#if NIPKDB > 0 -#define ipkdbsave 0xde0 /* primary save area for IPKDB */ -/* - * In case of IPKDB we want a separate trap catcher for it - */ -.lcomm ipkdbstk,INTSTK /* ipkdb stack */ - - .globl _C_LABEL(ipkdblow),_C_LABEL(ipkdbsize) - .type _C_LABEL(ipkdblow),@function - .type _C_LABEL(ipkdbsize),@object -_C_LABEL(ipkdblow): - mtsprg 1,1 /* save SP */ - stmw 28,ipkdbsave(0) /* free r28-r31 */ - lis 1,ipkdbstk+INTSTK@ha /* get new SP */ - addi 1,1,ipkdbstk+INTSTK@l - mflr 28 - mfcr 29 - bla ipkdbtrap -_C_LABEL(ipkdbsize) = .-_C_LABEL(ipkdblow) -#endif /* NIPKDB > 0 */ - -/* - * 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 30; \ - mfsrr1 31; \ - stmw 30,savearea+24(0); \ - mfmsr 30; \ - ori 30,30,(PSL_DR|PSL_IR); \ - mtmsr 30; \ - isync; \ - mfsprg 31,1; \ - stwu 31,-FRAMELEN(1); \ - stw 0,FRAME_0+8(1); \ - stw 31,FRAME_1+8(1); \ - stw 28,FRAME_LR+8(1); \ - stw 29,FRAME_CR+8(1); \ - lmw 28,savearea(0); \ - stmw 2,FRAME_2+8(1); \ - lmw 28,savearea+16(0); \ - mfxer 3; \ - mfctr 4; \ - mflr 5; \ - andi. 5,5,0xff00; \ - stw 3,FRAME_XER+8(1); \ - stw 4,FRAME_CTR+8(1); \ - stw 5,FRAME_EXC+8(1); \ - stw 28,FRAME_DAR+8(1); \ - stw 29,FRAME_DSISR+8(1); \ - stw 30,FRAME_SRR0+8(1); \ - stw 31,FRAME_SRR1+8(1) - -#define FRAME_LEAVE(savearea) \ -/* Now restore regs: */ \ - lwz 2,FRAME_SRR0+8(1); \ - lwz 3,FRAME_SRR1+8(1); \ - lwz 4,FRAME_CTR+8(1); \ - lwz 5,FRAME_XER+8(1); \ - lwz 6,FRAME_LR+8(1); \ - lwz 7,FRAME_CR+8(1); \ - stw 2,savearea(0); \ - stw 3,savearea+4(0); \ - mtctr 4; \ - mtxer 5; \ - mtlr 6; \ - mtsprg 1,7; /* save cr */ \ - lmw 2,FRAME_2+8(1); \ - lwz 0,FRAME_0+8(1); \ - lwz 1,FRAME_1+8(1); \ - mtsprg 2,2; /* save r2 & r3 */ \ - mtsprg 3,3; \ -/* Disable translation, machine check and recoverability: */ \ - mfmsr 2; \ - lis 3,(PSL_DR|PSL_IR|PSL_ME|PSL_RI)@ha; \ - addi 3,3,(PSL_DR|PSL_IR|PSL_ME|PSL_RI)@l; \ - andc 2,2,3; \ - mtmsr 2; \ - isync; \ -/* Decide whether we return to user mode: */ \ - lwz 3,savearea+4(0); \ - mtcr 3; \ - bc 4,17,1f; /* branch if PSL_PR is false */ \ -/* Restore user & kernel access SR: */ \ - lis 2,_C_LABEL(curpm)@ha; /* get real address of pmap */ \ - lwz 2,_C_LABEL(curpm)@l(2); \ - lwz 3,PM_USRSR(2); \ - mtsr USER_SR,3; \ - lwz 3,PM_KERNELSR(2); \ - mtsr KERNEL_SR,3; \ -1: mfsprg 2,1; /* restore cr */ \ - mtcr 2; \ - lwz 2,savearea(0); \ - lwz 3,savearea+4(0); \ - mtsrr0 2; \ - mtsrr1 3; \ - mfsprg 2,2; /* restore r2 & r3 */ \ - mfsprg 3,3 - -/* - * Preamble code for DSI/ISI traps - */ -disitrap: - lmw 30,disisave(0) - stmw 30,tempsave(0) - lmw 30,disisave+8(0) - stmw 30,tempsave+8(0) - mfdar 30 - mfdsisr 31 - stmw 30,tempsave+16(0) -realtrap: -/* Test whether we already had PR set */ - mfsrr1 1 - mtcr 1 - mfsprg 1,1 /* restore SP (might have been overwritten) */ - bc 4,17,s_trap /* branch if PSL_PR is false */ - lis 1,_C_LABEL(curpcb)@ha - lwz 1,_C_LABEL(curpcb)@l(1) - addi 1,1,USPACE /* stack is top of user struct */ -/* - * Now the common trap catching code. - */ -s_trap: -/* First have to enable KERNEL mapping */ - lis 31,KERNEL_SEGMENT@ha - addi 31,31,KERNEL_SEGMENT@l - mtsr KERNEL_SR,31 - FRAME_SETUP(tempsave) -/* Now we can recover interrupts again: */ - mfmsr 7 - ori 7,7,(PSL_EE|PSL_ME|PSL_RI) - mtmsr 7 - isync -/* Call C trap code: */ -trapagain: - addi 3,1,8 - bl _C_LABEL(trap) -trapexit: -/* Disable interrupts: */ - mfmsr 3 - andi. 3,3,~PSL_EE@l - mtmsr 3 -/* Test AST pending: */ - lwz 5,FRAME_SRR1+8(1) - mtcr 5 - bc 4,17,1f /* branch if PSL_PR is false */ - lis 3,_C_LABEL(astpending)@ha - lwz 4,_C_LABEL(astpending)@l(3) - andi. 4,4,1 - beq 1f - li 6,EXC_AST - stw 6,FRAME_EXC+8(1) - 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): - xor 3,3,3 - bl _C_LABEL(lcsplx) - mtlr 31 - mr 3,30 - blrl /* jump indirect to r31 */ - b trapexit - -/* - * DSI second stage fault handler - */ -s_dsitrap: - mfdsisr 31 /* test whether this may be a spill fault */ - mtcr 31 - mtsprg 1,1 /* save SP */ - bc 4,1,disitrap /* branch if table miss is false */ - lis 1,spillstk+SPILLSTK@ha - addi 1,1,spillstk+SPILLSTK@l /* get spill stack */ - stwu 1,-52(1) - stw 0,48(1) /* save non-volatile registers */ - stw 3,44(1) - stw 4,40(1) - stw 5,36(1) - stw 6,32(1) - stw 7,28(1) - stw 8,24(1) - stw 9,20(1) - stw 10,16(1) - stw 11,12(1) - stw 12,8(1) - mflr 30 /* save trap type */ - mfctr 31 /* & CTR */ - mfdar 3 -s_pte_spill: - bl _C_LABEL(pte_spill) /* try a spill */ - or. 3,3,3 - mtctr 31 /* restore CTR */ - mtlr 30 /* and trap type */ - mfsprg 31,2 /* get saved XER */ - mtxer 31 /* restore XER */ - lwz 12,8(1) /* restore non-volatile registers */ - lwz 11,12(1) - lwz 10,16(1) - lwz 9,20(1) - lwz 8,24(1) - lwz 7,28(1) - lwz 6,32(1) - lwz 5,36(1) - lwz 4,40(1) - lwz 3,44(1) - lwz 0,48(1) - beq disitrap - mfsprg 1,1 /* restore SP */ - mtcr 29 /* restore CR */ - mtlr 28 /* restore LR */ - lmw 28,disisave(0) /* restore r28-r31 */ - rfi /* return to trapped code */ - -/* - * ISI second stage fault handler - */ -s_isitrap: - mfsrr1 31 /* test whether this may be a spill fault */ - mtcr 31 - mtsprg 1,1 /* save SP */ - bc 4,1,disitrap /* branch if table miss is false */ - lis 1,spillstk+SPILLSTK@ha - addi 1,1,spillstk+SPILLSTK@l /* get spill stack */ - stwu 1,-52(1) - stw 0,48(1) /* save non-volatile registers */ - stw 3,44(1) - stw 4,40(1) - stw 5,36(1) - stw 6,32(1) - stw 7,28(1) - stw 8,24(1) - stw 9,20(1) - stw 10,16(1) - stw 11,12(1) - stw 12,8(1) - mfxer 30 /* save XER */ - mtsprg 2,30 - mflr 30 /* save trap type */ - mfctr 31 /* & ctr */ - mfsrr0 3 - b s_pte_spill /* above */ - -/* - * External interrupt second level handler - */ -#define INTRENTER \ -/* Save non-volatile registers: */ \ - stwu 1,-88(1); /* temporarily */ \ - stw 0,84(1); \ - mfsprg 0,1; /* get original SP */ \ - stw 0,0(1); /* and store it */ \ - stw 3,80(1); \ - stw 4,76(1); \ - stw 5,72(1); \ - stw 6,68(1); \ - stw 7,64(1); \ - stw 8,60(1); \ - stw 9,56(1); \ - stw 10,52(1); \ - stw 11,48(1); \ - stw 12,44(1); \ - stw 28,40(1); /* saved LR */ \ - stw 29,36(1); /* saved CR */ \ - stw 30,32(1); /* saved XER */ \ - lmw 28,tempsave(0); /* restore r28-r31 */ \ - mfctr 6; \ - lis 5,_C_LABEL(intr_depth)@ha; \ - lwz 5,_C_LABEL(intr_depth)@l(5); \ - mfsrr0 4; \ - mfsrr1 3; \ - stw 6,28(1); \ - stw 5,20(1); \ - stw 4,12(1); \ - stw 3,8(1); \ -/* interrupts are recoverable here, and enable translation */ \ - lis 3,(KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY)@ha; \ - addi 3,3,(KERNEL_SEGMENT|SR_SUKEY|SR_PRKEY)@l; \ - mtsr KERNEL_SR,3; \ - mfmsr 5; \ - ori 5,5,(PSL_IR|PSL_DR|PSL_RI); \ - mtmsr 5; \ - 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 3 - andi. 3,3,~(PSL_EE|PSL_ME|PSL_RI|PSL_DR|PSL_IR)@l - mtmsr 3 - isync -/* restore possibly overwritten registers: */ - lwz 12,44(1) - lwz 11,48(1) - lwz 10,52(1) - lwz 9,56(1) - lwz 8,60(1) - lwz 7,64(1) - lwz 6,8(1) - lwz 5,12(1) - lwz 4,28(1) - lwz 3,32(1) - mtsrr1 6 - mtsrr0 5 - mtctr 4 - mtxer 3 -/* Returning to user mode? */ - mtcr 6 /* saved SRR1 */ - bc 4,17,1f /* branch if PSL_PR is false */ - lis 3,_C_LABEL(curpm)@ha /* get current pmap real address */ - lwz 3,_C_LABEL(curpm)@l(3) - lwz 3,PM_KERNELSR(3) - mtsr KERNEL_SR,3 /* Restore kernel SR */ - lis 3,_C_LABEL(astpending)@ha /* Test AST pending */ - lwz 4,_C_LABEL(astpending)@l(3) - andi. 4,4,1 - beq 1f -/* Setup for entry to realtrap: */ - lwz 3,0(1) /* get saved SP */ - mtsprg 1,3 - li 6,EXC_AST - stmw 28,tempsave(0) /* establish tempsave again */ - mtlr 6 - lwz 28,40(1) /* saved LR */ - lwz 29,36(1) /* saved CR */ - lwz 6,68(1) - lwz 5,72(1) - lwz 4,76(1) - lwz 3,80(1) - lwz 0,84(1) - lis 30,_C_LABEL(intr_depth)@ha /* adjust reentrancy count */ - lwz 31,_C_LABEL(intr_depth)@l(30) - addi 31,31,-1 - stw 31,_C_LABEL(intr_depth)@l(30) - b realtrap -1: -/* Here is the normal exit of extintr: */ - lwz 5,36(1) - lwz 6,40(1) - mtcr 5 - mtlr 6 - lwz 6,68(1) - lwz 5,72(1) - lis 3,_C_LABEL(intr_depth)@ha /* adjust reentrancy count */ - lwz 4,_C_LABEL(intr_depth)@l(3) - addi 4,4,-1 - stw 4,_C_LABEL(intr_depth)@l(3) - lwz 4,76(1) - lwz 3,80(1) - lwz 0,84(1) - lwz 1,0(1) - rfi - -/* - * Decrementer interrupt second level handler - */ -decrintr: - INTRENTER - addi 3,1,8 /* intr frame */ - bl _C_LABEL(decr_intr) - b intr_exit - -#if NIPKDB > 0 -/* - * Deliberate entry to ipkdbtrap - */ - .globl _C_LABEL(ipkdb_trap) - .type _C_LABEL(ipkdb_trap),@function -_C_LABEL(ipkdb_trap): - - mtsprg 2,2 - mfmsr 3 - mtsrr1 3 - andi. 3,3,~(PSL_EE|PSL_ME)@l - mtmsr 3 /* disable interrupts */ - isync - stmw 28,ipkdbsave(0) - mflr 28 - li 29,EXC_BPT - mtlr 29 - mfcr 29 - mtsrr0 28 - -/* - * Now the ipkdb trap catching code. - */ -ipkdbtrap: - FRAME_SETUP(ipkdbsave) -/* Call C trap code: */ - addi 3,1,8 - bl _C_LABEL(ipkdb_trap_glue) - or. 3,3,3 - bne ipkdbleave -/* This wasn't for IPKDB, so switch to real trap: */ - lwz 3,FRAME_EXC+8(1) /* save exception */ - stw 3,ipkdbsave+8(0) - FRAME_LEAVE(ipkdbsave) - mtsprg 1,1 /* prepare for entrance to realtrap */ - stmw 28,tempsave(0) - mflr 28 - mfcr 29 - lwz 31,ipkdbsave+8(0) - mtlr 31 - b realtrap -ipkdbleave: - FRAME_LEAVE(ipkdbsave) - rfi - -ipkdbfault: - ba _C_LABEL(ipkdbfault) -_C_LABEL(ipkdbfault): - mfsrr0 3 - addi 3,3,4 - mtsrr0 3 - li 3,-1 - rfi - -/* - * int ipkdbfbyte(unsigned char *p) - */ - .globl _C_LABEL(ipkdbfbyte) - .type _C_LABEL(ipkdbfbyte),@function -_C_LABEL(ipkdbfbyte): - li 9,EXC_DSI /* establish new fault routine */ - lwz 5,0(9) - lis 6,ipkdbfault@ha - lwz 6,ipkdbfault@l(6) - stw 6,0(9) -#ifdef IPKDBUSERHACK - lis 8,_C_LABEL(ipkdbsr)@ha - lwz 8,_C_LABEL(ipkdbsr)@l(8) - mtsr USER_SR,8 - isync -#endif - dcbst 0,9 /* flush data... */ - sync - icbi 0,9 /* and instruction caches */ - lbz 3,0(3) /* fetch data */ - stw 5,0(9) /* restore previous fault handler */ - dcbst 0,9 /* and flush data... */ - sync - icbi 0,9 /* and instruction caches */ - blr - -/* - * int ipkdbsbyte(unsigned char *p, int c) - */ - .globl _C_LABEL(ipkdbsbyte) - .type _C_LABEL(ipkdbsbyte),@function -_C_LABEL(ipkdbsbyte): - li 9,EXC_DSI /* establish new fault routine */ - lwz 5,0(9) - lis 6,ipkdbfault@ha - lwz 6,ipkdbfault@l(6) - stw 6,0(9) -#ifdef IPKDBUSERHACK - lis 8,_C_LABEL(ipkdbsr)@ha - lwz 8,_C_LABEL(ipkdbsr)@l(8) - mtsr USER_SR,8 - isync -#endif - dcbst 0,9 /* flush data... */ - sync - icbi 0,9 /* and instruction caches */ - mr 6,3 - xor 3,3,3 - stb 4,0(6) - dcbst 0,6 /* Now do appropriate flushes to data... */ - sync - icbi 0,6 /* and instruction caches */ - stw 5,0(9) /* restore previous fault handler */ - dcbst 0,9 /* and flush data... */ - sync - icbi 0,9 /* and instruction caches */ - blr -#endif /* NIPKDB > 0 */ - -/* - * 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 0 - mfcr 12 - mfmsr 2 - lis 4,_C_LABEL(curpcb)@ha - lwz 4,_C_LABEL(curpcb)@l(4) - stw 3,PCB_FAULT(4) - stw 0,0(3) - stw 2,4(3) - stw 1,8(3) - stmw 12,12(3) - xor 3,3,3 - 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 1,1,-16 /* reserved space for callee */ - blrl - addi 3,1,16+8 /* compute &sf_sc */ - li 0,SYS_sigreturn - sc /* sigreturn(scp) */ - li 0,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" - .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 -_C_LABEL(eintrcnt): - -#ifdef DDB -/* - * Deliberate entry to ddbtrap - */ - .globl _C_LABEL(ddb_trap) -_C_LABEL(ddb_trap): - mtsprg 1,1 - mfmsr 3 - mtsrr1 3 - andi. 3,3,~(PSL_EE|PSL_ME)@l - mtmsr 3 /* disable interrupts */ - isync - stmw 28,ddbsave(0) - mflr 28 - li 29,EXC_BPT - mtlr 29 - mfcr 29 - mtsrr0 28 - -/* - * Now the ddb trap catching code. - */ -ddbtrap: - FRAME_SETUP(ddbsave) -/* Call C trap code: */ - addi 3,1,8 - bl _C_LABEL(ddb_trap_glue) - or. 3,3,3 - bne ddbleave -/* This wasn't for DDB, so switch to real trap: */ - lwz 3,FRAME_EXC+8(1) /* save exception */ - stw 3,ddbsave+8(0) - FRAME_LEAVE(ddbsave) - mtsprg 1,1 /* prepare for entrance to realtrap */ - stmw 28,tempsave(0) - mflr 28 - mfcr 29 - lwz 31,ddbsave+8(0) - mtlr 31 - b realtrap -ddbleave: - FRAME_LEAVE(ddbsave) - rfi -#endif /* DDB */ - diff --git a/sys/arch/powerpc/powerpc/machdep.c b/sys/arch/powerpc/powerpc/machdep.c deleted file mode 100644 index 200c213d785..00000000000 --- a/sys/arch/powerpc/powerpc/machdep.c +++ /dev/null @@ -1,1506 +0,0 @@ -/* $OpenBSD: machdep.c,v 1.80 2001/08/23 14:01:03 art 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 "machine/ipkdb.h" -*/ - -#include <sys/param.h> -#include <sys/buf.h> -#include <sys/timeout.h> -#include <sys/exec.h> -#include <sys/malloc.h> -#include <sys/map.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 <vm/vm.h> -#include <vm/vm_kern.h> - -#ifdef SYSVSHM -#include <sys/shm.h> -#endif -#ifdef SYSVSEM -#include <sys/sem.h> -#endif -#ifdef SYSVMSG -#include <sys/msg.h> -#endif -#include <net/netisr.h> - -#include <dev/cons.h> - -#include <dev/ofw/openfirm.h> - -#include <dev/pci/pcivar.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 "adb.h" -#if NADB > 0 -#include <arch/powerpc/mac/adbvar.h> -#include <arch/powerpc/mac/adb_direct.h> -#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; - -/* - * Declare these as initialized data so we can patch them. - */ -int nswbuf = 0; -#ifdef NBUF -int nbuf = NBUF; -#else -int nbuf = 0; -#endif -#ifdef BUFPAGES -int bufpages = BUFPAGES; -#else -int bufpages = 0; -#endif - -struct bat battable[16]; - -vm_map_t exec_map = NULL; -vm_map_t mb_map = NULL; -vm_map_t phys_map = NULL; - -int astpending; -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 - -void ofw_dbg(char *str); - -caddr_t allocsys __P((caddr_t)); -void dumpsys __P((void)); -void systype __P((char *name)); -void lcsplx __P((int ipl)); /* called from LCore */ -int power4e_get_eth_addr __P((void)); -void nameinterrupt __P((int replace, char *newstr)); -void ppc_intr_setup __P((intr_establish_t *establish, - intr_disestablish_t *disestablish)); -void *ppc_intr_establish __P((void *lcv, pci_intr_handle_t ih, int type, - int level, int (*func) __P((void *)), void *arg, char *name)); -int bus_mem_add_mapping __P((bus_addr_t bpa, bus_size_t size, int cacheable, - bus_space_handle_t *bshp)); - -/* - * 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; - -/* HACK - XXX */ -int segment8_a_mapped = 0; - -extern int OF_stdout; -extern int where; - -/* XXX, called from asm */ -void initppc(u_int startkernel, u_int endkernel, char *args); - -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; - extern void *ddblow; extern int ddbsize; -#if NIPKDB > 0 - extern ipkdblow, ipkdbsize; -#endif - extern void consinit __P((void)); - extern void callback __P((void *)); - int exc, scratch; - - proc0.p_addr = proc0paddr; - bzero(proc0.p_addr, sizeof *proc0.p_addr); - - /* - * XXX We use the page just above the interrupt vector as - * message buffer - */ - initmsgbuf((void *)0x3000, MSGBUFSIZE); - -where = 3; - curpcb = &proc0paddr->u_pcb; - - curpm = curpcb->pcb_pmreal = curpcb->pcb_pm = pmap_kernel(); - - /* - * Initialize BAT registers to unmapped to not generate - * overlapping mappings below. - */ - __asm__ volatile ("mtibatu 0,%0" :: "r"(0)); - __asm__ volatile ("mtibatu 1,%0" :: "r"(0)); - __asm__ volatile ("mtibatu 2,%0" :: "r"(0)); - __asm__ volatile ("mtibatu 3,%0" :: "r"(0)); - __asm__ volatile ("mtdbatu 0,%0" :: "r"(0)); - __asm__ volatile ("mtdbatu 1,%0" :: "r"(0)); - __asm__ volatile ("mtdbatu 2,%0" :: "r"(0)); - __asm__ volatile ("mtdbatu 3,%0" :: "r"(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); - - battable[0x8].batl = BATL(0x80000000, BAT_I); - battable[0x8].batu = BATU(0x80000000); - battable[0x9].batl = BATL(0x90000000, BAT_I); - battable[0x9].batu = BATU(0x90000000); - battable[0xa].batl = BATL(0xa0000000, BAT_I); - battable[0xa].batu = BATU(0xa0000000); - segment8_a_mapped = 1; - - /* - * 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 */ - __asm__ volatile ("mtibatl 0,%0; mtibatu 0,%1" - :: "r"(battable[0].batl), "r"(battable[0].batu)); - /* DBAT0 used similar */ - __asm__ volatile ("mtdbatl 0,%0; mtdbatu 0,%1" - :: "r"(battable[0].batl), "r"(battable[0].batu)); - -#if 0 - __asm__ volatile ("mtdbatl 1,%0; mtdbatu 1,%1" - :: "r"(battable[1].batl), "r"(battable[1].batu)); - __asm__ volatile ("sync;isync"); -#endif - - /* - * 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; -#if 1 - 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; -#endif - 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); -#else -#if NIPKDB > 0 - bcopy(&ipkdblow, (void *)exc, (size_t)&ipkdbsize); -#endif -#endif - break; - } - - syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100); - - - uvmexp.pagesize = 4096; - uvm_setpagesize(); - - /* - * Initialize pmap module. - */ - pmap_bootstrap(startkernel, endkernel); - - /* 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); - } - - /* - * 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)); - - /* - * 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]; -#if 0 - bcopy(args +strlen(args) + 1, &startsym, sizeof(startsym)); - bcopy(args +strlen(args) + 5, &endsym, sizeof(endsym)); - ddb_init((int)((u_int)endsym - (u_int)startsym), startsym, endsym); -#endif - -#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. - */ - consinit(); - /* while using openfirmware, run userconfig */ - if (boothowto & RB_CONFIG) { -#ifdef BOOT_CONFIG - user_config(); -#else - printf("kernel does not support -c; continuing..\n"); -#endif - } - /* - * Replace with real console. - */ - cninit(); - ofwconprobe(); - -#if NIPKDB > 0 - /* - * Now trap to IPKDB - */ - ipkdb_init(); - if (boothowto & RB_KDB) - ipkdb_connect(0); -#else -#ifdef DDB - if (boothowto & RB_KDB) - Debugger(); -#endif -#endif - - /* - * Figure out ethernet address. - */ - (void)power4e_get_eth_addr(); - -} -void ofw_dbg(char *str) -{ - int i = strlen (str); - OF_write(OF_stdout, str, i); -} - - -void -install_extint(handler) - void (*handler) __P((void)); -{ - void extint __P((void)); - void extsize __P((void)); - extern u_long extint_call; - u_long offset = (u_long)handler - (u_long)&extint_call; - int omsr, msr; - -#ifdef DIAGNOSTIC - if (offset > 0x1ffffff) - panic("install_extint: too far away"); -#endif - __asm__ volatile ("mfmsr %0; andi. %1, %0, %2; mtmsr %1" - : "=r"(omsr), "=r"(msr) : "K"((u_short)~PSL_EE)); - 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); - __asm__ volatile ("mtmsr %0" :: "r"(omsr)); -} - -/* - * 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\n", ctob(physmem)); - - /* - * 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, - UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, - UVM_ADV_NORMAL, 0)) != KERN_SUCCESS) - 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; - } - } - - /* - * Allocate a submap for exec arguments. This map effectively - * limits the number of processes exec'ing at any time. - */ - exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 16 * NCARGS, - TRUE, FALSE, NULL); - - /* - * Allocate a submap for physio - */ - phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, - VM_PHYS_SIZE, TRUE, FALSE, NULL); - ppc_malloc_ok = 1; - - mb_map = uvm_km_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr, - VM_MBUF_SIZE, FALSE, FALSE, NULL); - - printf("avail mem = %d\n", ptoa(uvmexp.free)); - 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(v) - caddr_t v; -{ -#define valloc(name, type, num) \ - v = (caddr_t)(((name) = (type *)v) + (num)) - -#ifdef SYSVSHM - valloc(shmsegs, struct shmid_ds, shminfo.shmmni); -#endif -#ifdef SYSVSEM - valloc(sema, struct semid_ds, seminfo.semmni); - valloc(sem, struct sem, seminfo.semmns); - valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int)); -#endif -#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 - -#ifndef BUFCACHEPERCENT -#define BUFCACHEPERCENT 5 -#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 70% filled kvm */ - if (nbuf * MAXBSIZE > - (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) * 7 / 10) - nbuf = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / - MAXBSIZE * 7 / 10; - - /* More buffer pages than fits into the buffers is senseless. */ - if (bufpages > nbuf * MAXBSIZE / PAGE_SIZE) - bufpages = nbuf * MAXBSIZE / PAGE_SIZE; - - if (nswbuf == 0) { - nswbuf = (nbuf / 2) & ~1; - if (nswbuf > 256) - nswbuf = 256; - } - 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(p, pack, stack, retval) - 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(catcher, sig, mask, code, type, val) - sig_t catcher; - int sig, 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 = (int)(((char *)PS_STRINGS) - - (p->p_emul->e_esigcode - p->p_emul->e_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(p, v, retval) - 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(name, namelen, oldp, oldlenp, newp, newlen, p) - 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]) { - default: - return EOPNOTSUPP; - } -} - -void -dumpsys() -{ - printf("dumpsys: TBD\n"); -} - -volatile int cpl, ipending, astpending, tickspending; -int imask[7]; - -/* - * Soft networking interrupts. - */ -void -softnet(isr) - int isr; -{ -#ifdef INET -#include "ether.h" -#if NETHER > 0 - if (isr & (1 << NETISR_ARP)) - arpintr(); -#endif - if (isr & (1 << NETISR_IP)) - ipintr(); -#endif -#ifdef INET6 - if (isr & (1 << NETISR_IPV6)) - ip6intr(); -#endif -#ifdef NETATALK - if (isr & (1 << NETISR_ATALK)) - atintr(); -#endif -#ifdef IMP - if (isr & (1 << NETISR_IMP)) - impintr(); -#endif -#ifdef NS - if (isr & (1 << NETISR_NS)) - nsintr(); -#endif -#ifdef ISO - if (isr & (1 << NETISR_ISO)) - clnlintr(); -#endif -#ifdef CCITT - if (isr & (1 << NETISR_CCITT)) - ccittintr(); -#endif -#include "ppp.h" -#if NPPP > 0 - if (isr & (1 << NETISR_PPP)) - pppintr(); -#endif -#include "bridge.h" -#if NBRIDGE > 0 - if (isr & (1 << NETISR_BRIDGE)) - bridgeintr(); -#endif -} - -void -lcsplx(ipl) - int ipl; -{ - splx(ipl); -} - -/* - * Halt or reboot the machine after syncing/dumping according to howto. - */ -void -boot(howto) - int howto; -#if 0 - char *what; -#endif -{ - 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) { -#if NADB > 0 - delay(1000000); - adb_poweroff(); - printf("WARNING: powerdown failed!\n"); -#endif - } - - printf("halted\n\n"); - (fw->exit)(); - } - if (!cold && (howto & RB_DUMP)) - dumpsys(); - doshutdownhooks(); - printf("rebooting\n\n"); - -#if NADB > 0 - adb_restart(); /* not return */ -#endif - - OF_exit(); - (fw->boot)(str); - 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(lcv, ih, type, level, func, arg, name) - void *lcv; - pci_intr_handle_t ih; - int type; - int level; - int (*func) __P((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\n", 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; -} - -/* - * General functions to enable and disable interrupts - * without having inlined assembly code in many functions, - * should be moved into a header file for inlining the function - * so it is faster - */ -void -ppc_intr_enable(int enable) -{ - u_int32_t emsr, dmsr; - if (enable != 0) { - __asm__ volatile("mfmsr %0" : "=r"(emsr)); - dmsr = emsr | PSL_EE; - __asm__ volatile("mtmsr %0" :: "r"(dmsr)); - } -} - -int -ppc_intr_disable(void) -{ - u_int32_t emsr, dmsr; - __asm__ volatile("mfmsr %0" : "=r"(emsr)); - dmsr = emsr & ~PSL_EE; - __asm__ volatile("mtmsr %0" :: "r"(dmsr)); - return (emsr & PSL_EE); -} - -/* BUS functions */ -int -bus_space_map(t, bpa, size, cacheable, bshp) - 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 ((error = extent_alloc_region(devio_ex, bpa, size, EX_NOWAIT | - (ppc_malloc_ok ? EX_MALLOCOK : 0)))) - { - return error; - } - if ((bpa >= 0x80000000) && ((bpa+size) < 0xb0000000)) { - if (segment8_a_mapped) { - *bshp = bpa; - return 0; - } - } - if ((error = bus_mem_add_mapping(bpa, size, cacheable, bshp))) { - 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"); - } - } - return 0; -} -bus_addr_t bus_space_unmap_p __P((bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t size)); -void bus_space_unmap __P((bus_space_tag_t t, bus_space_handle_t bsh, - bus_size_t size)); -bus_addr_t -bus_space_unmap_p(t, bsh, size) - 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(t, bsh, size) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t size; -{ - bus_addr_t sva; - bus_size_t off, len; - - /* should this verify that the proper size is freed? */ - sva = trunc_page(bsh); - off = bsh - sva; - len = size+off; - - uvm_km_free_wakeup(phys_map, sva, len); -#if 0 - pmap_extract(pmap_kernel(), sva, &bpa); - 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 - pmap_remove(vm_map_pmap(phys_map), sva, sva+len); -} - -int -bus_mem_add_mapping(bpa, size, cacheable, bshp) - 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(size); - ppc_kvm_size -= alloc_size; - - vaddr = VM_MIN_KERNEL_ADDRESS + ppc_kvm_size; - } else { - vaddr = uvm_km_valloc_wait(phys_map, 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) { -#if 0 - pmap_enter(vm_map_pmap(phys_map), vaddr, spa, -#else - pmap_enter(pmap_kernel(), vaddr, spa, -#endif - VM_PROT_READ | VM_PROT_WRITE, PMAP_WIRED /* XXX */); - spa += PAGE_SIZE; - vaddr += PAGE_SIZE; - } - return 0; -} - -int -bus_space_alloc(tag, rstart, rend, size, alignment, boundary, cacheable, addrp, handlep) - bus_space_tag_t tag; - bus_addr_t rstart, rend; - bus_size_t size, alignment, boundary; - int cacheable; - bus_addr_t *addrp; - bus_space_handle_t *handlep; -{ - - panic("bus_space_alloc: unimplemented"); -} - -void -bus_space_free(tag, handle, size) - bus_space_tag_t tag; - bus_space_handle_t handle; - bus_size_t size; -{ - - panic("bus_space_free: unimplemented"); -} - -void * -mapiodev(pa, len) - 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 ((pa >= 0x80000000) && ((pa+len) < 0xb0000000)) { - if (segment8_a_mapped) { - return (void *)pa; - } - } - va = vaddr = uvm_km_valloc(phys_map, size); - - if (va == 0) - return NULL; - - for (; size > 0; size -= PAGE_SIZE) { -#if 0 - pmap_enter(vm_map_pmap(phys_map), vaddr, spa, -#else - pmap_enter(pmap_kernel(), vaddr, spa, -#endif - VM_PROT_READ | VM_PROT_WRITE, PMAP_WIRED/* XXX */); - spa += PAGE_SIZE; - vaddr += PAGE_SIZE; - } - return (void*) (va+off); -} -void -unmapiodev(kva, p_size) - 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) { -#if 0 - pmap_remove(vm_map_pmap(phys_map), vaddr, vaddr+PAGE_SIZE-1); -#else - pmap_remove(pmap_kernel(), vaddr, vaddr+PAGE_SIZE-1); -#endif - vaddr += PAGE_SIZE; - } - return; -} - - - -/* - * 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)(v, h1, o1, h2, o2, c) \ - void *v; \ - bus_space_handle_t h1, h2; \ - bus_size_t o1, o2, c; \ -{ \ - TYPE *src, *dst; \ - int i; \ - \ - src = (TYPE *) (h1+o1); \ - dst = (TYPE *) (h2+o2); \ - \ - if (h1 == h2 && o2 > o1) { \ - for (i = c; 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) - -#define BUS_SPACE_SET_REGION_N(BYTES,TYPE) \ -void \ -__C(bus_space_set_region_,BYTES)(v, h, o, val, c) \ - void *v; \ - bus_space_handle_t h; \ - TYPE val; \ - bus_size_t o, c; \ -{ \ - TYPE *dst; \ - int i; \ - \ - dst = (TYPE *) (h+o); \ - for (i = 0; i < c; i++) { \ - dst[i] = val; \ - } \ -} - -BUS_SPACE_SET_REGION_N(1,u_int8_t) -BUS_SPACE_SET_REGION_N(2,u_int16_t) -BUS_SPACE_SET_REGION_N(4,u_int32_t) - -#define BUS_SPACE_READ_RAW_MULTI_N(BYTES,SHIFT,TYPE) \ -void \ -__C(bus_space_read_raw_multi_,BYTES)(bst, h, o, dst, size) \ - 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(1,0,u_int8_t) -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)(bst, h, o, src, size) \ - 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(1,0,u_int8_t) -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(t, bsh, offset, size, nbshp) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t offset, 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(from, to, size) - const void *from; - void *to; - size_t size; -{ - faultbuf env; - register void *oldh = curproc->p_addr->u_pcb.pcb_onfault; - - if (setfault(env)) { - curpcb->pcb_onfault = 0; - return EFAULT; - } - bcopy(from, to, size); - curproc->p_addr->u_pcb.pcb_onfault = oldh; - - return 0; -} - -void -nameinterrupt(replace, newstr) - 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 */ - } - - strcat(intrname[replace], "/"); - strcat(intrname[replace], newstr); - - 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/powerpc/powerpc/mainbus.c b/sys/arch/powerpc/powerpc/mainbus.c deleted file mode 100644 index 2158932f81e..00000000000 --- a/sys/arch/powerpc/powerpc/mainbus.c +++ /dev/null @@ -1,191 +0,0 @@ -/* $OpenBSD: mainbus.c,v 1.8 2001/07/09 04:41:28 mickey 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 __P((struct device *, void *, void *)); -static void mbattach __P((struct device *, struct device *, void *)); -static int mbprint __P((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 __P((struct confargs *, int (*)(void *), void *)); -void mb_intr_disestablish __P((struct confargs *)); -caddr_t mb_cvtaddr __P((struct confargs *)); -int mb_matchname __P((struct confargs *, char *)); - -/*ARGSUSED*/ -static int -mbmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - - /* - * That one mainbus is always here. - */ - return(1); -} - -static void -mbattach(parent, self, aux) - 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 an ISA bus */ - /* Do ISA first so the interrupt controller is set up! */ - if (system_type == POWER4e) { - nca.ca_name = "isabr"; - 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"); - continue; - } - if (strcmp(name, "memory-controller") == 0) { - nca.ca_name = "memc"; - nca.ca_node = node; - nca.ca_bus = &sc->sc_bus; - config_found(self, &nca, mbprint); - } - 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(aux, pnp) - void *aux; - const char *pnp; -{ - if (pnp) - return (QUIET); - return (UNCONF); -} - -void -mb_intr_establish(ca, handler, val) - struct confargs *ca; - int (*handler) __P((void *)); - void *val; -{ - panic("can never mb_intr_establish"); -} - -void -mb_intr_disestablish(ca) - struct confargs *ca; -{ - panic("can never mb_intr_disestablish"); -} - -caddr_t -mb_cvtaddr(ca) - struct confargs *ca; -{ - - return (NULL); -} - -int -mb_matchname(ca, name) - struct confargs *ca; - char *name; -{ - return (strcmp(name, ca->ca_name) == 0); -} diff --git a/sys/arch/powerpc/powerpc/mem.c b/sys/arch/powerpc/powerpc/mem.c deleted file mode 100644 index 846e6d16a5a..00000000000 --- a/sys/arch/powerpc/powerpc/mem.c +++ /dev/null @@ -1,184 +0,0 @@ -/* $OpenBSD: mem.c,v 1.8 2001/06/24 23:29:35 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. 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. - * - * @(#)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 <vm/vm.h> -#include <uvm/uvm_extern.h> - -#include <machine/conf.h> - -/*ARGSUSED*/ -int -mmopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - - switch (minor(dev)) { - case 0: - case 1: - case 2: - case 12: - return (0); - default: - return (ENXIO); - } -} - -/*ARGSUSED*/ -int -mmclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - - return 0; -} - -/*ARGSUSED*/ -int -mmrw(dev, uio, flags) - 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; -} - -int -mmmmap(dev, off, prot) - dev_t dev; - int off, prot; -{ - return (-1); -} - -/*ARGSUSED*/ -int -mmioctl(dev, cmd, data, flags, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flags; - struct proc *p; -{ - return (EOPNOTSUPP); -} diff --git a/sys/arch/powerpc/powerpc/ofw_machdep.c b/sys/arch/powerpc/powerpc/ofw_machdep.c deleted file mode 100644 index 9dea680f0fe..00000000000 --- a/sys/arch/powerpc/powerpc/ofw_machdep.c +++ /dev/null @@ -1,528 +0,0 @@ -/* $OpenBSD: ofw_machdep.c,v 1.25 2001/08/18 05:39:03 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 <vm/vm.h> -#include <vm/vm_kern.h> - -#include <machine/powerpc.h> -#include <machine/autoconf.h> - -#include <dev/ofw/openfirm.h> - -#include <ukbd.h> -#include <akbd.h> -#include <dev/usb/ukbdvar.h> -#include <powerpc/mac/akbdvar.h> - -/* XXX, called from asm */ -int save_ofw_mapping(void); -int restore_ofw_mapping(void); - -void OF_exit __P((void)) __attribute__((__noreturn__)); -void OF_boot __P((char *bootspec)) __attribute__((__noreturn__)); -void ofw_mem_regions __P((struct mem_region **memp, struct mem_region **availp)); -void ofw_vmon __P((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]; - -/* - * 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. - */ -void -ofw_mem_regions(memp, availp) - struct mem_region **memp, **availp; -{ - int phandle; - - /* - * 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; - /* HACK */ - if (OFmem[0].size == 0) { - *memp = OFavail; - } - *availp = OFavail; -} - -typedef void (fwcall_f) __P((int, int)); -extern fwcall_f *fwcall; -fwcall_f fwentry; -extern u_int32_t ofmsr; - -void -ofw_vmon() -{ - fwcall = &fwentry; -} - -/* 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 OF_stdout; -int OF_stdin; - -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; - } - 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; - } - } - - 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 emsr, dmsr; -static int processing; - - if(processing) - return; - - processing = 1; - __asm__ volatile("mfmsr %0" : "=r"(emsr)); - dmsr = emsr & ~PSL_EE; - __asm__ volatile("mtmsr %0" :: "r"(dmsr)); - - - 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! */ - __asm__ volatile("mtmsr %0" :: "r"(emsr)); - processing = 0; -} -#if 0 -u_int32_t ppc_console_iomem=0; -u_int32_t ppc_console_addr=0; -u_int32_t ppc_console_qhandle=0; -u_int32_t ppc_console_serfreq; - -void -ofwtrysercon(char *name, int qhandle) -{ -/* for serial we want regs field */ - int regs[4]; - int freq; - int regn; - if ((regn = OF_getprop(qhandle, "reg", ®s[0], sizeof regs)) >= 0) { - - if (regs[1] == 0x3f8) { - /* found preferred console */ - ppc_console_addr = regs[1]; - ppc_console_qhandle = qhandle; - ppc_console_iomem=0; /* 0 means io, 1 means mem */ - } - if ((regs[1] == 0x2e8) && (ppc_console_addr == 0)) { - /* found nonpreferred console */ - ppc_console_addr = regs[1]; - ppc_console_qhandle = qhandle; - ppc_console_iomem=0; /* 0 means io, 1 means mem */ - } - } - if ((OF_getprop(qhandle, "clock-frequency", &freq, sizeof regs)) >= 0) { - /* MCG value for this does not agree with PC value, - * but works correctly (while PC value does not), - * does VI set this correctly??? - */ - ppc_console_serfreq=freq; - } -} -#endif - -#include <dev/pci/pcivar.h> -#include <arch/powerpc/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(cpv, bus, dev, fnc) - void *cpv; - int bus, dev, fnc; -{ - return (bus << 16) | (dev << 11) | (fnc << 8); -} - -#if 0 -/* XXX */ -void -ofwenablepcimemio(char *name, int qhandle) -{ - /* THIS PROBABLY IS A MAJOR HACK - * AND IT WOULD PREVENT ofdisk and ofnet from working - * on MCG, VI machines. - */ -} -#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; - -#include "vgafb_pci.h" - -struct usb_kbd_ihandles { - struct usb_kbd_ihandles *next; - int ihandle; -}; - - -void -ofwconprobe() -{ -#if NVGAFB_PCI > 0 - char name[32]; - char iname[32]; - int len; - int stdout_node, stdin_node; - int err; - u_int32_t memtag, iotag; - struct ppc_pci_chipset pa; - struct { - u_int32_t phys_hi, phys_mid, phys_lo; - u_int32_t size_hi, size_lo; - } addr [8]; - - pa.pc_make_tag = &ofw_make_tag; - - stdout_node = OF_instance_to_package(OF_stdout); - len = OF_getprop(stdout_node, "name", name, 20); - name[len] = 0; - printf("console out [%s]", name); - cons_displaytype=1; - cons_display_ofh = OF_stdout; - err = OF_getprop(stdout_node, "width", &cons_width, 4); - if ( err != 4) { - cons_width = 0; - } - err = OF_getprop(stdout_node, "linebytes", &cons_linebytes, 4); - if ( err != 4) { - cons_linebytes = cons_width; - } - err = OF_getprop(stdout_node, "height", &cons_height, 4); - if ( err != 4) { - cons_height = 0; - } - err = OF_getprop(stdout_node, "depth", &cons_depth, 4); - if ( err != 4) { - cons_depth = 0; - } - err = OF_getprop(stdout_node, "address", &cons_addr, 4); - if ( err != 4) { - OF_interpret("frame-buffer-adr", 1, &cons_addr); - } - - stdin_node = OF_instance_to_package(OF_stdin); - len = OF_getprop(stdin_node, "name", iname, 20); - iname[len] = 0; - printf("console in [%s] ", iname); - /* what to do about serial console? */ - if (strcmp ("keyboard", iname) == 0) { - struct usb_kbd_ihandles *ukbds; -#if NAKBD > 0 - int akbd; -#endif - /* if there is a usb keyboard, we want it, do not - * dereference the pointer that is returned - */ - if (OF_call_method("`usb-kbd-ihandles", OF_stdin, 0, 1, &ukbds) - != -1 && ukbds != NULL) - { - printf("USB"); - ukbd_cnattach(); - goto kbd_found; - } -#if NAKBD > 0 - if (OF_call_method("`adb-kbd-ihandle", OF_stdin, 0, 1, &akbd) - != -1 && - akbd != 0 && - OF_instance_to_package(akbd) != -1) - { - printf("ADB"); - akbd_cnattach(); - goto kbd_found; - } -#endif - panic("no console keyboard"); -kbd_found: - } - printf("\n"); - - len = OF_getprop(stdout_node, "assigned-addresses", addr, sizeof(addr)); - if (len == -1) { - int node; - node = OF_parent(stdout_node); - len = OF_getprop(node, "name", name, 20); - name[len] = 0; - - printf("using parent %s:", name); - len = OF_getprop(node, "assigned-addresses", - addr, sizeof(addr)); - if (len < sizeof(addr[0])) { - panic(": no address\n"); - } - } - memtag = ofw_make_tag(NULL, pcibus(addr[0].phys_hi), - pcidev(addr[0].phys_hi), - pcifunc(addr[0].phys_hi)); - iotag = ofw_make_tag(NULL, pcibus(addr[1].phys_hi), - pcidev(addr[1].phys_hi), - pcifunc(addr[1].phys_hi)); - -#if 1 - printf(": memaddr %x size %x, ", addr[0].phys_lo, addr[0].size_lo); - printf(": consaddr %x, ", cons_addr); - printf(": ioaddr %x, size %x", addr[1].phys_lo, addr[1].size_lo); - printf(": memtag %x, iotag %x", memtag, iotag); - printf(": cons_width %d cons_linebytes %d cons_height %d\n", - cons_width, cons_linebytes, cons_height); -#endif - - { - int i; - - cons_membus->bus_base = 0x80000000; - cons_membus->bus_reverse = 1; -#if 0 - err = bus_space_map( cons_membus, cons_addr, addr[0].size_lo, - 0, &cons_display_mem_h); - printf("mem map err %x",err); - bus_space_map( cons_membus, addr[1].phys_lo, addr[1].size_lo, - 0, &cons_display_ctl_h); -#endif - - vgafb_pci_console(cons_membus, - addr[1].phys_lo, addr[1].size_lo, - cons_membus, - cons_addr, addr[0].size_lo, - &pa, pcibus(addr[1].phys_hi), pcidev(addr[1].phys_hi), - pcifunc(addr[1].phys_hi)); - -#if 1 - for (i = 0; i < cons_linebytes * cons_height; i++) { - bus_space_write_1(cons_membus, - cons_display_mem_h, i, 0); - - } -#endif - } -#endif -} diff --git a/sys/arch/powerpc/powerpc/ofwreal.S b/sys/arch/powerpc/powerpc/ofwreal.S deleted file mode 100644 index 01fa1f42452..00000000000 --- a/sys/arch/powerpc/powerpc/ofwreal.S +++ /dev/null @@ -1,450 +0,0 @@ -/* $OpenBSD: ofwreal.S,v 1.5 1999/07/05 20:56:26 rahnds 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 31 /* save return address */ - - mr 13,6 /* save args (only pointer used) */ - lis 8,ofentry@ha - stw 5,ofentry@l(8) /* save virtual mode firmware entry */ - - lis 4,fwcall@ha /* call ofw directly until vm setup */ - stw 5,fwcall@l(4) - - mfmsr 5 - lis 4,_C_LABEL(ofmsr)@ha /* save msr from openfirmware */ - stw 5,_C_LABEL(ofmsr)@l(4) -#if 0 - lis 0,(0x80001ffe)@ha - addi 0,0,(0x80001ffe)@l - mtdbatu 0,0 - lis 0,(0x80000022)@ha - addi 0,0,(0x80000022)@l - mtdbatl 0,0 -#endif - - lis 3,fwsave@ha /* save the mmu values of the firmware */ - addi 3,3,fwsave@l - lis 4,fwbatsave@ha - addi 4,4,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 3,fwbatsave@ha - addi 3,3,fwbatsave@l - li 4,64 - li 5,0 -1: subi 4,4,4 - stwx 5,4,3 - cmpi 4,0,0 - bne 1b -#endif - - mr 6,13 /* restore args pointer */ - mtlr 31 /* restore return address */ - blr - -/* - * Save everyting related to the mmu to the saveare pointed to by r3. - */ - .type savemmu,@function -savemmu: - - mr 6,4 /* r4 holds pointer to BAT save area */ - - li 4,0 /* save SRs */ -1: - addis 4,4,-0x10000000@ha - or. 4,4,4 - mfsrin 5,4 - stwu 5,4(3) - bne 1b - - mfibatl 4,0 /* save BATs */ - stw 4,0(6) - mfibatu 4,0 - stw 4,4(6) - mfibatl 4,1 - stw 4,8(6) - mfibatu 4,1 - stw 4,0xc(6) - mfibatl 4,2 - stw 4,0x10(6) - mfibatu 4,2 - stw 4,0x14(6) - mfibatl 4,3 - stw 4,0x18(6) - mfibatu 4,3 - stw 4,0x1c(6) - mfdbatl 4,0 - stw 4,0x20(6) - mfdbatu 4,0 - stw 4,0x24(6) - mfdbatl 4,1 - stw 4,0x28(6) - mfdbatu 4,1 - stw 4,0x2c(6) - mfdbatl 4,2 - stw 4,0x30(6) - mfdbatu 4,2 - stw 4,0x34(6) - mfdbatl 4,3 - stw 4,0x38(6) - mfdbatu 4,3 - stw 4,0x3c(6) - - mfsprg 4,0 /* save SPRGs */ - stw 4,4(3) - mfsprg 4,1 - stw 4,8(3) - mfsprg 4,2 - stw 4,12(3) - mfsprg 4,3 - stw 4,16(3) - - mfsdr1 4 /* save SDR1 */ - stw 4,20(3) - - addi 4,3,24 - - mfmsr 4 - stw 4,24(3) - - 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 0,0 - mtmsr 0 - mr 6,4 /* pointer to sr to restore */ - li 4,0 /* restore SRs */ -1: - lwzu 5,4(3) - addis 4,4,-0x10000000@ha - or. 4,4,4 - mtsrin 5,4 - bne 1b - - mfmsr 4 - lis 5,(PSL_IR|PSL_DR)@h /* turn off MMU */ - ori 5,5,(PSL_IR|PSL_DR)@l /* turn off MMU */ - andc 4,4,5 /* turn off MMU */ - mtmsr 4 - isync - - li 4,0 /* first, invalidate BATs */ - mtibatu 0,4 - mtibatu 1,4 - mtibatu 2,4 - mtibatu 3,4 - mtdbatu 0,4 - mtdbatu 1,4 - mtdbatu 2,4 - mtdbatu 3,4 - - lwz 4,0(6) - mtibatl 0,4 /* restore BATs */ - lwz 4,4(6) - mtibatu 0,4 - lwz 4,8(6) - mtibatl 1,4 - lwz 4,12(6) - mtibatu 1,4 - lwz 4,16(6) - mtibatl 2,4 - lwz 4,20(6) - mtibatu 2,4 - lwz 4,24(6) - mtibatl 3,4 - lwz 4,28(6) - mtibatu 3,4 - lwz 4,32(6) - mtdbatl 0,4 - lwz 4,36(6) - mtdbatu 0,4 - lwz 4,40(6) - mtdbatl 1,4 - lwz 4,44(6) - mtdbatu 1,4 - lwz 4,48(6) - mtdbatl 2,4 - lwz 4,52(6) - mtdbatu 2,4 - lwz 4,56(6) - mtdbatl 3,4 - lwz 4,60(6) - mtdbatu 3,4 - - lwz 4,4(3) - mtsprg 0,4 /* restore SPRGs */ - lwz 4,8(3) - mtsprg 1,4 - lwz 4,12(3) - mtsprg 2,4 - lwz 4,16(3) - mtsprg 3,4 - - sync /* remove everything from tlb */ - lis 4,0x40000@ha - li 5,0x1000 -1: - subf. 4,5,4 - tlbie 4 - bne 1b - - sync - tlbsync - sync - - lwz 4,20(3) - sync - mtsdr1 4 /* restore SDR1 */ - - - /* tlbia */ - sync - li 5,0x40 - mtctr 5 - li 4,0 - 1: - tlbie 4 - addi 4,4,0x1000 - bdnz 1b - sync - tlbsync - sync - - lwz 4,24(3) - mtmsr 4 - isync - - blr - - -_ENTRY(_C_LABEL(fwentry)) - stwu 1,-16(1) - mflr 4 - stw 4,20(1) - stw 3,12(1) /* save arg */ - - lis 3,clsave@ha /* save mmu values of client */ - addi 3,3,clsave@l - lis 4,clbatsave@ha /* save mmu values of client */ - addi 4,4,clbatsave@l - bl savemmu - - lis 3,fwsave@ha /* restore mmu values of firmware */ - addi 3,3,fwsave@l - lis 4,fwbatsave@ha - addi 4,4,fwbatsave@l - bl restoremmu - - lis 3,ofentry@ha - lwz 3,ofentry@l(3) /* get actual firmware entry */ - mtlr 3 - - mfmsr 4 - ori 4,4,PSL_IR|PSL_DR /* turn on MMU */ - mtmsr 4 - isync - - lwz 3,12(1) /* restore arg */ - blrl /* do actual firmware call */ - - stw 3,12(1) /* save return value */ - - lis 3,fwsave@ha /* save mmu values of firmare */ - addi 3,3,fwsave@l /* (might not be necessary, but... */ - lis 4,fwbatsave@ha - addi 4,4,fwbatsave@l - bl savemmu - - lis 3,clsave@ha /* restore mmu values of client */ - addi 3,3,clsave@l - lis 4,clbatsave@ha /* save mmu values of client */ - addi 4,4,clbatsave@l - bl restoremmu - - lwz 4,20(1) - lwz 3,12(1) /* restore return value */ - - mtlr 4 - addi 1,1,16 - blr - -/* - * OpenFirmware entry point - */ -_ENTRY(_C_LABEL(openfirmware)) - stwu 1,-16(1) - mflr 0 /* save return address */ - stw 0,20(1) - - lis 4,fwcall@ha - lwz 4,fwcall@l(4) - - mtlr 4 - blrl - - lwz 0,20(1) - mtlr 0 - lwz 1,0(1) - 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 8 /* turn off interrupts */ - andi. 0,8,~(PSL_EE|PSL_RI)@l - mtmsr 0 - stw 8,4(1) /* abuse return address slot */ - - lwz 5,0(1) /* get length of stack frame */ - subf 5,1,5 - - lis 7,firmstk+NBPG-8@ha - addi 7,7,firmstk+NBPG-8@l - li 6,0xf - andc 7,7,6 - lis 6,ofw_back@ha - addi 6,6,ofw_back@l - subf 4,5,7 /* make room for stack frame on new stack */ - stwu 1,-16(7) - stw 6,4(7) /* setup return pointer */ - - stw 7,-16(4) - - addi 3,1,8 - addi 1,4,-16 - subi 5,5,8 - subi 4,4,8 - - b _C_LABEL(ofbcopy) /* and copy it */ - - .type ofw_back,@function -ofw_back: - lwz 1,0(1) /* get callers original stack pointer */ - - lwz 0,4(1) /* get saved msr from abused slot */ - mtmsr 0 - - lwz 1,0(1) /* return */ - lwz 0,4(1) - mtlr 0 - blr - diff --git a/sys/arch/powerpc/powerpc/opendev.c b/sys/arch/powerpc/powerpc/opendev.c deleted file mode 100644 index f8f72452ccd..00000000000 --- a/sys/arch/powerpc/powerpc/opendev.c +++ /dev/null @@ -1,347 +0,0 @@ -/* $OpenBSD: opendev.c,v 1.5 2001/08/18 21:59:48 drahn 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 <machine/psl.h> -#include <machine/stdarg.h> - -#include <dev/ofw/openfirm.h> -#include <lib/libkern/libkern.h> - -extern void ofw_stack __P((void)); -extern void ofbcopy __P((const void *, void *, size_t)); - -int -OF_instance_to_package(ihandle) - 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(phandle, buf, buflen) - 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 -#ifdef __STDC__ -OF_call_method(char *method, int ihandle, int nargs, int nreturns, ...) -#else -OF_call_method(method, ihandle, nargs, nreturns, va_alist) - char *method; - int ihandle; - int nargs; - int nreturns; - va_dcl -#endif -{ - 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) - return -1; - if (args.args_n_results[nargs]) - 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 -#ifdef __STDC__ -OF_call_method_1(char *method, int ihandle, int nargs, ...) -#else -OF_call_method_1(method, ihandle, nargs, va_alist) - char *method; - int ihandle; - int nargs; - va_dcl -#endif -{ - 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(dname) - 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(handle) - 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(handle, addr, len) - 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(handle, addr, len) - 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(handle, pos) - 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/powerpc/powerpc/openfirm.c b/sys/arch/powerpc/powerpc/openfirm.c deleted file mode 100644 index ad27988930b..00000000000 --- a/sys/arch/powerpc/powerpc/openfirm.c +++ /dev/null @@ -1,279 +0,0 @@ -/* $OpenBSD: openfirm.c,v 1.8 2001/06/24 23:29:36 drahn 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 <machine/psl.h> -#include <machine/stdarg.h> - -#include <dev/ofw/openfirm.h> - -extern void ofw_stack __P((void)); -extern void ofbcopy __P((const void *, void *, size_t)); - -int -OF_peer(phandle) - 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(phandle) - 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(phandle) - 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(handle, prop, buf, buflen) - 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(name) - 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(bootspec) - 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(bootspec) - 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); -} - -/* XXX What is the reason to have this instead of bcopy/memcpy? */ -void -ofbcopy(src, dst, len) - 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/powerpc/powerpc/random.c b/sys/arch/powerpc/powerpc/random.c deleted file mode 100644 index 0dc2a42627d..00000000000 --- a/sys/arch/powerpc/powerpc/random.c +++ /dev/null @@ -1,88 +0,0 @@ -/* $OpenBSD: random.c,v 1.2 1997/10/13 13:43:00 pefo Exp $ */ - -/* - * Copyright (c) 1990,1993 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: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Here is a very good random number generator. This implementation is - * based on ``Two Fast Implementations of the "Minimal Standard" Random - * Number Generator'', David G. Carta, Communications of the ACM, Jan 1990, - * Vol 33 No 1. Do NOT modify this code unless you have a very thorough - * understanding of the algorithm. It's trickier than you think. If - * you do change it, make sure that its 10,000'th invocation returns - * 1043618065. - * - * Here is easier-to-decipher pseudocode: - * - * p = (16807*seed)<30:0> # e.g., the low 31 bits of the product - * q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32 - * if (p + q < 2^31) - * seed = p + q - * else - * seed = ((p + q) & (2^31 - 1)) + 1 - * return (seed); - * - * The result is in (0,2^31), e.g., it's always positive. - */ -#if 0 -#include <machine/asm.h> - - .data - .globl _C_SYMBOL(_randseed) -_C_SYMBOL(_randseed): - .long 1 - .text -ENTRY(random) -# movl #16807, d0 - lis r5, 1 - ori r5, r5, 0x6807 - lis r4, _C_SYMBOL(_randseed)@h - lwz r6, _C_SYMBOL(_randseed)@l(r4) -# mulsl __randseed, d1:d0 - mulhw r7, r6, r5 - mulhw r8, r6, r5 - -# lsll #1, d0 -# roxll #2, d1 -# addl d1, d0 -# moveql #1, d1 -# addxl d1, d0 -# lsrl #1, d0 - lis r4, _C_SYMBOL(_randseed)@h - stw r6, _C_SYMBOL(_randseed)@l(r4) -# movl d0, __randseed -# rts -#endif - -extern int _randseed; -int -random() -{ - long long value; - int p, q; - value = 16807 * _randseed; - p = value & (long long) (0xffffffff); - q = (value >> 32) & (long long) (0xffffffff); - if (((long long) p + q) < 0x3fffffff) { - _randseed = p + q; - } else { - _randseed = (int)(((long long)p + q ) & 0x3ffffffe) +1; - } - return _randseed; -} diff --git a/sys/arch/powerpc/powerpc/swapgeneric.c b/sys/arch/powerpc/powerpc/swapgeneric.c deleted file mode 100644 index ef2bd031930..00000000000 --- a/sys/arch/powerpc/powerpc/swapgeneric.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: swapgeneric.c,v 1.3 1997/10/13 13:43:01 pefo Exp $ */ -/* $NetBSD: swapgeneric.c,v 1.1 1996/09/30 16:34:55 ws Exp $ */ - -/*- - * Copyright (c) 1994 - * 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. 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. - * - * @(#)swapgeneric.c 8.2 (Berkeley) 3/21/94 - */ - -/* - * fake swapgeneric.c -- should do this differently. - */ - -#include <sys/param.h> -#include <sys/conf.h> - -int (*mountroot) __P((void *)) = NULL; /* tells autoconf.c that we are "generic" */ - -dev_t rootdev = NODEV; -dev_t dumpdev = NODEV; - -struct swdevt swdevt[] = { - { NODEV, 0, 0 }, /* Setup by autoconf.c/disksubr.c */ - { NODEV, 0, 0 }, - { NODEV, 0, 0 }, - { NODEV, 0, 0 }, -}; diff --git a/sys/arch/powerpc/powerpc/wscons_machdep.c b/sys/arch/powerpc/powerpc/wscons_machdep.c deleted file mode 100644 index 4abb121f1ab..00000000000 --- a/sys/arch/powerpc/powerpc/wscons_machdep.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $OpenBSD: wscons_machdep.c,v 1.2 2001/06/24 23:29:37 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Aaron Campbell. - * 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 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" -#if NWSDISPLAY > 0 -#include <dev/wscons/wsdisplayvar.h> -#endif -#include <dev/wscons/wskbdvar.h> - -void wscnprobe __P((struct consdev *)); -void wscninit __P((struct consdev *)); -void wscnputc __P((dev_t, char)); -int wscngetc __P((dev_t)); -void wscnpollc __P((dev_t, int)); - -void -wscnprobe(cp) - 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(cp) - struct consdev *cp; -{ - return; -} - -void -wscnputc(dev, i) - dev_t dev; - char i; -{ - wsdisplay_cnputc(dev, (int)i); -} - -int -wscngetc(dev) - dev_t dev; -{ - return (wskbd_cngetc(dev)); -} - -void -wscnpollc(dev, on) - dev_t dev; - int on; -{ - wskbd_cnpollc(dev, on); -} |