Module Name:    src
Committed By:   matt
Date:           Sun Feb 20 08:02:46 UTC 2011

Modified Files:
        src/sys/dev/arcbios: arcbios.c arcbios.h arcbios_tty.c
Added Files:
        src/sys/dev/arcbios: Makefile.inc arcbios_calls.S genassym.cf

Log Message:
(XXX this should be a library like libsa).
Deal with the need to save/restore T8 (CURLWP) across arcbios calls.
Call arcbios with O32 ABI conventions even if kernel/bootloader is N32/N64.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/arcbios/Makefile.inc \
    src/sys/dev/arcbios/arcbios_calls.S src/sys/dev/arcbios/genassym.cf
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/arcbios/arcbios.c \
    src/sys/dev/arcbios/arcbios.h
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/arcbios/arcbios_tty.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/dev/arcbios/arcbios.c
diff -u src/sys/dev/arcbios/arcbios.c:1.12 src/sys/dev/arcbios/arcbios.c:1.13
--- src/sys/dev/arcbios/arcbios.c:1.12	Mon Apr 28 20:23:47 2008
+++ src/sys/dev/arcbios/arcbios.c	Sun Feb 20 08:02:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: arcbios.c,v 1.12 2008/04/28 20:23:47 martin Exp $	*/
+/*	$NetBSD: arcbios.c,v 1.13 2011/02/20 08:02:46 matt Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arcbios.c,v 1.12 2008/04/28 20:23:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arcbios.c,v 1.13 2011/02/20 08:02:46 matt Exp $");
 
 #include <sys/param.h>
 
@@ -87,7 +87,7 @@
 	}
 
 	/* Initialize our pointer to the firmware vector. */
-	ARCBIOS = ARCBIOS_SPB->FirmwareVector;
+	ARCBIOS = (void *)(intptr_t)ARCBIOS_SPB->FirmwareVector;
 
 	/* Find the ARC BIOS console device major (needed by cnopen) */
 	maj = cdevsw_lookup_major(&arcbios_cdevsw);
@@ -100,7 +100,7 @@
 	/*
 	 * Fetch the system ID.
 	 */
-	sid = (*ARCBIOS->GetSystemId)();
+	sid = arcbios_GetSystemId();
 	if (sid != NULL) {
 		memcpy(arcbios_sysid_vendor, sid->VendorId,
 		    sizeof(sid->VendorId));
@@ -148,9 +148,9 @@
     struct arcbios_treewalk_context *atc)
 {
 
-	for (node = (*ARCBIOS->GetChild)(node);
+	for (node = arcbios_GetChild(node);
 	     node != NULL && atc->atc_terminate == 0;
-	     node = (*ARCBIOS->GetPeer)(node)) {
+	     node = arcbios_GetPeer(node)) {
 		(*func)(node, atc);
 		if (atc->atc_terminate)
 			return;
@@ -178,7 +178,7 @@
 	dstsize--;
 	if (dstsize > node->IdentifierLength)
 		dstsize = node->IdentifierLength;
-	memcpy(dst, node->Identifier, dstsize);
+	memcpy(dst, (void *)(intptr_t)node->Identifier, dstsize);
 	dst[dstsize] = '\0';
 }
 
@@ -192,7 +192,7 @@
 	u_long count;
 	char c;
 
-	(*ARCBIOS->Read)(ARCBIOS_STDIN, &c, 1, &count);
+	arcbios_Read(ARCBIOS_STDIN, &c, 1, &count);
 	return (c);
 }
 
@@ -202,5 +202,5 @@
 	u_long count;
 	char ch = c;
 
-	(*ARCBIOS->Write)(ARCBIOS_STDOUT, &ch, 1, &count);
+	arcbios_Write(ARCBIOS_STDOUT, &ch, 1, &count);
 }
