Module Name:    src
Committed By:   matt
Date:           Wed Sep 16 19:23:18 UTC 2009

Modified Files:
        src/sys/arch/pmax/include [matt-nb5-mips64]: dec_prom.h
        src/sys/arch/pmax/pmax [matt-nb5-mips64]: machdep.c promcall.c
        src/sys/arch/pmax/stand/common [matt-nb5-mips64]: callvec.c printf.S
            startprog.S

Log Message:
Deal with some LP64 issues with only O32 console.
Make bootloader invoke kernel compatible with both O32 and N32


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.96.1 src/sys/arch/pmax/include/dec_prom.h
cvs rdiff -u -r1.223.8.1.2.2 -r1.223.8.1.2.3 src/sys/arch/pmax/pmax/machdep.c
cvs rdiff -u -r1.12 -r1.12.76.1 src/sys/arch/pmax/pmax/promcall.c
cvs rdiff -u -r1.16 -r1.16.96.1 src/sys/arch/pmax/stand/common/callvec.c
cvs rdiff -u -r1.5 -r1.5.18.1 src/sys/arch/pmax/stand/common/printf.S
cvs rdiff -u -r1.4 -r1.4.18.1 src/sys/arch/pmax/stand/common/startprog.S

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/pmax/include/dec_prom.h
diff -u src/sys/arch/pmax/include/dec_prom.h:1.20 src/sys/arch/pmax/include/dec_prom.h:1.20.96.1
--- src/sys/arch/pmax/include/dec_prom.h:1.20	Sun Dec 11 12:18:39 2005
+++ src/sys/arch/pmax/include/dec_prom.h	Wed Sep 16 19:23:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dec_prom.h,v 1.20 2005/12/11 12:18:39 christos Exp $	*/
+/*	$NetBSD: dec_prom.h,v 1.20.96.1 2009/09/16 19:23:18 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -92,55 +92,59 @@
 typedef void (*psig_t)(int);
 
 struct callback {
-	void	*(*_memcpy) __P((void *, void *, int));		/* 00 */
-	void	*(*_memset) __P((void *, int, int));		/* 04 */
-	char	*(*_strcat) __P((char *, char *));		/* 08 */
-	int	(*_strcmp) __P((char *, char *));		/* 0c */
-	char	*(*_strcpy) __P((char *, char *));		/* 10 */
-	int	(*_strlen) __P((char *));			/* 14 */
-	char	*(*_strncat) __P((char *, char *, int));	/* 18 */
-	char	*(*_strncpy) __P((char *, char *, int));	/* 1c */
-	int	(*_strncmp) __P((char *, char *, int));		/* 20 */
-	int	(*_getchar) __P((void));			/* 24 */
-	char	*(*_gets) __P((char *));			/* 28 */
-	int	(*_puts) __P((char *));				/* 2c */
-	int	(*_printf) __P((const char *, ...));		/* 30 */
-	int	(*_sprintf) __P((char *, char *, ...));		/* 34 */
-	int	(*_io_poll) __P((void));			/* 38 */
-	long	(*_strtol) __P((char *, char **, int));		/* 3c */
-	psig_t	(*_signal) __P((int, psig_t));			/* 40 */
-	int	(*_raise) __P((int));				/* 44 */
-	long	(*_time) __P((long *));				/* 48 */
-	int	(*_setjmp) __P((jmp_buf));			/* 4c */
-	void	(*_longjmp) __P((jmp_buf, int));		/* 50 */
-	int	(*_bootinit) __P((char *));			/* 54 */
-	int	(*_bootread) __P((int, void *, int));		/* 58 */
-	int	(*_bootwrite) __P((int, void *, int));		/* 5c */
-	int	(*_setenv) __P((char *, char *));		/* 60 */
-	char	*(*_getenv) __P((const char *));		/* 64 */
-	int	(*_unsetenv) __P((char *));			/* 68 */
-	u_long	(*_slot_address) __P((int));			/* 6c */
-	void	(*_wbflush) __P((void));			/* 70 */
-	void	(*_msdelay) __P((int));				/* 74 */
-	void	(*_leds) __P((int));				/* 78 */
-	void	(*_clear_cache) __P((char *, int));		/* 7c */
-	int	(*_getsysid) __P((void));			/* 80 */
-	int	(*_getbitmap) __P((memmap *));			/* 84 */
-	int	(*_disableintr) __P((int));			/* 88 */
-	int	(*_enableintr) __P((int));			/* 8c */
-	int	(*_testintr) __P((int));			/* 90 */
+	void	*(*_memcpy)(void *, void *, int);		/* 00 */
+	void	*(*_memset)(void *, int, int);			/* 04 */
+	char	*(*_strcat)(char *, char *);			/* 08 */
+	int	(*_strcmp)(char *, char *);			/* 0c */
+	char	*(*_strcpy)(char *, char *);			/* 10 */
+	int	(*_strlen)(char *);				/* 14 */
+	char	*(*_strncat)(char *, char *, int);		/* 18 */
+	char	*(*_strncpy)(char *, char *, int);		/* 1c */
+	int	(*_strncmp)(char *, char *, int);		/* 20 */
+	int	(*_getchar)(void);				/* 24 */
+	char	*(*_gets)(char *);				/* 28 */
+	int	(*_puts)(char *);				/* 2c */
+	int	(*_printf)(const char *, ...);			/* 30 */
+	int	(*_sprintf)(char *, char *, ...);		/* 34 */
+	int	(*_io_poll)(void);				/* 38 */
+	long	(*_strtol)(char *, char **, int);		/* 3c */
+	psig_t	(*_signal)(int, psig_t);			/* 40 */
+	int	(*_raise)(int);					/* 44 */
+	long	(*_time)(long *);				/* 48 */
+	int	(*_setjmp)(jmp_buf);				/* 4c */
+	void	(*_longjmp)(jmp_buf, int);			/* 50 */
+	int	(*_bootinit)(char *);				/* 54 */
+	int	(*_bootread)(int, void *, int);			/* 58 */
+	int	(*_bootwrite)(int, void *, int);		/* 5c */
+	int	(*_setenv)(char *, char *);			/* 60 */
+	char	*(*_getenv)(const char *);			/* 64 */
+	int	(*_unsetenv)(char *);				/* 68 */
+	u_long	(*_slot_address)(int);				/* 6c */
+	void	(*_wbflush)(void);				/* 70 */
+	void	(*_msdelay)(int);				/* 74 */
+	void	(*_leds)(int);					/* 78 */
+	void	(*_clear_cache)(char *, int);			/* 7c */
+	int	(*_getsysid)(void);				/* 80 */
+	int	(*_getbitmap)(memmap *);			/* 84 */
+	int	(*_disableintr)(int);				/* 88 */
+	int	(*_enableintr)(int);				/* 8c */
+	int	(*_testintr)(int);				/* 90 */
 	void	*_reserved_data;				/* 94 */
