Module Name:    src
Committed By:   tsutsui
Date:           Sat Jun 25 13:17:04 UTC 2022

Modified Files:
        src/sys/arch/atari/atari: atari_init.c
        src/sys/arch/atari/conf: GENERIC.in files.atari

Log Message:
Allocalte enough reserved ST-RAM to make the old Xserver work by default.

Instead, check ST-RAM size and TT-RAM size on startup and restrict
size of reserved ST memory on lower RAM machines.
Closes PR port-atari/41002 from David Ross.

While here, make options ST_POOL_SIZE defparam'ed to make sure to
reflect config(5) changes on each build.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sys/arch/atari/atari/atari_init.c
cvs rdiff -u -r1.122 -r1.123 src/sys/arch/atari/conf/GENERIC.in
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/atari/conf/files.atari

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/atari/atari/atari_init.c
diff -u src/sys/arch/atari/atari/atari_init.c:1.104 src/sys/arch/atari/atari/atari_init.c:1.105
--- src/sys/arch/atari/atari/atari_init.c:1.104	Tue May 24 06:28:00 2022
+++ src/sys/arch/atari/atari/atari_init.c	Sat Jun 25 13:17:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: atari_init.c,v 1.104 2022/05/24 06:28:00 andvar Exp $	*/
+/*	$NetBSD: atari_init.c,v 1.105 2022/06/25 13:17:04 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -33,12 +33,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.104 2022/05/24 06:28:00 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.105 2022/06/25 13:17:04 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mbtype.h"
 #include "opt_m060sp.h"
 #include "opt_m68k_arch.h"
+#include "opt_st_pool_size.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -145,18 +146,29 @@ extern struct pcb	*curpcb;
 vaddr_t	page_zero;
 
 /*
- * Crude support for allocation in ST-ram. Currently only used to allocate
- * video ram.
+ * Simple support for allocation in ST-ram.
+ * Currently 16 bit ST-ram is required to allocate DMA buffers for SCSI and
+ * FDC transfers, and video memory for the XFree68 based Xservers.
  * The physical address is also returned because the video init needs it to
  * setup the controller at the time the vm-system is not yet operational so
  * 'kvtop()' cannot be used.
  */
+#define	ST_POOL_SIZE_MIN	24	/* for DMA bounce buffers */
 #ifndef ST_POOL_SIZE
-#define	ST_POOL_SIZE	40			/* XXX: enough? */
+#define	ST_POOL_SIZE		56	/* Xserver requires 320KB (40 pages) */
 #endif
 
-u_long	st_pool_size = ST_POOL_SIZE * PAGE_SIZE; /* Patchable	*/
-u_long	st_pool_virt, st_pool_phys;
+psize_t	st_pool_size = ST_POOL_SIZE * PAGE_SIZE; /* Patchable	*/
+vaddr_t	st_pool_virt;
+paddr_t	st_pool_phys;
+
+/*
+ * Thresholds to restrict size of reserved ST memory to make sure
+ * the kernel at least boot even on lower memory machines.
+ * Nowadays we could assume most users have 4MB ST-RAM and 16MB TT-RAM.
+ */
+#define	STRAM_MINTHRESH		(2 * 1024 * 1024)
+#define	TTRAM_MINTHRESH		(4 * 1024 * 1024)
 
 /* I/O address space variables */
 vaddr_t	stio_addr;		/* Where the st io-area is mapped	*/
@@ -284,12 +296,20 @@ start_c(int id, u_int ttphystart, u_int 
 #endif
 
 	/*
-	 * The following is a hack. We do not know how much ST memory we
-	 * really need until after configuration has finished. At this
-	 * time I have no idea how to grab ST memory at that time.
+	 * We do not know how much ST memory we really need until after
+	 * configuration has finished, but typical users of ST memory
+	 * are bounce buffers DMA against TT-RAM for SCSI and FDC,
+	 * and video memory for the Xserver.
+	 * If we have enough RAMs reserve ST memory including for the Xserver.
+	 * Otherwise just allocate minimum one for SCSI and FDC.
+	 *
 	 * The round_page() call is ment to correct errors made by
 	 * binpatching!
 	 */
+	if (st_pool_size > ST_POOL_SIZE_MIN * PAGE_SIZE &&
+	    (stphysize <= STRAM_MINTHRESH || ttphysize <= TTRAM_MINTHRESH)) {
+		st_pool_size = ST_POOL_SIZE_MIN * PAGE_SIZE;
+	}
 	st_pool_size   = m68k_round_page(st_pool_size);
 	st_pool_phys   = stphysize - st_pool_size;
 	stphysize      = st_pool_phys;

Index: src/sys/arch/atari/conf/GENERIC.in
diff -u src/sys/arch/atari/conf/GENERIC.in:1.122 src/sys/arch/atari/conf/GENERIC.in:1.123
--- src/sys/arch/atari/conf/GENERIC.in:1.122	Sun Jun 12 06:54:32 2022
+++ src/sys/arch/atari/conf/GENERIC.in	Sat Jun 25 13:17:04 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC.in,v 1.122 2022/06/12 06:54:32 tsutsui Exp $
+#	$NetBSD: GENERIC.in,v 1.123 2022/06/25 13:17:04 tsutsui Exp $
 #
 # Generic atari
 #
@@ -207,7 +207,7 @@ options		PIPE_SOCKETPAIR	# smaller, but 
 # Atari specific options
 #
 #options 	KFONT_8x8		# Use 8x8 font instead of 8x16
-options 	ST_POOL_SIZE=24		# smallest that allows TT-HIGH
+options 	ST_POOL_SIZE=56		# for SCSI, FDC, and Xserver
 #if defined(TT030_KERNEL) || defined(HADES_KERNEL)
 options 	TT_SCSI			# SCSI-support for TT
 options 	TT_VIDEO		# Graphics support for TT

Index: src/sys/arch/atari/conf/files.atari
diff -u src/sys/arch/atari/conf/files.atari:1.123 src/sys/arch/atari/conf/files.atari:1.124
--- src/sys/arch/atari/conf/files.atari:1.123	Mon Feb 18 01:12:22 2019
+++ src/sys/arch/atari/conf/files.atari	Sat Jun 25 13:17:04 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: files.atari,v 1.123 2019/02/18 01:12:22 thorpej Exp $
+#	$NetBSD: files.atari,v 1.124 2022/06/25 13:17:04 tsutsui Exp $
 
 maxpartitions 16
 
@@ -9,6 +9,7 @@ defflag 	opt_mbtype.h		_MILANHW_ _ATARIH
 defflag 	opt_serconsole.h	SERCONSOLE
 defflag 	opt_atariscsi.h		TT_SCSI FALCON_SCSI
 defparam	opt_atariscsi.h		TRY_SCSI_LINKED_COMMANDS
+defparam				ST_POOL_SIZE
 
 defflag		opt_m060sp.h		M060SP
 defflag					PANICBUTTON

Reply via email to