Index: src/sys/dev/arcbios/arcbios.h
diff -u src/sys/dev/arcbios/arcbios.h:1.12 src/sys/dev/arcbios/arcbios.h:1.13
--- src/sys/dev/arcbios/arcbios.h:1.12	Mon Apr 28 20:23:47 2008
+++ src/sys/dev/arcbios/arcbios.h	Sun Feb 20 08:02:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: arcbios.h,v 1.12 2008/04/28 20:23:47 martin Exp $	*/
+/*	$NetBSD: arcbios.h,v 1.13 2011/02/20 08:02:46 matt Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -78,22 +78,22 @@
  * 4.2.2: System Parameter Block
  */
 struct arcbios_spb {
-	u_long		SPBSignature;
-	u_long		SPBLength;
+	uint32_t	SPBSignature;
+	uint32_t	SPBLength;
 	uint16_t	Version;
 	uint16_t	Revision;
-	void		*RestartBlock;
-	void		*DebugBlock;
-	void		*GEVector;
-	void		*UTLBMissVector;
-	u_long		FirmwareVectorLength;
-	void		*FirmwareVector;
-	u_long		PrivateVectorLength;
-	void		*PrivateVector;
-	u_long		AdapterCount;
-	u_long		AdapterType;
-	u_long		AdapterVectorLength;
-	void		*AdapterVector;
+	int32_t		RestartBlock;
+	int32_t		DebugBlock;
+	int32_t		GEVector;
+	int32_t		UTLBMissVector;
+	uint32_t	FirmwareVectorLength;
+	int32_t		FirmwareVector;
+	uint32_t	PrivateVectorLength;
+	int32_t		PrivateVector;
+	uint32_t	AdapterCount;
+	uint32_t	AdapterType;
+	uint32_t	AdapterVectorLength;
+	int32_t		AdapterVector;
 };
 
 #define	ARCBIOS_SPB_SIGNATURE	0x53435241	/* A R C S */
@@ -108,11 +108,11 @@
 	uint32_t	Flags;
 	uint16_t	Version;
 	uint16_t	Revision;
-	u_long		Key;
-	u_long		AffinityMask;
-	u_long		ConfigurationDataSize;
-	u_long		IdentifierLength;
-	char		*Identifier;
+	uint32_t	Key;
+	uint32_t	AffinityMask;
+	uint32_t	ConfigurationDataSize;
+	uint32_t	IdentifierLength;
+	int32_t		Identifier;
 };
 
 /*
@@ -277,8 +277,8 @@
  */
 struct arcbios_mem {
 	uint32_t	Type;
-	u_long		BasePage;
-	u_long		PageCount;
+	uint32_t	BasePage;
+	uint32_t	PageCount;
 };
 
 #if defined(sgimips)
@@ -320,148 +320,89 @@
  * ARC firmware vector
  */
 struct arcbios_fv {
-	long		(*Load)(
-			    char *,		/* image to load */
-			    u_long,		/* top address */
-			    u_long,		/* entry address */
-			    u_long *);		/* low address */
-
-	long		(*Invoke)(
-			    u_long,		/* entry address */
-			    u_long,		/* stack address */
-			    u_long,		/* argc */
-			    char **,		/* argv */
-			    char **);		/* envp */
-
-	long		(*Execute)(
-			    char *,		/* image path */
-			    u_long,		/* argc */
-			    char **,		/* argv */
-			    char **);		/* envp */
-
-	void		(*Halt)(void)
-			    __dead;
-
-	void		(*PowerDown)(void)
-			    __dead;
-
-	void		(*Restart)(void)
-			    __dead;
-
-	void		(*Reboot)(void)
-			    __dead;
-
-	void		(*EnterInteractiveMode)(void)
-			    __dead;
-#if defined(sgimips)
-	void		*reserved0;
-#else
-	void		(*ReturnFromMain)(void)
-			    __dead;
-#endif
-	void		*(*GetPeer)(
-			    void *);		/* component */
-
-	void		*(*GetChild)(
-			    void *);		/* component */
-
-	void		*(*GetParent)(
-			    void *);		/* component */
-
-	long		(*GetConfigurationData)(
-			    void *,		/* configuration data */
-			    void *);		/* component */
-
-	void		*(*AddChild)(
-			    void *,		/* component */
-			    void *);		/* new component */
-
-	long		(*DeleteComponent)(
-			    void *);		/* component */
-
-	void		*(*GetComponent)(
-			    char *);		/* path */
-
-	long		(*SaveConfiguration)(void);
-
-	void		*(*GetSystemId)(void);
-
-	void		*(*GetMemoryDescriptor)(
-			    void *);		/* memory descriptor */
-#if defined(sgimips)
-	void		*reserved1;
-#else
-	void		(*Signal)(
-			    u_long,		/* signal number */
-			    void *);		/* handler */
-#endif
-	void		*(*GetTime)(void);
-
-	u_long		(*GetRelativeTime)(void);
+	int32_t		Load;
+	int32_t		Invoke;
+	int32_t		Execute;
+	int32_t		Halt;
+	int32_t		PowerDown;
+	int32_t		Restart;
+	int32_t		Reboot;
+	int32_t		EnterInteractiveMode;
+	int32_t		ReturnFromMain;		/* not on sgimips */
+	int32_t		GetPeer;
+	int32_t		GetChild;
+	int32_t		GetParent;
+	int32_t		GetConfigurationData;
+	int32_t		AddChild;
+	int32_t		DeleteComponent;
+	int32_t		GetComponent;
+	int32_t		SaveConfiguration;
+	int32_t		GetSystemId;
+	int32_t		GetMemoryDescriptor;
+	int32_t		Signal;			/* not on sgimips */
+	int32_t		GetTime;
+	int32_t		GetRelativeTime;
+	int32_t		GetDirectoryEntry;
+	int32_t		Open;
+	int32_t		Close;
+	int32_t		Read;
+	int32_t		GetReadStatus;
+	int32_t		Write;
+	int32_t		Seek;
+	int32_t		Mount;
+	int32_t		GetEnvironmentVariable;
+	int32_t		SetEnvironmentVariable;
+	int32_t		GetFileInformation;
+	int32_t		SetFileInformation;
+	int32_t		FlushAllCaches;
+	int32_t		TestUnicode;		/* not on sgimips */
+	int32_t		GetDisplayStatus;	/* not on sgimips */
+};
 