-	int	(*_console_init) __P((void));			/* 98 */
-	void	(*_halt) __P((int *, int));			/* 9c */
-	void	(*_showfault) __P((void));			/* a0 */
-	tcinfo	*(*_gettcinfo) __P((void)); /*XXX* bogus proto */ /* a4 */
-	int	(*_execute_cmd) __P((char *));			/* a8 */
-	void	(*_rex) __P((char));				/* ac */
+	int	(*_console_init)(void);				/* 98 */
+	void	(*_halt)(int *, int);				/* 9c */
+	void	(*_showfault)(void);				/* a0 */
+	tcinfo	*(*_gettcinfo)(void);	 /* XXX bogus proto */	/* a4 */
+	int	(*_execute_cmd)(char *);			/* a8 */
+	void	(*_rex)(char);					/* ac */
 	/* b0 to d4 reserved */
 };
 
 extern const struct callback *callv;
+#ifdef _LP64
+extern struct callback callvec;
+#else
 extern const struct callback callvec;
+#endif
 
 #if defined(_STANDALONE) && !defined(_NO_PROM_DEFINES)
 #define memcpy (*callv -> _memcpy)

Index: src/sys/arch/pmax/pmax/machdep.c
diff -u src/sys/arch/pmax/pmax/machdep.c:1.223.8.1.2.2 src/sys/arch/pmax/pmax/machdep.c:1.223.8.1.2.3
--- src/sys/arch/pmax/pmax/machdep.c:1.223.8.1.2.2	Tue Sep  8 17:24:09 2009
+++ src/sys/arch/pmax/pmax/machdep.c	Wed Sep 16 19:23:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.223.8.1.2.2 2009/09/08 17:24:09 matt Exp $	*/
+/*	$NetBSD: machdep.c,v 1.223.8.1.2.3 2009/09/16 19:23:18 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223.8.1.2.2 2009/09/08 17:24:09 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223.8.1.2.3 2009/09/16 19:23:18 matt Exp $");
 
 #include "fs_mfs.h"
 #include "opt_ddb.h"
@@ -101,12 +101,15 @@
 #include <ufs/mfs/mfs_extern.h>		/* mfs_initminiroot() */
 
 #include <mips/cache.h>
