summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDale S. Rahn <rahnds@cvs.openbsd.org>1999-11-09 00:20:43 +0000
committerDale S. Rahn <rahnds@cvs.openbsd.org>1999-11-09 00:20:43 +0000
commit3696a3fc1ae0aa6db62a06bf7c2059a41121b9f4 (patch)
tree2791c04e433868073859e7a2e5b6054f354f870e /sys
parenta0c38839ca98a5741d0ef994bcfd7630a68cae41 (diff)
autoconf.c:
calculate delay time for delay() before it is acutally used. add support for md_diskconf come closer to supporting crashdumps, eventually this code should be un if 0 ed and supported. add the wd device as a supported device, fix some comments. clock.c: support calculation of delay loop earlier, do the spin loop correcly, unsigned math on the lower half, not signed math. conf.c: addd support for wd driver, block major 0, char major 11. machdep.c: bus_space_map becomes a real function, not just inlined function. Support devices that are not mapped with bats (most still currently are mapped with bats,...). BAT mapping does not allow proper mapping of cachable devices. mapiodev HACK, NEEDS TO BE REMOVED. added for quicker import of BROKEN mac drivers. the drivers NEED to be rewritten in a busified manner. it would FIX all of the endian swabbing done by each driver. (Is that emphasized enough?) bus_space_(read|write)_raw_multi as functions, should these be turned into inline functions and put in bus.h? ofw_machdep.c: removed extranious variable. openfirm.c: telling openfirmware to "boot" will put the system in somewhat of a strange state, try reset-all, but that typically fails, therefore, try OF_exit before spinning. pmap.c: support stealing memory from kernel address space so that mappings can be created before vm is initalized. vm_machdep.c: maybe the meaning of removing this will later become obvious. ???
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/powerpc/powerpc/autoconf.c90
-rw-r--r--sys/arch/powerpc/powerpc/clock.c30
-rw-r--r--sys/arch/powerpc/powerpc/conf.c13
-rw-r--r--sys/arch/powerpc/powerpc/machdep.c330
-rw-r--r--sys/arch/powerpc/powerpc/ofw_machdep.c3
-rw-r--r--sys/arch/powerpc/powerpc/openfirm.c24
-rw-r--r--sys/arch/powerpc/powerpc/pmap.c8
-rw-r--r--sys/arch/powerpc/powerpc/vm_machdep.c5
8 files changed, 444 insertions, 59 deletions
diff --git a/sys/arch/powerpc/powerpc/autoconf.c b/sys/arch/powerpc/powerpc/autoconf.c
index 97fc7b4b99f..3e87a6831ee 100644
--- a/sys/arch/powerpc/powerpc/autoconf.c
+++ b/sys/arch/powerpc/powerpc/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.7 1998/08/22 18:31:52 rahnds Exp $ */
+/* $OpenBSD: autoconf.c,v 1.8 1999/11/09 00:20:41 rahnds Exp $ */
/*
* Copyright (c) 1996, 1997 Per Fogelstrom
* Copyright (c) 1995 Theo de Raadt
@@ -41,7 +41,7 @@
* from: Utah Hdr: autoconf.c 1.31 91/01/21
*
* from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93
- * $Id: autoconf.c,v 1.7 1998/08/22 18:31:52 rahnds Exp $
+ * $Id: autoconf.c,v 1.8 1999/11/09 00:20:41 rahnds Exp $
*/
/*
@@ -73,6 +73,7 @@ struct device * getdevunit __P((char *, int));
static struct devmap * findtype __P((char **));
void makebootdev __P((char *cp));
int getpno __P((char **));
+void diskconf();
/*
* The following several variables are related to
@@ -91,6 +92,8 @@ void
configure()
{
(void)splhigh(); /* To be really sure.. */
+ calc_delayconst();
+
/*
if(system_type == OFWMACH) {
ofrootfound();
@@ -100,9 +103,39 @@ configure()
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();
- cold = 0;
+#if 0
+ dumpconf();
+#endif
}
/*
@@ -129,12 +162,59 @@ swapconf()
#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 }, /* 2 = ofdisk */
+ { "ofdisk", 4 }, /* 4 = ofdisk */
};
static int
@@ -468,7 +548,7 @@ findtype(s)
}
/*
- * Look at the string 'cp' and decode the boot device.
+ * Look at the string 'bp' and decode the boot device.
* Boot names look like: '/pci/scsi@c/disk@0,0/bsd'
*/
void
diff --git a/sys/arch/powerpc/powerpc/clock.c b/sys/arch/powerpc/powerpc/clock.c
index 27c8149319d..8cce28d6904 100644
--- a/sys/arch/powerpc/powerpc/clock.c
+++ b/sys/arch/powerpc/powerpc/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.4 1998/08/25 07:46:58 pefo Exp $ */
+/* $OpenBSD: clock.c,v 1.5 1999/11/09 00:20:41 rahnds Exp $ */
/* $NetBSD: clock.c,v 1.1 1996/09/30 16:34:40 ws Exp $ */
/*
@@ -37,7 +37,9 @@
#include <machine/pio.h>
+#if 0
#include <powerpc/pci/mpc106reg.h>
+#endif
void resettodr();
/*
@@ -64,7 +66,7 @@ typedef int (clock_read_t)(int *sec, int *min, int *hour, int *day,
int power4e_getclock(int *, int *, int *, int *, int *, int *);
-clock_read_t *clock_read = power4e_getclock;
+clock_read_t *clock_read = NULL;
static u_long
chiptotime(int sec, int min, int hour, int day, int mon, int year);
@@ -222,6 +224,17 @@ decr_intr(frame)
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;
@@ -241,8 +254,6 @@ cpu_initclocks()
: "=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 ("mftb %0" : "=r"(lasttb));
- asm volatile ("mtdec %0" :: "r"(ticks_per_intr));
asm volatile ("mtmsr %0" :: "r"(msr));
break;
}
@@ -264,7 +275,7 @@ mftb()
u_long scratch;
u_quad_t tb;
- asm ("1: mftbu %0; mftb %0+1; mftbu %1; cmpw %0,%1; bne 1b"
+ asm ("1: mftbu %0; mftb %0+1; mftbu %1; cmpw 0,%0,%1; bne 1b"
: "=r"(tb), "=r"(scratch));
return tb;
}
@@ -295,7 +306,7 @@ microtime(tvp)
}
/*
- * Wait for about n microseconds (at least!).
+ * Wait for about n microseconds (us) (at least!).
*/
void
delay(n)
@@ -308,8 +319,11 @@ delay(n)
tb += (n * 1000 + ns_per_tick - 1) / ns_per_tick;
tbh = tb >> 32;
tbl = tb;
- asm ("1: mftbu %0; cmpw %0,%1; blt 1b; bgt 2f; mftb %0; cmpw %0,%2; blt 1b; 2:"
+ 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();
}
/*
@@ -323,6 +337,7 @@ setstatclockrate(arg)
}
+#if 0
int
power4e_getclock(sec, min, hour, day, mon, year)
int *sec;
@@ -344,3 +359,4 @@ power4e_getclock(sec, min, hour, day, mon, year)
outb(clkbase, inb(clkbase) & ~0x40);
return(0);
}
+#endif
diff --git a/sys/arch/powerpc/powerpc/conf.c b/sys/arch/powerpc/powerpc/conf.c
index 2768cb6ed33..1f227f1b12f 100644
--- a/sys/arch/powerpc/powerpc/conf.c
+++ b/sys/arch/powerpc/powerpc/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.13 1998/09/27 03:56:00 rahnds Exp $ */
+/* $OpenBSD: conf.c,v 1.14 1999/11/09 00:20:42 rahnds Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -40,6 +40,8 @@
#include <sys/tty.h>
#include <sys/vnode.h>
+#include "wd.h"
+bdev_decl(wd);
#include "sd.h"
bdev_decl(sd);
bdev_decl(sw);
@@ -58,7 +60,7 @@ bdev_decl(vnd);
bdev_decl(ccd);
struct bdevsw bdevsw[] = {
- bdev_notdef(), /* 0 */
+ 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 */
@@ -128,6 +130,9 @@ cdev_decl(vnd);
cdev_decl(ccd);
cdev_decl(rd);
+#include <wd.h>
+cdev_decl(wd);
+
dev_decl(filedesc,open);
#include "bpfilter.h"
@@ -171,7 +176,7 @@ struct cdevsw cdevsw[] = {
cdev_disk_init(NSD,sd), /* 8: SCSI disk */
cdev_disk_init(NCD,cd), /* 9: SCSI CD-ROM */
cdev_notdef(), /* 10: SCSI changer */
- cdev_notdef(), /* 11 */
+ 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 */
@@ -261,7 +266,7 @@ static int chrtoblktbl[] = {
/* 8 */ 2,
/* 9 */ NODEV,
/* 10 */ NODEV,
- /* 11 */ NODEV,
+ /* 11 */ 0,
/* 12 */ NODEV,
/* 13 */ 4,
/* 14 */ NODEV,
diff --git a/sys/arch/powerpc/powerpc/machdep.c b/sys/arch/powerpc/powerpc/machdep.c
index e0ce2ab6f5d..2f521753b11 100644
--- a/sys/arch/powerpc/powerpc/machdep.c
+++ b/sys/arch/powerpc/powerpc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.26 1999/10/28 04:28:03 rahnds Exp $ */
+/* $OpenBSD: machdep.c,v 1.27 1999/11/09 00:20:42 rahnds Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -46,6 +46,7 @@
#include <sys/reboot.h>
#include <sys/syscallargs.h>
#include <sys/syslog.h>
+#include <sys/extent.h>
#include <sys/systm.h>
#include <sys/user.h>
@@ -84,6 +85,7 @@ extern int cold;
struct bat battable[16];
int astpending;
+int ppc_malloc_ok = 0;
#ifndef SYS_TYPE
/* XXX Hardwire it for now */
@@ -98,6 +100,8 @@ char bootpathbuf[512];
struct firmware *fw = NULL;
+void ofw_dbg(char *str);
+
/*
* We use the page just above the interrupt vector as message buffer
*/
@@ -107,6 +111,17 @@ int msgbufmapped = 1; /* message buffer is always mapped */
caddr_t allocsys __P((caddr_t));
int power4e_get_eth_addr __P((void));
+/*
+ * 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_mapped = 0;
extern int OF_stdout;
extern int where;
@@ -132,7 +147,6 @@ initppc(startkernel, endkernel, args)
extern void callback __P((void *));
int exc, scratch;
-
proc0.p_addr = proc0paddr;
bzero(proc0.p_addr, sizeof *proc0.p_addr);
@@ -160,9 +174,10 @@ where = 3;
battable[0].batl = BATL(0x00000000, BAT_M);
battable[0].batu = BATU(0x00000000);
+#if 1
battable[1].batl = BATL(MPC106_V_ISA_IO_SPACE, BAT_I);
battable[1].batu = BATU(MPC106_P_ISA_IO_SPACE);
-#if 0
+ segment8_mapped = 1;
if(system_type == POWER4e) {
/* Map ISA I/O */
addbatmap(MPC106_V_ISA_IO_SPACE, MPC106_P_ISA_IO_SPACE, BAT_I);
@@ -184,9 +199,11 @@ where = 3;
__asm__ volatile ("mtdbatl 0,%0; mtdbatu 0,%1"
:: "r"(battable[0].batl), "r"(battable[0].batu));
+#if 1
__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
@@ -232,12 +249,6 @@ where = 3;
syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
- /*
- * Now enable translation (and machine checks/recoverable interrupts).
- */
- (fw->vmon)();
- #if 0
- #endif
vm_set_page_size();
@@ -246,6 +257,11 @@ where = 3;
*/
pmap_bootstrap(startkernel, endkernel);
+ /*
+ * 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));
@@ -287,6 +303,35 @@ where = 3;
}
}
+ /*
+ * 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);
+
+ ofwconprobe();
+
+ /*
+ * Now we can set up the console as mapping is enabled.
+ */
+ consinit();
+
#if NIPKDB > 0
/*
* Now trap to IPKDB
@@ -301,17 +346,15 @@ where = 3;
#endif
#endif
- ofwconprobe();
-
- /*
- * Now we can set up the console as mapping is enabled.
- */
- consinit();
-
- /*
* Figure out ethernet address.
*/
(void)power4e_get_eth_addr();
+
+}
+void ofw_dbg(char *str)
+{
+ int i = strlen (str);
+ OF_write(OF_stdout, str, i);
}
@@ -347,14 +390,14 @@ cpu_startup()
caddr_t v;
vm_offset_t minaddr, maxaddr;
int base, residual;
+ v = (caddr_t)proc0paddr + USPACE;
proc0.p_addr = proc0paddr;
- v = (caddr_t)proc0paddr + USPACE;
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.
@@ -364,7 +407,7 @@ cpu_startup()
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.
@@ -404,6 +447,7 @@ cpu_startup()
*/
phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, TRUE);
+ ppc_malloc_ok = 1;
/*
* Allocate mbuf pool.
@@ -425,6 +469,7 @@ cpu_startup()
printf("using %d buffers containing %d bytes of memory\n",
nbuf, bufpages * CLBYTES);
+
/*
* Set up the buffers.
*/
@@ -433,6 +478,7 @@ cpu_startup()
/*
* Configure devices.
*/
+ devio_malloc_safe = 1;
configure();
/*
@@ -672,13 +718,6 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
}
}
-/*
- * Crash dump handling.
- */
-u_long dumpmag = 0x8fca0101; /* magic number */
-int dumpsize = 0; /* size of dump in pages */
-long dumplo = -1; /* blocks */
-
void
dumpsys()
{
@@ -873,6 +912,7 @@ systype(char *name)
{ "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},
{ NULL,"",0}
};
for (i = 0; systypes[i].name != NULL; i++) {
@@ -945,6 +985,151 @@ ppc_intr_disable(void)
__asm__ volatile("mtmsr %0" :: "r"(dmsr));
}
+/* 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 (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;
+}
+void bus_space_unmap __P((bus_space_tag_t t, bus_space_handle_t bsh,
+ bus_size_t size));
+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;
+
+ kmem_free_wakeup(phys_map, sva, len);
+#ifdef DESTROY_MAPPINGS
+ for (; len > 0; len -= NBPG) {
+ pmap_enter(vm_map_pmap(phys_map), vaddr, sva,
+ VM_PROT_READ | VM_PROT_WRITE, TRUE);
+ sva += NBPG;
+ vaddr += NBPG;
+ }
+#endif
+
+}
+
+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 (epa <= spa) {
+ panic("bus_mem_add_mapping: overflow");
+ }
+ if (ppc_malloc_ok == 0) {
+ bus_size_t alloc_size;
+
+ /* need to steal vm space before kernel vm is initialized */
+ alloc_size = trunc_page(size + NBPG);
+ ppc_kvm_size -= alloc_size;
+
+ vaddr = VM_MIN_KERNEL_ADDRESS + ppc_kvm_size;
+ } else {
+ vaddr = kmem_alloc_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 -= NBPG) {
+#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, TRUE, 0/* XXX */);
+ spa += NBPG;
+ vaddr += NBPG;
+ }
+ return 0;
+}
+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);
+ va = vaddr = kmem_alloc(phys_map, size);
+
+ if (va == 0)
+ return NULL;
+
+ if (pa >= 0x80000000 && pa+len < 0x90000000) {
+ extern int segment8_mapped;
+ if (segment8_mapped) {
+ return (void *)pa;
+ }
+ }
+ for (; size > 0; size -= NBPG) {
+#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, TRUE, 0/* XXX */);
+ spa += NBPG;
+ vaddr += NBPG;
+ }
+ return (void*) (va+off);
+}
+
/*
* probably should be ppc_space_copy
*/
@@ -982,9 +1167,13 @@ 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) \
+__C(bus_space_set_region_,BYTES)(v, h, o, val, c) \
+ void *v; \
+ bus_space_handle_t h; \
+ TYPE val; \
+ bus_size_t c; \
{ \
- TYPE *src, *dst; \
+ TYPE *dst; \
int i; \
\
dst = (TYPE *) (h+o); \
@@ -996,3 +1185,86 @@ __C(bus_space_set_region_,BYTES)(v, h, o, val, c) \
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; \
+ TYPE *dst; \
+ bus_size_t size; \
+{ \
+ TYPE *src; \
+ int i; \
+ int count = size >> SHIFT; \
+ \
+ src = (TYPE *)(h+o); \
+ for (i = 0; i < count; i++) { \
+ dst[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 TYPE *src; \
+ bus_size_t size; \
+{ \
+ int i; \
+ TYPE *dst; \
+ int count = size >> SHIFT; \
+ \
+ dst = (TYPE *)(h+o); \
+ for (i = 0; i < count; i++) { \
+ *dst = src[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);
+}
diff --git a/sys/arch/powerpc/powerpc/ofw_machdep.c b/sys/arch/powerpc/powerpc/ofw_machdep.c
index 8f2cb93b6ae..b8d7cbb707d 100644
--- a/sys/arch/powerpc/powerpc/ofw_machdep.c
+++ b/sys/arch/powerpc/powerpc/ofw_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_machdep.c,v 1.11 1999/09/03 18:01:49 art Exp $ */
+/* $OpenBSD: ofw_machdep.c,v 1.12 1999/11/09 00:20:42 rahnds Exp $ */
/* $NetBSD: ofw_machdep.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
/*
@@ -241,7 +241,6 @@ ofw_intr_init()
void
ofw_do_pending_int()
{
- struct intrhand *ih;
int vector;
int pcpl;
int hwpend;
diff --git a/sys/arch/powerpc/powerpc/openfirm.c b/sys/arch/powerpc/powerpc/openfirm.c
index 5a4d9393887..156eb3c70b3 100644
--- a/sys/arch/powerpc/powerpc/openfirm.c
+++ b/sys/arch/powerpc/powerpc/openfirm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: openfirm.c,v 1.5 1999/10/28 04:28:03 rahnds Exp $ */
+/* $OpenBSD: openfirm.c,v 1.6 1999/11/09 00:20:42 rahnds Exp $ */
/* $NetBSD: openfirm.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
/*
@@ -170,17 +170,16 @@ OF_finddevice(name)
}
void
-OF_boot(bootspec)
+OF_rboot(bootspec)
char *bootspec;
{
static struct {
char *name;
int nargs;
int nreturns;
- char *bootspec;
} args = {
- "boot",
- 1,
+ "reset-all",
+ 0,
0,
};
int l;
@@ -188,11 +187,20 @@ OF_boot(bootspec)
if ((l = strlen(bootspec)) >= NBPG)
panic("OF_boot");
ofw_stack();
- ofbcopy(bootspec, OF_buf, l + 1);
- args.bootspec = OF_buf;
openfirmware(&args);
+ /* will attempt exit in OF_boot */
+}
+
+void OF_exit();
+
+void
+OF_boot(bootspec)
+ char *bootspec;
+{
+ OF_rboot(bootspec);
printf ("OF_boot returned!"); /* just in case */
- while (1);
+ OF_exit();
+ while(1);
}
void
diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c
index a70c9cee7b4..46fc66ec537 100644
--- a/sys/arch/powerpc/powerpc/pmap.c
+++ b/sys/arch/powerpc/powerpc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.12 1999/10/28 04:28:03 rahnds Exp $ */
+/* $OpenBSD: pmap.c,v 1.13 1999/11/09 00:20:42 rahnds Exp $ */
/* $NetBSD: pmap.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
/*
@@ -529,6 +529,8 @@ pmap_page_index(pa)
return -1;
}
+vm_offset_t ppc_kvm_size = VM_KERN_ADDR_SIZE_DEF;
+
/*
* How much virtual space is available to the kernel?
*/
@@ -540,7 +542,7 @@ pmap_virtual_space(start, end)
* Reserve one segment for kernel virtual memory
*/
*start = (vm_offset_t)(KERNEL_SR << ADDR_SR_SHFT);
- *end = *start + SEGMENT_LENGTH;
+ *end = *start + VM_KERN_ADDRESS_SIZE;
}
/*
@@ -998,7 +1000,7 @@ pmap_enter(pm, va, pa, prot, wired, access_type)
pte.pte_lo |= PTE_RW;
else
pte.pte_lo |= PTE_RO;
-
+
/*
* Now record mapping for later back-translation.
*/
diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c
index 20239aadef3..f6170f02552 100644
--- a/sys/arch/powerpc/powerpc/vm_machdep.c
+++ b/sys/arch/powerpc/powerpc/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.8 1999/09/03 18:01:51 art Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.9 1999/11/09 00:20:42 rahnds Exp $ */
/* $NetBSD: vm_machdep.c,v 1.1 1996/09/30 16:34:57 ws Exp $ */
/*
@@ -65,6 +65,9 @@ cpu_fork(p1, p2, stack, stacksize)
*pcb = p1->p_addr->u_pcb;
pcb->pcb_pm = &p2->p_vmspace->vm_pmap;
+ /*
+ pcb->pcb_pm = &p2->p_vmspace->vm_map.pmap;
+ */
pcb->pcb_pmreal = (struct pmap *)pmap_extract(pmap_kernel(), (vm_offset_t)pcb->pcb_pm);
/*