-	long		(*GetDirectoryEntry)(
-			    u_long,		/* file ID */
-			    void *,		/* directory entry */
-			    u_long,		/* length */
-			    u_long *);	/* count */
-
-	long		(*Open)(
-			    char *,		/* path */
-			    u_long,		/* open mode */
-			    u_long *);		/* file ID */
-
-	long		(*Close)(
-			    u_long);		/* file ID */
-
-	long		(*Read)(
-			    u_long,		/* file ID */
-			    void *,		/* buffer */
-			    u_long,		/* length */
-			    u_long *);		/* count */
-
-	long		(*GetReadStatus)(
-			    u_long);		/* file ID */
-
-	long		(*Write)(
-			    u_long,		/* file ID */
-			    void *,		/* buffer */
-			    u_long,		/* length */
-			    u_long *);		/* count */
-
-	long		(*Seek)(
-			    u_long,		/* file ID */
-			    int64_t *,		/* offset */
-			    u_long);		/* whence */
-
-	long		(*Mount)(
-			    char *,		/* path */
-			    u_long);		/* operation */
-
-	const char	*(*GetEnvironmentVariable)(
-			    const char *);	/* variable */
-
-	long		(*SetEnvironmentVariable)(
-			    const char *,	/* variable */
-			    const char *);	/* contents */
-
-	long		(*GetFileInformation)(
-			    u_long,		/* file ID */
-			    void *);		/* XXX */
-
-	long		(*SetFileInformation)(
-			    u_long,		/* file ID */
-			    u_long,		/* XXX */
-			    u_long);		/* XXX */
-
-	void		(*FlushAllCaches)(void);
-#if !defined(sgimips)
-	paddr_t		(*TestUnicode)(
-			    u_long,		/* file ID */
-			    uint16_t);		/* unicode character */
+#if defined(_KERNEL) || defined(_STANDALONE)
+/*
+ * ARC firmware vector calls
+ */
+long	arcbios_Load(char *, u_long, u_long, u_long *);
+long	arcbios_Invoke(u_long, u_long, u_long, char **, char **);
+long	arcbios_Execute(char *, u_long, char **, char **);
+void	arcbios_Halt(void) __dead;
+void	arcbios_PowerDown(void) __dead;
+void	arcbios_Restart(void) __dead;
+void	arcbios_Reboot(void) __dead;
+void	arcbios_EnterInteractiveMode(void) __dead;
+void	arcbios_ReturnFromMain(void) __dead;		/* not on sgimips */
+void *	arcbios_GetPeer(void *);
+void *	arcbios_GetChild(void *);
+void *	arcbios_GetParent(void *);
+long	arcbios_GetConfigurationData(void *, void *);
+void *	arcbios_AddChild(void *, void *);
+long	arcbios_DeleteComponent(void *);
+void *	arcbios_GetComponent(char *);
+long	arcbios_SaveConfiguration(void);
+void *	arcbios_GetSystemId(void);
+void *	arcbios_GetMemoryDescriptor(void *);
+void	arcbios_Signal(u_long, void *);			/* not on sgimips */
+void *	arcbios_GetTime(void);
+u_long	arcbios_GetRelativeTime(void);
+
+long	arcbios_GetDirectoryEntry(u_long, void *, u_long, u_long *);
+long	arcbios_Open(const char *, u_long, u_long *);
+long	arcbios_Close(u_long);
+long	arcbios_Read(u_long, void *, u_long, u_long *);
+long	arcbios_GetReadStatus(u_long);
+long	arcbios_Write(u_long, void *, u_long, u_long *);
+long	arcbios_Seek(u_long, int64_t *, u_long);
+long	arcbios_Mount(char *, u_long);
+const char *
+	arcbios_GetEnvironmentVariable(const char *);
+long	arcbios_SetEnvironmentVariable(const char *, const char *);
+long	arcbios_GetFileInformation(u_long, void *);
+long	arcbios_SetFileInformation(u_long, u_long, u_long);
+void	arcbios_FlushAllCaches(void);
+paddr_t	arcbios_TestUnicode(u_long, uint16_t);		/* not on sgimips */
+void *	arcbios_GetDisplayStatus(u_long);		/* not on sgimips */
 