-#include <machine/psl.h>
+#include <mips/regnum.h>
+#include <mips/psl.h>
+
 #include <machine/autoconf.h>
 #include <machine/dec_prom.h>
 #include <machine/sysconf.h>
 #include <machine/bootinfo.h>
 #include <machine/locore.h>
+
 #include <pmax/pmax/machdep.h>
 
 #define _PMAX_BUS_DMA_PRIVATE
@@ -158,7 +161,7 @@
  */
 int	safepri = MIPS3_PSL_LOWIPL;	/* XXX */
 
-void	mach_init __P((int, char *[], int, intptr_t, u_int, char *)); /* XXX */
+void	mach_init(int, int32_t *, int, intptr_t, u_int, char *); /* XXX */
 
 /* Motherboard or system-specific initialization vector */
 static void	unimpl_bus_reset __P((void));
@@ -183,19 +186,15 @@
 extern struct user *proc0paddr;		/* XXX */
 extern struct consdev promcd;		/* XXX */
 
+#define	ARGV(i)	((char *)(intptr_t)(argv32[i]))
+
 /*
  * Do all the stuff that locore normally does before calling main().
  * The first 4 argments are passed by PROM monitor, and remaining two
- * are built on temporary stack by our boot loader.
+ * are built on temporary stack by our boot loader (or in reg if N32/N64).
  */
 void
-mach_init(argc, argv, code, cv, bim, bip)
-	int argc;
-	char *argv[];
-	int code;
-	intptr_t cv;
-	u_int bim;
-	char *bip;
+mach_init(int argc, int32_t *argv32, int code, intptr_t cv, u_int bim, char *bip)
 {
 	char *cp;
 	const char *bootinfo_msg;
@@ -256,6 +255,21 @@
 	}
 
 	/* Initialize callv so we can do PROM output... */
+	if (code == DEC_PROM_MAGIC) {
+#ifdef _LP64
+		/*
+		 * Convert the call vector from using 32bit function pointers
+		 * to using 64bit function pointers.
+		 */
+		for (i = 0; i < sizeof(callvec) / sizeof(void *); i++)
+			((intptr_t *)&callvec)[i] = ((int32_t *)cv)[i];
+		callv = &callvec;
+#else
+		callv = (void *)cv;
+#endif
+	} else {
+		callv = &callvec;
+	}
 	callv = (code == DEC_PROM_MAGIC) ? (void *)cv : &callvec;
 
 	/* Use PROM console output until we initialize a console driver. */
@@ -284,13 +298,13 @@
 	pmax_bus_dma_init();
 
 	/* Check for direct boot from DS5000 REX monitor */
