📄 sbmips32.h
字号:
/* ********************************************************************* * Broadcom Common Firmware Environment (CFE) * * MIPS32 CPU definitions File: sbmips32.h * * This module contains constants and macros specific to the * Broadcom MIPS32 core. In addition to generic MIPS32, it * includes definitions for the MIP32-01 and MIPS3302 OCP cores * for the Silicon Backplane. * ********************************************************************* * * Copyright 2000,2001,2002,2003 * Broadcom Corporation. All rights reserved. * * This software is furnished under license and may be used and * copied only in accordance with the following terms and * conditions. Subject to these conditions, you may download, * copy, install, use, modify and distribute modified or unmodified * copies of this software in source and/or binary form. No title * or ownership is transferred hereby. * * 1) Any source code used, modified or distributed must reproduce * and retain this copyright notice and list of conditions * as they appear in the source file. * * 2) No right is granted to use any trade name, trademark, or * logo of Broadcom Corporation. The "Broadcom Corporation" * name may not be used to endorse or promote products derived * from this software without the prior written permission of * Broadcom Corporation. * * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR 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), EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************* */#ifndef _SB_MIPS32_H#define _SB_MIPS32_H/* ********************************************************************* * Configure language ********************************************************************* */#if defined(__ASSEMBLER__)#define _ATYPE_#define _ATYPE32_#else#define _ATYPE_ (__SIZE_TYPE__)#define _ATYPE32_ (int)#endif/* ********************************************************************* * Bitfield macros ********************************************************************* *//* Make a mask for 1 bit at position 'n' */#define _MM_MAKEMASK1(n) (1 << (n))/* Make a mask for 'v' bits at position 'n' */#define _MM_MAKEMASK(v,n) (((1<<(v))-1) << (n))/* Make a value at 'v' at bit position 'n' */#define _MM_MAKEVALUE(v,n) ((v) << (n))/* Retrieve a value from 'v' at bit position 'n' with 'm' mask bits */#define _MM_GETVALUE(v,n,m) (((v) & (m)) >> (n))/* ********************************************************************* * 32-bit MIPS Address Spaces ********************************************************************* */#ifdef __ASSEMBLER__#define _ACAST32_#else#define _ACAST32_ _ATYPE_ _ATYPE32_ /* widen if necessary */#endif/* 32-bit address map */#define UBASE 0x00000000 /* user+ mapped */#define USIZE 0x80000000#define K0BASE (_ACAST32_ 0x80000000) /* kernel unmapped cached */#define K0SIZE 0x20000000#define K1BASE (_ACAST32_ 0xa0000000) /* kernel unmapped uncached */#define K1SIZE 0x20000000#define K2BASE (_ACAST32_ 0xc0000000) /* kernel mapped */#define K2SIZE 0x40000000#define GEN_VECT (_ACAST32_ 0x80000080)#define UTLB_VECT (_ACAST32_ 0x80000000)/* ********************************************************************* * Address space coercion macros ********************************************************************* */#define PHYS_TO_K0(pa) (K0BASE | (pa))#define PHYS_TO_K1(pa) (K1BASE | (pa))#define K0_TO_PHYS(va) ((va) & (K0SIZE-1))#define K1_TO_PHYS(va) ((va) & (K1SIZE-1))#define K0_TO_K1(va) ((va) | K1SIZE)#define K1_TO_K0(va) ((va) & ~K1SIZE)#if !defined(__ASSEMBLER__)#define mips_wbflush() __asm__ __volatile__ ("sync" : : : "memory")#define ISK0SEG(va) ((va) >= K0BASE && (va) <= (K0BASE + K0SIZE - 1))#define ISK1SEG(va) ((va) >= K1BASE && (va) <= (K1BASE + K1SIZE - 1))#endif/* ********************************************************************* * Register aliases ********************************************************************* */#if defined(__ASSEMBLER__)#define zero $0#define AT $1 /* assembler temporaries */#define v0 $2 /* value holders */#define v1 $3#define a0 $4 /* arguments */#define a1 $5#define a2 $6#define a3 $7#define t0 $8 /* temporaries */#define t1 $9#define t2 $10#define t3 $11#define t4 $12#define t5 $13#define t6 $14#define t7 $15#define s0 $16 /* saved registers */#define s1 $17#define s2 $18#define s3 $19#define s4 $20#define s5 $21#define s6 $22#define s7 $23#define t8 $24 /* temporaries */#define t9 $25#define k0 $26 /* kernel registers */#define k1 $27#define gp $28 /* global pointer */#define sp $29 /* stack pointer */#define s8 $30 /* saved register */#define fp $30 /* frame pointer */#define ra $31 /* return address */#endif/* ********************************************************************* * CP0 Registers ********************************************************************* */#if defined(__ASSEMBLER__)#define C0_INX $0 /* CP0: TLB Index */#define C0_RAND $1 /* CP0: TLB Random */#define C0_TLBLO0 $2 /* CP0: TLB EntryLo0 */#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */#define C0_TLBLO1 $3 /* CP0: TLB EntryLo1 */#define C0_CTEXT $4 /* CP0: Context */#define C0_PGMASK $5 /* CP0: TLB PageMask */#define C0_WIRED $6 /* CP0: TLB Wired */#define C0_BADVADDR $8 /* CP0: Bad Virtual Address */#define C0_COUNT $9 /* CP0: Count */#define C0_TLBHI $10 /* CP0: TLB EntryHi */#define C0_COMPARE $11 /* CP0: Compare */#define C0_SR $12 /* CP0: Processor Status */#define C0_STATUS C0_SR /* CP0: Processor Status */#define C0_CAUSE $13 /* CP0: Exception Cause */#define C0_EPC $14 /* CP0: Exception PC */#define C0_PRID $15 /* CP0: Processor Revision Indentifier */#define C0_CONFIG $16 /* CP0: Config */#define C0_LLADDR $17 /* CP0: LLAddr */#define C0_WATCHLO $18 /* CP0: WatchpointLo */#define C0_WATCHHI $19 /* CP0: WatchpointHi */#define C0_BRCMCFG $22 /* CP0: Broadcom Config (BMIPS-330x) */#define C0_PERFCONT $25 /* CP0: Performance counters */#define C0_ECC $26 /* CP0: ECC */#define C0_CACHEERR $27 /* CP0: CacheErr */#define C0_TAGLO $28 /* CP0: TagLo */#define C0_TAGHI $29 /* CP0: TagHi */#define C0_ERREPC $30 /* CP0: ErrorEPC */#else#define C0_INX 0 /* CP0: TLB Index */#define C0_RAND 1 /* CP0: TLB Random */#define C0_TLBLO0 2 /* CP0: TLB EntryLo0 */#define C0_TLBLO C0_TLBLO0 /* CP0: TLB EntryLo0 */#define C0_TLBLO1 3 /* CP0: TLB EntryLo1 */#define C0_CTEXT 4 /* CP0: Context */#define C0_PGMASK 5 /* CP0: TLB PageMask */#define C0_WIRED 6 /* CP0: TLB Wired */#define C0_BADVADDR 8 /* CP0: Bad Virtual Address */#define C0_COUNT 9 /* CP0: Count */#define C0_TLBHI 10 /* CP0: TLB EntryHi */#define C0_COMPARE 11 /* CP0: Compare */#define C0_SR 12 /* CP0: Processor Status */#define C0_STATUS C0_SR /* CP0: Processor Status */#define C0_CAUSE 13 /* CP0: Exception Cause */#define C0_EPC 14 /* CP0: Exception PC */#define C0_PRID 15 /* CP0: Processor Revision Indentifier */#define C0_CONFIG 16 /* CP0: Config */#define C0_LLADDR 17 /* CP0: LLAddr */#define C0_WATCHLO 18 /* CP0: WatchpointLo */#define C0_WATCHHI 19 /* CP0: WatchpointHi */#define C0_BRCMCFG 22 /* CP0: Broadcom Config (BMIPS3302) */#define C0_PERFCONT 25 /* CP0: Performance counters */#define C0_ECC 26 /* CP0: ECC */#define C0_CACHEERR 27 /* CP0: CacheErr */#define C0_TAGLO 28 /* CP0: TagLo */#define C0_TAGHI 29 /* CP0: TagHi */#define C0_ERREPC 30 /* CP0: ErrorEPC */#endif/* Aliases to match MIPS manuals. */#define C0_INDEX C0_INX#define C0_RANDOM C0_RAND#define C0_ENTRYLO0 C0_TLBLO0#define C0_ENTRYLO1 C0_TLBLO1#define C0_CONTEXT C0_CTEXT#define C0_PAGEMASK C0_PGMASK#define C0_ENTRYHI C0_TLBHI#define C0_STATUS C0_SR#define C0_PERFCNT C0_PERFCONT#define C0_ERROREPC C0_ERREPC/* ********************************************************************* * CP1 (floating point) control registers ********************************************************************* */#define FPA_IRR 0 /* CP1: Implementation/Revision */#define FPA_CSR 31 /* CP1: Control/Status *//* ********************************************************************* * Macros for generating assembly language routines ********************************************************************* */#if defined(__ASSEMBLER__)/* global leaf function (does not call other functions) */#define LEAF(name) \ .globl name; \ .ent name; \name:/* global alternate entry to (local or global) leaf function */#define XLEAF(name) \ .globl name; \ .aent name; \name:/* end of a global function */#define END(name) \ .size name,.-name; \ .end name/* local leaf function (does not call other functions) */#define SLEAF(name) \ .ent name; \name:/* local alternate entry to (local or global) leaf function */#define SXLEAF(name) \ .aent name; \name:/* end of a local function */#define SEND(name) \ END(name)/* define & export a symbol */#define EXPORT(name) \ .globl name; \name:/* import a symbol */#define IMPORT(name, size) \ .extern name,size/* define a zero-fill common block (BSS if not overridden) with a global name */#define COMM(name,size) \ .comm name,size/* define a zero-fill common block (BSS if not overridden) with a local name */#define LCOMM(name,size) \ .lcomm name,size#endif/* Floating-Point Control register bits */#define CSR_C 0x00800000#define CSR_EXC 0x0003f000#define CSR_EE 0x00020000#define CSR_EV 0x00010000#define CSR_EZ 0x00008000#define CSR_EO 0x00004000#define CSR_EU 0x00002000#define CSR_EI 0x00001000#define CSR_TV 0x00000800#define CSR_TZ 0x00000400#define CSR_TO 0x00000200#define CSR_TU 0x00000100#define CSR_TI 0x00000080#define CSR_SV 0x00000040#define CSR_SZ 0x00000020#define CSR_SO 0x00000010#define CSR_SU 0x00000008#define CSR_SI 0x00000004#define CSR_RM 0x00000003/* Status Register */#define M_SR_CUMASK _MM_MAKEMASK(4,28) /* coprocessor usable bits */#define M_SR_CU3 _MM_MAKEMASK1(31) /* coprocessor 3 usable */#define M_SR_CU2 _MM_MAKEMASK1(30) /* coprocessor 2 usable */#define M_SR_CU1 _MM_MAKEMASK1(29) /* coprocessor 1 usable */#define M_SR_CU0 _MM_MAKEMASK1(28) /* coprocessor 0 usable */#define M_SR_RP _MM_MAKEMASK1(27) /* reduced power mode */#define M_SR_RE _MM_MAKEMASK1(25) /* reverse endian */#define M_SR_BEV _MM_MAKEMASK1(22) /* boot exception vectors */#define M_SR_TS _MM_MAKEMASK1(21) /* TLB is shut down */#define M_SR_SR _MM_MAKEMASK1(20) /* soft reset */#define M_SR_NMI _MM_MAKEMASK1(19) /* nonmaskable interrupt */#define S_SR_IMMASK 8#define M_SR_IMMASK _MM_MAKEMASK(9,S_SR_IMMASK)#define M_SR_IM8 _MM_MAKEMASK1(16) /* Broadcom extension */#define M_SR_IM7 _MM_MAKEMASK1(15) /* hardware interrupt masks */#define M_SR_IM6 _MM_MAKEMASK1(14)#define M_SR_IM5 _MM_MAKEMASK1(13)#define M_SR_IM4 _MM_MAKEMASK1(12)#define M_SR_IM3 _MM_MAKEMASK1(11)#define M_SR_IM2 _MM_MAKEMASK1(10)#define M_SR_IM1 _MM_MAKEMASK1(9) /* software interrupt masks */#define M_SR_IM0 _MM_MAKEMASK1(8)#define S_SR_KSU 3 /* base operating mode mode */#define M_SR_KSU _MM_MAKEMASK(2,S_SR_KSU)#define V_SR_KSU(x) _MM_MAKEVALUE(x,S_SR_KSU)#define G_SR_KSU(x) _MM_GETVALUE(x,S_SR_KSU,M_SR_KSU)#define K_SR_KSU_KERNEL 0#define K_SR_KSU_SUPR 1#define K_SR_KSU_USER 2#define M_SR_UM _MM_MAKEMASK1(4)#define M_SR_ERL _MM_MAKEMASK1(2)#define M_SR_EXL _MM_MAKEMASK1(1)#define M_SR_IE _MM_MAKEMASK1(0)/* * Cause Register
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -