Module Name:    src
Committed By:   martin
Date:           Sun Sep 11 18:14:55 UTC 2022

Modified Files:
        src/sys/arch/atari/atari [netbsd-9]: atari_init.c
        src/sys/arch/atari/conf [netbsd-9]: GENERIC.in files.atari

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1519):

        sys/arch/atari/conf/GENERIC.in: revision 1.123
        sys/arch/atari/conf/files.atari: revision 1.124
        sys/arch/atari/atari/atari_init.c: revision 1.105

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.101 -r1.101.8.1 src/sys/arch/atari/atari/atari_init.c
cvs rdiff -u -r1.118 -r1.118.4.1 src/sys/arch/atari/conf/GENERIC.in
cvs rdiff -u -r1.123 -r1.123.4.1 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.101 src/sys/arch/atari/atari/atari_init.c:1.101.8.1
--- src/sys/arch/atari/atari/atari_init.c:1.101	Mon Feb 26 15:11:12 2018
+++ src/sys/arch/atari/atari/atari_init.c	Sun Sep 11 18:14:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: atari_init.c,v 1.101 2018/02/26 15:11:12 tsutsui Exp $	*/
+/*	$NetBSD: atari_init.c,v 1.101.8.1 2022/09/11 18:14:55 martin Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -33,12 +33,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.101 2018/02/26 15:11:12 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.101.8.1 2022/09/11 18:14:55 martin 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.118 src/sys/arch/atari/conf/GENERIC.in:1.118.4.1
--- src/sys/arch/atari/conf/GENERIC.in:1.118	Sat Apr 13 08:22:59 2019
+++ src/sys/arch/atari/conf/GENERIC.in	Sun Sep 11 18:14:55 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC.in,v 1.118 2019/04/13 08:22:59 isaki Exp $
+#	$NetBSD: GENERIC.in,v 1.118.4.1 2022/09/11 18:14:55 martin Exp $
 #
 # Generic atari
 #
@@ -204,7 +204,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.123.4.1
--- src/sys/arch/atari/conf/files.atari:1.123	Mon Feb 18 01:12:22 2019
+++ src/sys/arch/atari/conf/files.atari	Sun Sep 11 18:14:55 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: files.atari,v 1.123 2019/02/18 01:12:22 thorpej Exp $
+#	$NetBSD: files.atari,v 1.123.4.1 2022/09/11 18:14:55 martin 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