-	void		*(*GetDisplayStatus)(
-			    u_long);		/* file ID */
-#endif
-};
+#endif /* _KERNEL || _STANDALONE */
 
 #endif /* _ARCBIOS_H_ */

Index: src/sys/dev/arcbios/arcbios_tty.c
diff -u src/sys/dev/arcbios/arcbios_tty.c:1.20 src/sys/dev/arcbios/arcbios_tty.c:1.21
--- src/sys/dev/arcbios/arcbios_tty.c:1.20	Mon Nov 23 02:13:45 2009
+++ src/sys/dev/arcbios/arcbios_tty.c	Sun Feb 20 08:02:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: arcbios_tty.c,v 1.20 2009/11/23 02:13:45 rmind Exp $	*/
+/*	$NetBSD: arcbios_tty.c,v 1.21 2011/02/20 08:02:46 matt Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arcbios_tty.c,v 1.20 2009/11/23 02:13:45 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arcbios_tty.c,v 1.21 2011/02/20 08:02:46 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/uio.h>
@@ -191,7 +191,7 @@
 	ttypull(tp);
 	tp->t_state |= TS_BUSY;
 	while (tp->t_outq.c_cc != 0) {
-		(*ARCBIOS->Write)(ARCBIOS_STDOUT, tp->t_outq.c_cf,
+		arcbios_Write(ARCBIOS_STDOUT, tp->t_outq.c_cf,
 		    ndqb(&tp->t_outq, 0), &count);
 		ndflush(&tp->t_outq, count);
 	}
@@ -219,10 +219,10 @@
 	int32_t q;
 	u_long count;
 
-	q = ARCBIOS->GetReadStatus(ARCBIOS_STDIN);
+	q = arcbios_GetReadStatus(ARCBIOS_STDIN);
 
 	if (q == 0) {
-		ARCBIOS->Read(ARCBIOS_STDIN, &c, 1, &count);
+		arcbios_Read(ARCBIOS_STDIN, &c, 1, &count);
 		*cp = c;
 
 		return 1;

Added files:

Index: src/sys/dev/arcbios/Makefile.inc
diff -u /dev/null src/sys/dev/arcbios/Makefile.inc:1.1
--- /dev/null	Sun Feb 20 08:02:46 2011
+++ src/sys/dev/arcbios/Makefile.inc	Sun Feb 20 08:02:46 2011
@@ -0,0 +1,13 @@
+#	$NetBSD: Makefile.inc,v 1.1 2011/02/20 08:02:46 matt Exp $
+
+GENASSYM_CONF=	${S}/dev/arcbios/genassym.cf
+
+.if !target(assym.h)
+assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRA}
+	${_MKTARGET_CREATE}
+	cat ${GENASSYM_CONF} ${GENASSYM_EXTRA} | \
+	    ${TOOL_GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
+	    > assym.h.tmp && \
+	mv -f assym.h.tmp assym.h
+${SRCS:C/\.[Ss]/.o/} ${SRCS:C/\.[Ss]/.d/}: assym.h
+.endif
Index: src/sys/dev/arcbios/arcbios_calls.S
diff -u /dev/null src/sys/dev/arcbios/arcbios_calls.S:1.1
--- /dev/null	Sun Feb 20 08:02:46 2011
+++ src/sys/dev/arcbios/arcbios_calls.S	Sun Feb 20 08:02:46 2011
@@ -0,0 +1,193 @@
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <machine/asm.h>
+
+#include "assym.h"
+
+RCSID("$NetBSD: arcbios_calls.S,v 1.1 2011/02/20 08:02:46 matt Exp $")
+
+	.text
+	.set noreorder
+
+#ifdef _LP64
+#define	FIX_V0		sll	v0, v0, 0
+#else
+#define FIX_V0		/* nothing */
+#endif
+
+#define	CALLFRAME2_SIZ	(CALLFRAME_SIZ + 16)
+#define	CALLFRAME2_RA	(CALLFRAME_RA + 16)
+#define	CALLFRAME2_S0	(CALLFRAME_S0 + 16)
+
+#ifndef _STANDALONE
+NESTED(arcbios_4orless_args, CALLFRAME_SIZ, ra)
+	PTR_SUBU sp, CALLFRAME_SIZ
+
+	REG_S	ra, CALLFRAME_RA(sp)
+	REG_S	s0, CALLFRAME_S0(sp)
+
+	PTR_L	t9, _C_LABEL(ARCBIOS)
+	PTR_ADDU t9, t0
+	INT_L	t9, 0(t9)
+	nop
+
+	jalr	t9
+	 move	s0, t8
+
+	FIX_V0
+
+	move	t8, s0
+
+	REG_L	ra, CALLFRAME_RA(sp)
+	REG_L	s0, CALLFRAME_S0(sp)
+
+	jr	ra
+	 PTR_ADDU sp, CALLFRAME_SIZ
+END(arcbios_4orless_args)
+
+NESTED(arcbios_5to8_args, CALLFRAME2_SIZ, ra)
+	PTR_SUBU sp, CALLFRAME2_SIZ
+
+	REG_S	ra, CALLFRAME2_RA(sp)
+	REG_S	s0, CALLFRAME2_S0(sp)
+
+#ifdef __mips_o32
+	INT_L	ta0, CALLFRAME2_SIZ+16(sp)	# load 5th arg
+	INT_L	ta1, CALLFRAME2_SIZ+20(sp)	# load 6th arg
+	INT_L	ta2, CALLFRAME2_SIZ+24(sp)	# load 7th arg
+	INT_L	ta3, CALLFRAME2_SIZ+28(sp)	# load 8th arg
+	INT_S	ta0, 16(sp)			# save 5th arg on stack (o32)
+	INT_S	ta1, 20(sp)			# save 6th arg on stack (o32)
+	INT_S	ta2, 24(sp)			# save 7th arg on stack (o32)
+	INT_S	ta3, 28(sp)			# save 8th arg on stack (o32)
+#else
+	INT_S	a4, 16(sp)			# save 5th arg on stack (o32)
+	INT_S	a5, 20(sp)			# save 6th arg on stack (o32)
+	INT_S	a6, 24(sp)			# save 7th arg on stack (o32)
+	INT_S	a7, 28(sp)			# save 8th arg on stack (o32)
+#endif
+
+	PTR_L	t9, _C_LABEL(ARCBIOS)
+	PTR_ADDU t9, t0
+	INT_L	t9, 0(t9)
+	nop
+
+	jalr	t9
+	 nop
+
+	FIX_V0
+
+	move	t8, s0
+
+	REG_L	ra, CALLFRAME2_RA(sp)
+	REG_L	s0, CALLFRAME2_S0(sp)
+
+	jr	ra
+	 PTR_ADDU sp, CALLFRAME2_SIZ
+END(arcbios_5to8_args)
+#endif /* !_STANDALONE */
+
+#define AFVDIRECT(name)						\
+	.globl	__CONCAT(arcbios_,name);			\
+LEAF(__CONCAT(arcbios_,name));					\
+	PTR_L	t9, _C_LABEL(ARCBIOS); 				\
+	 nop;							\
+	INT_L	t9, __CONCAT(AFV_,name)(t9);			\
+	 nop;							\
+	jr	t9;						\
+	 nop;							\
+END(__CONCAT(arcbios_,name))
+
+#ifdef _STANDALONE
+#define	AFV4ORLESS(name)	AFVDIRECT(name)
+#define	AFV5ORMORE(name)	AFVDIRECT(name)
+#else
+#define	AFV4ORLESS(name)					\
+	.globl	__CONCAT(arcbios_,name);			\
+NESTED(__CONCAT(arcbios_,name), 0, ra);				\
+	b	arcbios_4orless_args;				\
+	 li	t0, __CONCAT(AFV_,name);			\
+END(__CONCAT(arcbios_,name))
+
+#define	AFV5ORMORE(name)					\
+	.globl	__CONCAT(arcbios_,name);			\
+NESTED(__CONCAT(arcbios_,name), 0, ra);				\
+	b	arcbios_5to8_args;				\
+	 li	t0, __CONCAT(AFV_,name);			\
+END(__CONCAT(arcbios_,name))
+#endif
+
+/*
+ * ARC firmware vector
+ */
+AFV4ORLESS(Load)		/* long (*Load)(char *image, u_long top, u_long entry, u_long *low); */
+AFV5ORMORE(Invoke)		/* long (*Invoke)(u_long, u_long, u_long, char **, char **);	*/
+AFV4ORLESS(Execute)		/* long (*Execute)(char *, u_long, char **, char **); */
+AFVDIRECT(Halt)			/* void (*Halt)(void) __dead; */
+AFVDIRECT(PowerDown)		/* void (*PowerDown)(void) __dead; */
+AFVDIRECT(Restart)		/* void (*Restart)(void) __dead; */
+AFVDIRECT(Reboot)		/* void (*Reboot)(void) __dead; */
+AFVDIRECT(EnterInteractiveMode)	/* void (*EnterInteractiveMode)(void) __dead; */
+#ifndef sgimips
+AFVDIRECT(ReturnFromMain)	/* void (*ReturnFromMain)(void) __dead; */
+#endif
+AFV4ORLESS(GetPeer)		/* void *(*GetPeer)(void *); */
+AFV4ORLESS(GetChild)		/* void *(*GetChild)(void *); */
+AFV4ORLESS(GetParent)		/* void *(*GetParent)(void *); */
+AFV4ORLESS(GetConfigurationData) /* long (*GetConfigurationData)(void *, void *); */
+AFV4ORLESS(AddChild)		/* void *(*AddChild)(void *, void *); */
+AFV4ORLESS(DeleteComponent)	/* long (*DeleteComponent)(void *component); */
+AFV4ORLESS(GetComponent)	/* void *(*GetComponent)(char *path); */
+AFV4ORLESS(SaveConfiguration)	/* long (*SaveConfiguration)(void); */
+AFV4ORLESS(GetSystemId)		/* void *(*GetSystemId)(void); */
+AFV4ORLESS(GetMemoryDescriptor)	/* void *(*GetMemoryDescriptor)(void *); */
+#if !defined(sgimips)
+AFV4ORLESS(Signal)		/* void (*Signal)(u_long, void *); */
+#endif
+AFV4ORLESS(GetTime)		/* void *(*GetTime)(void); */
+AFV4ORLESS(GetRelativeTime)	/* u_long (*GetRelativeTime)(void); */
+AFV4ORLESS(GetDirectoryEntry)	/* long	(*GetDirectoryEntry)(u_long, void *, u_long, u_long *); */
+AFV4ORLESS(Open)		/* long (*Open)(char *, u_long, u_long *); */
+AFV4ORLESS(Close)		/* long (*Close)(u_long); */
+AFV4ORLESS(Read)		/* long (*Read)(u_long, void *, u_long, u_long *); */
+AFV4ORLESS(GetReadStatus)	/* long (*GetReadStatus)(u_long); */
+AFV4ORLESS(Write)		/* long (*Write)(u_long, void *, u_long, u_long *); */
+AFV4ORLESS(Seek)		/* long (*Seek)(u_long, int64_t *, u_long); */
+AFV4ORLESS(Mount)		/* long (*Mount)(char *, u_long); */
+AFV4ORLESS(GetEnvironmentVariable) /* const char *(*GetEnvironmentVariable)(const char *); */
+AFV4ORLESS(SetEnvironmentVariable) /* long (*SetEnvironmentVariable)(const char *, const char *); */
+AFV4ORLESS(GetFileInformation)	/* long (*GetFileInformation)(u_long, void *); */
+AFV4ORLESS(SetFileInformation)	/* long (*SetFileInformation)(u_long, u_long, u_long); */
+AFV4ORLESS(FlushAllCaches)	/* void (*FlushAllCaches)(void); */
+#ifndef sgimips
+AFV4ORLESS(TestUnicode)		/* paddr_t (*TestUnicode)(u_long, uint16_t); */
+AFV4ORLESS(GetDisplayStatus)	/* void *(*GetDisplayStatus)(u_long); */
+#endif
Index: src/sys/dev/arcbios/genassym.cf
diff -u /dev/null src/sys/dev/arcbios/genassym.cf:1.1
--- /dev/null	Sun Feb 20 08:02:46 2011
+++ src/sys/dev/arcbios/genassym.cf	Sun Feb 20 08:02:46 2011
@@ -0,0 +1,73 @@
+#	$NetBSD: genassym.cf,v 1.1 2011/02/20 08:02:46 matt Exp $
+#
+#-
+# Copyright (c) 2010 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Matt Thomas of 3am Software Foundry.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#+
+
+include <sys/types.h>
+include <dev/arcbios/arcbios.h>
+
+define	SPB_FirmwareVector	offsetof(struct arcbios_spb, FirmwareVector)
+
+define	AFV_Load		offsetof(struct arcbios_fv, Load)
+define	AFV_Invoke		offsetof(struct arcbios_fv, Invoke)
+define	AFV_Execute		offsetof(struct arcbios_fv, Execute)
+define	AFV_Halt		offsetof(struct arcbios_fv, Halt)
+define	AFV_PowerDown		offsetof(struct arcbios_fv, PowerDown)
+define	AFV_Restart		offsetof(struct arcbios_fv, Restart)
+define	AFV_Reboot		offsetof(struct arcbios_fv, Reboot)
+define	AFV_EnterInteractiveMode offsetof(struct arcbios_fv, EnterInteractiveMode)
+define	AFV_ReturnFromMain	offsetof(struct arcbios_fv, ReturnFromMain)
+define	AFV_GetPeer		offsetof(struct arcbios_fv, GetPeer)
+define	AFV_GetChild		offsetof(struct arcbios_fv, GetChild)
+define	AFV_GetParent		offsetof(struct arcbios_fv, GetParent)
+define	AFV_GetConfigurationData offsetof(struct arcbios_fv, GetConfigurationData)
+define	AFV_AddChild		offsetof(struct arcbios_fv, AddChild)
+define	AFV_DeleteComponent	offsetof(struct arcbios_fv, DeleteComponent)
+define	AFV_GetComponent	offsetof(struct arcbios_fv, GetComponent)
+define	AFV_SaveConfiguration	offsetof(struct arcbios_fv, SaveConfiguration)
+define	AFV_GetSystemId		offsetof(struct arcbios_fv, GetSystemId)
+define	AFV_GetMemoryDescriptor	offsetof(struct arcbios_fv, GetMemoryDescriptor)
+define	AFV_Signal		offsetof(struct arcbios_fv, Signal)
+define	AFV_GetTime		offsetof(struct arcbios_fv, GetTime)
+define	AFV_GetRelativeTime	offsetof(struct arcbios_fv, GetRelativeTime)
+define	AFV_GetDirectoryEntry	offsetof(struct arcbios_fv, GetDirectoryEntry)
+define	AFV_Open		offsetof(struct arcbios_fv, Open)
+define	AFV_Close		offsetof(struct arcbios_fv, Close)
+define	AFV_Read		offsetof(struct arcbios_fv, Read)
+define	AFV_GetReadStatus	offsetof(struct arcbios_fv, GetReadStatus)
+define	AFV_Write		offsetof(struct arcbios_fv, Write)
+define	AFV_Seek		offsetof(struct arcbios_fv, Seek)
+define	AFV_Mount		offsetof(struct arcbios_fv, Mount)
+define	AFV_GetEnvironmentVariable offsetof(struct arcbios_fv, GetEnvironmentVariable)
+define	AFV_SetEnvironmentVariable offsetof(struct arcbios_fv, SetEnvironmentVariable)
+define	AFV_GetFileInformation	offsetof(struct arcbios_fv, GetFileInformation)
+define	AFV_SetFileInformation	offsetof(struct arcbios_fv, SetFileInformation)
+define	AFV_FlushAllCaches	offsetof(struct arcbios_fv, FlushAllCaches)
+define	AFV_TestUnicode		offsetof(struct arcbios_fv, TestUnicode)
+define	AFV_GetDisplayStatus	offsetof(struct arcbios_fv, GetDisplayStatus)

Reply via email to