summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/powerpc/include/bus.h149
-rw-r--r--sys/arch/powerpc/include/vmparam.h10
-rw-r--r--sys/arch/powerpc/pci/macobio.c4
-rw-r--r--sys/arch/powerpc/pci/mpcpcibus.c8
-rw-r--r--sys/arch/powerpc/powerpc/copyinstr.c4
-rw-r--r--sys/arch/powerpc/powerpc/copyoutstr.c4
-rw-r--r--sys/arch/powerpc/powerpc/locore.S6
-rw-r--r--sys/arch/powerpc/powerpc/machdep.c123
-rw-r--r--sys/arch/powerpc/powerpc/mem.c3
-rw-r--r--sys/arch/powerpc/powerpc/pmap.c79
-rw-r--r--sys/arch/powerpc/powerpc/trap.c43
-rw-r--r--sys/arch/powerpc/powerpc/vm_machdep.c18
-rw-r--r--sys/arch/powerpc/stand/boot.c4
13 files changed, 415 insertions, 40 deletions
diff --git a/sys/arch/powerpc/include/bus.h b/sys/arch/powerpc/include/bus.h
index f1f1d7dbb05..250b3f6d32d 100644
--- a/sys/arch/powerpc/include/bus.h
+++ b/sys/arch/powerpc/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.4 1999/11/09 04:13:54 rahnds Exp $ */
+/* $OpenBSD: bus.h,v 1.5 2000/01/14 05:42:16 rahnds Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom. All rights reserved.
@@ -164,8 +164,149 @@ bus_space_write_raw_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
#define bus_space_write_raw_multi_8 \
!!! bus_space_write_raw_multi_8 not implemented !!!
-/* XXX placeholders */
-typedef void *bus_dma_tag_t;
-typedef void *bus_dmamap_t;
+#define BUS_DMA_WAITOK 0x00
+#define BUS_DMA_NOWAIT 0x01
+#define BUS_DMA_ALLOCNOW 0x02
+#define BUS_DMAMEM_NOSYNC 0x04
+
+/* Forwards needed by prototypes below. */
+struct mbuf;
+struct proc;
+struct uio;
+
+typedef enum {
+ BUS_DMASYNC_POSTREAD,
+ BUS_DMASYNC_POSTWRITE,
+ BUS_DMASYNC_PREREAD,
+ BUS_DMASYNC_PREWRITE
+} bus_dmasync_op_t;
+
+typedef struct powerpc_bus_dma_tag *bus_dma_tag_t;
+typedef struct powerpc_bus_dmamap *bus_dmamap_t;
+
+/*
+ * bus_dma_segment_t
+ *
+ * Describes a single contiguous DMA transaction. Values
+ * are suitable for programming into DMA registers.
+ */
+struct powerpc_bus_dma_segment {
+ bus_addr_t ds_addr; /* DMA address */
+ bus_size_t ds_len; /* length of transfer */
+};
+typedef struct powerpc_bus_dma_segment bus_dma_segment_t;
+
+/*
+ * bus_dma_tag_t
+ *
+ * A machine-dependent opaque type describing the implementation of
+ * DMA for a given bus.
+ */
+
+struct powerpc_bus_dma_tag {
+ void *_cookie; /* cookie used in the guts */
+
+ /*
+ * DMA mapping methods.
+ */
+ int (*_dmamap_create) __P((void *, bus_size_t, int,
+ bus_size_t, bus_size_t, int, bus_dmamap_t *));
+ void (*_dmamap_destroy) __P((void *, bus_dmamap_t));
+ int (*_dmamap_load) __P((void *, bus_dmamap_t, void *,
+ bus_size_t, struct proc *, int));
+ int (*_dmamap_load_mbuf) __P((void *, bus_dmamap_t,
+ struct mbuf *, int));
+ int (*_dmamap_load_uio) __P((void *, bus_dmamap_t,
+ struct uio *, int));
+ int (*_dmamap_load_raw) __P((void *, bus_dmamap_t,
+ bus_dma_segment_t *, int, bus_size_t, int));
+ void (*_dmamap_unload) __P((void *, bus_dmamap_t));
+ void (*_dmamap_sync) __P((void *, bus_dmamap_t, bus_dmasync_op_t));
+
+ /*
+ * DMA memory utility functions.
+ */
+ int (*_dmamem_alloc) __P((void *, bus_size_t, bus_size_t,
+ bus_size_t, bus_dma_segment_t *, int, int *, int));
+ void (*_dmamem_free) __P((void *, bus_dma_segment_t *, int));
+ int (*_dmamem_map) __P((void *, bus_dma_segment_t *,
+ int, size_t, caddr_t *, int));
+ void (*_dmamem_unmap) __P((void *, caddr_t, size_t));
+ int (*_dmamem_mmap) __P((void *, bus_dma_segment_t *,
+ int, int, int, int));
+};
+
+#define bus_dmamap_create(t, s, n, m, b, f, p) \
+ (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
+#define bus_dmamap_destroy(t, p) \
+ (*(t)->_dmamap_destroy)((t), (p))
+#define bus_dmamap_load(t, m, b, s, p, f) \
+ (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
+#define bus_dmamap_load_mbuf(t, m, b, f) \
+ (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
+#define bus_dmamap_load_uio(t, m, u, f) \
+ (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
+#define bus_dmamap_load_raw(t, m, sg, n, s, f) \
+ (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
+#define bus_dmamap_unload(t, p) \
+ (*(t)->_dmamap_unload)((t), (p))
+#define bus_dmamap_sync(t, p, o) \
+ (void)((t)->_dmamap_sync ? \
+ (*(t)->_dmamap_sync)((t), (p), (o)) : (void)0)
+
+#define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
+ (*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f))
+#define bus_dmamem_free(t, sg, n) \
+ (*(t)->_dmamem_free)((t)->_cookie, (sg), (n))
+#define bus_dmamem_map(t, sg, n, s, k, f) \
+ (*(t)->_dmamem_map)((t)->_cookie, (sg), (n), (s), (k), (f))
+#define bus_dmamem_unmap(t, k, s) \
+ (*(t)->_dmamem_unmap)((t)->_cookie, (k), (s))
+#define bus_dmamem_mmap(t, sg, n, o, p, f) \
+ (*(t)->_dmamem_mmap)((t)->_cookie, (sg), (n), (o), (p), (f))
+
+int _dmamap_create __P((void *, bus_size_t, int,
+ bus_size_t, bus_size_t, int, bus_dmamap_t *));
+void _dmamap_destroy __P((void *, bus_dmamap_t));
+int _dmamap_load __P((void *, bus_dmamap_t, void *,
+ bus_size_t, struct proc *, int));
+int _dmamap_load_mbuf __P((void *, bus_dmamap_t, struct mbuf *, int));
+int _dmamap_load_uio __P((void *, bus_dmamap_t, struct uio *, int));
+int _dmamap_load_raw __P((void *, bus_dmamap_t,
+ bus_dma_segment_t *, int, bus_size_t, int));
+void _dmamap_unload __P((void *, bus_dmamap_t));
+void _dmamap_sync __P((void *, bus_dmamap_t, bus_dmasync_op_t));
+
+int _dmamem_alloc __P((void *, bus_size_t, bus_size_t,
+ bus_size_t, bus_dma_segment_t *, int, int *, int));
+void _dmamem_free __P((void *, bus_dma_segment_t *, int));
+int _dmamem_map __P((void *, bus_dma_segment_t *,
+ int, size_t, caddr_t *, int));
+void _dmamem_unmap __P((void *, caddr_t, size_t));
+int _dmamem_mmap __P((void *, bus_dma_segment_t *, int, int, int, int));
+
+/*
+ * bus_dmamap_t
+ *
+ * Describes a DMA mapping.
+ */
+struct powerpc_bus_dmamap {
+ /*
+ * PRIVATE MEMBERS: not for use by machine-independent code.
+ */
+ bus_size_t _dm_size; /* largest DMA transfer mappable */
+ int _dm_segcnt; /* number of segs this map can map */
+ bus_size_t _dm_maxsegsz; /* largest possible segment */
+ bus_size_t _dm_boundary; /* don't cross this */
+ int _dm_flags; /* misc. flags */
+
+ void *_dm_cookie; /* cookie for bus-specific functions */
+
+ /*
+ * PUBLIC MEMBERS: these are used by machine-independent code.
+ */
+ int dm_nsegs; /* # valid segments in mapping */
+ bus_dma_segment_t dm_segs[1]; /* segments; variable length */
+};
#endif /* _MACHINE_BUS_H_ */
diff --git a/sys/arch/powerpc/include/vmparam.h b/sys/arch/powerpc/include/vmparam.h
index 0f70ea14760..eee44b09c16 100644
--- a/sys/arch/powerpc/include/vmparam.h
+++ b/sys/arch/powerpc/include/vmparam.h
@@ -31,6 +31,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef MACHINE_VMPARAM_H
+#define MACHINE_VMPARAM_H
+
#define USRTEXT CLBYTES
#define USRSTACK VM_MAXUSER_ADDRESS
@@ -100,13 +103,19 @@ extern vm_offset_t ppc_kvm_size;
#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)((KERNEL_SR << ADDR_SR_SHFT) \
+ VM_KERN_ADDRESS_SIZE))
+#ifdef UVM
+#define MACHINE_NEW_NONCONTIG /* VM <=> pmap interface modifier */
+#else
#define MACHINE_NONCONTIG /* VM <=> pmap interface modifier */
+#endif
#define VM_KMEM_SIZE (NKMEMCLUSTERS * CLBYTES)
#define VM_MBUF_SIZE (NMBCLUSTERS * CLBYTES)
#define VM_PHYS_SIZE (USRIOSIZE * CLBYTES)
struct pmap_physseg {
+ struct pv_entry *pvent;
+ char *attrs;
/* NULL ??? */
};
@@ -117,3 +126,4 @@ struct pmap_physseg {
#define VM_NFREELIST 1
#define VM_FREELIST_DEFAULT 0
+#endif
diff --git a/sys/arch/powerpc/pci/macobio.c b/sys/arch/powerpc/pci/macobio.c
index f7d9de1b34b..3d566ef19f1 100644
--- a/sys/arch/powerpc/pci/macobio.c
+++ b/sys/arch/powerpc/pci/macobio.c
@@ -89,7 +89,11 @@ u_int32_t *heathrow_FCR = NULL;
void prog_switch (void *arg)
{
+#ifdef DDB
Debugger();
+#else
+ printf("programmer button pressed, debugger not available\n");
+#endif
}
/*
diff --git a/sys/arch/powerpc/pci/mpcpcibus.c b/sys/arch/powerpc/pci/mpcpcibus.c
index 18fa6b7f103..0937b1f2a7b 100644
--- a/sys/arch/powerpc/pci/mpcpcibus.c
+++ b/sys/arch/powerpc/pci/mpcpcibus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpcpcibus.c,v 1.10 1999/11/08 23:49:00 rahnds Exp $ */
+/* $OpenBSD: mpcpcibus.c,v 1.11 2000/01/14 05:42:16 rahnds Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -443,7 +443,9 @@ mpc_conf_read(cpv, tag, offset)
device = (tag >> 11) & 0x1f;
if(device > 11)
return(~0); /* Outside config space */
+#if 0
printf("mpc_conf_read tag %x offset %x: ", tag, offset);
+#endif
addr = (0x800 << device) | (tag & 0x380) | offset;
@@ -455,7 +457,9 @@ mpc_conf_read(cpv, tag, offset)
splx(s);
ppc_close_pci_bridge(handle);
+#if 0
printf("data %x\n", data);
+#endif
return(data);
}
@@ -471,7 +475,9 @@ mpc_conf_write(cpv, tag, offset, data)
int device;
int s;
int handle;
+#if 0
printf("mpc_conf_write tag %x offset %x data %x\n", tag, offset, data);
+#endif
device = (tag >> 11) & 0x1f;
addr = (0x800 << device) | (tag & 0x380) | offset;
diff --git a/sys/arch/powerpc/powerpc/copyinstr.c b/sys/arch/powerpc/powerpc/copyinstr.c
index 606cd98e3dc..15d4312bd39 100644
--- a/sys/arch/powerpc/powerpc/copyinstr.c
+++ b/sys/arch/powerpc/powerpc/copyinstr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: copyinstr.c,v 1.3 1997/10/13 13:42:55 pefo Exp $ */
+/* $OpenBSD: copyinstr.c,v 1.4 2000/01/14 05:42:17 rahnds Exp $ */
/*-
* Copyright (C) 1995 Wolfgang Solfrank.
@@ -50,7 +50,7 @@ copyinstr(udaddr, kaddr, len, done)
for (l = 0; len-- > 0; l++) {
if ((c = fubyte(udaddr++)) < 0) {
*done = l;
- return EACCES;
+ return EFAULT;
}
if (!(*kp++ = c)) {
*done = l + 1;
diff --git a/sys/arch/powerpc/powerpc/copyoutstr.c b/sys/arch/powerpc/powerpc/copyoutstr.c
index bcf11420469..6a72e2080ba 100644
--- a/sys/arch/powerpc/powerpc/copyoutstr.c
+++ b/sys/arch/powerpc/powerpc/copyoutstr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: copyoutstr.c,v 1.3 1997/10/13 13:42:55 pefo Exp $ */
+/* $OpenBSD: copyoutstr.c,v 1.4 2000/01/14 05:42:17 rahnds Exp $ */
/*-
* Copyright (C) 1995 Wolfgang Solfrank.
@@ -49,7 +49,7 @@ copyoutstr(kaddr, udaddr, len, done)
for (l = 0; len-- > 0; l++) {
if (subyte(udaddr++, *kp) < 0) {
*done = l;
- return EACCES;
+ return EFAULT;
}
if (!*kp++) {
*done = l + 1;
diff --git a/sys/arch/powerpc/powerpc/locore.S b/sys/arch/powerpc/powerpc/locore.S
index ff37cc5b498..f406b8e2ebf 100644
--- a/sys/arch/powerpc/powerpc/locore.S
+++ b/sys/arch/powerpc/powerpc/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.8 1999/07/05 20:56:26 rahnds Exp $ */
+/* $OpenBSD: locore.S,v 1.9 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: locore.S,v 1.2 1996/10/16 19:33:09 ws Exp $ */
/*
@@ -195,7 +195,11 @@ _ENTRY(_C_LABEL(switchexit))
stw 6,_C_LABEL(curpcb)@l(7)
addi 1,6,USPACE-16 /* 16 bytes are reserved at stack top */
/* Now free the old user structure (args are already in r3, r4, r5) */
+#ifdef UVM
+ bl _C_LABEL(uvm_km_free)
+#else
bl _C_LABEL(kmem_free)
+#endif
/* Fall through to cpu_switch to actually select another proc */
/*
diff --git a/sys/arch/powerpc/powerpc/machdep.c b/sys/arch/powerpc/powerpc/machdep.c
index 6bd87cf9ae5..3cb8cd1e7e2 100644
--- a/sys/arch/powerpc/powerpc/machdep.c
+++ b/sys/arch/powerpc/powerpc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.30 2000/01/14 05:16:03 rahnds Exp $ */
+/* $OpenBSD: machdep.c,v 1.31 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */
/*
@@ -69,6 +69,7 @@
#include <machine/powerpc.h>
#include <machine/trap.h>
#include <machine/autoconf.h>
+#include <machine/bus.h>
#include <machine/pio.h>
#include <powerpc/pci/mpc106reg.h>
@@ -82,8 +83,30 @@ struct proc *fpuproc;
extern struct user *proc0paddr;
extern int cold;
+/*
+ * 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];
+#ifdef UVM
+/* ??? */
+vm_map_t exec_map = NULL;
+vm_map_t mb_map = NULL;
+vm_map_t phys_map = NULL;
+#endif
+
int astpending;
int ppc_malloc_ok = 0;
@@ -250,7 +273,13 @@ where = 3;
syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
+#ifdef UVM
+ uvmexp.pagesize = 4096;
+ uvm_setpagesize();
+
+#else
vm_set_page_size();
+#endif
/*
* Initialize pmap module.
@@ -265,7 +294,6 @@ where = 3;
__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
@@ -404,11 +432,17 @@ cpu_startup()
* and then give everything true virtual addresses.
*/
sz = (int)allocsys((caddr_t)0);
+#ifdef UVM
+ if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0)
+ panic("startup: no room for tables");
+#else
if ((v = (caddr_t)kmem_alloc(kernel_map, round_page(sz))) == 0)
panic("startup: no room for tables");
+#endif
if (allocsys(v) - v != sz)
panic("startup: table size inconsistency");
+#if !defined (UVM)
/*
* Now allocate buffers proper. They are different than the above
* in that they usually occupy more virtual memory than physical.
@@ -417,7 +451,7 @@ cpu_startup()
buffer_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, sz, TRUE);
buffers = (char *)minaddr;
if (vm_map_find(buffer_map, vm_object_allocate(sz), (vm_offset_t)0,
- &minaddr, sz, FALSE) != KERN_SUCCESS)
+ &minaddr, sz, FALSE) != KERN_SUCCESS)
panic("startup: cannot allocate buffers");
base = bufpages / nbuf;
residual = bufpages % nbuf;
@@ -432,32 +466,49 @@ cpu_startup()
curbuf = (vm_offset_t)buffers + i * MAXBSIZE;
curbufsize = CLBYTES * (i < residual ? base + 1 : base);
- vm_map_pageable(buffer_map, curbuf, curbuf + curbufsize, FALSE);
+ vm_map_pageable(buffer_map, curbuf, curbuf + curbufsize,
+ FALSE);
vm_map_simplify(buffer_map, curbuf);
}
+#endif
/*
* Allocate a submap for exec arguments. This map effectively
* limits the number of processes exec'ing at any time.
*/
- exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
- 16*NCARGS, TRUE);
+#ifdef UVM
+ exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 16 * NCARGS,
+ TRUE, FALSE, NULL);
+#else
+ exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, 16 * NCARGS,
+ TRUE);
+#endif
/*
* Allocate a submap for physio
*/
- phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
- VM_PHYS_SIZE, TRUE);
+#ifdef UVM
+ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
+ VM_PHYS_SIZE, TRUE, FALSE, NULL);
+#else
+ phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE,
+ TRUE);
+#endif
ppc_malloc_ok = 1;
/*
* Allocate mbuf pool.
*/
- mclrefcnt = (char *)malloc(NMBCLUSTERS + CLBYTES/MCLBYTES,
- M_MBUF, M_NOWAIT);
+ mclrefcnt = (char *)malloc(NMBCLUSTERS + CLBYTES/MCLBYTES, M_MBUF,
+ M_NOWAIT);
bzero(mclrefcnt, NMBCLUSTERS + CLBYTES/MCLBYTES);
+#ifdef UVM
+ mb_map = uvm_km_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr,
+ VM_MBUF_SIZE, FALSE, FALSE, NULL);
+#else
mb_map = kmem_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr,
- VM_MBUF_SIZE, FALSE);
+ VM_MBUF_SIZE, FALSE);
+#endif
/*
* Initialize callouts.
@@ -466,9 +517,13 @@ cpu_startup()
for (i = 1; i < ncallout; i++)
callout[i - 1].c_next = &callout[i];
+#ifdef UVM
+ printf("avail mem = %d\n", ptoa(uvmexp.free));
+#else
printf("avail mem = %d\n", ptoa(cnt.v_free_count));
- printf("using %d buffers containing %d bytes of memory\n",
- nbuf, bufpages * CLBYTES);
+#endif
+ printf("using %d buffers containing %d bytes of memory\n", nbuf,
+ bufpages * CLBYTES);
/*
@@ -528,7 +583,7 @@ allocsys(v)
* Decide on buffer space to use.
*/
if (bufpages == 0)
- bufpages = (physmem / ((100/BUFCACHEPERCENT) / CLSIZE));
+ bufpages = (physmem / ((100 / BUFCACHEPERCENT) / CLSIZE));
if (nbuf == 0) {
nbuf = bufpages;
if (nbuf < 16)
@@ -536,8 +591,8 @@ allocsys(v)
}
/* 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) /
+ (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. */
@@ -549,7 +604,9 @@ allocsys(v)
if (nswbuf > 256)
nswbuf = 256;
}
+#if !defined(UVM)
valloc(swbuf, struct buf, nswbuf);
+#endif
valloc(buf, struct buf, nbuf);
return v;
@@ -914,7 +971,7 @@ systype(char *name)
{ "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},
+ { "PowerBook", "(APPL) Apple Powerbook ", APPL},
{ NULL,"",0}
};
for (i = 0; systypes[i].name != NULL; i++) {
@@ -1035,7 +1092,11 @@ bus_space_unmap(t, bsh, size)
off = bsh - sva;
len = size+off;
+#ifdef UVM
+ uvm_km_free_wakeup(phys_map, sva, len);
+#else
kmem_free_wakeup(phys_map, sva, len);
+#endif
#ifdef DESTROY_MAPPINGS
for (; len > 0; len -= NBPG) {
pmap_enter(vm_map_pmap(phys_map), vaddr, sva,
@@ -1076,7 +1137,11 @@ bus_mem_add_mapping(bpa, size, cacheable, bshp)
vaddr = VM_MIN_KERNEL_ADDRESS + ppc_kvm_size;
} else {
+#ifdef UVM
+ vaddr = uvm_km_valloc_wait(phys_map, len);
+#else
vaddr = kmem_alloc_wait(phys_map, len);
+#endif
}
*bshp = vaddr + off;
#ifdef DEBUG_BUS_MEM_ADD_MAPPING
@@ -1108,7 +1173,11 @@ mapiodev(pa, len)
spa = trunc_page(pa);
off = pa - spa;
size = round_page(off+len);
+#ifdef UVM
+ va = vaddr = uvm_km_valloc(phys_map, size);
+#else
va = vaddr = kmem_alloc(phys_map, size);
+#endif
if (va == 0)
return NULL;
@@ -1270,3 +1339,23 @@ 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;
+}
diff --git a/sys/arch/powerpc/powerpc/mem.c b/sys/arch/powerpc/powerpc/mem.c
index 93f6d412b23..fc4a3021866 100644
--- a/sys/arch/powerpc/powerpc/mem.c
+++ b/sys/arch/powerpc/powerpc/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.4 1999/11/22 19:22:02 matthieu Exp $ */
+/* $OpenBSD: mem.c,v 1.5 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: mem.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
/*
@@ -162,7 +162,6 @@ mmmmap(dev, off, prot)
{
return EOPNOTSUPP;
}
-
/*ARGSUSED*/
int
mmioctl(dev, cmd, data, flags, p)
diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c
index 46fc66ec537..eba267c40d1 100644
--- a/sys/arch/powerpc/powerpc/pmap.c
+++ b/sys/arch/powerpc/powerpc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.13 1999/11/09 00:20:42 rahnds Exp $ */
+/* $OpenBSD: pmap.c,v 1.14 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: pmap.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */
/*
@@ -33,12 +33,18 @@
*/
#include <sys/param.h>
#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/user.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
+#ifdef UVM
+#include <uvm/uvm.h>
+#endif
+
#include <machine/pcb.h>
#include <machine/powerpc.h>
@@ -437,6 +443,13 @@ avail_end = npgs * NBPG;
LIST_INIT(potable + i);
LIST_INIT(&pv_page_freelist);
+#ifdef UVM
+ for (mp = avail; mp->size; mp++) {
+ uvm_page_physload(atop(mp->start), atop(mp->start + mp->size),
+ atop(mp->start), atop(mp->start + mp->size),
+ VM_FREELIST_DEFAULT);
+ }
+#endif
/*
* Initialize kernel pmap and hardware.
*/
@@ -491,13 +504,21 @@ void
pmap_init()
{
struct pv_entry *pv;
- vm_size_t sz;
- vm_offset_t addr;
+ vsize_t sz;
+ vaddr_t addr;
int i, s;
+#ifdef UVM
+ int bank;
+ char *attr;
+#endif
sz = (vm_size_t)((sizeof(struct pv_entry) + 1) * npgs);
sz = round_page(sz);
- addr = (vm_offset_t)kmem_alloc(kernel_map, sz);
+#ifdef UVM
+ addr = uvm_km_zalloc(kernel_map, sz);
+#else
+ addr = kmem_alloc(kernel_map, sz);
+#endif
s = splimp();
pv = pv_table = (struct pv_entry *)addr;
for (i = npgs; --i >= 0;)
@@ -505,6 +526,17 @@ pmap_init()
LIST_INIT(&pv_page_freelist);
pmap_attrib = (char *)pv;
bzero(pv, npgs);
+#ifdef UVM
+ pv = pv_table;
+ attr = pmap_attrib;
+ for (bank = 0; bank < vm_nphysseg; bank++) {
+ sz = vm_physmem[bank].end - vm_physmem[bank].start;
+ vm_physmem[bank].pmseg.pvent = pv;
+ vm_physmem[bank].pmseg.attrs = attr;
+ pv += sz;
+ attr += sz;
+ }
+#endif
pmap_initialized = 1;
splx(s);
}
@@ -738,8 +770,13 @@ pmap_alloc_pv()
int i;
if (pv_nfree == 0) {
+#ifdef UVM
+ if (!(pvp = (struct pv_page *)uvm_km_zalloc(kernel_map, NBPG)))
+ panic("pmap_alloc_pv: uvm_km_zalloc() failed");
+#else
if (!(pvp = (struct pv_page *)kmem_alloc(kernel_map, NBPG)))
panic("pmap_alloc_pv: kmem_alloc() failed");
+#endif
pv_pcnt++;
pvp->pvp_pgi.pgi_freelist = pv = &pvp->pvp_pv[1];
for (i = NPVPPG - 2; --i >= 0; pv++)
@@ -778,7 +815,11 @@ pmap_free_pv(pv)
pv_nfree -= NPVPPG - 1;
pv_pcnt--;
LIST_REMOVE(pvp, pvp_pgi.pgi_list);
+#ifdef UVM
+ uvm_km_free(kernel_map, (vaddr_t)pvp, NBPG);
+#else
kmem_free(kernel_map, (vm_offset_t)pvp, NBPG);
+#endif
break;
}
}
@@ -803,7 +844,11 @@ poalloc()
* Since we cannot use maps for potable allocation,
* we have to steal some memory from the VM system. XXX
*/
+#ifdef UVM
+ mem = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE);
+#else
mem = vm_page_alloc(NULL, NULL);
+#endif
po_pcnt++;
pop = (struct po_page *)VM_PAGE_TO_PHYS(mem);
pop->pop_pgi.pgi_page = mem;
@@ -839,7 +884,11 @@ pofree(po, freepage)
po_nfree -= NPOPPG - 1;
po_pcnt--;
LIST_REMOVE(pop, pop_pgi.pgi_list);
+#ifdef UVM
+ uvm_pagefree(pop->pop_pgi.pgi_page);
+#else
vm_page_free(pop->pop_pgi.pgi_page);
+#endif
return;
case 1:
LIST_INSERT_HEAD(&po_page_freelist, pop, pop_pgi.pgi_list);
@@ -1367,3 +1416,25 @@ addbatmap(u_int32_t vaddr, u_int32_t raddr, u_int32_t wimg)
battable[segment].batl = BATL(raddr, wimg);
}
+/* ??? */
+void
+pmap_activate(struct proc *p)
+{
+ struct pcb *pcb = &p->p_addr->u_pcb;
+ pmap_t pmap = p->p_vmspace->vm_map.pmap;
+
+ /*
+ * XXX Normally performed in cpu_fork();
+ */
+ if (pcb->pcb_pm != pmap) {
+ pcb->pcb_pm = pmap;
+ }
+ curpcb=pcb;
+ return;
+}
+/* ??? */
+void
+pmap_deactivate(struct proc *p)
+{
+ return;
+}
diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c
index 894882c3851..a11510662b1 100644
--- a/sys/arch/powerpc/powerpc/trap.c
+++ b/sys/arch/powerpc/powerpc/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.15 1999/07/05 20:29:14 rahnds Exp $ */
+/* $OpenBSD: trap.c,v 1.16 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
@@ -42,6 +42,10 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
+#ifdef UVM
+#include <uvm/uvm_extern.h>
+#endif
+
#include <machine/cpu.h>
#include <machine/frame.h>
#include <machine/pcb.h>
@@ -132,9 +136,16 @@ trap(frame)
ftype = VM_PROT_READ | VM_PROT_WRITE;
else
ftype = VM_PROT_READ;
+#ifdef UVM
+ if (uvm_fault(map, trunc_page(va), 0, ftype)
+ == KERN_SUCCESS)
+#else
if (vm_fault(map, trunc_page(va), ftype, FALSE)
== KERN_SUCCESS)
+#endif
+ {
return;
+ }
if (fb = p->p_addr->u_pcb.pcb_onfault) {
p->p_addr->u_pcb.pcb_onfault = 0;
frame->srr0 = fb->pc; /* PC */
@@ -157,10 +168,18 @@ printf("kern dsi on addr %x iar %x\n", frame->dar, frame->srr0);
vftype = VM_PROT_WRITE;
} else
vftype = ftype = VM_PROT_READ;
+#ifdef UVM
+ if (uvm_fault(&p->p_vmspace->vm_map,
+ trunc_page(frame->dar), 0, ftype)
+ == KERN_SUCCESS)
+#else
if (vm_fault(&p->p_vmspace->vm_map,
trunc_page(frame->dar), ftype, FALSE)
== KERN_SUCCESS)
+#endif
+ {
break;
+ }
printf("dsi on addr %x iar %x lr %x\n", frame->dar, frame->srr0,frame->lr);
/*
* keep this for later in case we want it later.
@@ -174,10 +193,18 @@ printf("dsi on addr %x iar %x lr %x\n", frame->dar, frame->srr0,frame->lr);
int ftype;
ftype = VM_PROT_READ | VM_PROT_EXECUTE;
+#ifdef UVM
+ if (uvm_fault(&p->p_vmspace->vm_map,
+ trunc_page(frame->srr0), 0, ftype)
+ == KERN_SUCCESS)
+#else
if (vm_fault(&p->p_vmspace->vm_map,
trunc_page(frame->srr0), ftype, FALSE)
== KERN_SUCCESS)
+#endif
+ {
break;
+ }
}
printf("isi iar %x\n", frame->srr0);
case EXC_MCHK|EXC_USER:
@@ -195,7 +222,11 @@ printf("isi iar %x\n", frame->srr0);
int nsys, n;
register_t args[10];
+#ifdef UVM
+ uvmexp.syscalls++;
+#else
cnt.v_syscall++;
+#endif
nsys = p->p_emul->e_nsysent;
callp = p->p_emul->e_sysent;
@@ -377,7 +408,11 @@ for (i = 0; i < errnum; i++) {
astpending = 0; /* we are about to do it */
+#ifdef UVM
+ uvmexp.softs++;
+#else
cnt.v_soft++;
+#endif
if (p->p_flag & P_OWEUPC) {
p->p_flag &= ~P_OWEUPC;
@@ -467,7 +502,7 @@ badaddr(addr, len)
if (setfault(env)) {
curpcb->pcb_onfault = 0;
- return EACCES;
+ return EFAULT;
}
switch(len) {
case 4:
@@ -496,7 +531,7 @@ copyin(udaddr, kaddr, len)
if (setfault(env)) {
curpcb->pcb_onfault = 0;
- return EACCES;
+ return EFAULT;
}
while (len > 0) {
p = USER_ADDR + ((u_int)udaddr & ~SEGMENT_MASK);
@@ -525,7 +560,7 @@ copyout(kaddr, udaddr, len)
if (setfault(env)) {
curpcb->pcb_onfault = 0;
- return EACCES;
+ return EFAULT;
}
while (len > 0) {
p = USER_ADDR + ((u_int)udaddr & ~SEGMENT_MASK);
diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c
index f6170f02552..673745c05b4 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.9 1999/11/09 00:20:42 rahnds Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.10 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: vm_machdep.c,v 1.1 1996/09/30 16:34:57 ws Exp $ */
/*
@@ -41,6 +41,10 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
+#ifdef UVM
+#include <uvm/uvm_extern.h>
+#endif
+
#include <machine/pcb.h>
/*
@@ -174,7 +178,11 @@ cpu_exit(p)
if (p == fpuproc) /* release the fpu */
fpuproc = 0;
+#ifdef UVM
+ uvmspace_free(p->p_vmspace);
+#else
vmspace_free(p->p_vmspace);
+#endif
(void)splhigh();
switchexit(kernel_map, p->p_addr, USPACE);
}
@@ -238,7 +246,11 @@ vmapbuf(bp, len)
faddr = trunc_page(bp->b_saveaddr = bp->b_data);
off = (vm_offset_t)bp->b_data - faddr;
len = round_page(off + len);
+#ifdef UVM
+ taddr = uvm_km_valloc_wait(phys_map, len);
+#else
taddr = kmem_alloc_wait(phys_map, len);
+#endif
bp->b_data = (caddr_t)(taddr + off);
for (; len > 0; len -= NBPG) {
pa = pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), faddr);
@@ -266,7 +278,11 @@ vunmapbuf(bp, len)
addr = trunc_page(bp->b_data);
off = (vm_offset_t)bp->b_data - addr;
len = round_page(off + len);
+#ifdef UVM
+ uvm_km_free_wakeup(phys_map, addr, len);
+#else
kmem_free_wakeup(phys_map, addr, len);
+#endif
bp->b_data = bp->b_saveaddr;
bp->b_saveaddr = 0;
}
diff --git a/sys/arch/powerpc/stand/boot.c b/sys/arch/powerpc/stand/boot.c
index fab53975cea..0a23e4943fa 100644
--- a/sys/arch/powerpc/stand/boot.c
+++ b/sys/arch/powerpc/stand/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.8 1999/11/09 06:30:15 rahnds Exp $ */
+/* $OpenBSD: boot.c,v 1.9 2000/01/14 05:42:17 rahnds Exp $ */
/* $NetBSD: boot.c,v 1.1 1997/04/16 20:29:17 thorpej Exp $ */
/*
@@ -454,7 +454,7 @@ main()
char *cp;
int fd;
- printf("\n>> OpenBSD/powerpc Boot\n");
+ printf("\n>> OpenBSD/powerpc Boot tst \n");
/*
* Get the boot arguments from Openfirmware