-	if (argc > 0 && strcmp(argv[0], "boot") == 0) {
+	if (argc > 0 && strcmp(ARGV(0), "boot") == 0) {
 		argc--;
-		argv++;
+		argv32++;
 	}
 
 	/* Look at argv[0] and compute bootdev */
-	makebootdev(argv[0]);
+	makebootdev(ARGV(0));
 
 	/*
 	 * Look at arguments passed to us and compute boothowto.
@@ -300,7 +314,7 @@
 	boothowto |= RB_KDB;
 #endif
 	for (i = 1; i < argc; i++) {
-		for (cp = argv[i]; *cp; cp++) {
+		for (cp = ARGV(i); *cp; cp++) {
 			switch (*cp) {
 			case 'a': /* autoboot */
 				boothowto &= ~RB_SINGLE;
@@ -347,7 +361,7 @@
 	lwp0.l_md.md_regs = (struct frame *)(kernend + USPACE) - 1;
 	memset(lwp0.l_addr, 0, USPACE);
 #ifdef _LP64
-	lwp0.l_md.md_regs->f_regs[_L_SR] = MIPS_SR_KX;
+	lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
 #endif
 	lwp0.l_addr->u_pcb.pcb_context.val[_L_SR] =
 #ifdef _LP64

Index: src/sys/arch/pmax/pmax/promcall.c
diff -u src/sys/arch/pmax/pmax/promcall.c:1.12 src/sys/arch/pmax/pmax/promcall.c:1.12.76.1
--- src/sys/arch/pmax/pmax/promcall.c:1.12	Sat Sep  9 08:27:13 2006
+++ src/sys/arch/pmax/pmax/promcall.c	Wed Sep 16 19:23:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: promcall.c,v 1.12 2006/09/09 08:27:13 tsutsui Exp $	*/
+/*	$NetBSD: promcall.c,v 1.12.76.1 2009/09/16 19:23:18 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.12 2006/09/09 08:27:13 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.12.76.1 2009/09/16 19:23:18 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -90,8 +90,8 @@
 #include <pmax/pmax/pmaxtype.h>
 #include <pmax/pmax/machdep.h>
 
-static int  romgetc __P((dev_t));
-static void romputc __P((dev_t, int));
+static int  romgetc (dev_t);
+static void romputc (dev_t, int);
 
 #define DEFAULT_SCSIID	7    /* XXX - this should really live somewhere else */
 
@@ -114,8 +114,7 @@
  * Get character from PROM console.
  */
 static int
-romgetc(dev)
-	dev_t dev;
+romgetc(dev_t dev)
 {
 	int chr, s;
 
@@ -129,9 +128,7 @@
  * Print a character on PROM console.
  */
 static void
-romputc(dev, c)
-	dev_t dev;
-	int c;
+romputc(dev_t dev, int c)
 {
 	int s;
 
@@ -146,10 +143,7 @@
  * Encoding is idiosyncratic; see DECstation Owners Guide.
  */
 void
-prom_findcons(kbdslot, crtslot, prom_using_screen)
-	int *kbdslot;
-	int *crtslot;
-	int *prom_using_screen;
+prom_findcons(int *kbdslot, int *crtslot, int *prom_using_screen)
 {
 	char *oscon = 0;	/* PROM osconsole string */
 
@@ -198,8 +192,7 @@
  * Get a prom environment variable.
  */
 char *
-prom_getenv(name)
-	const char *name;
+prom_getenv(const char *name)
 {
 	return (*callv->_getenv)(name);
 }
@@ -212,7 +205,7 @@
  *	hardware revision.	u_int8_t [0]
  */
 int
-prom_systype()
+prom_systype(void)
 {
 	char *cp;
 
@@ -226,7 +219,7 @@
  * Reset machine by haltbutton.
  */
 void
-prom_haltbutton()
+prom_haltbutton(void)
 {
 	(*callv->_halt)((int *)0, 0);
 }
@@ -234,15 +227,13 @@
 /*
  * Halt/reboot machine.
  */
-void __attribute__((__noreturn__))
-prom_halt(howto, bootstr)
-	int howto;
-	char *bootstr;
+void __dead
+prom_halt(int howto, char *bootstr)
 {
 	if (callv != &callvec)
 		(*callv->_rex)((howto & RB_HALT) ? 'h' : 'b');
 	else {
-		void __attribute__((__noreturn__)) (*f) __P((void));
+		void __dead (*f) __P((void));
 
 		f = (howto & RB_HALT)
 			? (void *)DEC_PROM_REINIT
@@ -258,8 +249,7 @@
  * Get the host SCSI ID from the PROM.
  */
 int
-prom_scsiid(cnum)
-	int cnum;
+prom_scsiid(int cnum)
 {
 	char scsiid_var[8];	/* strlen("scsiidX") + NULL */
 	char *cp;
@@ -273,8 +263,7 @@
  * Get the memory bitmap from the PROM if we can
  */
 int
-prom_getbitmap(map)
-	struct memmap *map;
+prom_getbitmap(struct memmap *map)
 {
 	char *cp;
 	int len;

Index: src/sys/arch/pmax/stand/common/callvec.c
diff -u src/sys/arch/pmax/stand/common/callvec.c:1.16 src/sys/arch/pmax/stand/common/callvec.c:1.16.96.1
--- src/sys/arch/pmax/stand/common/callvec.c:1.16	Sun Dec 11 12:18:39 2005
+++ src/sys/arch/pmax/stand/common/callvec.c	Wed Sep 16 19:23:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: callvec.c,v 1.16 2005/12/11 12:18:39 christos Exp $	*/
+/*	$NetBSD: callvec.c,v 1.16.96.1 2009/09/16 19:23:18 matt Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -36,51 +36,22 @@
 
 #include <machine/dec_prom.h>
 
-const struct callback callvec = {
-	(void *(*) __P((void *, void *, int)))0,
-	(void *(*) __P((void *, int, int)))0,
-	(char *(*) __P((char *, char *)))DEC_PROM_STRCAT,
-	(int (*) __P((char *, char *)))DEC_PROM_STRCMP,
-	(char *(*) __P((char *, char *)))DEC_PROM_STRCPY,
-	(int (*) __P((char *)))DEC_PROM_STRLEN,
-	(char *(*) __P((char *, char *, int)))0,
-	(char *(*) __P((char *, char *, int)))0,
-	(int (*) __P((char *, char *, int)))0,
-	(int (*) __P((void)))DEC_PROM_GETCHAR,
-	(char *(*) __P((char *)))DEC_PROM_GETS,
-	(int (*) __P((char *)))DEC_PROM_PUTS,
-	(int (*) __P((const char *, ...)))DEC_PROM_PRINTF,
-	(int (*) __P((char *, char *, ...)))0,
-	(int (*) __P((void)))0,
-	(long (*) __P((char *, char **, int)))0,
-	(psig_t (*) __P((int, psig_t)))0,
-	(int (*) __P((int)))0,
-	(long (*) __P((long *)))0,
-	(int (*) __P((jmp_buf)))0,
-	(void (*) __P((jmp_buf, int)))0,
-	(int (*) __P(( char *)))0,
-	(int (*) __P((int, void *, int)))0,
-	(int (*) __P((int, void *, int)))0,
-	(int (*) __P((char *, char *)))DEC_PROM_SETENV2,
-	(char *(*) __P((const char *)))DEC_PROM_GETENV2,
-	(int (*) __P((char *)))DEC_PROM_UNSETENV,
-	(u_long (*) __P((int)))0,
-	(void (*) __P((void)))0,
-	(void (*) __P((int)))0,
-	(void (*) __P((int)))0,
-	(void (*) __P((char *, int)))DEC_PROM_CLEARCACHE,
-	(int (*) __P((void)))0,
-	(int (*) __P((memmap *)))0,
-	(int (*) __P((int)))0,
-	(int (*) __P((int)))0,
-	(int (*) __P((int)))0,
-	(void *)0,
-	(int (*) __P((void)))0,
-	(void (*) __P((int *, int)))0,
-	(void (*) __P((void)))0,
-	(tcinfo *(*) __P((void)))0,	/* XXX what are the args for this?*/
-	(int (*) __P((char *)))0,
-	(void (*) __P((char)))0,
+#ifndef _LP64
+const
+#endif
+struct callback callvec = {
+	._strcat	= (void *)DEC_PROM_STRCAT,
+	._strcmp	= (void *)DEC_PROM_STRCMP,
+	._strcpy	= (void *)DEC_PROM_STRCPY,
+	._strlen	= (void *)DEC_PROM_STRLEN,
+	._getchar	= (void *)DEC_PROM_GETCHAR,
+	._gets		= (void *)DEC_PROM_GETS,
+	._puts		= (void *)DEC_PROM_PUTS,
+	._printf	= (void *)DEC_PROM_PRINTF,
+	._setenv	= (void *)DEC_PROM_SETENV2,
+	._getenv	= (void *)DEC_PROM_GETENV2,
+	._unsetenv	= (void *)DEC_PROM_UNSETENV,
+	._clear_cache	= (void *)DEC_PROM_CLEARCACHE,
 };
 
-const   struct callback *callv = &callvec;
+const struct callback *callv = &callvec;

Index: src/sys/arch/pmax/stand/common/printf.S
diff -u src/sys/arch/pmax/stand/common/printf.S:1.5 src/sys/arch/pmax/stand/common/printf.S:1.5.18.1
--- src/sys/arch/pmax/stand/common/printf.S:1.5	Mon Apr 28 20:23:31 2008
+++ src/sys/arch/pmax/stand/common/printf.S	Wed Sep 16 19:23:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: printf.S,v 1.5 2008/04/28 20:23:31 martin Exp $	*/
+/*	$NetBSD: printf.S,v 1.5.18.1 2009/09/16 19:23:18 matt Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,8 +35,27 @@
 
 LEAF(printf)
 	lw	v0, _C_LABEL(callv)	# get pointer to call back vectors
-	lw	v0, 0x30(v0)	# offset for callv->_printf
+	lw	t9, 0x30(v0)	# offset for callv->_printf
 	nop
-	j	v0		# call PROM printf
+#ifdef __mips_n32
+	/*
+	 * If someone calls printf with more than 4 args on n32,
+	 * we need to synthesize a o32 call.  For now we assume no more than
+	 * 8 arguments and no 64bit values.
+	 */
+	subu	sp, sp,	48
+	sw	a4, 16(sp)
+	sw	a5, 20(sp)
+	sw	a6, 24(sp)
+	sw	a7, 28(sp)
+	sw	ra, 44(sp)
+	jalr	t9		# call PROM printf
+	 nop
+	lw	ra, 44(sp)
+	j	ra
+	 addu	sp, sp, 48
+#else
+	j	t9		# call PROM printf
 	nop
+#endif
 END(printf)

Index: src/sys/arch/pmax/stand/common/startprog.S
diff -u src/sys/arch/pmax/stand/common/startprog.S:1.4 src/sys/arch/pmax/stand/common/startprog.S:1.4.18.1
--- src/sys/arch/pmax/stand/common/startprog.S:1.4	Mon Apr 28 20:23:31 2008
+++ src/sys/arch/pmax/stand/common/startprog.S	Wed Sep 16 19:23:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: startprog.S,v 1.4 2008/04/28 20:23:31 martin Exp $	*/
+/*	$NetBSD: startprog.S,v 1.4.18.1 2009/09/16 19:23:18 matt Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -39,26 +39,33 @@
 #include <mips/asm.h>
 
 LEAF(startprog)
-        subu    sp,sp,32
-	addu	t0,a1,-CALLFRAME_SIZ	# new stack value
-	move	t1,a0
+        subu    sp,sp,CALLFRAME_SIZ
+	addu	t2,a1,-CALLFRAME_SIZ	# new stack value
+	move	t9,a0
 	move	a0,a2
 	move	a1,a3
 
+#ifdef __mips_o32
 	lw	a2,48(sp)		# load everything from old stack we need
 	lw	a3,52(sp)
-	lw	v0,56(sp)
-	lw	v1,60(sp)
-
-	move	sp,t0			# new stack pointer
-	sw	ra,24(sp)
-
-	sw	v0,16(sp)
-	sw	v1,20(sp)
-	jal	ra,t1
+	lw	$8,56(sp)		# use a4/t0 in case N32/N64 kernel
+	lw	$9,60(sp)		# use a5/t1 in case N32/N64 kernel
+#else
+	move	a2,a4
+	move	a3,a5
+	move	a4,a6
+	move	a5,a7
+#endif
+
+	move	sp,t2			# new stack pointer
+	sw	ra,CALLFRAME_RA(sp)
+
+	sw	$8,16(sp)		# save on stack for O32
+	sw	$9,20(sp)		# save on stack for O32
+	jal	ra,t9
 	nop				# BDslot
 
-	lw	ra,24(sp)		# should not get back here!
+	lw	ra,CALLFRAME_RA(sp)	# should not get back here!
 	j	ra
-	addu	sp,sp,32
+	addu	sp,sp,CALLFRAME_SIZ
 END(startprog)

Reply via email to