diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-12-31 21:38:09 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-12-31 21:38:09 +0000 |
commit | ac70415760e796ddc49d0a3f42cef4d80e3cd79c (patch) | |
tree | 320bd94ef834f8806974e699f17f9347fc1ed7e8 /sys/arch/luna88k | |
parent | 0b6d62f095cb4dece152a6de03a65095436aed03 (diff) |
Massive overhauling of the m88k pmap, though I can't pretend it's a new pmap
since a large part of the structures and logic remains.
Since m88k has separate supervisor/user spaces, we can map physical memory 1:1
in supervisor space, and have the kernel virtual address space start from the
end of physical memory.
This allows us to switch to __HAVE_PMAP_DIRECT. And to get rid of the double
mapped sdt, since now their virtual and physical addresses will always match.
The upper bound of the kernel virtual memory space is now platform dependent,
until the code which relies upon some hardware devices being mapped 1:1 in
supervisor mode is updated to no longer require this (this is mainly a PITA on
luna88k, where onboard devices start at 0x40000000, leaving only 1GB of KVA at
the moment - still much better than the previous 512MB).
Tested on mvme88k only (187, 188, 197LE, 197DP). Other platforms ought to
work, aviion will be checked shortly and fixed if necessary. No known
OpenBSD/luna88k system in working condition at the moment.
Diffstat (limited to 'sys/arch/luna88k')
-rw-r--r-- | sys/arch/luna88k/conf/files.luna88k | 3 | ||||
-rw-r--r-- | sys/arch/luna88k/include/pmap.h | 10 | ||||
-rw-r--r-- | sys/arch/luna88k/include/vmparam.h | 10 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/machdep.c | 39 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/mem.c | 229 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/pmap_table.c | 58 |
6 files changed, 49 insertions, 300 deletions
diff --git a/sys/arch/luna88k/conf/files.luna88k b/sys/arch/luna88k/conf/files.luna88k index 86fee4aa4bc..6b0e37b63d7 100644 --- a/sys/arch/luna88k/conf/files.luna88k +++ b/sys/arch/luna88k/conf/files.luna88k @@ -1,4 +1,4 @@ -# $OpenBSD: files.luna88k,v 1.15 2010/12/06 20:10:18 jasper Exp $ +# $OpenBSD: files.luna88k,v 1.16 2010/12/31 21:38:08 miod Exp $ # maxpartitions 16 @@ -78,5 +78,4 @@ file arch/luna88k/luna88k/disksubr.c file arch/luna88k/luna88k/eh.S file arch/luna88k/luna88k/isr.c file arch/luna88k/luna88k/machdep.c -file arch/luna88k/luna88k/mem.c file arch/luna88k/luna88k/pmap_table.c diff --git a/sys/arch/luna88k/include/pmap.h b/sys/arch/luna88k/include/pmap.h index 7782e7ae394..e662d952774 100644 --- a/sys/arch/luna88k/include/pmap.h +++ b/sys/arch/luna88k/include/pmap.h @@ -1,11 +1,3 @@ -/* $OpenBSD: pmap.h,v 1.4 2004/07/25 11:06:41 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.5 2010/12/31 21:38:08 miod Exp $ */ /* public domain */ - -#ifndef _LUNA88K_PMAP_H_ -#define _LUNA88K_PMAP_H_ - #include <m88k/pmap.h> - -#define pmap_bootstrap_md(va) (va) - -#endif _LUNA88K_PMAP_H_ diff --git a/sys/arch/luna88k/include/vmparam.h b/sys/arch/luna88k/include/vmparam.h index d93bf092181..e1ff08cddf5 100644 --- a/sys/arch/luna88k/include/vmparam.h +++ b/sys/arch/luna88k/include/vmparam.h @@ -1,3 +1,11 @@ -/* $OpenBSD: vmparam.h,v 1.3 2004/04/26 14:31:08 miod Exp $ */ +/* $OpenBSD: vmparam.h,v 1.4 2010/12/31 21:38:08 miod Exp $ */ /* public domain */ +/* + * Physical memory is mapped 1:1 at the bottom of the supervisor address + * space. Kernel virtual memory space starts from the end of physical memory, + * up to the on-board devices appearing all over the last 3GB of address space. + */ +#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0x00000000) +#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0x40000000) + #include <m88k/vmparam.h> diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 26bf9a89155..988e9b42925 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.72 2010/06/27 12:41:23 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.73 2010/12/31 21:38:08 miod Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -173,8 +173,6 @@ struct nvram_t { char value[NVVALLEN]; } nvram[NNVSYM]; -vaddr_t obiova; - int physmem; /* available physical memory, in pages */ struct vm_map *exec_map = NULL; @@ -359,16 +357,6 @@ cpu_startup() int i; vaddr_t minaddr, maxaddr; - /* - * Initialize error message buffer (at end of core). - * avail_end was pre-decremented in luna88k_bootstrap() to compensate. - */ - for (i = 0; i < atop(MSGBUFSIZE); i++) - pmap_kenter_pa((paddr_t)msgbufp + i * PAGE_SIZE, - avail_end + i * PAGE_SIZE, VM_PROT_READ | VM_PROT_WRITE); - pmap_update(pmap_kernel()); - initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE)); - /* Determine the machine type from FUSE ROM data. */ get_fuse_rom_data(); if (strncmp(fuse_rom_data, "MNAME=LUNA88K+", 14) == 0) { @@ -441,17 +429,6 @@ cpu_startup() #endif /* - * Grab the OBIO space that we hardwired in pmap_bootstrap - */ - obiova = OBIO_START; - uvm_map(kernel_map, (vaddr_t *)&obiova, OBIO_SIZE, - NULL, UVM_UNKNOWN_OFFSET, 0, - UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, - UVM_ADV_NORMAL, UVM_FLAG_FIXED)); - if (obiova != OBIO_START) - panic("obiova %lx: OBIO not free", obiova); - - /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. */ @@ -979,16 +956,10 @@ luna88k_bootstrap() avail_start = first_addr; avail_end = last_addr; - /* - * Steal MSGBUFSIZE at the top of physical memory for msgbuf - */ - avail_end -= round_page(MSGBUFSIZE); - #ifdef DEBUG printf("LUNA88K boot: memory from 0x%x to 0x%x\n", avail_start, avail_end); #endif - pmap_bootstrap((vaddr_t)trunc_page((vaddr_t)&kernelstart)); /* * Tell the VM system about available physical memory. @@ -997,6 +968,14 @@ luna88k_bootstrap() uvm_page_physload(atop(avail_start), atop(avail_end), atop(avail_start), atop(avail_end),VM_FREELIST_DEFAULT); + /* + * Initialize message buffer. + */ + initmsgbuf((caddr_t)pmap_steal_memory(MSGBUFSIZE, NULL, NULL), + MSGBUFSIZE); + + pmap_bootstrap(); + /* Initialize the "u-area" pages. */ bzero((caddr_t)curpcb, USPACE); diff --git a/sys/arch/luna88k/luna88k/mem.c b/sys/arch/luna88k/luna88k/mem.c deleted file mode 100644 index 79d4f7e9ecc..00000000000 --- a/sys/arch/luna88k/luna88k/mem.c +++ /dev/null @@ -1,229 +0,0 @@ -/* $OpenBSD: mem.c,v 1.5 2007/12/09 13:14:53 miod Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1982, 1986, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)mem.c 8.3 (Berkeley) 1/12/94 - */ - -/* - * Memory special file - */ - -#include <sys/param.h> -#include <sys/buf.h> -#include <sys/systm.h> -#include <sys/uio.h> -#include <sys/malloc.h> - -#include <machine/board.h> -#include <machine/conf.h> - -#include <uvm/uvm_extern.h> - -caddr_t zpage; -extern vaddr_t last_addr; - -/*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; -{ - vaddr_t o, v; - int c; - struct iovec *iov; - int error = 0; - static int physlock = 0; - extern caddr_t vmmap; - - if (minor(dev) == 0) { - /* lock against other uses of shared vmmap */ - while (physlock > 0) { - physlock++; - error = tsleep((caddr_t)&physlock, PZERO | PCATCH, - "mmrw", 0); - if (error) - return (error); - } - physlock = 1; - } - 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: - /* move one page at a time */ - v = uio->uio_offset; - if (v > last_addr) { - error = EFAULT; - goto unlock; - } - pmap_enter(pmap_kernel(), (vaddr_t)vmmap, - trunc_page(v), - uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE, - (uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE) | PMAP_WIRED); - pmap_update(pmap_kernel()); - o = uio->uio_offset & PGOFSET; - c = min(uio->uio_resid, (int)(NBPG - o)); - error = uiomove((caddr_t)vmmap + o, c, uio); - pmap_remove(pmap_kernel(), (vaddr_t)vmmap, - (vaddr_t)vmmap + NBPG); - pmap_update(pmap_kernel()); - continue; - -/* minor device 1 is kernel memory */ - case 1: - v = uio->uio_offset; - c = min(iov->iov_len, MAXPHYS); - if (!uvm_kernacc((caddr_t)v, c, - uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) - return (EFAULT); - if (v < NBPG) { -#ifdef DEBUG - /* - * For now, return zeros on read of page 0 - * and EFAULT for writes. - */ - if (uio->uio_rw == UIO_READ) { - if (zpage == NULL) - zpage = malloc(PAGE_SIZE, - M_TEMP, M_WAITOK | M_ZERO); - c = min(c, NBPG - (int)v); - v = (vaddr_t)zpage; - } else -#endif - return (EFAULT); - } - 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); - -/* should add vme bus so that we can do user level probes */ - -/* 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 (zpage == NULL) - zpage = malloc(PAGE_SIZE, M_TEMP, - M_WAITOK | M_ZERO); - c = min(iov->iov_len, PAGE_SIZE); - error = uiomove(zpage, 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; - } - if (minor(dev) == 0) { -unlock: - if (physlock > 1) - wakeup((caddr_t)&physlock); - physlock = 0; - } - return (error); -} - -paddr_t -mmmmap(dev, off, prot) - dev_t dev; - off_t off; - int 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/luna88k/luna88k/pmap_table.c b/sys/arch/luna88k/luna88k/pmap_table.c index ca0db418392..bfa967156a3 100644 --- a/sys/arch/luna88k/luna88k/pmap_table.c +++ b/sys/arch/luna88k/luna88k/pmap_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_table.c,v 1.5 2005/04/27 14:07:36 miod Exp $ */ +/* $OpenBSD: pmap_table.c,v 1.6 2010/12/31 21:38:08 miod Exp $ */ /* * Mach Operating System @@ -41,38 +41,38 @@ #define CI CACHE_INH #define CG CACHE_GLOBAL -/* phys_start, virt_start, size, prot, cacheability */ +/* start, size, prot, cacheability */ const pmap_table_entry luna88k_board_table[] = { - { PROM_ADDR , PROM_ADDR , PROM_SPACE , R, CI }, - { FUSE_ROM_ADDR, FUSE_ROM_ADDR, FUSE_ROM_SPACE, RW, CI }, - { NVRAM_ADDR , NVRAM_ADDR , NVRAM_SPACE , RW, CI }, - { NVRAM_ADDR_88K2, NVRAM_ADDR_88K2, PAGE_SIZE, RW, CI }, - { OBIO_PIO0_BASE, OBIO_PIO0_BASE, PAGE_SIZE, RW, CI }, - { OBIO_PIO1_BASE, OBIO_PIO1_BASE, PAGE_SIZE, RW, CI }, - { OBIO_SIO , OBIO_SIO, PAGE_SIZE, RW, CI }, - { OBIO_TAS , OBIO_TAS, PAGE_SIZE, RW, CI }, - { OBIO_CLOCK0 , OBIO_CLOCK0, PAGE_SIZE, RW, CI }, - { INT_ST_MASK0 , INT_ST_MASK0, PAGE_SIZE, RW, CI }, - { SOFT_INT0 , SOFT_INT0, PAGE_SIZE, RW, CI }, - { SOFT_INT_FLAG0, SOFT_INT_FLAG0, PAGE_SIZE, RW, CI }, - { RESET_CPU0 , RESET_CPU0, PAGE_SIZE, RW, CI }, - { TRI_PORT_RAM, TRI_PORT_RAM, TRI_PORT_RAM_SPACE, RW, CI }, + { PROM_ADDR, PROM_SPACE, R, CI }, + { FUSE_ROM_ADDR, FUSE_ROM_SPACE, RW, CI }, + { NVRAM_ADDR, NVRAM_SPACE, RW, CI }, + { NVRAM_ADDR_88K2, PAGE_SIZE, RW, CI }, + { OBIO_PIO0_BASE, PAGE_SIZE, RW, CI }, + { OBIO_PIO1_BASE, PAGE_SIZE, RW, CI }, + { OBIO_SIO, PAGE_SIZE, RW, CI }, + { OBIO_TAS, PAGE_SIZE, RW, CI }, + { OBIO_CLOCK0, PAGE_SIZE, RW, CI }, + { INT_ST_MASK0, PAGE_SIZE, RW, CI }, + { SOFT_INT0, PAGE_SIZE, RW, CI }, + { SOFT_INT_FLAG0, PAGE_SIZE, RW, CI }, + { RESET_CPU0, PAGE_SIZE, RW, CI }, + { TRI_PORT_RAM, TRI_PORT_RAM_SPACE, RW, CI }, #if 0 - { EXT_A_ADDR , EXT_A_ADDR, EXT_A_SPACE, RW, CI }, - { EXT_B_ADDR , EXT_B_ADDR, EXT_B_SPACE, RW, CI }, - { PC_BASE , PC_BASE, PC_SPACE, RW, CI }, + { EXT_A_ADDR, EXT_A_SPACE, RW, CI }, + { EXT_B_ADDR, EXT_B_SPACE, RW, CI }, + { PC_BASE, PC_SPACE, RW, CI }, #endif - { MROM_ADDR , MROM_ADDR, MROM_SPACE, R, CI }, - { BMAP_START , BMAP_START, BMAP_SPACE, RW, CI }, - { BMAP_PALLET0 , BMAP_PALLET0, PAGE_SIZE, RW, CI }, - { BMAP_PALLET1 , BMAP_PALLET1, PAGE_SIZE, RW, CI }, - { BMAP_PALLET2 , BMAP_PALLET2, PAGE_SIZE, RW, CI }, - { BOARD_CHECK_REG, BOARD_CHECK_REG,PAGE_SIZE, RW, CI }, - { BMAP_CRTC, BMAP_CRTC, PAGE_SIZE, RW, CI }, - { SCSI_ADDR, SCSI_ADDR, PAGE_SIZE, RW, CI }, - { LANCE_ADDR, LANCE_ADDR, PAGE_SIZE, RW, CI }, - { 0, 0, 0xffffffff, 0, 0 }, + { MROM_ADDR, MROM_SPACE, R, CI }, + { BMAP_START, BMAP_SPACE, RW, CI }, + { BMAP_PALLET0, PAGE_SIZE, RW, CI }, + { BMAP_PALLET1, PAGE_SIZE, RW, CI }, + { BMAP_PALLET2, PAGE_SIZE, RW, CI }, + { BOARD_CHECK_REG, PAGE_SIZE, RW, CI }, + { BMAP_CRTC, PAGE_SIZE, RW, CI }, + { SCSI_ADDR, PAGE_SIZE, RW, CI }, + { LANCE_ADDR, PAGE_SIZE, RW, CI }, + { 0, 0xffffffff, 0, 0 }, }; pmap_table_t |