Subject: Re: Fun w/ 4GB RAM
To: None <port-i386@netbsd.org>
From: Jason R Thorpe <thorpej@zembu.com>
List: port-i386
Date: 04/21/2000 11:34:41
--MGYHOYXEY6WxJCY8
Content-Type: text/plain; charset=us-ascii

On Fri, Apr 21, 2000 at 04:53:39AM +0200, Hubert Feyrer wrote:

 > Today I had the opportunity to play with a 4*PIII-550Xeon machine with 4GB
 > RAM. Both the 20000416 snapshot's floppies and the latest mptest floppies
 > (dated feb 29) give some funny things from the boot loader, and then 
 > exploded at different places.

I just committed the attached patch.

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>

--MGYHOYXEY6WxJCY8
Content-Type: text/plain; charset=us-ascii
Content-Description: bios{base,ext}mem overflow fix
Content-Disposition: attachment; filename=foo

Index: i386/apm.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/apm.c,v
retrieving revision 1.46
diff -c -r1.46 apm.c
*** apm.c	2000/03/15 09:30:11	1.46
--- apm.c	2000/04/21 18:26:32
***************
*** 906,912 ****
  	struct device *parent, *self;
  	void *aux;
  {
- 	extern int biosbasemem;
  	struct apm_softc *apmsc = (void *)self;
  	struct bioscallregs regs;
  	int error, apm_data_seg_ok;
--- 906,911 ----
Index: i386/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.380
diff -c -r1.380 machdep.c
*** machdep.c	2000/04/05 10:09:50	1.380
--- machdep.c	2000/04/21 18:26:41
***************
*** 201,207 ****
  vm_map_t mb_map = NULL;
  vm_map_t phys_map = NULL;
  
- extern	int biosbasemem, biosextmem;
  extern	paddr_t avail_start, avail_end;
  extern	paddr_t hole_start, hole_end;
  
--- 206,211 ----
***************
*** 1521,1534 ****
  extern vector IDTVEC(svr4_fasttrap);
  #endif /* COMPAT_SVR4 */
  
  void
  init386(first_avail)
  	vaddr_t first_avail;
  {
- 	int x;
- 	struct region_descriptor region;
  	extern void consinit __P((void));
  	extern struct extent *iomem_ex;
  
  	proc0.p_addr = proc0paddr;
  	curpcb = &proc0.p_addr->u_pcb;
--- 1528,1543 ----
  extern vector IDTVEC(svr4_fasttrap);
  #endif /* COMPAT_SVR4 */
  
+ #define	KBTOB(x)	((size_t)(x) * 1024UL)
+ 
  void
  init386(first_avail)
  	vaddr_t first_avail;
  {
  	extern void consinit __P((void));
  	extern struct extent *iomem_ex;
+ 	struct region_descriptor region;
+ 	int x;
  
  	proc0.p_addr = proc0paddr;
  	curpcb = &proc0.p_addr->u_pcb;
***************
*** 1542,1552 ****
  	 * extent map.  This is done before the addresses are
  	 * page rounded just to make sure we get them all.
  	 */
! 	if (extent_alloc_region(iomem_ex, 0, biosbasemem * 1024, EX_NOWAIT)) {
  		/* XXX What should we do? */
  		printf("WARNING: CAN'T ALLOCATE BASE MEMORY FROM IOMEM EXTENT MAP!\n");
  	}
! 	if (extent_alloc_region(iomem_ex, IOM_END, biosextmem * 1024,
  	    EX_NOWAIT)) {
  		/* XXX What should we do? */
  		printf("WARNING: CAN'T ALLOCATE EXTENDED MEMORY FROM IOMEM EXTENT MAP!\n");
--- 1551,1561 ----
  	 * extent map.  This is done before the addresses are
  	 * page rounded just to make sure we get them all.
  	 */
! 	if (extent_alloc_region(iomem_ex, 0, KBTOB(biosbasemem), EX_NOWAIT)) {
  		/* XXX What should we do? */
  		printf("WARNING: CAN'T ALLOCATE BASE MEMORY FROM IOMEM EXTENT MAP!\n");
  	}
! 	if (extent_alloc_region(iomem_ex, IOM_END, KBTOB(biosextmem),
  	    EX_NOWAIT)) {
  		/* XXX What should we do? */
  		printf("WARNING: CAN'T ALLOCATE EXTENDED MEMORY FROM IOMEM EXTENT MAP!\n");
***************
*** 1575,1588 ****
  
  #if NBIOSCALL > 0
  	avail_start = 3*NBPG;	/* save us a page for trampoline code and
! 				 one additional PT page! */
  #else
  	avail_start = NBPG;	/* BIOS leaves data in low memory */
  				/* and VM system doesn't work with phys 0 */
  #endif
! 	avail_end = IOM_END + trunc_page(biosextmem * 1024);
  
! 	hole_start = trunc_page(biosbasemem * 1024);
  	/* we load right after the I/O hole; adjust hole_end to compensate */
  	hole_end = round_page(first_avail);
  
--- 1584,1597 ----
  
  #if NBIOSCALL > 0
  	avail_start = 3*NBPG;	/* save us a page for trampoline code and
! 				   one additional PT page! */
  #else
  	avail_start = NBPG;	/* BIOS leaves data in low memory */
  				/* and VM system doesn't work with phys 0 */
  #endif
! 	avail_end = IOM_END + trunc_page(KBTOB(biosextmem));
  
! 	hole_start = trunc_page(KBTOB(biosbasemem));
  	/* we load right after the I/O hole; adjust hole_end to compensate */
  	hole_end = round_page(first_avail);
  
***************
*** 1694,1706 ****
  	enable_intr();
  
  	/* number of pages of physmem addr space */
! 	physmem = btoc(biosbasemem * 1024) + btoc(biosextmem * 1024);
  
  	mem_clusters[0].start = 0;
! 	mem_clusters[0].size  = trunc_page(biosbasemem * 1024);
  
  	mem_clusters[1].start = IOM_END;
! 	mem_clusters[1].size  = trunc_page(biosextmem * 1024);
  
  	mem_cluster_cnt = 2;
  
--- 1703,1715 ----
  	enable_intr();
  
  	/* number of pages of physmem addr space */
! 	physmem = btoc(KBTOB(biosbasemem)) + btoc(KBTOB(biosextmem));
  
  	mem_clusters[0].start = 0;
! 	mem_clusters[0].size  = trunc_page(KBTOB(biosbasemem));
  
  	mem_clusters[1].start = IOM_END;
! 	mem_clusters[1].size  = trunc_page(KBTOB(biosextmem));
  
  	mem_cluster_cnt = 2;
  
Index: include/cpu.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/include/cpu.h,v
retrieving revision 1.61
diff -c -r1.61 cpu.h
*** cpu.h	2000/03/29 03:54:03	1.61
--- cpu.h	2000/04/21 18:26:50
***************
*** 120,125 ****
--- 120,127 ----
  };
  
  #ifdef _KERNEL
+ extern int biosbasemem;
+ extern int biosextmem;
  extern int cpu;
  extern int cpu_class;
  extern int cpu_feature;
  

--MGYHOYXEY6WxJCY8--