⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osi_calls.h

📁 open source bios with linux platform, very good and can be reused.
💻 H
📖 第 1 页 / 共 2 页
字号:
/*  *   Creation Date: <2002/06/16 01:40:57 samuel> *   Time-stamp: <2003/12/26 17:02:09 samuel> *    *	<osi_calls.h> *	 *	OSI call inlines *    *   Copyright (C) 2002, 2003 Samuel Rydh (samuel@ibrium.se) *    *   This program is free software; you can redistribute it and/or *   modify it under the terms of the GNU General Public License *   as published by the Free Software Foundation *    */#ifndef _H_OSI_CALLS#define _H_OSI_CALLS#include "osi.h"/* Old gcc versions have a limit on the number of registers used. * Newer gcc versions (gcc 3.3) require that the clobber list does * not overlap declared registers. */#if __GNUC__ == 2 || ( __GNUC__ == 3 && __GNUC_MINOR__ < 3 )#define SHORT_REGLIST#endif/************************************************************************//*	OSI call instantiation macros					*//************************************************************************/#define dreg(n)			__oc_##n __asm__ (#n)#define ir(n)			"r" (__oc_##n)#define rr(n)			"=r" (__oc_##n)#define _oc_head( input_regs... )				\{								\	int _ret=0;						\	{							\		register unsigned long dreg(r3);		\		register unsigned long dreg(r4);		\		register unsigned long dreg(r5)			\			,##input_regs ; #define _oc_syscall( number, extra_ret_regs... )		\		__oc_r3 = OSI_SC_MAGIC_R3;			\		__oc_r4 = OSI_SC_MAGIC_R4;			\		__oc_r5 = number;				\		__asm__ __volatile__ (				\		  "sc	" : rr(r3) ,## extra_ret_regs#define _oc_input( regs... )					\		: ir(r3), ir(r4), ir(r5)			\		, ## regs					\		: "memory" );/* the tail memory clobber is necessary since we violate the strict * aliasing rules when we return structs through the registers. */#define _oc_tail						\		asm volatile ( "" : : : "memory" );		\		_ret = __oc_r3;					\	}							\	return _ret;						\}/************************************************************************//*	Alternatives 							*//************************************************************************/#ifdef SHORT_REGLIST#define _oc_syscall_r10w6( number, inputregs... )		\		__oc_r3 = OSI_SC_MAGIC_R3;			\		__oc_r4 = OSI_SC_MAGIC_R4;			\		__oc_r5 = number;				\		__asm__ __volatile__ (				\		  "sc			\n"			\		  "stw	4,0(10) 	\n"			\		  "stw	5,4(10) 	\n"			\		  "stw	6,8(10) 	\n"			\		  "stw	7,12(10) 	\n"			\		  "stw	8,16(10) 	\n"			\		  "stw	9,20(10) 	\n"			\		: rr(r3)					\		: ir(r3), ir(r4), ir(r5), ir(r10) 		\		  ,## inputregs 				\		: "memory",					\		   "r4", "r5", "r6", "r7", "r8", "r9" );#endif		   /************************************************************************//*	Common helper functions						*//************************************************************************/#define _osi_call0( type, name, number ) 			\type name( void ) 						\	_oc_head()						\	_oc_syscall( number )					\	_oc_input()						\	_oc_tail#define _osi_call1( type, name, number, type1, arg1 ) 		\type name( type1 arg1 ) 					\	_oc_head( dreg(r6) )					\	__oc_r6 = (ulong)arg1;					\	_oc_syscall( number )					\	_oc_input( ir(r6) )					\	_oc_tail#define _osi_call2( type, name, number, t1, a1, t2, a2 ) 	\type name( t1 a1, t2 a2 ) 					\	_oc_head( dreg(r6), dreg(r7) )				\	__oc_r6 = (ulong)a1;					\	__oc_r7 = (ulong)a2;					\	_oc_syscall( number )					\	_oc_input( ir(r6), ir(r7) )				\	_oc_tail#define _osi_call3( type, name, number, t1, a1, t2, a2, t3, a3 ) \type name( t1 a1, t2 a2, t3 a3 ) 				\	_oc_head( dreg(r6), dreg(r7), dreg(r8) )		\	__oc_r6 = (ulong)a1;					\	__oc_r7 = (ulong)a2;					\	__oc_r8 = (ulong)a3;					\	_oc_syscall( number )					\	_oc_input( ir(r6), ir(r7), ir(r8) )			\	_oc_tail#define _osi_call4( type, name, number, t1, a1, t2, a2, t3, a3, t4, a4 ) \type name( t1 a1, t2 a2, t3 a3, t4 a4 ) 			\	_oc_head( dreg(r6), dreg(r7), dreg(r8), dreg(r9) )	\	__oc_r6 = (ulong)a1;					\	__oc_r7 = (ulong)a2;					\	__oc_r8 = (ulong)a3;					\	__oc_r9 = (ulong)a4;					\	_oc_syscall( number )					\	_oc_input( ir(r6), ir(r7), ir(r8), ir(r9) )		\	_oc_tail#define _osi_call5( type, name, number, t1, a1, t2, a2, t3, a3, t4, a4, t5, a5 ) \type name( t1 a1, t2 a2, t3 a3, t4 a4, t5 a5 ) 				\	_oc_head( dreg(r6), dreg(r7), dreg(r8), dreg(r9), dreg(r10) )	\	__oc_r6 = (ulong)a1;						\	__oc_r7 = (ulong)a2;						\	__oc_r8 = (ulong)a3;						\	__oc_r9 = (ulong)a4;						\	__oc_r10 = (ulong)a5;						\	_oc_syscall( number )						\	_oc_input( ir(r6), ir(r7), ir(r8), ir(r9), ir(r10) )		\	_oc_tail#define _osi_call6( type, name, number, t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6 ) \type name( t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6 ) 				\	_oc_head( dreg(r6), dreg(r7), dreg(r8), dreg(r9), dreg(r10), dreg(r11) )\	__oc_r6 = (ulong)a1;						\	__oc_r7 = (ulong)a2;						\	__oc_r8 = (ulong)a3;						\	__oc_r9 = (ulong)a4;						\	__oc_r10 = (ulong)a5;						\	__oc_r11 = (ulong)a6;						\	_oc_syscall( number )						\	_oc_input( ir(r6), ir(r7), ir(r8), ir(r9), ir(r10), ir(r11) )	\	_oc_tail/************************************************************************//*	Special 							*//************************************************************************//* r4 returned in retarg1 pointer */#define _osi_call0_w1( type, name, number, type1, retarg1 ) 	\type name( type1 retarg1 ) 					\	_oc_head()						\	_oc_syscall( number, rr(r4) )				\	_oc_input()						\	*retarg1 = __oc_r4;					\	_oc_tail#define _osi_call0_w2( type, name, number, type1, retarg1 ) 	\type name( type1 retarg1 ) 					\	_oc_head()						\	_oc_syscall( number, rr(r4), rr(r5) )			\	_oc_input()						\	((ulong*)retarg1)[0] = __oc_r4;				\	((ulong*)retarg1)[1] = __oc_r5;				\	_oc_tail/* r4-r8 returned in retarg1 pointer */#define _osi_call0_w5( type, name, number, type1, retarg1 ) 	\type name( type1 retarg1 ) 					\	_oc_head( dreg(r6), dreg(r7), dreg(r8) )		\	_oc_syscall( number, 					\		rr(r4), rr(r5), rr(r6), rr(r7), rr(r8) )	\	_oc_input()						\	((ulong*)retarg1)[0] = __oc_r4;				\	((ulong*)retarg1)[1] = __oc_r5;				\	((ulong*)retarg1)[2] = __oc_r6;				\	((ulong*)retarg1)[3] = __oc_r7;				\	((ulong*)retarg1)[4] = __oc_r8;				\	_oc_tail/* r4 returned in retarg pointer */#define _osi_call1_w1( type, name, number, t1, a1, t2, retarg ) \type name( t1 a1, t2 retarg ) 					\	_oc_head( dreg(r6) )					\	__oc_r6 = (ulong)a1;					\	_oc_syscall( number, rr(r4) )				\	_oc_input( ir(r6) )					\	((ulong*)retarg)[0] = __oc_r4;				\	_oc_tail/* r4,r5 returned in retarg1, retarg2 */#define _osi_call1_w1w1( type, name, number, t1, a1, t2, retarg1, t3, retarg2 ) \type name( t1 a1, t2 retarg1, t3 retarg2 )			\	_oc_head( dreg(r6) )					\	__oc_r6 = (ulong)a1;					\	_oc_syscall( number, rr(r4), rr(r5) )			\	_oc_input( ir(r6) )					\	((ulong*)retarg1)[0] = __oc_r4;				\	((ulong*)retarg2)[0] = __oc_r5;				\	_oc_tail/* r4,r5 returned in retarg1, retarg2, retarg3 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -