summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/arch/macppc/macppc/ofw_machdep.c34
-rw-r--r--sys/arch/macppc/macppc/ofw_machdep.h6
-rw-r--r--sys/arch/macppc/pci/vgafb.c100
-rw-r--r--sys/arch/macppc/pci/vgafb_pci.c45
-rw-r--r--sys/arch/macppc/pci/vgafb_pcivar.h11
-rw-r--r--sys/arch/macppc/pci/vgafbvar.h13
6 files changed, 58 insertions, 151 deletions
diff --git a/sys/arch/macppc/macppc/ofw_machdep.c b/sys/arch/macppc/macppc/ofw_machdep.c
index fb500c4975f..1b8d8fa63c4 100644
--- a/sys/arch/macppc/macppc/ofw_machdep.c
+++ b/sys/arch/macppc/macppc/ofw_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_machdep.c,v 1.35 2010/04/21 03:03:26 deraadt Exp $ */
+/* $OpenBSD: ofw_machdep.c,v 1.36 2012/06/21 10:08:16 mpi Exp $ */
/* $NetBSD: ofw_machdep.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */
/*
@@ -210,10 +210,8 @@ ofw_make_tag(void *cpv, int bus, int dev, int fnc)
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;
@@ -396,7 +394,6 @@ of_display_console()
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) {
@@ -455,33 +452,10 @@ of_display_console()
cons_width, cons_linebytes, cons_height, cons_depth);
#endif
- {
- int i;
+ cons_membus->bus_base = 0x80000000;
+ vgafb_pci_console_tag = iotag;
- cons_membus->bus_base = 0x80000000;
-#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
- }
+ vgafb_cnattach(cons_membus, cons_membus, -1, 0);
if (cons_backlight_available == 1)
of_setbrightness(DEFAULT_BRIGHTNESS);
diff --git a/sys/arch/macppc/macppc/ofw_machdep.h b/sys/arch/macppc/macppc/ofw_machdep.h
index 3fc4b6ad6a8..0694b65f722 100644
--- a/sys/arch/macppc/macppc/ofw_machdep.h
+++ b/sys/arch/macppc/macppc/ofw_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ofw_machdep.h,v 1.3 2003/06/02 16:16:27 miod Exp $ */
+/* $OpenBSD: ofw_machdep.h,v 1.4 2012/06/21 10:08:16 mpi Exp $ */
/*
* Copyright (c) 2002, Miodrag Vallat.
@@ -29,10 +29,6 @@
/*
* Various console variables...
*/
-extern int cons_displaytype;
-extern bus_space_tag_t cons_membus;
-extern bus_space_handle_t cons_display_mem_h;
-extern bus_space_handle_t cons_display_ctl_h;
extern int cons_height, cons_width, cons_linebytes, cons_depth;
extern int cons_display_ofh;
extern u_int32_t cons_addr;
diff --git a/sys/arch/macppc/pci/vgafb.c b/sys/arch/macppc/pci/vgafb.c
index fa80fe7516e..023e8181f32 100644
--- a/sys/arch/macppc/pci/vgafb.c
+++ b/sys/arch/macppc/pci/vgafb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vgafb.c,v 1.39 2012/01/29 14:20:42 mpi Exp $ */
+/* $OpenBSD: vgafb.c,v 1.40 2012/06/21 10:08:16 mpi Exp $ */
/* $NetBSD: vga.c,v 1.3 1996/12/02 22:24:54 cgd Exp $ */
/*
@@ -106,35 +106,23 @@ extern int allowaperture;
void
-vgafb_common_setup(bus_space_tag_t iot, bus_space_tag_t memt,
- struct vgafb_config *vc, u_int32_t iobase, size_t iosize,
+vgafb_init(bus_space_tag_t iot, bus_space_tag_t memt, struct vgafb_config *vc,
u_int32_t membase, size_t memsize, u_int32_t mmiobase, size_t mmiosize)
{
vc->vc_iot = iot;
vc->vc_memt = memt;
vc->vc_paddr = membase;
- if (iosize != 0) {
- if (bus_space_map(vc->vc_iot, iobase+0x3b0, 0xc, 0, &vc->vc_ioh_b))
- panic("vgafb_common_setup: couldn't map io b");
- if (bus_space_map(vc->vc_iot, iobase+0x3c0, 0x10, 0, &vc->vc_ioh_c))
- panic("vgafb_common_setup: couldn't map io c");
- if (bus_space_map(vc->vc_iot, iobase+0x3d0, 0x10, 0, &vc->vc_ioh_d))
- panic("vgafb_common_setup: couldn't map io d");
- }
if (mmiosize != 0)
if (bus_space_map(vc->vc_memt, mmiobase, mmiosize, 0,
&vc->vc_mmioh))
- panic("vgafb_common_setup: couldn't map mmio");
+ panic("vgafb_init: couldn't map mmio");
/* memsize should only be visible region for console */
memsize = cons_height * cons_linebytes;
if (bus_space_map(vc->vc_memt, membase, memsize,
/* XXX */ppc_proc_is_64b ? 0 : 1, &vc->vc_memh))
- panic("vgafb_common_setup: can't map mem space");
- cons_display_mem_h = vc->vc_memh;
- vc->vc_ofh = cons_display_ofh;
-
+ panic("vgafb_init: can't map mem space");
vc->vc_crow = vc->vc_ccol = 0; /* Has to be some onscreen value */
vc->vc_so = 0;
@@ -292,83 +280,75 @@ vgafb_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
}
paddr_t
-vgafb_mmap(void *v, off_t offset, int prot)
+vgafb_mmap(void *v, off_t off, int prot)
{
struct vgafb_config *vc = v;
- bus_space_handle_t h;
+
+ if (off & PGOFSET)
+ return (-1);
switch (vc->vc_mode) {
case WSDISPLAYIO_MODE_MAPPED:
#ifdef APERTURE
- if (allowaperture == 0) {
- h = -1;
- break;
- }
-#endif
- if (offset >= 0xa0000 && offset < 0xfffff)
- h = offset;
- /* XXX the following are probably wrong.
- we want physical addresses here, not virtual ones */
- else if (offset >= 0x10000000 && offset < 0x10040000 )
- /* 256KB of iohb */
- h = vc->vc_ioh_b;
- else if (offset >= 0x10040000 && offset < 0x10080000)
- /* 256KB of iohc */
- h = vc->vc_ioh_c;
- else if (offset >= 0x10080000 && offset < 0x100c0000)
- /* 256KB of iohd */
- h = vc->vc_ioh_d;
- else if (offset >= 0x20000000 && offset < 0x20000000+vc->mmiosize)
- /* mmiosize... */
- h = vc->vc_mmioh + (offset - 0x20000000);
- else if (offset >= vc->membase && (offset < vc->membase+vc->memsize)) {
- /* allow mmapping of memory */
- h = offset;
- } else if (offset >= vc->mmiobase &&
- (offset < vc->mmiobase+vc->mmiosize)) {
- /* allow mmapping of mmio space */
- h = offset;
- } else {
- h = -1;
- }
+ if (allowaperture == 0)
+ return (-1);
+#endif
+
+ if (vc->mmiosize == 0)
+ return (-1);
+
+ if (off >= vc->membase && off < (vc->membase + vc->memsize))
+ return (off);
+
+ if (off >= vc->mmiobase && off < (vc->mmiobase+vc->mmiosize))
+ return (off);
break;
case WSDISPLAYIO_MODE_DUMBFB:
- if (offset >= 0x00000 && offset < vc->memsize)
- h = vc->vc_paddr + offset;
- else
- h = -1;
+ if (off >= 0x00000 && off < vc->memsize)
+ return (vc->vc_paddr + off);
break;
}
- return h;
+
+ return (-1);
}
-void
-vgafb_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, void *pc, int bus,
- int device, int function)
+int
+vgafb_cnattach(bus_space_tag_t iot, bus_space_tag_t memt, int type, int check)
{
- long defattr;
-
+ struct vgafb_config *vc = &vgafb_pci_console_vc;
struct vgafb_devconfig *dc = &vgafb_console_dc;
struct rasops_info *ri = &dc->dc_rinfo;
+ long defattr;
+ int i;
+
+ vgafb_init(iot, memt, vc, cons_addr, cons_linebytes * cons_height,0, 0);
ri->ri_flg = RI_CENTER;
ri->ri_depth = cons_depth;
- ri->ri_bits = (void *)cons_display_mem_h;
+ ri->ri_bits = (void *)vc->vc_memh;
ri->ri_width = cons_width;
ri->ri_height = cons_height;
ri->ri_stride = cons_linebytes;
ri->ri_hw = dc;
+ /* Clear the screen */
+ for (i = 0; i < cons_linebytes * cons_height; i++)
+ bus_space_write_1(memt, vc->vc_memh, i, 0);
+
rasops_init(ri, 160, 160); /* XXX */
vgafb_stdscreen.nrows = ri->ri_rows;
vgafb_stdscreen.ncols = ri->ri_cols;
vgafb_stdscreen.textops = &ri->ri_ops;
+
ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr);
wsdisplay_cnattach(&vgafb_stdscreen, ri, 0, 0, defattr);
+ vc->nscreens++;
+
+ return (0);
}
struct {
diff --git a/sys/arch/macppc/pci/vgafb_pci.c b/sys/arch/macppc/pci/vgafb_pci.c
index 590e9dabfe9..8e8bc529a14 100644
--- a/sys/arch/macppc/pci/vgafb_pci.c
+++ b/sys/arch/macppc/pci/vgafb_pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vgafb_pci.c,v 1.24 2012/01/29 14:44:16 mpi Exp $ */
+/* $OpenBSD: vgafb_pci.c,v 1.25 2012/06/21 10:08:16 mpi Exp $ */
/* $NetBSD: vga_pci.c,v 1.4 1996/12/05 01:39:38 cgd Exp $ */
/*
@@ -272,8 +272,8 @@ vgafb_pci_attach(struct device *parent, struct device *self, void *aux)
malloc(sizeof(struct vgafb_config), M_DEVBUF, M_WAITOK);
/* set up bus-independent VGA configuration */
- vgafb_common_setup(pa->pa_iot, pa->pa_memt, vc,
- ioaddr, iosize, memaddr, memsize, mmioaddr, mmiosize);
+ vgafb_init(pa->pa_iot, pa->pa_memt, vc,
+ memaddr, memsize, mmioaddr, mmiosize);
}
vc->vc_mmap = vgafb_mmap;
vc->vc_ioctl = vgafb_ioctl;
@@ -295,42 +295,3 @@ vgafb_pci_attach(struct device *parent, struct device *self, void *aux)
vgafb_wsdisplay_attach(self, vc, console);
id++;
}
-
-void
-vgafb_pci_console(bus_space_tag_t iot, u_int32_t ioaddr, u_int32_t iosize,
- bus_space_tag_t memt, u_int32_t memaddr, u_int32_t memsize,
- pci_chipset_tag_t pc, int bus, int device, int function)
-{
- struct vgafb_config *vc = &vgafb_pci_console_vc;
- u_int32_t mmioaddr;
- u_int32_t mmiosize;
- static struct pci_attach_args spa;
- struct pci_attach_args *pa = &spa;
-
- /* for later recognition */
- vgafb_pci_console_tag = pci_make_tag(pc, bus, device, function);
-
- pa->pa_iot = iot;
- pa->pa_memt = memt;
- pa->pa_tag = vgafb_pci_console_tag;
- /*
- pa->pa_pc = XXX;
- */
-
-/* XXX probe pci before pci bus config? */
-
- mmioaddr =0;
- mmiosize =0;
-#if 0
- vgafb_pci_probe(pa, 0, &ioaddr, &iosize,
- &memaddr, &memsize, &cacheable, mmioaddr, mmiosize);
-#endif
-
-
- /* set up bus-independent VGA configuration */
- vgafb_common_setup(iot, memt, vc,
- ioaddr, iosize, memaddr, memsize, mmioaddr, mmiosize);
-
- vgafb_cnattach(iot, memt, pc, bus, device, function);
- vc->nscreens++;
-}
diff --git a/sys/arch/macppc/pci/vgafb_pcivar.h b/sys/arch/macppc/pci/vgafb_pcivar.h
index 0633a331dbb..11ce586abe6 100644
--- a/sys/arch/macppc/pci/vgafb_pcivar.h
+++ b/sys/arch/macppc/pci/vgafb_pcivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vgafb_pcivar.h,v 1.5 2007/11/05 19:24:31 martin Exp $ */
+/* $OpenBSD: vgafb_pcivar.h,v 1.6 2012/06/21 10:08:16 mpi Exp $ */
/* $NetBSD: vga_pcivar.h,v 1.1 1996/11/19 04:38:36 cgd Exp $ */
/*
@@ -36,8 +36,7 @@
(PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \
PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) ? 1 : 0)
-void vgafb_pci_console(bus_space_tag_t,
- u_int32_t ioaddr, u_int32_t iosize,
- bus_space_tag_t,
- u_int32_t memaddr, u_int32_t memsize,
- pci_chipset_tag_t, int, int, int);
+extern pcitag_t vgafb_pci_console_tag;
+
+/* XXX */
+int vgafb_cnattach(bus_space_tag_t, bus_space_tag_t, int, int);
diff --git a/sys/arch/macppc/pci/vgafbvar.h b/sys/arch/macppc/pci/vgafbvar.h
index c1a015b78d8..2708a732f7f 100644
--- a/sys/arch/macppc/pci/vgafbvar.h
+++ b/sys/arch/macppc/pci/vgafbvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vgafbvar.h,v 1.13 2012/01/29 14:20:42 mpi Exp $ */
+/* $OpenBSD: vgafbvar.h,v 1.14 2012/06/21 10:08:16 mpi Exp $ */
/* $NetBSD: vgavar.h,v 1.2 1996/11/23 06:06:43 cgd Exp $ */
/*
@@ -32,9 +32,8 @@ struct vgafb_config {
/*
* Filled in by front-ends.
*/
- int vc_ofh; /* openfirmware handle */
bus_space_tag_t vc_iot, vc_memt;
- bus_space_handle_t vc_ioh_b, vc_ioh_c, vc_ioh_d, vc_memh, vc_mmioh;
+ bus_space_handle_t vc_memh, vc_mmioh;
paddr_t vc_paddr; /* physical address */
/* Colormap */
u_char vc_cmap_red[256];
@@ -68,13 +67,11 @@ struct vgafb_config {
u_int vc_mode;
};
-void vgafb_common_setup(bus_space_tag_t, bus_space_tag_t,
- struct vgafb_config *, u_int32_t, size_t, u_int32_t, size_t,
- u_int32_t, size_t);
+void vgafb_init(bus_space_tag_t, bus_space_tag_t,
+ struct vgafb_config *, u_int32_t, size_t, u_int32_t, size_t);
void vgafb_wscons_attach(struct device *, struct vgafb_config *, int);
void vgafb_wscons_console(struct vgafb_config *);
-void vgafb_cnattach(bus_space_tag_t iot, bus_space_tag_t memt,
- void *pc, int bus, int device, int function);
+int vgafb_cnattach(bus_space_tag_t, bus_space_tag_t, int, int);
void vgafb_wsdisplay_attach(struct device *parent,
struct vgafb_config *vc, int console);
int vgafbioctl(void *, u_long, caddr_t, int, struct proc *);