summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/dev/ebus.c16
-rw-r--r--sys/arch/sparc64/dev/psycho.c21
-rw-r--r--sys/arch/sparc64/dev/sbus.c9
-rw-r--r--sys/arch/sparc64/dev/vgafb.c22
-rw-r--r--sys/arch/sparc64/include/bus.h146
-rw-r--r--sys/arch/sparc64/include/pmap.h6
-rw-r--r--sys/arch/sparc64/sparc64/machdep.c62
7 files changed, 173 insertions, 109 deletions
diff --git a/sys/arch/sparc64/dev/ebus.c b/sys/arch/sparc64/dev/ebus.c
index a00e9839518..76e01f7816c 100644
--- a/sys/arch/sparc64/dev/ebus.c
+++ b/sys/arch/sparc64/dev/ebus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ebus.c,v 1.6 2001/12/14 14:53:48 jason Exp $ */
+/* $OpenBSD: ebus.c,v 1.7 2002/02/05 18:34:39 jason Exp $ */
/* $NetBSD: ebus.c,v 1.24 2001/07/25 03:49:54 eeh Exp $ */
/*
@@ -99,8 +99,7 @@ int ebus_find_node __P((struct pci_attach_args *));
/*
* here are our bus space and bus dma routines.
*/
-static int ebus_bus_mmap __P((bus_space_tag_t, bus_type_t, bus_addr_t,
- int, bus_space_handle_t *));
+static paddr_t ebus_bus_mmap __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
static int _ebus_bus_map __P((bus_space_tag_t, bus_type_t, bus_addr_t,
bus_size_t, int, vaddr_t,
bus_space_handle_t *));
@@ -502,13 +501,13 @@ _ebus_bus_map(t, btype, offset, size, flags, vaddr, hp)
return (EINVAL);
}
-static int
-ebus_bus_mmap(t, btype, paddr, flags, hp)
+static paddr_t
+ebus_bus_mmap(t, paddr, off, prot, flags)
bus_space_tag_t t;
- bus_type_t btype;
bus_addr_t paddr;
+ off_t off;
+ int prot;
int flags;
- bus_space_handle_t *hp;
{
bus_addr_t offset = paddr;
struct ebus_softc *sc = t->cookie;
@@ -523,8 +522,7 @@ ebus_bus_mmap(t, btype, paddr, flags, hp)
DPRINTF(EDB_BUSMAP, ("\n_ebus_bus_mmap: mapping paddr %qx\n",
(unsigned long long)paddr));
- return (bus_space_mmap(sc->sc_memtag, 0, paddr,
- flags, hp));
+ return (bus_space_mmap(sc->sc_memtag, paddr, off, prot, flags));
}
return (-1);
diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c
index 4de00164ffd..e5f53ca081d 100644
--- a/sys/arch/sparc64/dev/psycho.c
+++ b/sys/arch/sparc64/dev/psycho.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: psycho.c,v 1.13 2002/01/31 18:27:26 jason Exp $ */
+/* $OpenBSD: psycho.c,v 1.14 2002/02/05 18:34:39 jason Exp $ */
/* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */
/*
@@ -93,8 +93,7 @@ void psycho_iommu_init __P((struct psycho_softc *, int));
* bus space and bus dma support for UltraSPARC `psycho'. note that most
* of the bus dma support is provided by the iommu dvma controller.
*/
-int psycho_bus_mmap __P((bus_space_tag_t, bus_type_t, bus_addr_t,
- int, bus_space_handle_t *));
+paddr_t psycho_bus_mmap __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
int _psycho_bus_map __P((bus_space_tag_t, bus_type_t, bus_addr_t,
bus_size_t, int, vaddr_t, bus_space_handle_t *));
void *psycho_intr_establish __P((bus_space_tag_t, int, int, int,
@@ -906,13 +905,13 @@ _psycho_bus_map(t, btype, offset, size, flags, vaddr, hp)
return (EINVAL);
}
-int
-psycho_bus_mmap(t, btype, paddr, flags, hp)
+paddr_t
+psycho_bus_mmap(t, paddr, off, prot, flags)
bus_space_tag_t t;
- bus_type_t btype;
bus_addr_t paddr;
+ off_t off;
+ int prot;
int flags;
- bus_space_handle_t *hp;
{
bus_addr_t offset = paddr;
struct psycho_pbm *pp = t->cookie;
@@ -921,7 +920,8 @@ psycho_bus_mmap(t, btype, paddr, flags, hp)
ss = psycho_get_childspace(t->type);
- DPRINTF(PDB_BUSMAP, ("_psycho_bus_mmap: type %d flags %d pa %qx\n", btype, flags, (unsigned long long)paddr));
+ DPRINTF(PDB_BUSMAP, ("_psycho_bus_mmap: prot %d flags %d pa %qx\n",
+ prot, flags, (unsigned long long)paddr));
for (i = 0; i < pp->pp_nrange; i++) {
bus_addr_t paddr;
@@ -931,10 +931,11 @@ psycho_bus_mmap(t, btype, paddr, flags, hp)
paddr = pp->pp_range[i].phys_lo + offset;
paddr |= ((bus_addr_t)pp->pp_range[i].phys_hi<<32);
- DPRINTF(PDB_BUSMAP, ("\n_psycho_bus_mmap: mapping paddr space %lx offset %lx paddr %qx\n",
+ DPRINTF(PDB_BUSMAP, ("\n_psycho_bus_mmap: mapping paddr "
+ "space %lx offset %lx paddr %qx\n",
(long)ss, (long)offset,
(unsigned long long)paddr));
- return (bus_space_mmap(sc->sc_bustag, 0, paddr, flags, hp));
+ return (bus_space_mmap(sc->sc_bustag, paddr, off, prot, flags));
}
return (-1);
diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c
index c9c776f0d84..374c61134f5 100644
--- a/sys/arch/sparc64/dev/sbus.c
+++ b/sys/arch/sparc64/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbus.c,v 1.9 2002/01/10 00:06:17 nordin Exp $ */
+/* $OpenBSD: sbus.c,v 1.10 2002/02/05 18:34:39 jason Exp $ */
/* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */
/*-
@@ -123,6 +123,8 @@
#include <sparc64/dev/sbusreg.h>
#include <dev/sbus/sbusvar.h>
+#include <uvm/uvm_extern.h>
+
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <machine/sparc64.h>
@@ -513,10 +515,11 @@ sbus_bus_mmap(t, btype, paddr, flags, hp)
paddr = sc->sc_range[i].poffset + offset;
paddr |= ((bus_addr_t)sc->sc_range[i].pspace<<32);
- return (bus_space_mmap(sc->sc_bustag, 0, paddr, flags, hp));
+ *hp = bus_space_mmap(sc->sc_bustag, paddr, 0,
+ VM_PROT_READ|VM_PROT_WRITE, flags);
}
- return (-1);
+ return (*hp == -1 ? -1 : 0);
}
bus_addr_t
diff --git a/sys/arch/sparc64/dev/vgafb.c b/sys/arch/sparc64/dev/vgafb.c
index 8d8bf2d10c9..566a2223b9c 100644
--- a/sys/arch/sparc64/dev/vgafb.c
+++ b/sys/arch/sparc64/dev/vgafb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vgafb.c,v 1.3 2002/01/03 16:26:27 jason Exp $ */
+/* $OpenBSD: vgafb.c,v 1.4 2002/02/05 18:34:39 jason Exp $ */
/*
* Copyright (c) 2001 Jason L. Wright (jason@thought.net)
@@ -61,6 +61,7 @@ struct vgafb_softc {
int sc_node, sc_ofhandle;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_bh;
+ bus_addr_t sc_paddr;
struct rcons sc_rcons;
struct raster sc_raster;
int sc_console;
@@ -164,7 +165,6 @@ vgafbattach(parent, self, aux)
struct wsemuldisplaydev_attach_args waa;
bus_size_t memsize;
long defattr;
- bus_addr_t membase;
sc->sc_node = PCITAG_NODE(pa->pa_tag);
@@ -187,12 +187,12 @@ vgafbattach(parent, self, aux)
sc->sc_console = vgafb_is_console(sc->sc_node);
if (pci_mem_find(pa->pa_pc, pa->pa_tag, 0x10,
- &membase, &memsize, NULL)) {
+ &sc->sc_paddr, &memsize, NULL)) {
printf(": can't find mem space\n");
goto fail;
}
if (bus_space_map2(pa->pa_memt, SBUS_BUS_SPACE,
- membase, memsize, 0, NULL, &sc->sc_bh)) {
+ sc->sc_paddr, memsize, 0, NULL, &sc->sc_bh)) {
printf(": can't map mem space\n");
goto fail;
}
@@ -406,17 +406,21 @@ vgafb_show_screen(v, cookie, waitok, cb, cbarg)
}
paddr_t
-vgafb_mmap(v, offset, prot)
+vgafb_mmap(v, off, prot)
void *v;
- off_t offset;
+ off_t off;
int prot;
{
-#if 0
struct vgafb_softc *sc = v;
-#endif
- if (offset & PGOFSET)
+ if (off & PGOFSET)
return (-1);
+
+ if (off >= 0 && off < 0x800000) {
+ return (bus_space_mmap(sc->sc_bt, sc->sc_paddr, off, prot,
+ BUS_SPACE_MAP_LINEAR));
+ }
+
return (-1);
}
diff --git a/sys/arch/sparc64/include/bus.h b/sys/arch/sparc64/include/bus.h
index 11afad06d95..ee9455a5f67 100644
--- a/sys/arch/sparc64/include/bus.h
+++ b/sys/arch/sparc64/include/bus.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: bus.h,v 1.7 2001/09/26 21:30:27 jason Exp $ */
-/* $NetBSD: bus.h,v 1.28 2001/07/19 15:32:19 thorpej Exp $ */
+/* $OpenBSD: bus.h,v 1.8 2002/02/05 18:34:39 jason Exp $ */
+/* $NetBSD: bus.h,v 1.31 2001/09/21 15:30:41 wiz Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -116,6 +116,11 @@ typedef enum bus_type bus_type_t;
typedef u_int64_t bus_addr_t;
typedef u_int64_t bus_size_t;
+/* For buses which have an iospace. */
+#define BUS_ADDR_IOSPACE(x) ((x)>>32)
+#define BUS_ADDR_PADDR(x) ((x)&0xffffffff)
+#define BUS_ADDR(io, pa) (((io)<<32)|(pa))
+
/*
* Access methods for bus resources and address space.
*/
@@ -126,47 +131,35 @@ struct sparc_bus_space_tag {
bus_space_tag_t parent;
int type;
- int (*sparc_bus_map) __P((
- bus_space_tag_t,
- bus_type_t,
- bus_addr_t,
- bus_size_t,
- int, /*flags*/
- vaddr_t, /*preferred vaddr*/
- bus_space_handle_t *));
- int (*sparc_bus_unmap) __P((
- bus_space_tag_t,
- bus_space_handle_t,
- bus_size_t));
- int (*sparc_bus_subregion) __P((
- bus_space_tag_t,
- bus_space_handle_t,
- bus_size_t, /*offset*/
- bus_size_t, /*size*/
- bus_space_handle_t *));
+ int (*sparc_bus_alloc) __P((bus_space_tag_t,
+ bus_addr_t, bus_addr_t,
+ bus_size_t, bus_size_t, bus_size_t,
+ int, bus_addr_t *, bus_space_handle_t *));
- void (*sparc_bus_barrier) __P((
- bus_space_tag_t,
- bus_space_handle_t,
- bus_size_t, /*offset*/
- bus_size_t, /*size*/
- int)); /*flags*/
+ void (*sparc_bus_free) __P((bus_space_tag_t,
+ bus_space_handle_t, bus_size_t));
- int (*sparc_bus_mmap) __P((
- bus_space_tag_t,
- bus_type_t, /**/
- bus_addr_t, /**/
- int, /*flags*/
- bus_space_handle_t *));
+ int (*sparc_bus_map) __P((bus_space_tag_t,
+ bus_type_t, bus_addr_t, bus_size_t,
+ int, vaddr_t, bus_space_handle_t *));
- void *(*sparc_intr_establish) __P((
- bus_space_tag_t,
- int, /*bus-specific intr*/
- int, /*device class level,
- see machine/intr.h*/
- int, /*flags*/
- int (*) __P((void *)), /*handler*/
- void *)); /*handler arg*/
+ int (*sparc_bus_unmap) __P((bus_space_tag_t,
+ bus_space_handle_t, bus_size_t));
+
+ int (*sparc_bus_subregion) __P((bus_space_tag_t,
+ bus_space_handle_t, bus_size_t,
+ bus_size_t, bus_space_handle_t *));
+
+ void (*sparc_bus_barrier) __P((bus_space_tag_t,
+ bus_space_handle_t, bus_size_t,
+ bus_size_t, int));
+
+ paddr_t (*sparc_bus_mmap) __P((bus_space_tag_t,
+ bus_addr_t, off_t, int, int));
+
+ void *(*sparc_intr_establish) __P((bus_space_tag_t,
+ int, int, int,
+ int (*) __P((void *)), void *));
};
@@ -190,6 +183,20 @@ struct sparc_bus_space_tag {
/*
* Bus space function prototypes.
*/
+static int bus_space_alloc __P((
+ bus_space_tag_t,
+ bus_addr_t, /* reg start */
+ bus_addr_t, /* reg end */
+ bus_size_t, /* size */
+ bus_size_t, /* alignment */
+ bus_size_t, /* boundary */
+ int, /* flags */
+ bus_addr_t *,
+ bus_space_handle_t *));
+static void bus_space_free __P((
+ bus_space_tag_t,
+ bus_space_handle_t,
+ bus_size_t));
static int bus_space_map __P((
bus_space_tag_t,
bus_addr_t,
@@ -220,12 +227,12 @@ static void bus_space_barrier __P((
bus_size_t,
bus_size_t,
int));
-static int bus_space_mmap __P((
+static paddr_t bus_space_mmap __P((
bus_space_tag_t,
- bus_type_t, /**/
- bus_addr_t, /**/
- int, /*flags*/
- bus_space_handle_t *));
+ bus_addr_t, /*addr*/
+ off_t, /*offset*/
+ int, /*prot*/
+ int)); /*flags*/
static void *bus_intr_establish __P((
bus_space_tag_t,
int, /*bus-specific intr*/
@@ -243,6 +250,30 @@ static void *bus_intr_establish __P((
return (*(t)->f)
__inline__ int
+bus_space_alloc(t, rs, re, s, a, b, f, ap, hp)
+ bus_space_tag_t t;
+ bus_addr_t rs;
+ bus_addr_t re;
+ bus_size_t s;
+ bus_size_t a;
+ bus_size_t b;
+ int f;
+ bus_addr_t *ap;
+ bus_space_handle_t *hp;
+{
+ _BS_CALL(t, sparc_bus_alloc)(t, rs, re, s, a, b, f, ap, hp);
+}
+
+__inline__ void
+bus_space_free(t, h, s)
+ bus_space_tag_t t;
+ bus_space_handle_t h;
+ bus_size_t s;
+{
+ _BS_CALL(t, sparc_bus_free)(t, h, s);
+}
+
+__inline__ int
bus_space_map(t, a, s, f, hp)
bus_space_tag_t t;
bus_addr_t a;
@@ -250,7 +281,7 @@ bus_space_map(t, a, s, f, hp)
int f;
bus_space_handle_t *hp;
{
- _BS_CALL(t, sparc_bus_map)((t), 0, (a), (s), (f), 0, (hp));
+ _BS_CALL(t, sparc_bus_map)(t, 0, a, s, f, 0, hp);
}
__inline__ int
@@ -286,15 +317,15 @@ bus_space_subregion(t, h, o, s, hp)
_BS_CALL(t, sparc_bus_subregion)(t, h, o, s, hp);
}
-__inline__ int
-bus_space_mmap(t, bt, a, f, hp)
+__inline__ paddr_t
+bus_space_mmap(t, a, o, p, f)
bus_space_tag_t t;
- bus_type_t bt;
bus_addr_t a;
+ off_t o;
+ int p;
int f;
- bus_space_handle_t *hp;
{
- _BS_CALL(t, sparc_bus_mmap)(t, bt, a, f, hp);
+ _BS_CALL(t, sparc_bus_mmap)(t, a, o, p, f);
}
__inline__ void *
@@ -320,14 +351,11 @@ bus_space_barrier(t, h, o, s, f)
_BS_CALL(t, sparc_bus_barrier)(t, h, o, s, f);
}
-
-#if 0
-int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
- bus_addr_t rend, bus_size_t size, bus_size_t align,
- bus_size_t boundary, int flags, bus_addr_t *addrp,
- bus_space_handle_t *bshp));
-void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size));
+#if 1
+/* XXXX Things get complicated if we use unmapped register accesses. */
+#define bus_space_vaddr(t, h) (vaddr_t)(h)
+#else
+void * bus_space_vaddr __P((bus_space_tag_t space, bus_space_handle_t handle));
#endif
/* flags for bus space map functions */
diff --git a/sys/arch/sparc64/include/pmap.h b/sys/arch/sparc64/include/pmap.h
index 703e1f79b8c..81e368c8e8c 100644
--- a/sys/arch/sparc64/include/pmap.h
+++ b/sys/arch/sparc64/include/pmap.h
@@ -158,9 +158,9 @@ extern struct pmap kernel_pmap_;
int pmap_count_res __P((pmap_t pmap));
/* int pmap_change_wiring __P((pmap_t pm, vaddr_t va, boolean_t wired)); */
-#define pmap_resident_count(pm) pmap_count_res((pm))
-#define pmap_from_phys_address(x,f) ((x)>>PGSHIFT)
-#define pmap_phys_address(x) ((((paddr_t)(x))<<PGSHIFT)|PMAP_NC)
+#define pmap_resident_count(pm) pmap_count_res((pm))
+#define pmap_from_phys_address(x,f) ((x)&~PGOFSET)
+#define pmap_phys_address(x) (x)
#define pmap_update(pm) /* nothing (yet) */
void pmap_bootstrap __P((u_long kernelstart, u_long kernelend, u_int numctx));
diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c
index 0a7bcf85172..2d17378419b 100644
--- a/sys/arch/sparc64/sparc64/machdep.c
+++ b/sys/arch/sparc64/sparc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.33 2002/02/01 21:48:23 jason Exp $ */
+/* $OpenBSD: machdep.c,v 1.34 2002/02/05 18:34:39 jason Exp $ */
/* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
/*-
@@ -1686,14 +1686,17 @@ static int sparc_bus_unmap __P((bus_space_tag_t, bus_space_handle_t,
static int sparc_bus_subregion __P((bus_space_tag_t, bus_space_handle_t,
bus_size_t, bus_size_t,
bus_space_handle_t *));
-static int sparc_bus_mmap __P((bus_space_tag_t, bus_type_t,
- bus_addr_t, int, bus_space_handle_t *));
+static paddr_t sparc_bus_mmap __P((bus_space_tag_t, bus_addr_t, off_t, int, int));
static void *sparc_mainbus_intr_establish __P((bus_space_tag_t, int, int,
int, int (*) __P((void *)),
void *));
-static void sparc_bus_barrier __P(( bus_space_tag_t, bus_space_handle_t,
- bus_size_t, bus_size_t, int));
-
+static void sparc_bus_barrier __P((bus_space_tag_t, bus_space_handle_t,
+ bus_size_t, bus_size_t, int));
+static int sparc_bus_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
+ bus_size_t, bus_size_t, bus_size_t, int,
+ bus_addr_t *, bus_space_handle_t *));
+static void sparc_bus_free __P((bus_space_tag_t, bus_space_handle_t,
+ bus_size_t));
vaddr_t iobase = IODEV_BASE;
struct extent *io_space = NULL;
@@ -1818,17 +1821,16 @@ sparc_bus_unmap(t, bh, size)
return (0);
}
-int
-sparc_bus_mmap(t, iospace, paddr, flags, hp)
+paddr_t
+sparc_bus_mmap(t, paddr, off, prot, flags)
bus_space_tag_t t;
- bus_type_t iospace;
- bus_addr_t paddr;
- int flags;
- bus_space_handle_t *hp;
+ bus_addr_t paddr;
+ off_t off;
+ int prot;
+ int flags;
{
-
- *hp = (bus_space_handle_t)(paddr>>PGSHIFT);
- return (0);
+ /* Devices are un-cached... although the driver should do that */
+ return ((paddr+off)|PMAP_NC);
}
/*
@@ -1882,7 +1884,8 @@ sparc_mainbus_intr_establish(t, pil, level, flags, handler, arg)
return (ih);
}
-void sparc_bus_barrier (t, h, offset, size, flags)
+void
+sparc_bus_barrier (t, h, offset, size, flags)
bus_space_tag_t t;
bus_space_handle_t h;
bus_size_t offset;
@@ -1906,10 +1909,37 @@ void sparc_bus_barrier (t, h, offset, size, flags)
return;
}
+int
+sparc_bus_alloc(t, rs, re, s, a, b, f, ap, hp)
+ bus_space_tag_t t;
+ bus_addr_t rs;
+ bus_addr_t re;
+ bus_size_t s;
+ bus_size_t a;
+ bus_size_t b;
+ int f;
+ bus_addr_t *ap;
+ bus_space_handle_t *hp;
+{
+ return (ENOTTY);
+}
+
+void
+sparc_bus_free(t, h, s)
+ bus_space_tag_t t;
+ bus_space_handle_t h;
+ bus_size_t s;
+{
+ return;
+}
+
+
struct sparc_bus_space_tag mainbus_space_tag = {
NULL, /* cookie */
NULL, /* parent bus tag */
UPA_BUS_SPACE, /* type */
+ sparc_bus_alloc,
+ sparc_bus_free,
sparc_bus_map, /* bus_space_map */
sparc_bus_unmap, /* bus_space_unmap */
sparc_bus_subregion, /* bus_space_subregion */