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

📄 mips.h

📁 UCOS在我的MIPS CPU上的移植 1. 这是UCOS在我的MIPS CPU上的移植代码, 编译工具使用标准的MIPS GCC. 2. 所有CPU相关的代码全在start.S中,相关函数说明如
💻 H
字号:

/*
 * Coprocessor 0 register names
 */
#define CP0_INDEX $0
#define CP0_RANDOM $1
#define CP0_ENTRYLO0 $2
#define CP0_ENTRYLO1 $3
#define CP0_CONF $3
#define CP0_CONTEXT $4
#define CP0_PAGEMASK $5
#define CP0_WIRED $6
#define CP0_INFO $7
#define CP0_BADVADDR $8
#define CP0_COUNT $9
#define CP0_ENTRYHI $10
#define CP0_COMPARE $11
#define CP0_STATUS 12
#define CP0_CAUSE $13
#define CP0_EPC $14
#define CP0_PRID $15
#define CP0_CONFIG $16
#define CP0_LLADDR $17
#define CP0_WATCHLO $18
#define CP0_WATCHHI $19
#define CP0_XCONTEXT $20
#define CP0_FRAMEMASK $21
#define CP0_DIAGNOSTIC $22
#define CP0_DEBUG $23
#define CP0_DEPC $24
#define CP0_PERFORMANCE $25
#define CP0_ECC $26
#define CP0_CACHEERR $27
#define CP0_TAGLO $28
#define CP0_TAGHI $29
#define CP0_ERROREPC $30
#define CP0_DESAVE $31

//设置中断频率
#define		HZ			1000	//每秒多少次中断
#define		CPU_SPEED	100000000	//33M
#define		TIME_PERIC	100000		//计数器

//CP0_STATUS($12) 设置中断使能
//Disable interrupt, 只使用到最低位 
#define	CLI		\
		__asm__ ( \
			"mtc0 $0, $12\n\t" \
			: \
			: );

//Enable interrupt
#define	STI		\
		__asm__ ( \
			"mtc0 %0, $12\n\t" \
			: \
			: "r"(1) );


//CP0_INDEX($0) 设置中断入口函数
#define	install_isr(func) \
			__asm__ ("mtc0 %0, $0" : :"r"(func));

//CP0_COMPARE($11) 设置计数器,计数器到这个值时,CP0_COUNT == CP0_COMPARE将产生一个中断
#define	set_cp0_compare(cnt) \
		__asm__ ("mtc0 %0, $11" : :"r"(cnt));

//CP0_COUNT($9) 获得当前 CP0_COUNT 值
#define	get_cp0_count(cnt) \
		__asm__ ( \
				"mfc0 $26, $9\n\t" \
				"sw $26, %0\n\t" \
				"nop\n\t" \			
				: "=m"(cnt) \
				:  );

//CP0_CAUSE($13) 获得当前中断原因
#define	get_cp0_cause(cause) \
		__asm__ ( \
				"mfc0 $26, $13\n\t"	\
				"sw $26, %0\n\t" \
				"nop\n\t" \			
				: "=m"(cause) \
				: );

//clear interrupt
#define	set_cp0_cause(cause) \
		__asm__ ("mtc0 %0, $13" : :"r"(cause));

#define		CAUSE_TIMER		1
#define		CAUSE_DISK		2
#define		CAUSE_NET		4

//保存任务现场
//#define	ALLOCATE_SP(num)	__asm__("addiu $29, $29, %0\n\t" : : "I"(num) );
//#define	PUSH(reg, mem, off)	__asm__("sw %0, %2(%1)" : :"string"(reg), "memory"(mem), "I"(off));


⌨️ 快捷键说明

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