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

📄 sys.h

📁 自己正在开发的一个ARM9的操作系统。详细信息请访问www.another-prj.com
💻 H
字号:
/*
 *	ApOS (Another Project software for s3c2410)
 *	
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *			
 *						Copyright caiyuqing
 *
 */
#ifndef _SYS_H
#define _SYS_H

#include "../s3c2410/cpu.h"

typedef int(* fn_ptr)(struct cpu_registers *regs);

#define NR_fork 	0
#define NR_singal 	1
#define NR_sigaction  	2
#define NR_free_process 3
#define NR_printf 	4




extern int sys_fork(struct cpu_registers *regs);
extern int sys_singal(struct cpu_registers *regs);
extern int sys_sigaction(struct cpu_registers *regs);
extern int sys_free_process(struct cpu_registers *regs);
extern int sys_printf(struct cpu_registers *regs);


#define system_call0(type,name) \
type name()\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id)\
		:"r0","memory"\
	);\
	return (type)res;\
}


#define system_call1(type,name,atype,a) \
type name(atype a)\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"ldr r1,%2 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id),"m"(a)\
		:"r0","r1","memory"\
	);\
	return (type)res;\
}


#define system_call2(type,name,atype,a,btype,b) \
type name(atype a,btype b)\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"ldr r1,%2 \n\t"\
		"ldr r2,%3 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id),"m"(a),"m"(b)\
		:"r0","r1","r2","memory"\
	);\
	return (type)res;\
}


#define system_call3(type,name,atype,a,btype,b,ctype,c) \
type name(atype a,btype b,ctype c)\
{\
	unsigned int res;\
	unsigned int fun_id=NR_##name;\
	asm volatile(\
		"ldr r0,%1 \n\t"\
		"ldr r1,%2 \n\t"\
		"ldr r2,%3 \n\t"\
		"ldr r3,%4 \n\t"\
		"swi \n\t"\
		"str r0,%0 \n\t"\
		:"=m"(res)\
		:"m"(fun_id),"m"(a),"m"(b),"m"(c)\
		:"r0","r1","r2","r3","memory"\
	);\
	return (type)res;\
}

#endif

⌨️ 快捷键说明

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