Module Name:    src
Committed By:   cyber
Date:           Tue Dec  8 01:58:43 UTC 2009

Modified Files:
        src/sys/arch/sbmips/include [matt-nb5-mips64]: autoconf.h
        src/sys/arch/sbmips/sbmips [matt-nb5-mips64]: machdep.c

Log Message:
- fix to allow 64bit kernels to properly talk to the firmware
- allow visibiliy of additional RAM


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.126.1 src/sys/arch/sbmips/include/autoconf.h
cvs rdiff -u -r1.38.10.2 -r1.38.10.3 src/sys/arch/sbmips/sbmips/machdep.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/sbmips/include/autoconf.h
diff -u src/sys/arch/sbmips/include/autoconf.h:1.3 src/sys/arch/sbmips/include/autoconf.h:1.3.126.1
--- src/sys/arch/sbmips/include/autoconf.h:1.3	Sat Mar 22 14:26:43 2003
+++ src/sys/arch/sbmips/include/autoconf.h	Tue Dec  8 01:58:43 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.h,v 1.3 2003/03/22 14:26:43 simonb Exp $ */
+/* $NetBSD: autoconf.h,v 1.3.126.1 2009/12/08 01:58:43 cyber Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -49,14 +49,39 @@
 #define	BOOTINFO_MAGIC			0x1234ABCD
 #define	BOOTINFO_VERSION		1
 
+#if _LP64
+#define BI_FIXUP(x) ((vaddr_t)x | 0xffffffff00000000)
+#else
+#define BI_FIXUP(x) x
+#endif
+ 
+
 struct bootinfo_v1 {
-	u_long	version;		/*  0: version of bootinfo	 */
-	u_long	reserved;		/*  4: round to 64-bit boundary	 */
-	u_long	ssym;			/*  8: start of kernel sym table */
-	u_long	esym;			/* 12: end of kernel sym table	 */
+	uint32_t	version;	/*  0: version of bootinfo	 */
+	uint32_t	reserved;	/*  4: round to 64-bit boundary	 */
+	uint32_t	ssym;		/*  8: start of kernel sym table */
+	uint32_t	esym;		/* 12: end of kernel sym table	 */
 	char	boot_flags[64];		/* 16: boot flags		 */
 	char	booted_kernel[64];	/* 80: name of booted kernel	 */
-	u_long	fwhandle;		/* 144: firmware handle		 */
-	u_long	fwentry;		/* 148: firmware entry point	 */
+	uint32_t	fwhandle;	/* 144: firmware handle		 */
+	uint32_t	fwentry;	/* 148: firmware entry point	 */
 	u_char	reserved2[100];		/* 256: total size		 */
 };
+
+
+struct bootinfo_v1_int {
+	uint32_t	version;	/*   0/0: version of bootinfo	    */
+	uint32_t	reserved;	/*   4/4: round to 64-bit boundary  */
+	vaddr_t	ssym;			/*   8/8: start of kernel sym table */
+	vaddr_t	esym;			/* 12/16: end of kernel sym table   */
+	char	boot_flags[64];		/* 16/24: boot flags		    */
+	char	booted_kernel[64];	/* 80/88: name of booted kernel	    */
+	vaddr_t	fwhandle;		/* 144/152: firmware handle	    */
+	vaddr_t	fwentry;		/* 148/160: firmware entry point    */
+#ifdef _LP64
+	u_char	reserved2[88];		/* 168: total size -> 256	    */
+#else
+	u_char	reserved2[104];		/* 152: total size -> 256	    */
+#endif
+};
+

Index: src/sys/arch/sbmips/sbmips/machdep.c
diff -u src/sys/arch/sbmips/sbmips/machdep.c:1.38.10.2 src/sys/arch/sbmips/sbmips/machdep.c:1.38.10.3
--- src/sys/arch/sbmips/sbmips/machdep.c:1.38.10.2	Mon Nov 23 18:23:02 2009
+++ src/sys/arch/sbmips/sbmips/machdep.c	Tue Dec  8 01:58:43 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.38.10.2 2009/11/23 18:23:02 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.38.10.3 2009/12/08 01:58:43 cyber Exp $ */
 
 /*
  * Copyright 2000, 2001
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.10.2 2009/11/23 18:23:02 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.38.10.3 2009/12/08 01:58:43 cyber Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -134,7 +134,7 @@
 int	netboot;		/* Are we netbooting? */
 int	cfe_present;
 
-struct bootinfo_v1 bootinfo;
+struct bootinfo_v1_int bootinfo;
 
 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
 int mem_cluster_cnt;
@@ -162,6 +162,7 @@
 	extern char edata[], end[];
 	int i;
 	uint32_t config;
+	struct bootinfo_v1 *tmp_bi;
 
 	/* XXX this code must run on the target CPU */
 	config = mips3_cp0_config_read();
@@ -170,7 +171,11 @@
 	mips3_cp0_config_write(config);
 
 	/* Zero BSS.  XXXCGD: uh, is this really necessary still?  */
+#ifdef _LP64
+	memset((char *)((vaddr_t)edata | 0xffffffff00000000), 0, end - edata);
+#else
 	memset(edata, 0, end - edata);
+#endif
 
 	/*
 	 * Copy the bootinfo structure from the boot loader.
@@ -178,9 +183,16 @@
 	 * called because we may need CFE's TLB handler
 	 */
 
-	if (magic == BOOTINFO_MAGIC)
-		memcpy(&bootinfo, (struct bootinfo_v1 *)bootdata,
-		    sizeof bootinfo);
+	if (magic == BOOTINFO_MAGIC) {
+		tmp_bi = (struct bootinfo_v1 *)bootdata;
+		bootinfo.version = tmp_bi->version;
+		bootinfo.ssym =		BI_FIXUP(tmp_bi->ssym);
+		bootinfo.esym =		BI_FIXUP(tmp_bi->esym);
+		memcpy(&(bootinfo.boot_flags), tmp_bi->boot_flags, 64);
+		memcpy(&(bootinfo.booted_kernel), tmp_bi->booted_kernel, 64);
+		bootinfo.fwhandle =	BI_FIXUP(tmp_bi->fwhandle);
+		bootinfo.fwentry =	BI_FIXUP(tmp_bi->fwentry);
+	}
 	else if (reserved == CFE_EPTSEAL) {
 		magic = BOOTINFO_MAGIC;
 		bzero(&bootinfo, sizeof bootinfo);
@@ -240,7 +252,9 @@
 				 * XXX Ignore memory above 256MB for now, it
 				 * XXX needs special handling.
 				 */
+#ifndef _LP64
 				if (start < (256*1024*1024)) {
+#endif
 				    physmem += btoc(((int) len));
 				    mem_clusters[mem_cluster_cnt].start =
 					(long) start;
@@ -248,7 +262,9 @@
 					(long) len;
 				    mem_cluster_cnt++;
 				    added = 1;
+#ifndef _LP64
 				}
+#endif
 			}
 			if (added)
 				printf("added to map\n");

Reply via email to