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

📄 arch.inc

📁 eCos1.31版
💻 INC
📖 第 1 页 / 共 2 页
字号:
#ifndef CYGONCE_HAL_ARCH_INC#define CYGONCE_HAL_ARCH_INC##=============================================================================####	arch.inc####	MIPS assembler header file####=============================================================================#####COPYRIGHTBEGIN#####                                                                          # -------------------------------------------                              # The contents of this file are subject to the Red Hat eCos Public License # Version 1.1 (the "License"); you may not use this file except in         # compliance with the License.  You may obtain a copy of the License at    # http://www.redhat.com/                                                   #                                                                          # Software distributed under the License is distributed on an "AS IS"      # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the # License for the specific language governing rights and limitations under # the License.                                                             #                                                                          # The Original Code is eCos - Embedded Configurable Operating System,      # released September 30, 1998.                                             #                                                                          # The Initial Developer of the Original Code is Red Hat.                   # Portions created by Red Hat are                                          # Copyright (C) 1998, 1999, 2000 Red Hat, Inc.                             # All Rights Reserved.                                                     # -------------------------------------------                              #                                                                          #####COPYRIGHTEND######=============================================================================#######DESCRIPTIONBEGIN######## Author(s): 	nickg## Contributors:	nickg## Date:	1997-10-16## Purpose:	Architecture definitions.## Description:	This file contains various definitions and macros that are##              useful for writing assembly code for the MIPS CPU family.## Usage:##		#include <cyg/hal/arch.inc>##		...##		########DESCRIPTIONEND########=============================================================================#include <cyg/hal/mips.inc>	#include <cyg/hal/variant.inc>##-----------------------------------------------------------------------------	## Set up the value for the initial status register	#ifndef INITIAL_SR#if defined(CYG_HAL_STARTUP_RAM)# if defined(CYGPKG_HAL_MIPS_SIM) || !defined(CYGSEM_HAL_USE_ROM_MONITOR)#  define INITIAL_SR	0x1000ff00	/* CP0 usable, Ints enabled	*/# else#  define INITIAL_SR	0x1040ff00	/* as above + ROM vectors used	*/# endif	#elif defined(CYG_HAL_STARTUP_ROM)# define INITIAL_SR	0x1040ff00	/* as above + ROM vectors used	*/#endif#endif##-----------------------------------------------------------------------------## Setup the initial value for the config0 register#ifndef INITIAL_CONFIG0#define	INITIAL_CONFIG0	0x00000002#endif##-----------------------------------------------------------------------------## MIPS thread and interrupt saved state. This must match the layout of the## HAL_SavedRegisters in hal_arch.h. Do not change this without changing the## layout there, or viceversa.	#ifdef CYGHWR_HAL_MIPS_64BIT# define mips_regsize 	8#else# define mips_regsize 	4#endif# define mips_regsize32	4#if defined(CYGHWR_HAL_MIPS_FPU)# if defined(CYGHWR_HAL_MIPS_FPU_64BIT)#  define mips_fpuregsize 8# elif defined(CYGHWR_HAL_MIPS_FPU_32BIT)#  define mips_fpuregsize 4# else#  error MIPS FPU register size not defined# endif#endif#define	mipsreg_regs	0#define	mipsreg_hi	(mips_regsize*32)#define	mipsreg_lo	(mipsreg_hi+mips_regsize)#ifdef CYGHWR_HAL_MIPS_FPU# define mipsreg_fpureg	(mipsreg_lo+mips_regsize)# define mipsreg_fcr31	(mipsreg_fpureg+(mips_fpuregsize*32))# define mipsreg_fppad  (mipsreg_fcr31+mips_regsize32)# define mipsreg_vector	(mipsreg_fppad+mips_regsize32)#else# define mipsreg_vector	(mipsreg_lo+mips_regsize32)#endif#define	mipsreg_pc	(mipsreg_vector+mips_regsize32)#define	mipsreg_sr	(mipsreg_pc+mips_regsize32)#define	mipsreg_cachectrl (mipsreg_sr+mips_regsize32)#define	mipsreg_cause	(mipsreg_cachectrl+mips_regsize32)#define	mipsreg_badvr	(mipsreg_cause+mips_regsize32)#define	mipsreg_prid	(mipsreg_badvr+mips_regsize32)#define	mipsreg_config	(mipsreg_prid+mips_regsize32)#define	mipsreg_size	(mipsreg_config+mips_regsize32)#define mips_exception_decrement	(mipsreg_size*2)##-----------------------------------------------------------------------------## Minimal stack frame size uses to call functions from asm.	#define mips_stack_frame_size		32	// 4 (64 bit) args worth##-----------------------------------------------------------------------------## Load Address and Relocate. This macro is used in code that may be linked## to execute out of RAM but is actually executed from ROM. If that is the## case a suitable version of this macro will have been defined elsewhere.## This is just a default version for use when that does not happen.#ifndef CYGPKG_HAL_MIPS_LAR_DEFINED	.macro	lar	reg,addr	la	\reg,\addr	.endm#define CYGPKG_HAL_MIPS_LAR_DEFINED#endif##-----------------------------------------------------------------------------## CPU specific macros. These provide a common assembler interface to## operations that may have CPU specific implementations on different## variants of the architecture.				# Initialize CPU	.macro	hal_cpu_init	mtc0	zero,cause		# zero cause reg	nop	la	v0,INITIAL_SR		# initialize status register	mtc0	v0,status	nop	nop	nop	la	v0,INITIAL_CONFIG0	mtc0	v0,config0	nop	nop	nop	.endm	# Enable interrupts#ifdef CYG_HAL_MIPS_R3900		.macro hal_cpu_int_enable	mfc0	v0,status	nop	nop	ori	v0,v0,0x0001		# set IE bit	mtc0	v0,status	nop	nop	nop	.endm		#else	.macro hal_cpu_int_enable		mfc0	v0,status	la	v1,0xFFFFFFF9	and	v0,v0,v1		# clear EXL and ERL bits		ori	v0,v0,0x0001		# set IE bit	mtc0	v0,status	nop	nop	nop		.endm	#endif			# Disable interrupts	.macro hal_cpu_int_disable	mfc0	v0,status	la	v1,0xFFFFFFFE	and	v0,v0,v1	mtc0	v0,status	nop	nop	nop	.endm		# Merge the interrupt enable state of the status register in	# \sr with the current sr.#ifdef CYG_HAL_MIPS_R3900#define HAL_SR_INT_MASK	0x00000001		// IEc only#else#define HAL_SR_INT_MASK	0x00000007		// IE, EXL, ERL#endif				.macro	hal_cpu_int_merge sr	mfc0	v0,status			# V0 = current SR	la	v1,HAL_SR_INT_MASK		# V1 = SR interrupt bits mask	and	\sr,\sr,v1			# Isolate interrupt bits of \sr	nor	v1,v1,zero			# Invert mask	and	v0,v0,v1			# V0 = current SR except int bits	or	v0,v0,\sr			# V0 = New SR	mtc0	v0,status			# Return to SR	.endm	# Enable further exception processing, and disable	# interrupt processing.#ifdef CYG_HAL_MIPS_R3900		.macro hal_cpu_except_enable	hal_cpu_int_disable	.endm		#else	.macro hal_cpu_except_enable	mfc0	v0,status	la	v1,0xFFFFFFF0	and	v0,v0,v1		# clear EXL, ERL and IE bits		mtc0	v0,status	nop	nop	nop	.endm#endif				# Return from exception.#ifdef CYG_HAL_MIPS_R3900	.macro	hal_cpu_eret pc,sr	mtc0	\sr,status			# Load status register	nop	nop	nop	sync					# settle things down	jr	\pc				# jump back to interrupted code	rfe					# restore state	(delay slot)		.endm#else	.macro	hal_cpu_eret pc,sr	mtc0	\pc,epc				# put PC in EPC	nop	nop	nop	mtc0	\sr,status			# put SR back	nop	nop	nop	sync					# settle things down	eret					# return	nop					# just to be safe	.endm#endif		##-----------------------------------------------------------------------------# Default MIPS interrupt decoding macros. This uses the basic interrupt# support provided by CP0 in the cause and status registers. If there is# a more complex external interrupt controller, or the default stuff is# interpreted differently (as in the TX3904) then these macros will be # overridden and CYGPKG_HAL_MIPS_INTC_DEFINED will be defined.#ifndef CYGPKG_HAL_MIPS_INTC_DEFINED#ifndef CYGPKG_HAL_MIPS_INTC_INIT_DEFINED	# initialize all interrupts to disabled	.macro	hal_intc_init	mfc0	v0,status	nop	lui	v1,0xFFFF	ori	v1,v1,0x00FF	and	v0,v0,v1		# clear the IntMask bits	mtc0	v0,status	nop	nop	nop	.endm#endif	.macro	hal_intc_decode vnum	mfc0	v0,cause		# get cause register	nop				# delay slot	srl	v0,v0,10		# shift interrupt bits down	andi	v0,v0,0x7f		# isolate 6 interrupt bits	la	v1,hal_intc_translation_table	add	v0,v0,v1		# index into table	lb	\vnum,0(v0)		# pick up vector number	.endm#ifndef CYGPKG_HAL_MIPS_INTC_TRANSLATE_DEFINED#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN	.macro	hal_intc_translate inum,vnum	move	\vnum,zero			# Just vector zero is supported	.endm#else				.macro	hal_intc_translate inum,vnum	move	\vnum,\inum			# Vector == interrupt number	.endm#endif#endif	.macro	hal_intc_decode_datahal_intc_translation_table:		.byte	0, 0, 1, 0	.byte	2, 0, 1, 0	.byte	3, 0, 1, 0	.byte	2, 0, 1, 0	.byte	4, 0, 1, 0	.byte	2, 0, 1, 0	.byte	3, 0, 1, 0	.byte	2, 0, 1, 0	.byte	5, 0, 1, 0	.byte	2, 0, 1, 0	.byte	3, 0, 1, 0	.byte	2, 0, 1, 0	.byte	4, 0, 1, 0	.byte	2, 0, 1, 0	.byte	3, 0, 1, 0	.byte	2, 0, 1, 0	.endm#endif#------------------------------------------------------------------------------# Register save and restore macros. These expect a pointer to a CPU save state# area in the register \ptr. The GPR indicated by \reg will be saved into its# slot in that structure.#ifdef CYGHWR_HAL_MIPS_64BIT	.macro sgpr reg,ptr	sd	$\reg,(mipsreg_regs+\reg*mips_regsize)(\ptr)	.endm

⌨️ 快捷键说明

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