Module Name: src
Committed By: tsutsui
Date: Sat Feb 11 02:31:34 UTC 2023
Modified Files:
src/sys/arch/next68k/dev: intio.c intiovar.h nextdisplay.c
src/sys/arch/next68k/include: bus_space.h cpu.h
src/sys/arch/next68k/next68k: locore.s nextrom.c pmap_bootstrap.c
Log Message:
Handle NeXT Turbo VRAM regions properly.
Info from Andreas Grabher on port-next68k@:
https://mail-index.netbsd.org/port-next68k/2023/02/06/msg000052.html
Also refactor bus_space_map(9) and fix (unused) bus_space_mmap(9).
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/next68k/dev/intio.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/next68k/dev/intiovar.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/next68k/dev/nextdisplay.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/next68k/include/bus_space.h
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/next68k/include/cpu.h
cvs rdiff -u -r1.71 -r1.72 src/sys/arch/next68k/next68k/locore.s
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/next68k/next68k/nextrom.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/next68k/next68k/pmap_bootstrap.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/next68k/dev/intio.c
diff -u src/sys/arch/next68k/dev/intio.c:1.18 src/sys/arch/next68k/dev/intio.c:1.19
--- src/sys/arch/next68k/dev/intio.c:1.18 Sat Feb 4 14:38:09 2023
+++ src/sys/arch/next68k/dev/intio.c Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: intio.c,v 1.18 2023/02/04 14:38:09 tsutsui Exp $ */
+/* $NetBSD: intio.c,v 1.19 2023/02/11 02:31:34 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.18 2023/02/04 14:38:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.19 2023/02/11 02:31:34 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: intio.c,v 1.
#include <sys/reboot.h>
#include <machine/autoconf.h>
+#include <machine/cpu.h>
#include <next68k/dev/intiovar.h>
@@ -107,3 +108,27 @@ intiosearch(device_t parent, cfdata_t cf
return 0;
}
+
+int
+bus_space_map(bus_space_tag_t bst, bus_addr_t addr, bus_size_t size,
+ int flags, bus_space_handle_t *bsh)
+{
+
+ if (addr >= INTIOBASE && (addr + size) < INTIOTOP) {
+ *bsh = IIOV(addr);
+ return 0;
+ }
+
+ return EINVAL;
+}
+
+paddr_t
+bus_space_mmap(bus_space_tag_t bst, bus_addr_t addr, off_t offset, int prot,
+ int flags)
+{
+
+ if (addr >= INTIOBASE && (addr + offset) < INTIOTOP)
+ return m68k_btop(addr + offset);
+
+ return -1;
+}
Index: src/sys/arch/next68k/dev/intiovar.h
diff -u src/sys/arch/next68k/dev/intiovar.h:1.7 src/sys/arch/next68k/dev/intiovar.h:1.8
--- src/sys/arch/next68k/dev/intiovar.h:1.7 Sun Jan 2 08:19:03 2011
+++ src/sys/arch/next68k/dev/intiovar.h Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: intiovar.h,v 1.7 2011/01/02 08:19:03 tsutsui Exp $ */
+/* $NetBSD: intiovar.h,v 1.8 2023/02/11 02:31:34 tsutsui Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@ struct intio_attach_args {
extern vaddr_t intiobase;
extern vaddr_t intiolimit;
-extern vaddr_t monobase;
-extern vaddr_t monolimit;
-extern vaddr_t colorbase;
-extern vaddr_t colorlimit;
+extern vaddr_t fbbase;
+extern vaddr_t fblimit;
+extern paddr_t fbbasepa;
+extern paddr_t fblimitpa;
Index: src/sys/arch/next68k/dev/nextdisplay.c
diff -u src/sys/arch/next68k/dev/nextdisplay.c:1.27 src/sys/arch/next68k/dev/nextdisplay.c:1.28
--- src/sys/arch/next68k/dev/nextdisplay.c:1.27 Fri Feb 3 23:21:17 2023
+++ src/sys/arch/next68k/dev/nextdisplay.c Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: nextdisplay.c,v 1.27 2023/02/03 23:21:17 tsutsui Exp $ */
+/* $NetBSD: nextdisplay.c,v 1.28 2023/02/11 02:31:34 tsutsui Exp $ */
/*
* Copyright (c) 1998 Matt DeBergalis
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nextdisplay.c,v 1.27 2023/02/03 23:21:17 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nextdisplay.c,v 1.28 2023/02/11 02:31:34 tsutsui Exp $");
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
@@ -162,15 +162,9 @@ nextdisplay_init(struct nextdisplay_conf
/* printf("in nextdisplay_init\n"); */
- if (color) {
- dc->dc_vaddr = colorbase;
- dc->dc_paddr = COLORBASE;
- dc->dc_size = NEXT_P_C16_VIDEOSIZE;
- } else {
- dc->dc_vaddr = monobase;
- dc->dc_paddr = MONOBASE;
- dc->dc_size = NEXT_P_VIDEOSIZE;
- }
+ dc->dc_vaddr = fbbase;
+ dc->dc_paddr = fbbasepa;
+ dc->dc_size = color ? NEXT_P_C16_VIDEOSIZE : NEXT_P_VIDEOSIZE;
dc->dc_wid = 1120;
dc->dc_ht = 832;
@@ -182,8 +176,8 @@ nextdisplay_init(struct nextdisplay_conf
#if 0
printf("intiobase at: %08x\n", intiobase);
printf("intiolimit at: %08x\n", intiolimit);
- printf("videobase at: %08x\n", color ? colorbase : monobase);
- printf("videolimit at: %08x\n", color ? colorlimit : monolimit);
+ printf("videobase at: %08x\n", fbbase);
+ printf("videolimit at: %08x\n", fblimit);
printf("virtual fb at: %08x\n", dc->dc_vaddr);
printf("physical fb at: %08x\n", dc->dc_paddr);
@@ -231,19 +225,11 @@ nextdisplay_attach(device_t parent, devi
struct nextdisplay_softc *sc = device_private(self);
struct wsemuldisplaydev_attach_args waa;
int isconsole;
- int iscolor;
- paddr_t addr;
+ vaddr_t addr;
sc->sc_dev = self;
- if (rom_machine_type == NeXT_WARP9C ||
- rom_machine_type == NeXT_TURBO_COLOR) {
- iscolor = 1;
- addr = colorbase;
- } else {
- iscolor = 0;
- addr = monobase;
- }
+ addr = fbbase;
isconsole = nextdisplay_is_console(addr);
@@ -400,13 +386,6 @@ nextdisplay_cnattach(void)
{
struct nextdisplay_config *dc = &nextdisplay_console_dc;
long defattr;
- int iscolor;
-
- if (rom_machine_type == NeXT_WARP9C ||
- rom_machine_type == NeXT_TURBO_COLOR)
- iscolor = 1;
- else
- iscolor = 0;
/* set up the display */
nextdisplay_init(&nextdisplay_console_dc, iscolor);
Index: src/sys/arch/next68k/include/bus_space.h
diff -u src/sys/arch/next68k/include/bus_space.h:1.22 src/sys/arch/next68k/include/bus_space.h:1.23
--- src/sys/arch/next68k/include/bus_space.h:1.22 Fri Feb 3 23:21:18 2023
+++ src/sys/arch/next68k/include/bus_space.h Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.h,v 1.22 2023/02/03 23:21:18 tsutsui Exp $ */
+/* $NetBSD: bus_space.h,v 1.23 2023/02/11 02:31:34 tsutsui Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -82,22 +82,11 @@ typedef u_long bus_space_handle_t;
#define NEXT68K_INTIO_BUS_SPACE ((bus_space_tag_t)intiobase)
/*
- * Values for the next68k video bus space tags, not to be used directly
- * by MI code.
- */
-#define NEXT68K_MONO_VIDEO_BUS_SPACE ((bus_space_tag_t)monobase)
-#define NEXT68K_COLOR_VIDEO_BUS_SPACE ((bus_space_tag_t)colorbase)
-
-/*
* Mapping and unmapping operations.
*/
-#define bus_space_map(t, a, s, f, hp) \
- ((((a)>=INTIOBASE)&&((a)+(s)<INTIOTOP)) ? \
- ((*(hp)=(bus_space_handle_t)((t)+((a)-INTIOBASE))),0) : \
- ((((a)>=MONOBASE)&&((a)+(s)<MONOTOP)) ? \
- ((*(hp)=(bus_space_handle_t)((t)+((a)-MONOBASE))),0) : \
- ((((a)>=COLORBASE)&&((a)+(s)<COLORTOP)) ? \
- ((*(hp)=(bus_space_handle_t)((t)+((a)-COLORBASE))),0) : (-1))))
+
+int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
+ bus_space_handle_t *);
#define bus_space_unmap(t, h, s)
@@ -122,13 +111,7 @@ typedef u_long bus_space_handle_t;
* Mmap an area of bus space.
*/
-#define bus_space_mmap(t, a, s, prot, flags) \
- ((((a)>=INTIOBASE)&&((a)+(s)<INTIOTOP)) ? \
- m68k_btop((t)+((a)-INTIOBASE)) : \
- ((((a)>=MONOBASE)&&((a)+(s)<MONOTOP)) ? \
- m68k_btop((t)+((a)-MONOBASE)) : \
- ((((a)>=COLORBASE)&&((a)+(s)<COLORTOP)) ? \
- m68k_btop((t)+((a)-COLORBASE)) : (-1))))
+paddr_t bus_space_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
/*
* uintN_t bus_space_read_N(bus_space_tag_t tag,
Index: src/sys/arch/next68k/include/cpu.h
diff -u src/sys/arch/next68k/include/cpu.h:1.51 src/sys/arch/next68k/include/cpu.h:1.52
--- src/sys/arch/next68k/include/cpu.h:1.51 Fri Jan 27 15:21:52 2023
+++ src/sys/arch/next68k/include/cpu.h Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.51 2023/01/27 15:21:52 tsutsui Exp $ */
+/* $NetBSD: cpu.h,v 1.52 2023/02/11 02:31:34 tsutsui Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -120,6 +120,7 @@ void loadustp(int);
void doboot(void) __attribute__((__noreturn__));
int nmihand(void *);
+extern int iscolor;
#endif /* _KERNEL */
#define NEXT_RAMBASE (0x4000000) /* really depends on slot, but... */
@@ -315,7 +316,10 @@ int nmihand(void *);
#define MONOBASE (0x0b000000)
#define MONOTOP (0x0b03a800)
#define COLORBASE (0x2c000000)
-#define COLORTOP (0x2c1D4000)
+#define COLORTOP (0x2c1d4000)
+#define TURBOFBBASE (0x0c000000)
+#define TURBOMONOTOP (0x0c03a800)
+#define TURBOCOLORTOP (0x0c1d4000)
#define NEXT_INTR_BITS \
"\20\40NMI\37PFAIL\36TIMER\35ENETX_DMA\34ENETR_DMA\33SCSI_DMA\32DISK_DMA\31PRINTER_DMA\30SOUND_OUT_DMA\27SOUND_IN_DMA\26SCC_DMA\25DSP_DMA\24M2R_DMA\23R2M_DMA\22SCC\21REMOTE\20BUS\17DSP_4\16DISK|C16_VIDEO\15SCSI\14PRINTER\13ENETX\12ENETR\11SOUND_OVRUN\10PHONE\07DSP_3\06VIDEO\05MONITOR\04KYBD_MOUSE\03POWER\02SOFTINT1\01SOFTINT0"
@@ -333,10 +337,4 @@ int nmihand(void *);
#define IIOP(va) ((int)(va)-intiobase+INTIOBASE)
#define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 2mb */
-/* mono fb space */
-#define MONOMAPSIZE btoc(MONOTOP-MONOBASE) /* who cares */
-
-/* color fb space */
-#define COLORMAPSIZE btoc(COLORTOP-COLORBASE) /* who cares */
-
#endif /* _MACHINE_CPU_H_ */
Index: src/sys/arch/next68k/next68k/locore.s
diff -u src/sys/arch/next68k/next68k/locore.s:1.71 src/sys/arch/next68k/next68k/locore.s:1.72
--- src/sys/arch/next68k/next68k/locore.s:1.71 Sat Feb 4 08:42:45 2023
+++ src/sys/arch/next68k/next68k/locore.s Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.71 2023/02/04 08:42:45 tsutsui Exp $ */
+/* $NetBSD: locore.s,v 1.72 2023/02/11 02:31:34 tsutsui Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
@@ -1076,17 +1076,17 @@ GLOBAL(intiobase)
GLOBAL(intiolimit)
.long INTIOTOP | KVA of end of internal IO space
-GLOBAL(monobase)
- .long MONOBASE | KVA of base of mono FB
+GLOBAL(fbbase)
+ .long 0 | KVA of base of framebuffer
-GLOBAL(monolimit)
- .long MONOTOP | KVA of end of mono FB
+GLOBAL(fblimit)
+ .long 0 | KVA of end of framebuffer
-GLOBAL(colorbase)
- .long COLORBASE | KVA of base of color FB
+GLOBAL(fbbasepa)
+ .long MONOBASE | PA of base of framebuffer
-GLOBAL(colorlimit)
- .long COLORTOP | KVA of end of color FB
+GLOBAL(fblimitpa)
+ .long MONOTOP | PA of end of framebuffer
ASLOCAL(save_vbr) | VBR from ROM
.long 0xdeadbeef
Index: src/sys/arch/next68k/next68k/nextrom.c
diff -u src/sys/arch/next68k/next68k/nextrom.c:1.27 src/sys/arch/next68k/next68k/nextrom.c:1.28
--- src/sys/arch/next68k/next68k/nextrom.c:1.27 Wed Jul 18 23:10:27 2018
+++ src/sys/arch/next68k/next68k/nextrom.c Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: nextrom.c,v 1.27 2018/07/18 23:10:27 sevan Exp $ */
+/* $NetBSD: nextrom.c,v 1.28 2023/02/11 02:31:34 tsutsui Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
* All rights reserved.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nextrom.c,v 1.27 2018/07/18 23:10:27 sevan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nextrom.c,v 1.28 2023/02/11 02:31:34 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_serial.h"
@@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: nextrom.c,v
#include <next68k/next68k/seglist.h>
#include <next68k/next68k/nextrom.h>
+#include <next68k/dev/intiovar.h>
#ifdef DDB
#include <sys/param.h>
@@ -130,6 +131,7 @@ u_int rom_intrstat;
paddr_t rom_reboot_vect;
int turbo;
+int iscolor;
void
next68k_bootargs(unsigned char **args)
@@ -230,6 +232,8 @@ next68k_bootargs(unsigned char **args)
int ix;
int j = 0;
char mach;
+ int turbo_l, iscolor_l;
+ paddr_t fbbasepa_l, fblimitpa_l;
if (MONRELOC(char, MG_machine_type) == NeXT_X15) {
msize16 = 0x1000000;
@@ -267,9 +271,32 @@ next68k_bootargs(unsigned char **args)
mach = MONRELOC(char, MG_machine_type);
RELOC(rom_machine_type, char) = mach;
if (mach == NeXT_TURBO_MONO || mach == NeXT_TURBO_COLOR)
- RELOC(turbo, int) = 1;
+ turbo_l = 1;
else
- RELOC(turbo, int) = 0;
+ turbo_l = 0;
+ RELOC(turbo, int) = turbo_l;
+
+ /* save framebuffer addresses for pmap_bootstrap() */
+ if (mach == NeXT_WARP9C || mach == NeXT_TURBO_COLOR)
+ iscolor_l = 1;
+ else
+ iscolor_l = 0;
+ if (turbo_l == 1) {
+ fbbasepa_l = TURBOFBBASE;
+ fblimitpa_l = (iscolor_l == 1) ?
+ TURBOCOLORTOP : TURBOMONOTOP;
+ } else {
+ if (iscolor_l == 1) {
+ fbbasepa_l = COLORBASE;
+ fblimitpa_l = COLORTOP;
+ } else {
+ fbbasepa_l = MONOBASE;
+ fblimitpa_l = MONOTOP;
+ }
+ }
+ RELOC(iscolor, int) = iscolor_l;
+ RELOC(fbbasepa, paddr_t) = fbbasepa_l;
+ RELOC(fblimitpa, paddr_t) = fblimitpa_l;
for (ix = 0; ix < N_SIMM; ix++) {
Index: src/sys/arch/next68k/next68k/pmap_bootstrap.c
diff -u src/sys/arch/next68k/next68k/pmap_bootstrap.c:1.46 src/sys/arch/next68k/next68k/pmap_bootstrap.c:1.47
--- src/sys/arch/next68k/next68k/pmap_bootstrap.c:1.46 Sat Feb 4 14:38:09 2023
+++ src/sys/arch/next68k/next68k/pmap_bootstrap.c Sat Feb 11 02:31:34 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap_bootstrap.c,v 1.46 2023/02/04 14:38:09 tsutsui Exp $ */
+/* $NetBSD: pmap_bootstrap.c,v 1.47 2023/02/11 02:31:34 tsutsui Exp $ */
/*
* This file was taken from mvme68k/mvme68k/pmap_bootstrap.c
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.46 2023/02/04 14:38:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.47 2023/02/11 02:31:34 tsutsui Exp $");
#include "opt_m68k_arch.h"
@@ -108,6 +108,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
#if defined(M68040) || defined(M68060)
u_int stfree = 0; /* XXX: gcc -Wuninitialized */
#endif
+ u_int fbmapsize;
/*
* Initialize the mem_clusters[] array for the crash dump
@@ -178,8 +179,9 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
kptmpa = nextpa;
nextpa += PAGE_SIZE;
kptpa = nextpa;
- nptpages = RELOC(Sysptsize, int) + howmany(RELOC(physmem, int), NPTEPG) +
- (IIOMAPSIZE + MONOMAPSIZE + COLORMAPSIZE + NPTEPG - 1) / NPTEPG;
+ fbmapsize = btoc(RELOC(fblimitpa, paddr_t) - RELOC(fbbasepa, paddr_t));
+ nptpages = RELOC(Sysptsize, int) + howmany(RELOC(physmem, int), NPTEPG)
+ + (IIOMAPSIZE + fbmapsize + NPTEPG - 1) / NPTEPG;
nextpa += nptpages * PAGE_SIZE;
/*
@@ -416,29 +418,20 @@ pmap_bootstrap(paddr_t nextpa, paddr_t f
protopte = INTIOBASE | PG_RW | PG_CI | PG_U | PG_M | PG_V;
epte = &pte[IIOMAPSIZE];
- RELOC(intiobase, uint8_t *) = (uint8_t *)PTE2VA(pte);
- RELOC(intiolimit, uint8_t *) = (uint8_t *)PTE2VA(epte);
+ RELOC(intiobase, vaddr_t) = PTE2VA(pte);
+ RELOC(intiolimit, vaddr_t) = PTE2VA(epte);
while (pte < epte) {
*pte++ = protopte;
protopte += PAGE_SIZE;
}
- /* validate the mono fb space PTEs */
+ /* validate the framebuffer space PTEs */
- protopte = MONOBASE | PG_RW | PG_CWT | PG_U | PG_M | PG_V;
- epte = &pte[MONOMAPSIZE];
- RELOC(monobase, uint8_t *) = (uint8_t *)PTE2VA(pte);
- RELOC(monolimit, uint8_t *) = (uint8_t *)PTE2VA(epte);
- while (pte < epte) {
- *pte++ = protopte;
- protopte += PAGE_SIZE;
- }
-
- /* validate the color fb space PTEs */
- protopte = COLORBASE | PG_RW | PG_CWT | PG_U | PG_M | PG_V;
- epte = &pte[COLORMAPSIZE];
- RELOC(colorbase, uint8_t *) = (uint8_t *)PTE2VA(pte);
- RELOC(colorlimit, uint8_t *) = (uint8_t *)PTE2VA(epte);
+ protopte = RELOC(fbbasepa, paddr_t) |
+ PG_RW | PG_CWT | PG_U | PG_M | PG_V;
+ epte = &pte[fbmapsize];
+ RELOC(fbbase, vaddr_t) = PTE2VA(pte);
+ RELOC(fblimit, vaddr_t) = PTE2VA(epte);
while (pte < epte) {
*pte++ = protopte;
protopte += PAGE_SIZE;