summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/atj2137/adfuload/test_binary/backlight_c/Makefile4
-rw-r--r--utils/atj2137/adfuload/test_binary/backlight_c/crt0.S66
-rw-r--r--utils/atj2137/adfuload/test_binary/backlight_c/test_bl.lds4
-rw-r--r--utils/hwstub/hwstub_protocol.h1
-rw-r--r--utils/hwstub/stub/SOURCES9
-rw-r--r--utils/hwstub/stub/asm/mips/memcpy.S153
-rw-r--r--utils/hwstub/stub/asm/mips/memset.S239
-rw-r--r--utils/hwstub/stub/atj213x/Makefile14
-rw-r--r--utils/hwstub/stub/atj213x/atj213x.h385
-rw-r--r--utils/hwstub/stub/atj213x/crt0.S206
-rw-r--r--utils/hwstub/stub/atj213x/hwstub.lds70
-rw-r--r--utils/hwstub/stub/atj213x/mips-archdefs.h2358
-rw-r--r--utils/hwstub/stub/atj213x/mips.h820
-rw-r--r--utils/hwstub/stub/atj213x/target-config.h12
-rw-r--r--utils/hwstub/stub/atj213x/target.c113
-rw-r--r--utils/hwstub/stub/atj213x/usb_drv_atj213x.c267
-rw-r--r--utils/hwstub/stub/main.c19
17 files changed, 4706 insertions, 34 deletions
diff --git a/utils/atj2137/adfuload/test_binary/backlight_c/Makefile b/utils/atj2137/adfuload/test_binary/backlight_c/Makefile
index a3cc13642a..d36664819d 100644
--- a/utils/atj2137/adfuload/test_binary/backlight_c/Makefile
+++ b/utils/atj2137/adfuload/test_binary/backlight_c/Makefile
@@ -10,12 +10,12 @@ AS = $(TOOLCHAIN)as
10OBJCOPY = $(TOOLCHAIN)objcopy 10OBJCOPY = $(TOOLCHAIN)objcopy
11OBJDUMP = $(TOOLCHAIN)objdump 11OBJDUMP = $(TOOLCHAIN)objdump
12 12
13CFLAGS = -Wundef -march=4kec -nostdlib -Os -c 13CFLAGS = -Wundef -march=mips32r2 -nostdlib -Os -c
14 14
15OBJS = crt0.o test_bl.o 15OBJS = crt0.o test_bl.o
16LDSCRIPT= test_bl.lds 16LDSCRIPT= test_bl.lds
17 17
18LDFLAGS = -Wundef -march=4kec -T$(LDSCRIPT) -nostartfiles \ 18LDFLAGS = -Wundef -march=mips32r2 -T$(LDSCRIPT) -nostartfiles \
19 -nostdlib -Xlinker -Map=$(TARGET).map 19 -nostdlib -Xlinker -Map=$(TARGET).map
20 20
21all : $(TARGET).bin 21all : $(TARGET).bin
diff --git a/utils/atj2137/adfuload/test_binary/backlight_c/crt0.S b/utils/atj2137/adfuload/test_binary/backlight_c/crt0.S
index 485a4fc26c..1d6293bd93 100644
--- a/utils/atj2137/adfuload/test_binary/backlight_c/crt0.S
+++ b/utils/atj2137/adfuload/test_binary/backlight_c/crt0.S
@@ -5,7 +5,7 @@
5 5
6 .set mips32r2 6 .set mips32r2
7 .set noreorder 7 .set noreorder
8 .set noat 8// .set noat
9 9
10 .section .init.text,"ax",%progbits 10 .section .init.text,"ax",%progbits
11 11
@@ -18,50 +18,68 @@ load_addr:
18 addiu v0, ra, -12 # calc real load address 18 addiu v0, ra, -12 # calc real load address
19 # account for branch delay slot 19 # account for branch delay slot
20 # and very first 'di' instruction 20 # and very first 'di' instruction
21 la t0, relocstart
22 la t1, relocend
23 beq t0, v0, entry_point # no relocation needed
24 nop
25 21
26reloc_loop:
27 lw t2, 0(v0) # src
28 addiu v0, 4 # inc src addr
29 addiu t0, 4 # inc dst addr
30 bne t0, t1, reloc_loop
31 sw t2, -4(t0) # dst
32
33entry_point_jump:
34 la t0, entry_point
35 jr t0
36 nop
37
38entry_point:
39 # setup caches 22 # setup caches
40 # 4-way, 256 sets, 16 bytes cacheline I/D 23 # 4-way, 256 sets, 16 bytes cacheline I/D
41 li t0, 3 # enable cache for kseg0 accesses
42 mtc0 t0, C0_CONFIG
43
44 la t0, 0x80000000 # an idx op should use an unmappable address 24 la t0, 0x80000000 # an idx op should use an unmappable address
45 ori t1, t0, 0x4000 # 16kB cache 25 ori t1, t0, 0x4000 # 16kB cache
46 mtc0 zero, C0_TAGLO 26 mtc0 zero, C0_TAGLO
47 mtc0 zero, C0_TAGHI 27 mtc0 zero, C0_TAGHI
28 ehb # execution hazard barrier
48 29
49cache_init_loop: 30cache_init_loop:
50 cache 8, 0(t0) # index store icache tag 31 cache ICIndexStTag, 0(t0) # index store icache tag
51 cache 9, 0(t0) # index store dcache tag 32 cache DCIndexStTag, 0(t0) # index store dcache tag
52 addiu t0, t0, 0x10 33 addiu t0, t0, 0x10
53 bne t0, t1, cache_init_loop 34 bne t0, t1, cache_init_loop
54 nop 35 nop
55 36
37 li t0, 3 # enable cache for kseg0 accesses
38 mtc0 t0, C0_CONFIG
39 ehb
40
41relocation:
42 la t0, relocstart
43 la t1, relocend
44 beq t0, v0, entry_point # no relocation needed
45 nop
46
47reloc_loop:
48 lw s0, 0(v0) # src
49 lw s1, 4(v0)
50 lw s2, 8(v0)
51 lw s3, 12(v0)
52
53 sw s0, 0(t0) # dst
54 sw s1, 4(t0)
55 sw s2, 8(t0)
56 sw s3, 12(t0)
57
58 synci 0(t0) # dcache writeback invalidate
59 # icache invalidate
60
61 addiu t0, t0, 16 # inc dst addr
62 blt t0, t1, reloc_loop
63 addiu v0, v0, 16 # inc src addr
64
65entry_point_jump:
66 la t0, entry_point
67 jr.hb t0 # jump register with hazard barier
68 nop
69
70entry_point:
56 # clear bss 71 # clear bss
57 la t0, bssbegin 72 la t0, bssbegin
58 la t1, bssend 73 la t1, bssend
59 74 beq t0, t1, stack_setup
75 nop
76
60clear_bss_loop: 77clear_bss_loop:
61 addiu t0, 4 78 addiu t0, 4
62 bne t0, t1, clear_bss_loop 79 bne t0, t1, clear_bss_loop
63 sw zero, -4(t0) 80 sw zero, -4(t0)
64 81
82stack_setup:
65 # setup stack 83 # setup stack
66 la sp, stackend 84 la sp, stackend
67 la t0, stackbegin 85 la t0, stackbegin
diff --git a/utils/atj2137/adfuload/test_binary/backlight_c/test_bl.lds b/utils/atj2137/adfuload/test_binary/backlight_c/test_bl.lds
index 744cad5175..870b708fa3 100644
--- a/utils/atj2137/adfuload/test_binary/backlight_c/test_bl.lds
+++ b/utils/atj2137/adfuload/test_binary/backlight_c/test_bl.lds
@@ -5,7 +5,7 @@ SECTIONS
5{ 5{
6 6
7 7
8.text 0xa0001000 : 8.text 0x80000000 :
9 { 9 {
10 relocstart = .; 10 relocstart = .;
11 *(.init.text*) 11 *(.init.text*)
@@ -21,6 +21,7 @@ SECTIONS
21 21
22.bss : 22.bss :
23 { 23 {
24 . = ALIGN(4);
24 bssbegin = .; 25 bssbegin = .;
25 *(.sbss*) 26 *(.sbss*)
26 *(.bss*) 27 *(.bss*)
@@ -31,6 +32,7 @@ SECTIONS
31 32
32.stack (NOLOAD) : 33.stack (NOLOAD) :
33 { 34 {
35 . = ALIGN(4);
34 stackbegin = .; 36 stackbegin = .;
35 . += 0x2000; 37 . += 0x2000;
36 stackend = .; 38 stackend = .;
diff --git a/utils/hwstub/hwstub_protocol.h b/utils/hwstub/hwstub_protocol.h
index dcf8c0950d..33081d3ca2 100644
--- a/utils/hwstub/hwstub_protocol.h
+++ b/utils/hwstub/hwstub_protocol.h
@@ -109,6 +109,7 @@ struct hwstub_pp_desc_t
109#define HWSTUB_TARGET_STMP ('S' | 'T' << 8 | 'M' << 16 | 'P' << 24) 109#define HWSTUB_TARGET_STMP ('S' | 'T' << 8 | 'M' << 16 | 'P' << 24)
110#define HWSTUB_TARGET_RK27 ('R' | 'K' << 8 | '2' << 16 | '7' << 24) 110#define HWSTUB_TARGET_RK27 ('R' | 'K' << 8 | '2' << 16 | '7' << 24)
111#define HWSTUB_TARGET_PP ('P' | 'P' << 8 | ' ' << 16 | ' ' << 24) 111#define HWSTUB_TARGET_PP ('P' | 'P' << 8 | ' ' << 16 | ' ' << 24)
112#define HWSTUB_TARGET_ATJ ('A' | 'T' << 8 | 'J' << 16 | ' ' << 24)
112 113
113struct hwstub_target_desc_t 114struct hwstub_target_desc_t
114{ 115{
diff --git a/utils/hwstub/stub/SOURCES b/utils/hwstub/stub/SOURCES
index 9693fdd408..1b0b56072d 100644
--- a/utils/hwstub/stub/SOURCES
+++ b/utils/hwstub/stub/SOURCES
@@ -2,6 +2,11 @@
2asm/arm/memcpy.S 2asm/arm/memcpy.S
3asm/arm/memmove.S 3asm/arm/memmove.S
4asm/arm/memset.S 4asm/arm/memset.S
5#elif defined(CPU_MIPS)
6asm/mips/memcpy.S
7asm/mips/memset.S
8#else
9#error "Unimplemented ISA"
5#endif 10#endif
6main.c 11main.c
7logf.c 12logf.c
@@ -19,4 +24,8 @@ rk27xx/target.c
19pp/crt0.S 24pp/crt0.S
20pp/target.c 25pp/target.c
21usb_drv_arc.c 26usb_drv_arc.c
27#elif defined(CONFIG_ATJ213X)
28atj213x/crt0.S
29atj213x/target.c
30atj213x/usb_drv_atj213x.c
22#endif 31#endif
diff --git a/utils/hwstub/stub/asm/mips/memcpy.S b/utils/hwstub/stub/asm/mips/memcpy.S
new file mode 100644
index 0000000000..0477dcd0fb
--- /dev/null
+++ b/utils/hwstub/stub/asm/mips/memcpy.S
@@ -0,0 +1,153 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002, 2003 Free Software Foundation, Inc.
11 * This file was originally part of the GNU C Library
12 * Contributed to glibc by Hartvig Ekner <hartvige@mips.com>, 2002
13 * Adapted for Rockbox by Maurus Cuelenaere, 2009
14 * memmove() adapted after linux kernel by Marcin Bukat, 2014
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
20 *
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
23 *
24 ****************************************************************************/
25
26#include "config.h"
27#include "mips.h"
28
29/* void *memcpy(void *s1, const void *s2, size_t n); */
30
31#ifdef ROCKBOX_BIG_ENDIAN
32# define LWHI lwl /* high part is left in big-endian */
33# define SWHI swl /* high part is left in big-endian */
34# define LWLO lwr /* low part is right in big-endian */
35# define SWLO swr /* low part is right in big-endian */
36#else
37# define LWHI lwr /* high part is right in little-endian */
38# define SWHI swr /* high part is right in little-endian */
39# define LWLO lwl /* low part is left in little-endian */
40# define SWLO swl /* low part is left in little-endian */
41#endif
42
43 .section .icode, "ax", %progbits
44
45 .global memcpy
46 .type memcpy, %function
47 .global mempcpy
48 .type mempcpy, %function
49
50 .set noreorder
51mempcpy:
52 slti t0, a2, 8 # Less than 8?
53 bne t0, zero, last8
54 addu v0, a0, a2 # exit value = s1 + n
55 b 1f
56 xor t0, a1, a0 # Find a0/a1 displacement (fill delay)
57
58memcpy:
59 slti t0, a2, 8 # Less than 8?
60 bne t0, zero, last8
61 move v0, a0 # Setup exit value before too late
62
63 xor t0, a1, a0 # Find a0/a1 displacement
64
651: andi t0, 0x3
66 bne t0, zero, shift # Go handle the unaligned case
67 subu t1, zero, a1
68 andi t1, 0x3 # a0/a1 are aligned, but are we
69 beq t1, zero, chk8w # starting in the middle of a word?
70 subu a2, t1
71 LWHI t0, 0(a1) # Yes we are... take care of that
72 addu a1, t1
73 SWHI t0, 0(a0)
74 addu a0, t1
75
76chk8w:
77 andi t0, a2, 0x1f # 32 or more bytes left?
78 beq t0, a2, chk1w
79 subu a3, a2, t0 # Yes
80 addu a3, a1 # a3 = end address of loop
81 move a2, t0 # a2 = what will be left after loop
82lop8w:
83 lw t0, 0(a1) # Loop taking 8 words at a time
84 lw t1, 4(a1)
85 lw t2, 8(a1)
86 lw t3, 12(a1)
87 lw t4, 16(a1)
88 lw t5, 20(a1)
89 lw t6, 24(a1)
90 lw t7, 28(a1)
91 addiu a0, 32
92 addiu a1, 32
93 sw t0, -32(a0)
94 sw t1, -28(a0)
95 sw t2, -24(a0)
96 sw t3, -20(a0)
97 sw t4, -16(a0)
98 sw t5, -12(a0)
99 sw t6, -8(a0)
100 bne a1, a3, lop8w
101 sw t7, -4(a0)
102
103chk1w:
104 andi t0, a2, 0x3 # 4 or more bytes left?
105 beq t0, a2, last8
106 subu a3, a2, t0 # Yes, handle them one word at a time
107 addu a3, a1 # a3 again end address
108 move a2, t0
109lop1w:
110 lw t0, 0(a1)
111 addiu a0, 4
112 addiu a1, 4
113 bne a1, a3, lop1w
114 sw t0, -4(a0)
115
116last8:
117 blez a2, lst8e # Handle last 8 bytes, one at a time
118 addu a3, a2, a1
119lst8l:
120 lb t0, 0(a1)
121 addiu a0, 1
122 addiu a1, 1
123 bne a1, a3, lst8l
124 sb t0, -1(a0)
125lst8e:
126 jr ra # Bye, bye
127 nop
128
129shift:
130 subu a3, zero, a0 # Src and Dest unaligned
131 andi a3, 0x3 # (unoptimized case...)
132 beq a3, zero, shft1
133 subu a2, a3 # a2 = bytes left
134 LWHI t0, 0(a1) # Take care of first odd part
135 LWLO t0, 3(a1)
136 addu a1, a3
137 SWHI t0, 0(a0)
138 addu a0, a3
139shft1:
140 andi t0, a2, 0x3
141 subu a3, a2, t0
142 addu a3, a1
143shfth:
144 LWHI t1, 0(a1) # Limp through, word by word
145 LWLO t1, 3(a1)
146 addiu a0, 4
147 addiu a1, 4
148 bne a1, a3, shfth
149 sw t1, -4(a0)
150 b last8 # Handle anything which may be left
151 move a2, t0
152
153 .set reorder
diff --git a/utils/hwstub/stub/asm/mips/memset.S b/utils/hwstub/stub/asm/mips/memset.S
new file mode 100644
index 0000000000..8db76d9123
--- /dev/null
+++ b/utils/hwstub/stub/asm/mips/memset.S
@@ -0,0 +1,239 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * This file was originally part of the Linux/MIPS GNU C Library
11 * Copyright (C) 1998 by Ralf Baechle
12 * Adapted for Rockbox by Maurus Cuelenaere, 2009
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#include "config.h"
25#include "mips.h"
26
27#define FILL256(dst, offset, val) \
28 sw val, (offset + 0x00)(dst); \
29 sw val, (offset + 0x04)(dst); \
30 sw val, (offset + 0x08)(dst); \
31 sw val, (offset + 0x0c)(dst); \
32 sw val, (offset + 0x10)(dst); \
33 sw val, (offset + 0x14)(dst); \
34 sw val, (offset + 0x18)(dst); \
35 sw val, (offset + 0x1c)(dst); \
36 sw val, (offset + 0x20)(dst); \
37 sw val, (offset + 0x24)(dst); \
38 sw val, (offset + 0x28)(dst); \
39 sw val, (offset + 0x2c)(dst); \
40 sw val, (offset + 0x30)(dst); \
41 sw val, (offset + 0x34)(dst); \
42 sw val, (offset + 0x38)(dst); \
43 sw val, (offset + 0x3c)(dst); \
44 sw val, (offset + 0x40)(dst); \
45 sw val, (offset + 0x44)(dst); \
46 sw val, (offset + 0x48)(dst); \
47 sw val, (offset + 0x4c)(dst); \
48 sw val, (offset + 0x50)(dst); \
49 sw val, (offset + 0x54)(dst); \
50 sw val, (offset + 0x58)(dst); \
51 sw val, (offset + 0x5c)(dst); \
52 sw val, (offset + 0x60)(dst); \
53 sw val, (offset + 0x64)(dst); \
54 sw val, (offset + 0x68)(dst); \
55 sw val, (offset + 0x6c)(dst); \
56 sw val, (offset + 0x70)(dst); \
57 sw val, (offset + 0x74)(dst); \
58 sw val, (offset + 0x78)(dst); \
59 sw val, (offset + 0x7c)(dst); \
60 sw val, (offset + 0x80)(dst); \
61 sw val, (offset + 0x84)(dst); \
62 sw val, (offset + 0x88)(dst); \
63 sw val, (offset + 0x8c)(dst); \
64 sw val, (offset + 0x90)(dst); \
65 sw val, (offset + 0x94)(dst); \
66 sw val, (offset + 0x98)(dst); \
67 sw val, (offset + 0x9c)(dst); \
68 sw val, (offset + 0xa0)(dst); \
69 sw val, (offset + 0xa4)(dst); \
70 sw val, (offset + 0xa8)(dst); \
71 sw val, (offset + 0xac)(dst); \
72 sw val, (offset + 0xb0)(dst); \
73 sw val, (offset + 0xb4)(dst); \
74 sw val, (offset + 0xb8)(dst); \
75 sw val, (offset + 0xbc)(dst); \
76 sw val, (offset + 0xc0)(dst); \
77 sw val, (offset + 0xc4)(dst); \
78 sw val, (offset + 0xc8)(dst); \
79 sw val, (offset + 0xcc)(dst); \
80 sw val, (offset + 0xd0)(dst); \
81 sw val, (offset + 0xd4)(dst); \
82 sw val, (offset + 0xd8)(dst); \
83 sw val, (offset + 0xdc)(dst); \
84 sw val, (offset + 0xe0)(dst); \
85 sw val, (offset + 0xe4)(dst); \
86 sw val, (offset + 0xe8)(dst); \
87 sw val, (offset + 0xec)(dst); \
88 sw val, (offset + 0xf0)(dst); \
89 sw val, (offset + 0xf4)(dst); \
90 sw val, (offset + 0xf8)(dst); \
91 sw val, (offset + 0xfc)(dst);
92
93#define FILL128(dst, offset, val) \
94 sw val, (offset + 0x00)(dst); \
95 sw val, (offset + 0x04)(dst); \
96 sw val, (offset + 0x08)(dst); \
97 sw val, (offset + 0x0c)(dst); \
98 sw val, (offset + 0x10)(dst); \
99 sw val, (offset + 0x14)(dst); \
100 sw val, (offset + 0x18)(dst); \
101 sw val, (offset + 0x1c)(dst); \
102 sw val, (offset + 0x20)(dst); \
103 sw val, (offset + 0x24)(dst); \
104 sw val, (offset + 0x28)(dst); \
105 sw val, (offset + 0x2c)(dst); \
106 sw val, (offset + 0x30)(dst); \
107 sw val, (offset + 0x34)(dst); \
108 sw val, (offset + 0x38)(dst); \
109 sw val, (offset + 0x3c)(dst); \
110 sw val, (offset + 0x40)(dst); \
111 sw val, (offset + 0x44)(dst); \
112 sw val, (offset + 0x48)(dst); \
113 sw val, (offset + 0x4c)(dst); \
114 sw val, (offset + 0x50)(dst); \
115 sw val, (offset + 0x54)(dst); \
116 sw val, (offset + 0x58)(dst); \
117 sw val, (offset + 0x5c)(dst); \
118 sw val, (offset + 0x60)(dst); \
119 sw val, (offset + 0x64)(dst); \
120 sw val, (offset + 0x68)(dst); \
121 sw val, (offset + 0x6c)(dst); \
122 sw val, (offset + 0x70)(dst); \
123 sw val, (offset + 0x74)(dst); \
124 sw val, (offset + 0x78)(dst); \
125 sw val, (offset + 0x7c)(dst);
126
127#define FILL64(dst, offset, val) \
128 sw val, (offset + 0x00)(dst); \
129 sw val, (offset + 0x04)(dst); \
130 sw val, (offset + 0x08)(dst); \
131 sw val, (offset + 0x0c)(dst); \
132 sw val, (offset + 0x10)(dst); \
133 sw val, (offset + 0x14)(dst); \
134 sw val, (offset + 0x18)(dst); \
135 sw val, (offset + 0x1c)(dst); \
136 sw val, (offset + 0x20)(dst); \
137 sw val, (offset + 0x24)(dst); \
138 sw val, (offset + 0x28)(dst); \
139 sw val, (offset + 0x2c)(dst); \
140 sw val, (offset + 0x30)(dst); \
141 sw val, (offset + 0x34)(dst); \
142 sw val, (offset + 0x38)(dst); \
143 sw val, (offset + 0x3c)(dst);
144
145#define FILL32(dst, offset, val) \
146 sw val, (offset + 0x00)(dst); \
147 sw val, (offset + 0x04)(dst); \
148 sw val, (offset + 0x08)(dst); \
149 sw val, (offset + 0x0c)(dst); \
150 sw val, (offset + 0x10)(dst); \
151 sw val, (offset + 0x14)(dst); \
152 sw val, (offset + 0x18)(dst); \
153 sw val, (offset + 0x1c)(dst);
154
155#define FILL 64
156#define F_FILL FILL64
157
158
159#ifdef ROCKBOX_BIG_ENDIAN
160# define SWHI swl /* high part is left in big-endian */
161#else
162# define SWHI swr /* high part is right in little-endian */
163#endif
164
165/*
166 * memset(void *s, int c, size_t n)
167 *
168 * a0: start of area to clear
169 * a1: char to fill with
170 * a2: size of area to clear
171 */
172 .section .icode, "ax", %progbits
173
174 .global memset
175 .type memset, %function
176
177 .set noreorder
178 .align 5
179memset:
180 beqz a1, 1f
181 move v0, a0 /* result */
182
183 andi a1, 0xff /* spread fillword */
184 sll t1, a1, 8
185 or a1, t1
186 sll t1, a1, 16
187 or a1, t1
1881:
189
190 sltiu t0, a2, 4 /* very small region? */
191 bnez t0, small_memset
192 andi t0, a0, 3 /* aligned? */
193
194 beqz t0, 1f
195 subu t0, 4 /* alignment in bytes */
196
197 SWHI a1, (a0) /* make word aligned */
198 subu a0, t0 /* word align ptr */
199 addu a2, t0 /* correct size */
200
2011: ori t1, a2, (FILL-1) /* # of full blocks */
202 xori t1, (FILL-1)
203 beqz t1, memset_partial /* no block to fill */
204 andi t0, a2, (FILL-4)
205
206 addu t1, a0 /* end address */
207 .set reorder
2081: addiu a0, FILL
209 F_FILL( a0, -FILL, a1 )
210 bne t1, a0, 1b
211 .set noreorder
212
213memset_partial:
214 la t1, 2f /* where to start */
215 subu t1, t0
216 jr t1
217 addu a0, t0 /* dest ptr */
218
219 F_FILL( a0, -FILL, a1 ) /* ... but first do words ... */
2202: andi a2, 3 /* 0 <= n <= 3 to go */
221
222 beqz a2, 1f
223 addu a0, a2 /* What's left */
224 SWHI a1, -1(a0)
2251: jr ra
226 move a2, zero
227
228small_memset:
229 beqz a2, 2f
230 addu t1, a0, a2
231
2321: addiu a0, 1 /* fill bytewise */
233 bne t1, a0, 1b
234 sb a1, -1(a0)
235
2362: jr ra /* done */
237 move a2, zero
238
239 .set reorder
diff --git a/utils/hwstub/stub/atj213x/Makefile b/utils/hwstub/stub/atj213x/Makefile
new file mode 100644
index 0000000000..8ec37f3543
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/Makefile
@@ -0,0 +1,14 @@
1#
2# common
3#
4CC=mipsel-elf-gcc
5LD=mipsel-elf-gcc
6AS=mipsel-elf-gcc
7OC=mipsel-elf-objcopy
8DEFINES=
9INCLUDES=-I$(CURDIR)
10GCCOPTS=-march=mips32r2 -G0 -msoft-float
11BUILD_DIR=$(CURDIR)/build/
12ROOT_DIR=$(CURDIR)/..
13
14include ../hwstub.make
diff --git a/utils/hwstub/stub/atj213x/atj213x.h b/utils/hwstub/stub/atj213x/atj213x.h
new file mode 100644
index 0000000000..cc5c4fef3e
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/atj213x.h
@@ -0,0 +1,385 @@
1#define PMU_BASE 0xB0000000
2#define PMU_CTL (*(volatile uint32_t *)(PMU_BASE + 0x00))
3#define PMU_CTL_BL_EN (1<<15)
4#define PMU_LRADC (*(volatile uint32_t *)(PMU_BASE + 0x04))
5#define PMU_CHG (*(volatile uint32_t *)(PMU_BASE + 0x08))
6#define PMU_CHG_PBLS (1<<15)
7#define PMU_CHG_PBLS_PWM (1<<15)
8#define PMU_CHG_PBLS_BL_NDR (0<<15)
9#define PMU_CHG_PPHS (1<<14)
10#define PMU_CHG_PPHS_HIGH (1<<14)
11#define PMU_CHG_PPHS_LOW (0<<14)
12#define PMU_CHG_PDUT(x) (((x) & 0x1f) << 8)
13#define PMU_CHG_PDOUT_MASK (0x1f << 8)
14
15#define CMU_BASE 0xB0010000
16#define CMU_COREPLL (*(volatile uint32_t *)(CMU_BASE + 0x00))
17#define CMU_DSPPLL (*(volatile uint32_t *)(CMU_BASE + 0x04))
18#define CMU_AUDIOPLL (*(volatile uint32_t *)(CMU_BASE + 0x08))
19#define CMU_BUSCLK (*(volatile uint32_t *)(CMU_BASE + 0x0C))
20#define CMU_SDRCLK (*(volatile uint32_t *)(CMU_BASE + 0x10))
21#define CMU_ATACLK (*(volatile uint32_t *)(CMU_BASE + 0x04))
22#define CMU_NANDCLK (*(volatile uint32_t *)(CMU_BASE + 0x18))
23#define CMU_SDCLK (*(volatile uint32_t *)(CMU_BASE + 0x1C))
24#define CMU_MHACLK (*(volatile uint32_t *)(CMU_BASE + 0x20))
25#define CMU_BTCLK (*(volatile uint32_t *)(CMU_BASE + 0x24))
26#define CMU_IRCLK (*(volatile uint32_t *)(CMU_BASE + 0x28))
27#define CMU_UART2CLK (*(volatile uint32_t *)(CMU_BASE + 0x2C))
28#define CMU_DMACLK (*(volatile uint32_t *)(CMU_BASE + 0x30))
29#define CMU_FMCLK (*(volatile uint32_t *)(CMU_BASE + 0x34))
30#define CMU_FMCLK_BCKE (1<<5)
31#define CMI_FMCLK_BCKS (1<<4)
32#define CMU_FMCLK_BCKS_32K (0<<4)
33#define CMU_FMCLK_BCKS_3M (1<<4)
34
35#define CMU_FMCLK_BCLK_MASK (CMI_FMCLK_BCKS | (3<<2))
36#define CMU_FMCLK_BCLK_3M (CMU_FMCLK_BCKS_3M | (0<<2))
37#define CMU_FMCLK_BCLK_1_5M (CMU_FMCLK_BCKS_3M | (1<<2))
38#define CMU_FMCLK_BCLK_750K (CMU_FMCLK_BCKS_3M | (2<<2))
39#define CMU_FMCLK_BCLK_375K (CMU_FMCLK_BCKS_3M | (3<<2))
40
41#define CMU_FMCLK_BCLK_32K (0<<2)
42#define CMU_FMCLK_BCLK_16K (1<<2)
43#define CMU_FMCLK_BCLK_8K (2<<2)
44#define CMU_FMCLK_BCLK_4K (3<<2)
45
46#define CMU_MCACLK (*(volatile uint32_t *)(CMU_BASE + 0x38))
47
48#define CMU_DEVCLKEN (*(volatile uint32_t *)(CMU_BASE + 0x80))
49#define CMU_DEVRST (*(volatile uint32_t *)(CMU_BASE + 0x84))
50
51#define RTC_BASE 0xB0018000
52#define RTC_CTL (*(volatile uint32_t *)(RTC_BASE + 0x00))
53#define RTC_DHMS (*(volatile uint32_t *)(RTC_BASE + 0x04))
54#define RTC_YMD (*(volatile uint32_t *)(RTC_BASE + 0x08))
55#define RTC_DHMSALM (*(volatile uint32_t *)(RTC_BASE + 0x0C))
56#define RTC_YMDALM (*(volatile uint32_t *)(RTC_BASE + 0x10))
57#define RTC_WDCTL (*(volatile uint32_t *)(RTC_BASE + 0x14))
58#define RTC_WDCTL_CLR (1<<0)
59
60#define RTC_T0CTL (*(volatile uint32_t *)(RTC_BASE + 0x18))
61#define RTC_T0 (*(volatile uint32_t *)(RTC_BASE + 0x1C))
62#define RTC_T1CTL (*(volatile uint32_t *)(RTC_BASE + 0x20))
63#define RTC_T1 (*(volatile uint32_t *)(RTC_BASE + 0x24))
64
65#define INTC_BASE 0xB0020000
66#define INTC_PD (*(volatile uint32_t *)(INTC_BASE + 0x00))
67#define INTC_MSK (*(volatile uint32_t *)(INTC_BASE + 0x04))
68#define INTC_CFG0 (*(volatile uint32_t *)(INTC_BASE + 0x08))
69#define INTC_CFG1 (*(volatile uint32_t *)(INTC_BASE + 0x0C))
70#define INTC_CFG2 (*(volatile uint32_t *)(INTC_BASE + 0x10))
71#define INTC_EXTCTL (*(volatile uint32_t *)(INTC_BASE + 0x14))
72
73#define SRAMOC_BASE 0xB0030000
74#define SRAMOC_CTL (*(volatile uint32_t *)(SRAMOC_BASE + 0x00))
75#define SRAMOC_STAT (*(volatile uint32_t *)(SRAMOC_BASE + 0x04))
76
77#define BOOT_BASE 0xB00380000
78#define BOOT_NORCTL (*(volatile uint32_t *)(BOOT_BASE + 0x00))
79#define BOOT_BROMCTL (*(volatile uint32_t *)(BOOT_BASE + 0x04))
80#define BOOT_CHIPID (*(volatile uint32_t *)(BOOT_BASE + 0x08))
81
82#define PCNT_BASE 0xB0040000
83#define PCNT_CTL (*(volatile uint32_t *)(PCNT_BASE + 0x00))
84#define PCNT_PC0 (*(volatile uint32_t *)(PCNT_BASE + 0x04))
85#define PCNT_PC1 (*(volatile uint32_t *)(PCNT_BASE + 0x08))
86
87#define DSP_BASE 0xB0050000
88#define DSP_HDR0 (*(volatile uint32_t *)(DSP_BASE + 0x00))
89#define DSP_HDR1 (*(volatile uint32_t *)(DSP_BASE + 0x04))
90#define DSP_HDR2 (*(volatile uint32_t *)(DSP_BASE + 0x08))
91#define DSP_HDR3 (*(volatile uint32_t *)(DSP_BASE + 0x0C))
92#define DSP_HDR4 (*(volatile uint32_t *)(DSP_BASE + 0x10))
93#define DSP_HDR5 (*(volatile uint32_t *)(DSP_BASE + 0x14))
94#define DSP_HSR6 (*(volatile uint32_t *)(DSP_BASE + 0x18))
95#define DSP_HSR7 (*(volatile uint32_t *)(DSP_BASE + 0x1C))
96#define DSP_CTL (*(volatile uint32_t *)(DSP_BASE + 0x20))
97
98#define DMAC_BASE(n) (0xB0060000 + (n<<5))
99#define DMAC_CTL (*(volatile uint32_t *)(DMAC_BASE(0) + 0x00))
100#define DMAC_IRQEN (*(volatile uint32_t *)(DMAC_BASE(0) + 0x04))
101#define DMAC_IRQPD (*(volatile uint32_t *)(DMAC_BASE(0) + 0x08))
102
103/* n in range 0-7 */
104#define DMA_MODE(n) (*(volatile uint32_t *)(DMAC_BASE(n) + 0x100))
105#define DMA_SRC(n) (*(volatile uint32_t *)(DMAC_BASE(n) + 0x104))
106#define DMA_DST(n) (*(volatile uint32_t *)(DMAC_BASE(n) + 0x108))
107#define DMA_CNT(n) (*(volatile uint32_t *)(DMAC_BASE(n) + 0x10C))
108#define DMA_REM(n) (*(volatile uint32_t *)(DMAC_BASE(n) + 0x110))
109#define DMA_CMD(n) (*(volatile uint32_t *)(DMAC_BASE(n) + 0x114))
110
111#define SDR_BASE 0xB0070000
112#define SDR_CTL (*(volatile uint32_t *)(SDR_BASE + 0x00))
113#define SDR_ADDRCFG (*(volatile uint32_t *)(SDR_BASE + 0x04))
114#define SDR_EN (*(volatile uint32_t *)(SDR_BASE + 0x08))
115#define SDR_CMD (*(volatile uint32_t *)(SDR_BASE + 0x0C))
116#define SDR_STAT (*(volatile uint32_t *)(SDR_BASE + 0x10))
117#define SDR_RFSH (*(volatile uint32_t *)(SDR_BASE + 0x14))
118#define SDR_MODE (*(volatile uint32_t *)(SDR_BASE + 0x18))
119#define SDR_MOBILE (*(volatile uint32_t *)(SDR_BASE + 0x1C))
120
121#define MCA_BASE 0xB0080000
122#define MCA_CTL (*(volatile uint32_t *)(MCA_BASE + 0x00))
123
124#define ATA_BASE 0xB0090000
125#define ATA_CONFIG (*(volatile uint32_t *)(ATA_BASE + 0x00))
126#define ATA_UDMACTL (*(volatile uint32_t *)(ATA_BASE + 0x04))
127#define ATA_DATA (*(volatile uint32_t *)(ATA_BASE + 0x08))
128#define ATA_FEATURE (*(volatile uint32_t *)(ATA_BASE + 0x0C))
129#define ATA_SECCNT (*(volatile uint32_t *)(ATA_BASE + 0x10))
130#define ATA_SECNUM (*(volatile uint32_t *)(ATA_BASE + 0x14))
131#define ATA_CLDLOW (*(volatile uint32_t *)(ATA_BASE + 0x18))
132#define ATA_CLDHI (*(volatile uint32_t *)(ATA_BASE + 0x1C))
133#define ATA_HEAD (*(volatile uint32_t *)(ATA_BASE + 0x20))
134#define ATA_CMD (*(volatile uint32_t *)(ATA_BASE + 0x24))
135#define ATA_BYTECNT (*(volatile uint32_t *)(ATA_BASE + 0x28))
136#define ATA_FIFOCTL (*(volatile uint32_t *)(ATA_BASE + 0x2C))
137#define ATA_FIFOCFG (*(volatile uint32_t *)(ATA_BASE + 0x30))
138#define ATA_ADDRDEC (*(volatile uint32_t *)(ATA_BASE + 0x34))
139#define ATA_IRQCTL (*(volatile uint32_t *)(ATA_BASE + 0x38))
140
141#define NAND_BASE 0xB00A0000
142#define NAND_CTL (*(volatile uint32_t *)(NAND_BASE + 0x00))
143#define NAND_STATUS (*(volatile uint32_t *)(NAND_BASE + 0x04))
144#define NAND_FIFOTIM (*(volatile uint32_t *)(NAND_BASE + 0x08))
145#define NAND_CLKCTL (*(volatile uint32_t *)(NAND_BASE + 0x0C))
146#define NAND_BYTECNT (*(volatile uint32_t *)(NAND_BASE + 0x10))
147#define NAND_ADDRLO1234 (*(volatile uint32_t *)(NAND_BASE + 0x14))
148#define NAND_ADDRLO56 (*(volatile uint32_t *)(NAND_BASE + 0x18))
149#define NAND_ADDRHI1234 (*(volatile uint32_t *)(NAND_BASE + 0x1C))
150#define NAND_ADDRHI56 (*(volatile uint32_t *)(NAND_BASE + 0x20))
151#define NAND_BUF0 (*(volatile uint32_t *)(NAND_BASE + 0x24))
152#define NAND_BUF1 (*(volatile uint32_t *)(NAND_BASE + 0x28))
153#define NAND_CMD (*(volatile uint32_t *)(NAND_BASE + 0x2C))
154#define NAND_ECCCTL (*(volatile uint32_t *)(NAND_BASE + 0x30))
155#define NAND_HAMECC0 (*(volatile uint32_t *)(NAND_BASE + 0x34))
156#define NAND_HAMECC1 (*(volatile uint32_t *)(NAND_BASE + 0x38))
157#define NAND_HAMECC2 (*(volatile uint32_t *)(NAND_BASE + 0x3C))
158#define NAND_HAMCEC (*(volatile uint32_t *)(NAND_BASE + 0x40))
159#define NAND_RSE0 (*(volatile uint32_t *)(NAND_BASE + 0x44))
160#define NAND_RSE1 (*(volatile uint32_t *)(NAND_BASE + 0x48))
161#define NAND_RSE2 (*(volatile uint32_t *)(NAND_BASE + 0x4C))
162#define NAND_RSE3 (*(volatile uint32_t *)(NAND_BASE + 0x50))
163#define NAND_RSPS0 (*(volatile uint32_t *)(NAND_BASE + 0x54))
164#define NAND_RSPS1 (*(volatile uint32_t *)(NAND_BASE + 0x58))
165#define NAND_RSPS2 (*(volatile uint32_t *)(NAND_BASE + 0x5C))
166#define NAND_FIFODATA (*(volatile uint32_t *)(NAND_BASE + 0x60))
167#define NAND_DEBUG (*(volatile uint32_t *)(NAND_BASE + 0x70))
168
169#define SD_BASE 0xB00B0000
170#define SD_CTL (*(volatile uint32_t *)(SD_BASE + 0x00))
171#define SD_CMDRSP (*(volatile uint32_t *)(SD_BASE + 0x04))
172#define SD_RW (*(volatile uint32_t *)(SD_BASE + 0x08))
173#define SD_FIFOCTL (*(volatile uint32_t *)(SD_BASE + 0x0C))
174#define SD_CMD (*(volatile uint32_t *)(SD_BASE + 0x10))
175#define SD_ARG (*(volatile uint32_t *)(SD_BASE + 0x14))
176#define SD_CRC7 (*(volatile uint32_t *)(SD_BASE + 0x18))
177#define SD_RSPBUF0 (*(volatile uint32_t *)(SD_BASE + 0x1C))
178#define SD_RSPBUF1 (*(volatile uint32_t *)(SD_BASE + 0x20))
179#define SD_RSPBUF2 (*(volatile uint32_t *)(SD_BASE + 0x24))
180#define SD_RSPBUF3 (*(volatile uint32_t *)(SD_BASE + 0x28))
181#define SD_RSPBUF4 (*(volatile uint32_t *)(SD_BASE + 0x2C))
182#define SD_DAT (*(volatile uint32_t *)(SD_BASE + 0x30))
183#define SD_CLK (*(volatile uint32_t *)(SD_BASE + 0x34))
184#define SD_BYTECNT (*(volatile uint32_t *)(SD_BASE + 0x38))
185
186#define MHA_BASE 0xB00C0000
187#define MHA_CTL (*(volatile uint32_t *)(MHA_BASE + 0x00))
188#define MHA_CFG (*(volatile uint32_t *)(MHA_BASE + 0x04))
189#define MHA_DCSCL01 (*(volatile uint32_t *)(MHA_BASE + 0x10))
190#define MHA_DCSCL23 (*(volatile uint32_t *)(MHA_BASE + 0x14))
191#define MHA_DCSCL45 (*(volatile uint32_t *)(MHA_BASE + 0x18))
192#define MHA_DCSCL67 (*(volatile uint32_t *)(MHA_BASE + 0x1C))
193#define MHA_QSCL (*(volatile uint32_t *)(MHA_BASE + 0x20))
194
195#define BT_BASE 0xB00D0000
196#define BT_MODESEL (*(volatile uint32_t *)(BT_BASE + 0x00))
197#define BT_FIFODAT (*(volatile uint32_t *)(BT_BASE + 0x04))
198
199/* video Encoder */
200#define BT_VEICTL (*(volatile uint32_t *)(BT_BASE + 0x08))
201#define BT_VEIVSEPOF (*(volatile uint32_t *)(BT_BASE + 0x14))
202#define BT_VEIVSEPEF (*(volatile uint32_t *)(BT_BASE + 0x18))
203#define BT_VEIFTP (*(volatile uint32_t *)(BT_BASE + 0x24))
204#define BT_VEIFIFOCTL (*(volatile uint32_t *)(BT_BASE + 0x30))
205
206/* Video Decoder */
207#define BT_VDICTL (*(volatile uint32_t *)(BT_BASE + 0x08))
208#define BT_VDIHSPOS (*(volatile uint32_t *)(BT_BASE + 0x0C))
209#define BT_VDIHEPOS (*(volatile uint32_t *)(BT_BASE + 0x10))
210#define BT_VDIVSEPOF (*(volatile uint32_t *)(BT_BASE + 0x14))
211#define BT_VDIVSEPEF (*(volatile uint32_t *)(BT_BASE + 0x18))
212#define BT_VDIIRQSTA (*(volatile uint32_t *)(BT_BASE + 0x28))
213#define BT_VDIXYDAT (*(volatile uint32_t *)(BT_BASE + 0x2C))
214#define BT_VDIFIFOCTL (*(volatile uint32_t *)(BT_BASE + 0x30))
215
216/* CMOS Sensor Interface */
217#define BT_CSICTL (*(volatile uint32_t *)(BT_BASE + 0x08))
218#define BT_CSIHSPOS (*(volatile uint32_t *)(BT_BASE + 0x0C))
219#define BT_CSIHEPOS (*(volatile uint32_t *)(BT_BASE + 0x10))
220#define BT_CSIVSPOS (*(volatile uint32_t *)(BT_BASE + 0x1C))
221#define BT_CSIVEPOS (*(volatile uint32_t *)(BT_BASE + 0x20))
222#define BT_CSIIRQSTA (*(volatile uint32_t *)(BT_BASE + 0x28))
223#define BT_CSIXYDAT (*(volatile uint32_t *)(BT_BASE + 0x2C))
224#define BT_CSIFIFOCTL (*(volatile uint32_t *)(BT_BASE + 0x30))
225
226/* TS */
227#define BT_TSICTL (*(volatile uint32_t *)(BT_BASE + 0x08))
228#define BT_TSIFIFOCTL (*(volatile uint32_t *)(BT_BASE + 0x30))
229
230/* Integrated Video Encoder */
231#define BT_IVECTL (*(volatile uint32_t *)(BT_BASE + 0x34))
232#define BT_IVEOUTCTL (*(volatile uint32_t *)(BT_BASE + 0x38))
233#define BT_IVECOTCTL (*(volatile uint32_t *)(BT_BASE + 0x3C))
234#define BT_IVEBRGCTL (*(volatile uint32_t *)(BT_BASE + 0x40))
235#define BT_IVECSATCTL (*(volatile uint32_t *)(BT_BASE + 0x44))
236#define BT_IVECBURCTL (*(volatile uint32_t *)(BT_BASE + 0x48))
237#define BT_IVESYNCAMCTL (*(volatile uint32_t *)(BT_BASE + 0x4C))
238
239#define OTG_BASE 0xB00E0000
240#define OTG_OUT0BC (*(volatile uint8_t *)(OTG_BASE + 0x00)) // ok (byte count?)
241#define OTG_IN0BC (*(volatile uint8_t *)(OTG_BASE + 0x01)) // ok (byte count?)
242#define OTG_EP0CS (*(volatile uint8_t *)(OTG_BASE + 0x02)) // ok
243#define EP_NAK (1<<1) // from rt source
244#define EP0_IN_BUSY (1<<2)
245#define EP0_OUT_BUSY (1<<3)
246
247#define OTG_OUT1CON (*(volatile uint8_t *)(OTG_BASE + 0x0A)) // ok
248#define OTG_OUT1CS (*(volatile uint8_t *)(OTG_BASE + 0x0B)) // missing in rt
249
250#define OTG_OUT2CON (*(volatile uint8_t *)(OTG_BASE + 0x12)) // missing in sdk
251#define OTG_OUT2CS (*(volatile uint8_t *)(OTG_BASE + 0x13)) // deduced
252
253#define OTG_IN2BCL (*(volatile uint8_t *)(OTG_BASE + 0x14)) // missing in rt
254#define OTG_IN2BCH (*(volatile uint8_t *)(OTG_BASE + 0x15)) // missing in rt
255#define OTG_IN2CON (*(volatile uint8_t *)(OTG_BASE + 0x16)) // ok
256#define OTG_IN2CS (*(volatile uint8_t *)(OTG_BASE + 0x17)) //
257
258#define OTG_FIFO1DAT (*(volatile uint32_t *)(OTG_BASE + 0x84)) // missing in rt
259#define OTG_FIFO2DAT (*(volatile uint32_t *)(OTG_BASE + 0x88)) // missing in rt
260
261#define OTG_EP0INDAT (*(volatile uint32_t *)(OTG_BASE + 0x100)) // ok
262
263#define OTG_EP0OUTDAT (*(volatile uint32_t *)(OTG_BASE + 0x140)) // ok
264
265#define OTG_SETUPDAT (*(volatile uint32_t *)(OTG_BASE + 0x180)) // ok
266#define OTG_IN04IRQ (*(volatile uint8_t *)(OTG_BASE + 0x188))
267#define OTG_OUT04IRQ (*(volatile uint8_t *)(OTG_BASE + 0x18a))
268#define OTG_USBIRQ (*(volatile uint8_t *)(OTG_BASE + 0x18C)) // ok
269
270#define OTG_IN04IEN (*(volatile uint8_t *)(OTG_BASE + 0x194))
271#define OTG_OUT04IEN (*(volatile uint8_t *)(OTG_BASE + 0x196))
272#define OTG_USBIEN (*(volatile uint8_t *)(OTG_BASE + 0x198)) // ok
273
274#define OTG_IVECT (*(volatile uint8_t *)(OTG_BASE + 0x1A0)) // missing in rt
275#define OTG_ENDPRST (*(volatile uint8_t *)(OTG_BASE + 0x1A2)) // ok
276#define OTG_USBCS (*(volatile uint8_t *)(OTG_BASE + 0x1A3)) // ok
277#define SOFT_DISCONN (1<<6) // set for soft disconnect
278
279#define OTG_FIFOCTL (*(volatile uint8_t *)(OTG_BASE + 0x1A8)) // ok
280
281
282#define OTG_OTGIRQ (*(volatile uint8_t *)(OTG_BASE + 0x1BC))
283#define OTG_FSMSTAT (*(volatile uint8_t *)(OTG_BASE + 0x1BD))
284#define OTG_CTRL (*(volatile uint8_t *)(OTG_BASE + 0x1BE))
285#define OTG_STAT (*(volatile uint8_t *)(OTG_BASE + 0x1BF))
286#define OTG_OTGIEN (*(volatile uint8_t *)(OTG_BASE + 0x1C0))
287
288#define OTG_TAAIDLBDIS (*(volatile uint8_t *)(OTG_BASE + 0x1C1))
289#define OTG_TAWAITBCON (*(volatile uint8_t *)(OTG_BASE + 0x1C2))
290#define OTG_TBVBUSPLS (*(volatile uint8_t *)(OTG_BASE + 0x1C3))
291#define OTG_TBVBUSDISPLS (*(volatile uint8_t *)(OTG_BASE + 0x1C7))
292
293#define OTG_HCIN1MAXPCKL (*(volatile uint8_t *)(OTG_BASE + 0x1E2))
294#define OTG_HCIN1MAXPCKH (*(volatile uint8_t *)(OTG_BASE + 0x1E3))
295
296#define OTG_OUT1STADDR (*(volatile uint8_t *)(OTG_BASE + 0x304))
297
298#define OTG_IN2STADDR (*(volatile uint8_t *)(OTG_BASE + 0x348))
299
300#define OTG_HCOUT2MAXPCKL (*(volatile uint8_t *)(OTG_BASE + 0x3E4))
301#define OTG_HCOUT2MAXPCKH (*(volatile uint8_t *)(OTG_BASE + 0x3E5))
302
303#define OTG_USBEIRQ (*(volatile uint8_t *)(OTG_BASE + 0x400))
304
305#define OTG_DMAEPSEL (*(volatile uint8_t *)(OTG_BASE + 0x40C))
306
307#define YUV2RGB_BASE 0xB00F0000
308#define YUV2RGB_CTL (*(volatile uint32_t *)(YUV2RGB_BASE + 0x00))
309#define YUV2RGB_FIFODATA (*(volatile uint32_t *)(YUV2RGB_BASE + 0x04))
310#define YUV2RGB_CLKCTL (*(volatile uint32_t *)(YUV2RGB_BASE + 0x08))
311#define YUV2RGB_FRAMECOUNT (*(volatile uint32_t *)(YUV2RGB_BASE + 0x0C))
312
313#define DAC_BASE 0xB0100000
314#define DAC_CTL (*(volatile uint32_t *)(DAC_BASE + 0x00))
315#define DAC_FIFOCTL (*(volatile uint32_t *)(DAC_BASE + 0x04))
316#define DAC_DAT (*(volatile uint32_t *)(DAC_BASE + 0x08))
317#define DAC_DEBUG (*(volatile uint32_t *)(DAC_BASE + 0x0C))
318#define DAC_ANALOG (*(volatile uint32_t *)(DAC_BASE + 0x10))
319
320#define ADC_BASE 0xB0110000
321#define ADC_CTL (*(volatile uint32_t *)(ADC_BASE + 0x00))
322#define ADC_FIFOCTL (*(volatile uint32_t *)(ADC_BASE + 0x04))
323#define ADC_DAT (*(volatile uint32_t *)(ADC_BASE + 0x08))
324#define ADC_DEBUG (*(volatile uint32_t *)(ADC_BASE + 0x0C))
325#define ADC_ANALOG (*(volatile uint32_t *)(ADC_BASE + 0x10))
326
327#define TP_BASE 0xB0120000
328#define TP_CTL (*(volatile uint32_t *)(TP_BASE + 0x00))
329#define TP_DAT (*(volatile uint32_t *)(TP_BASE + 0x04))
330
331#define SPDIF_BASE 0xB0140000
332#define SPDIF_CTL (*(volatile uint32_t *)(SPDIF_BASE + 0x00))
333#define SPDIF_STAT (*(volatile uint32_t *)(SPDIF_BASE + 0x04))
334#define SPDIF_TXDAT (*(volatile uint32_t *)(SPDIF_BASE + 0x08))
335#define SPDIF_RXDAT (*(volatile uint32_t *)(SPDIF_BASE + 0x0C))
336#define SPDIF_TXCSTAT (*(volatile uint32_t *)(SPDIF_BASE + 0x10))
337#define SPDIF_RXCSTAT (*(volatile uint32_t *)(SPDIF_BASE + 0x14))
338
339#define PCM_BASE 0xB0150000
340#define PCM_CTL (*(volatile uint32_t *)(PCM_BASE + 0x00))
341#define PCM_STAT (*(volatile uint32_t *)(PCM_BASE + 0x04))
342#define PCM_RXDAT (*(volatile uint32_t *)(PCM_BASE + 0x08))
343#define PCM_TXDAT (*(volatile uint32_t *)(PCM_BASE + 0x0C))
344
345/* n = 0,1 */
346#define UART_BASE(n) (0xB0160000 + (n<<5))
347#define UART_CTL(n) (*(volatile uint32_t *)(UART_BASE(n) + 0x00))
348#define UART_RXDAT(n) (*(volatile uint32_t *)(UART_BASE(n) + 0x04))
349#define UART_TXDAT(n) (*(volatile uint32_t *)(UART_BASE(n) + 0x08))
350#define UART_STAT(n) (*(volatile uint32_t *)(UART_BASE(n) + 0x0C))
351
352#define IR_PL (*(volatile uint32_t *)(UART_BASE(0) + 0x10))
353#define IR_RBC (*(volatile uint32_t *)(UART_BASE(0) + 0x14))
354
355/* n = 0,1 */
356#define I2C_BASE(n) (0xB0180000 + (n<<5))
357#define I2C_CTL(n) (*(volatile uint32_t *)(I2C_BASE(n) + 0x00))
358#define I2C_CLKDIV(n) (*(volatile uint32_t *)(I2C_BASE(n) + 0x04))
359#define I2C_STAT(n) (*(volatile uint32_t *)(I2C_BASE(n) + 0x08))
360#define I2C_ADDR(n) (*(volatile uint32_t *)(I2C_BASE(n) + 0x0C))
361#define I2C_DAT(n) (*(volatile uint32_t *)(I2C_BASE(n) + 0x10))
362
363#define SPI_BASE 0xB0190000
364#define SPI_CTL (*(volatile uint32_t *)(SPI_BASE + 0x00))
365#define SPI_CLKDIV (*(volatile uint32_t *)(SPI_BASE + 0x04))
366#define SPI_STAT (*(volatile uint32_t *)(SPI_BASE + 0x08))
367#define SPI_RXDAT (*(volatile uint32_t *)(SPI_BASE + 0x0C))
368#define SPI_TXDAT (*(volatile uint32_t *)(SPI_BASE + 0x10))
369
370#define KEY_BASE 0xB01A0000
371#define KEY_CTL (*(volatile uint32_t *)(KEY_BASE + 0x00))
372#define KEY_DAT0 (*(volatile uint32_t *)(KEY_BASE + 0x04))
373#define KEY_DAT1 (*(volatile uint32_t *)(KEY_BASE + 0x08))
374#define KEY_DAT2 (*(volatile uint32_t *)(KEY_BASE + 0x0C))
375#define KEY_DAT3 (*(volatile uint32_t *)(KEY_BASE + 0x10))
376
377#define GPIO_BASE 0xB01C0000
378#define GPIO_AOUTEN (*(volatile uint32_t *)(GPIO_BASE + 0x00))
379#define GPIO_AINEN (*(volatile uint32_t *)(GPIO_BASE + 0x04))
380#define GPIO_ADAT (*(volatile uint32_t *)(GPIO_BASE + 0x08))
381#define GPIO_BOUTEN (*(volatile uint32_t *)(GPIO_BASE + 0x0C))
382#define GPIO_BINEN (*(volatile uint32_t *)(GPIO_BASE + 0x10))
383#define GPIO_BDAT (*(volatile uint32_t *)(GPIO_BASE + 0x14))
384#define GPIO_MFCTL0 (*(volatile uint32_t *)(GPIO_BASE + 0x18))
385#define GPIO_MFCTL1 (*(volatile uint32_t *)(GPIO_BASE + 0x1C))
diff --git a/utils/hwstub/stub/atj213x/crt0.S b/utils/hwstub/stub/atj213x/crt0.S
new file mode 100644
index 0000000000..16dd2ced8b
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/crt0.S
@@ -0,0 +1,206 @@
1#include "mips.h"
2
3 .extern main
4 .global start
5
6 .set mips32r2
7 .set noreorder
8
9 .section .init.text,"ax",%progbits
10
11start:
12 di # disable interrupts
13 bltzal zero, load_addr # ra = PC + 8, branch not taken
14 nop
15
16load_addr:
17 addiu v0, ra, -12 # calc real load address
18 # account for branch delay slot
19 # and very first 'di' instruction
20
21 la t0, 0x80000000 # an idx op should use an unmappable address
22 ori t1, t0, 0x4000 # 16kB cache
23 mtc0 zero, C0_TAGLO
24 mtc0 zero, C0_TAGHI
25
26cache_init_loop:
27 cache ICIndexStTag, 0(t0) # index store icache tag
28 cache DCIndexStTag, 0(t0) # index store dcache tag
29 bne t0, t1, cache_init_loop
30 addiu t0, t0, 0x10
31
32 li t0, 3 # enable cache for kseg0 accesses
33 mtc0 t0, C0_CONFIG
34 ehb
35
36 la t0, relocstart
37 la t1, relocend
38 beq t0, v0, entry_point # no relocation needed
39 nop
40
41reloc_loop:
42 lw s0, 0(v0) # src
43 lw s1, 4(v0)
44 lw s2, 8(v0)
45 lw s3, 12(v0)
46
47 sw s0, 0(t0) # dst
48 sw s1, 4(t0)
49 sw s2, 8(t0)
50 sw s3, 12(t0)
51
52 synci 0(t0) # dcache writeback invalidate
53 # icache invalidate
54
55 addiu t0, t0, 16 # inc dst addr
56 blt t0, t1, reloc_loop
57 addiu v0, v0, 16 # inc src addr
58
59entry_point_jump:
60 la t0, entry_point
61 jr.hb t0
62 nop
63
64entry_point:
65intc_setup:
66 li t0, 0xb0020000 # INTC base
67 lw zero, 4(t0) # INTC_MSK mask all interrupt sources
68
69core_irq_setup:
70 li t0, 0x00404000 # BEV=1 for C0_EBASE setup, IM6=1, IE=0
71 mtc0 t0, C0_STATUS
72
73 la t0, _irqbase # vectors base address must be 4k aligned
74 mtc0 t0, C0_EBASE
75
76 li t0, 0x00004000
77 mtc0 t0, C0_STATUS # BEV=0, IM6=1, IE=0
78
79 li t1, 0x08800000
80 mtc0 t1, C0_CAUSE # DC=1, IV=1
81 mtc0 zero,C0_INTCTL # VS = 0
82
83 # clear bss
84 la t0, bssbegin
85 la t1, bssend
86 beq t0, t1, stack_setup
87 nop
88
89clear_bss_loop:
90 sw zero, 0(t0)
91 bne t0, t1, clear_bss_loop
92 addiu t0, 4
93
94stack_setup:
95 # setup stack
96 la k0, irqstackend
97 la sp, stackend
98 la t0, stackbegin
99 li t1, 0xdeadbeef
100
101stack_munge_loop:
102 sw t1, 0(t0)
103 bne t0, sp, stack_munge_loop
104 addiu t0, 4
105
106 # jump to C code with enabled interrupts
107 la t0, main
108 jr.hb t0
109 ei
110
111 .set at
112 .set reorder
113
114/* s0-s7 not saved as this are callee saved registers
115 * CO_STATUS is not saved as nested interrupts are not supported
116 *
117 * Separate irqstack is used for context save and irq processing
118 * k0 holds the address of the top of this stack and k1 is used
119 * to hold original sp value. Since we do not support nesting
120 * there is nothing to worry about
121 */
122 .extern INT_UDC
123
124 .global irq_handler
125 .set mips32r2
126 .set noreorder
127 .set noat
128 .section .irq_vector,"ax",%progbits
129
130irq_handler:
131 move k1, sp
132 move sp, k0
133 addiu sp, sp, -84
134
135 /* context save */
136 sw AT, 0(sp)
137 sw v0, 4(sp)
138 sw v1, 8(sp)
139 sw a0, 12(sp)
140 sw a1, 16(sp)
141 sw a2, 20(sp)
142 sw a3, 24(sp)
143 sw t0, 28(sp)
144 sw t1, 32(sp)
145 sw t2, 36(sp)
146 sw t3, 40(sp)
147 sw t4, 44(sp)
148 sw t5, 48(sp)
149 sw t6, 52(sp)
150 sw t7, 56(sp)
151 sw t8, 60(sp)
152 sw t9, 64(sp)
153 sw fp, 68(sp)
154 sw ra, 72(sp)
155
156 mfhi t0
157 mflo t1
158 sw t0, 76(sp)
159 sw t1, 80(sp)
160
161 /* handle interrupt */
162 lui t0, 0xb002 /* INTC base */
163 lw a0, 0(t0) /* INTC_PD */
164 lw a1, 4(t0) /* INTC_MSK */
165 and a0, a0, a1 /* mask */
166 andi a0, a0, 0x10 /* UDC flag */
167 beq a0, zero, restore
168 nop
169 /* irq dispatch */
170 la a0, INT_UDC
171 jalr a0
172 nop
173
174restore:
175 /* context restore */
176 lw t0, 76(sp)
177 lw t1, 80(sp)
178 mthi t0
179 mtlo t1
180 lw AT, 0(sp)
181 lw v0, 4(sp)
182 lw v1, 8(sp)
183 lw a0, 12(sp)
184 lw a1, 16(sp)
185 lw a2, 20(sp)
186 lw a3, 24(sp)
187 lw t0, 28(sp)
188 lw t1, 32(sp)
189 lw t2, 36(sp)
190 lw t3, 40(sp)
191 lw t4, 44(sp)
192 lw t5, 48(sp)
193 lw t6, 52(sp)
194 lw t7, 56(sp)
195 lw t8, 60(sp)
196 lw t9, 64(sp)
197 lw fp, 68(sp)
198 lw ra, 72(sp)
199
200 addiu sp, sp, 84
201 move sp, k1
202 eret
203
204 .set reorder
205 .set at
206
diff --git a/utils/hwstub/stub/atj213x/hwstub.lds b/utils/hwstub/stub/atj213x/hwstub.lds
new file mode 100644
index 0000000000..7f5c9fae18
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/hwstub.lds
@@ -0,0 +1,70 @@
1#include "config.h"
2ENTRY(main)
3OUTPUT_ARCH(mips)
4STARTUP(atj213x/crt0.o)
5
6MEMORY
7{
8 DRAM : ORIGIN = DRAM_ORIG, LENGTH = DRAM_SIZE
9 IRAM : ORIGIN = IRAM_ORIG, LENGTH = IRAM_SIZE
10}
11
12SECTIONS
13{
14 .init.text :
15 {
16 _irqbase = .;
17 relocstart = .;
18 oc_codestart = .;
19 *(.init.text*)
20 } > IRAM
21
22 .exception.text (IRAM_ORIG + 0x200) :
23 {
24 *(.irq_vector*)
25 } > IRAM
26
27 .text :
28 {
29 *(.text*)
30 *(.icode*)
31 } > IRAM
32
33 .data :
34 {
35 *(.rodata*)
36 *(.data*)
37 *(.rel.dyn)
38 relocend = .;
39 } > IRAM
40
41 .stack (NOLOAD) :
42 {
43 . = ALIGN(4);
44 stackbegin = .;
45 oc_stackstart = .;
46 . += 0x2000;
47 stackend = .;
48 irqstackbegin = .;
49 . += 0x400;
50 irqstackend = .;
51 oc_stackend = .;
52 } > IRAM
53
54 .bss (NOLOAD) :
55 {
56 bssbegin = .;
57 *(.sbss*)
58 *(.bss*)
59 *(COMMON)
60 *(.scommon*)
61 bssend = .;
62 oc_codeend = .;
63 oc_bufferstart = .;
64 } > IRAM
65
66 .end IRAM_ORIG+IRAM_SIZE (NOLOAD) :
67 {
68 oc_bufferend = .;
69 } > IRAM
70}
diff --git a/utils/hwstub/stub/atj213x/mips-archdefs.h b/utils/hwstub/stub/atj213x/mips-archdefs.h
new file mode 100644
index 0000000000..79995479c4
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/mips-archdefs.h
@@ -0,0 +1,2358 @@
1/**************************************************************************
2* *
3* PROJECT : MIPS port for uC/OS-II *
4* *
5* MODULE : ARCHDEFS.h *
6* *
7* AUTHOR : Michael Anburaj *
8* URL : http://geocities.com/michaelanburaj/ *
9* EMAIL: michaelanburaj@hotmail.com *
10* *
11* PROCESSOR : MIPS 4Kc (32 bit RISC) - ATLAS board *
12* *
13* TOOL-CHAIN : SDE & Cygnus *
14* *
15* DESCRIPTION : *
16* Architecture definitions. *
17* *
18**************************************************************************/
19
20
21#ifndef __ARCHDEFS_H__
22#define __ARCHDEFS_H__
23
24
25/* ********************************************************************* */
26/* Module configuration */
27
28
29/* ********************************************************************* */
30/* Interface macro & data definition */
31
32/*
33 * Utility defines for cross platform handling of 64bit constants.
34 */
35
36#if !defined(Append)
37 #define Append(c,s) (c##s)
38#endif
39
40#if !defined(__assembler) && !defined(MIPSAVPENV)
41 #if defined(NT)
42 #if !defined(UNS64Const)
43 #define UNS64Const(c) Append(c,ui64)
44 #endif
45
46 #if !defined(INT64Const)
47 #define INT64Const(c) Append(c,i64)
48 #endif
49 #else
50 #if !defined(UNS64Const)
51 #define UNS64Const(c) Append(c,ull)
52 #endif
53
54 #if !defined(INT64Const)
55 #define INT64Const(c) Append(c,ll)
56 #endif
57 #endif
58#else /* Not C or C++ */
59 #if !defined(UNS64Const)
60 #define UNS64Const(c) c
61 #endif
62
63 #if !defined(INT64Const)
64 #define INT64Const(c) c
65 #endif
66#endif /* C or C++ */
67
68
69/*
70 ************************************************************************
71 * I N S T R U C T I O N F O R M A T S *
72 ************************************************************************
73 *
74 * The following definitions describe each field in an instruction. There
75 * is one diagram for each type of instruction, with field definitions
76 * following the diagram for that instruction. Note that if a field of
77 * the same name and position is defined in an earlier diagram, it is
78 * not defined again in the subsequent diagram. Only new fields are
79 * defined for each diagram.
80 *
81 * R-Type (operate)
82 *
83 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
84 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
85 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
86 * | | rs | rt | rd | sa | |
87 * | Opcode | | | Tcode | func |
88 * | | Bcode | | sel |
89 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 */
91
92#define S_InstnOpcode 26
93#define M_InstnOpcode (0x3f << S_InstnOpcode)
94#define S_InstnRS 21
95#define M_InstnRS (0x1f << S_InstnRS)
96#define S_InstnRT 16
97#define M_InstnRT (0x1f << S_InstnRT)
98#define S_InstnRD 11
99#define M_InstnRD (0x1f << S_InstnRD)
100#define S_InstnSA 6
101#define M_InstnSA (0x1f << S_InstnSA)
102#define S_InstnTcode 6
103#define M_InstnTcode (0x3ff << S_InstnTcode)
104#define S_InstnBcode 6
105#define M_InstnBcode (0xfffff << S_InstnBcode)
106#define S_InstnFunc 0
107#define M_InstnFunc (0x3f << S_InstnFunc)
108#define S_InstnSel 0
109#define M_InstnSel (0x7 << S_InstnSel)
110
111/*
112 * I-Type (load, store, branch, immediate)
113 *
114 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
115 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
116 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
117 * | Opcode | rs | rt | Offset |
118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119 */
120
121#define S_InstnOffset 0
122#define M_InstnOffset (0xffff << S_InstnOffset)
123
124/*
125 * I-Type (pref)
126 *
127 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
128 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
129 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130 * | Opcode | rs | hint | Offset |
131 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132 */
133
134#define S_InstnHint S_InstnRT
135#define M_InstnHint M_InstnRT
136
137/*
138 * J-Type (jump)
139 *
140 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
141 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
142 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 * | Opcode | JIndex |
144 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145 */
146
147#define S_InstnJIndex 0
148#define M_InstnJIndex (0x03ffffff << S_InstnJIndex)
149
150/*
151 * FP R-Type (operate)
152 *
153 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
154 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
155 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
156 * | Opcode | fmt | ft | fs | fd | func |
157 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
158 */
159
160#define S_InstnFmt S_InstnRS
161#define M_InstnFmt M_InstnRS
162#define S_InstnFT S_InstnRT
163#define M_InstnFT M_InstnRT
164#define S_InstnFS S_InstnRD
165#define M_InstnFS M_InstnRD
166#define S_InstnFD S_InstnSA
167#define M_InstnFD M_InstnSA
168
169/*
170 * FP R-Type (cpu <-> cpu data movement))
171 *
172 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
173 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
174 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
175 * | Opcode | sub | rt | fs | 0 |
176 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177 */
178
179#define S_InstnSub S_InstnRS
180#define M_InstnSub M_InstnRS
181
182/*
183 * FP R-Type (compare)
184 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
185 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
186 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
187 * | | | | | | |C| |
188 * | Opcode | fmt | ft | fs | cc |0|A| func |
189 * | | | | | | |B| |
190 * | | | | | | |S| |
191 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
192 */
193
194#define S_InstnCCcmp 8
195#define M_InstnCCcmp (0x7 << S_InstnCCcmp)
196#define S_InstnCABS 6
197#define M_InstnCABS (0x1 << S_InstnCABS)
198
199/*
200 * FP R-Type (FPR conditional move on FP cc)
201 *
202 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
203 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
204 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
205 * | Opcode | fmt | cc |n|t| fs | fd | func |
206 * | | | |d|f| | | |
207 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
208 */
209
210#define S_InstnCC 18
211#define M_InstnCC (0x7 << S_InstnCC)
212#define S_InstnND 17
213#define M_InstnND (0x1 << S_InstnND)
214#define S_InstnTF 16
215#define M_InstnTF (0x1 << S_InstnTF)
216
217/*
218 * FP R-Type (3-operand operate)
219 *
220 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
221 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
222 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
223 * | Opcode | fr | ft | fs | fd | op4 | fmt3|
224 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
225 */
226
227#define S_InstnFR S_InstnRS
228#define M_InstnFR M_InstnRS
229#define S_InstnOp4 3
230#define M_InstnOp4 (0x7 << S_InstnOp4)
231#define S_InstnFmt3 0
232#define M_InstnFmt3 (0x7 << S_InstnFmt3)
233
234/*
235 * FP R-Type (Indexed load, store)
236 *
237 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
238 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
239 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
240 * | Opcode | rs | rt | 0 | fd | func |
241 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 */
243/*
244 * FP R-Type (prefx)
245 *
246 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
247 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
248 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
249 * | Opcode | rs | rt | hint | 0 | func |
250 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
251 */
252
253#define S_InstnHintX S_InstnRD
254#define M_InstnHintX M_InstnRD
255
256/*
257 * FP R-Type (GPR conditional move on FP cc)
258 *
259 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
260 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
261 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
262 * | Opcode | rs | cc |n|t| rd | 0 | func |
263 * | | | |d|f| | | |
264 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
265 */
266
267/*
268 * FP I-Type (load, store)
269 *
270 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
271 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
272 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
273 * | Opcode | rs | ft | Offset |
274 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
275 */
276
277/*
278 * FP I-Type (branch)
279 *
280 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
281 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
282 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
283 * | Opcode | fmt | cc |n|t| Offset |
284 * | | | |d|f| |
285 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
286 */
287
288
289/*
290 *************************************************************************
291 * V I R T U A L A D D R E S S D E F I N I T I O N S *
292 *************************************************************************
293 */
294
295#ifdef MIPSADDR64
296#define A_K0BASE UNS64Const(0xffffffff80000000)
297#define A_K1BASE UNS64Const(0xffffffffa0000000)
298#define A_K2BASE UNS64Const(0xffffffffc0000000)
299#define A_K3BASE UNS64Const(0xffffffffe0000000)
300#define A_REGION UNS64Const(0xc000000000000000)
301#define A_XKPHYS_ATTR UNS64Const(0x3800000000000000)
302#else
303#define A_K0BASE 0x80000000
304#define A_K1BASE 0xa0000000
305#define A_K2BASE 0xc0000000
306#define A_K3BASE 0xe0000000
307#endif
308#define M_KMAPPED 0x40000000 /* KnSEG address is mapped if bit is one */
309
310
311#ifdef MIPS_Model64
312
313#define S_VMAP64 62
314#define M_VMAP64 UNS64Const(0xc000000000000000)
315
316#define K_VMode11 3
317#define K_VMode10 2
318#define K_VMode01 1
319#define K_VMode00 0
320
321#define S_KSEG3 29
322#define M_KSEG3 (0x7 << S_KSEG3)
323#define K_KSEG3 7
324
325#define S_SSEG 29
326#define M_SSEG (0x7 << S_KSEG3)
327#define K_SSEG 6
328
329#define S_KSSEG 29
330#define M_KSSEG (0x7 << S_KSEG3)
331#define K_KSSEG 6
332
333#define S_KSEG1 29
334#define M_KSEG1 (0x7 << S_KSEG3)
335#define K_KSEG1 5
336
337#define S_KSEG0 29
338#define M_KSEG0 (0x7 << S_KSEG3)
339#define K_KSEG0 4
340
341#define S_XKSEG 29
342#define M_XKSEG (0x7 << S_KSEG3)
343#define K_XKSEG 3
344
345#define S_USEG 31
346#define M_USEG (0x1 << S_USEG)
347#define K_USEG 0
348
349#define S_EjtagProbeMem 20
350#define M_EjtagProbeMem (0x1 << S_EjtagProbeMem)
351#define K_EjtagProbeMem 0
352
353
354
355#else
356
357#define S_KSEG3 29
358#define M_KSEG3 (0x7 << S_KSEG3)
359#define K_KSEG3 7
360
361#define S_KSSEG 29
362#define M_KSSEG (0x7 << S_KSSEG)
363#define K_KSSEG 6
364
365#define S_SSEG 29
366#define M_SSEG (0x7 << S_SSEG)
367#define K_SSEG 6
368
369#define S_KSEG1 29
370#define M_KSEG1 (0x7 << S_KSEG1)
371#define K_KSEG1 5
372
373#define S_KSEG0 29
374#define M_KSEG0 (0x7 << S_KSEG0)
375#define K_KSEG0 4
376
377#define S_KUSEG 31
378#define M_KUSEG (0x1 << S_KUSEG)
379#define K_KUSEG 0
380
381#define S_SUSEG 31
382#define M_SUSEG (0x1 << S_SUSEG)
383#define K_SUSEG 0
384
385#define S_USEG 31
386#define M_USEG (0x1 << S_USEG)
387#define K_USEG 0
388
389#define K_EjtagLower 0xff200000
390#define K_EjtagUpper 0xff3fffff
391
392#define S_EjtagProbeMem 20
393#define M_EjtagProbeMem (0x1 << S_EjtagProbeMem)
394#define K_EjtagProbeMem 0
395
396#endif
397
398
399
400/*
401 *************************************************************************
402 * C A C H E I N S T R U C T I O N O P E R A T I O N C O D E S *
403 *************************************************************************
404 */
405
406/*
407 * Cache encodings
408 */
409#define K_CachePriI 0 /* Primary Icache */
410#define K_CachePriD 1 /* Primary Dcache */
411#define K_CachePriU 1 /* Unified primary */
412#define K_CacheTerU 2 /* Unified Tertiary */
413#define K_CacheSecU 3 /* Unified secondary */
414
415
416/*
417 * Function encodings
418 */
419#define S_CacheFunc 2 /* Amount to shift function encoding within 5-bit field */
420#define K_CacheIndexInv 0 /* Index invalidate */
421#define K_CacheIndexWBInv 0 /* Index writeback invalidate */
422#define K_CacheIndexLdTag 1 /* Index load tag */
423#define K_CacheIndexStTag 2 /* Index store tag */
424#define K_CacheHitInv 4 /* Hit Invalidate */
425#define K_CacheFill 5 /* Fill (Icache only) */
426#define K_CacheHitWBInv 5 /* Hit writeback invalidate */
427#define K_CacheHitWB 6 /* Hit writeback */
428#define K_CacheFetchLock 7 /* Fetch and lock */
429
430#define ICIndexInv ((K_CacheIndexInv << S_CacheFunc) | K_CachePriI)
431#define DCIndexWBInv ((K_CacheIndexWBInv << S_CacheFunc) | K_CachePriD)
432#define DCIndexInv DCIndexWBInv
433#define ICIndexLdTag ((K_CacheIndexLdTag << S_CacheFunc) | K_CachePriI)
434#define DCIndexLdTag ((K_CacheIndexLdTag << S_CacheFunc) | K_CachePriD)
435#define ICIndexStTag ((K_CacheIndexStTag << S_CacheFunc) | K_CachePriI)
436#define DCIndexStTag ((K_CacheIndexStTag << S_CacheFunc) | K_CachePriD)
437#define ICHitInv ((K_CacheHitInv << S_CacheFunc) | K_CachePriI)
438#define DCHitInv ((K_CacheHitInv << S_CacheFunc) | K_CachePriD)
439#define ICFill ((K_CacheFill << S_CacheFunc) | K_CachePriI)
440#define DCHitWBInv ((K_CacheHitWBInv << S_CacheFunc) | K_CachePriD)
441#define DCHitWB ((K_CacheHitWB << S_CacheFunc) | K_CachePriD)
442#define ICFetchLock ((K_CacheFetchLock << S_CacheFunc) | K_CachePriI)
443#define DCFetchLock ((K_CacheFetchLock << S_CacheFunc) | K_CachePriD)
444
445
446/*
447 *************************************************************************
448 * P R E F E T C H I N S T R U C T I O N H I N T S *
449 *************************************************************************
450 */
451
452#define PrefLoad 0
453#define PrefStore 1
454#define PrefLoadStreamed 4
455#define PrefStoreStreamed 5
456#define PrefLoadRetained 6
457#define PrefStoreRetained 7
458#define PrefWBInval 25
459#define PrefNudge 25
460
461
462/*
463 *************************************************************************
464 * C P U R E G I S T E R D E F I N I T I O N S *
465 *************************************************************************
466 */
467
468
469/*
470 *************************************************************************
471 * S O F T W A R E G P R N A M E S *
472 *************************************************************************
473 */
474
475#define zero $0
476#define AT $1
477#define v0 $2
478#define v1 $3
479#define a0 $4
480#define a1 $5
481#define a2 $6
482#define a3 $7
483#define t0 $8
484#define t1 $9
485#define t2 $10
486#define t3 $11
487#define t4 $12
488#define t5 $13
489#define t6 $14
490#define t7 $15
491#define s0 $16
492#define s1 $17
493#define s2 $18
494#define s3 $19
495#define s4 $20
496#define s5 $21
497#define s6 $22
498#define s7 $23
499#define t8 $24
500#define t9 $25
501#define k0 $26
502#define k1 $27
503#define gp $28
504#define sp $29
505#define fp $30
506#define ra $31
507
508/*
509 * The following registers are used by the AVP environment and
510 * are not part of the normal software definitions.
511 */
512
513#ifdef MIPSAVPENV
514#define repc $25 /* Expected exception PC */
515#define tid $30 /* Current test case address */
516#endif
517
518
519/*
520 *************************************************************************
521 * H A R D W A R E G P R N A M E S *
522 *************************************************************************
523 *
524 * In the AVP environment, several of the `r' names are removed from the
525 * name space because they are used by the kernel for special purposes.
526 * Removing them causes assembly rather than runtime errors for tests that
527 * use the `r' names.
528 *
529 * - r25 (repc) is used as the expected PC on an exception
530 * - r26-r27 (k0, k1) are used in the exception handler
531 * - r30 (tid) is used as the current test address
532 */
533
534#define r0 $0
535#define r1 $1
536#define r2 $2
537#define r3 $3
538#define r4 $4
539#define r5 $5
540#define r6 $6
541#define r7 $7
542#define r8 $8
543#define r9 $9
544#define r10 $10
545#define r11 $11
546#define r12 $12
547#define r13 $13
548#define r14 $14
549#define r15 $15
550#define r16 $16
551#define r17 $17
552#define r18 $18
553#define r19 $19
554#define r20 $20
555#define r21 $21
556#define r22 $22
557#define r23 $23
558#define r24 $24
559#ifdef MIPSAVPENV
560#define r25 r25_unknown
561#define r26 r26_unknown
562#define r27 r27_unknown
563#else
564#define r25 $25
565#define r26 $26
566#define r27 $27
567#endif
568#define r28 $28
569#define r29 $29
570#ifdef MIPSAVPENV
571#define r30 r30_unknown
572#else
573#define r30 $30
574#endif
575#define r31 $31
576
577
578/*
579 *************************************************************************
580 * H A R D W A R E G P R I N D I C E S *
581 *************************************************************************
582 *
583 * These definitions provide the index (number) of the GPR, as opposed
584 * to the assembler register name ($n).
585 */
586
587#define R_r0 0
588#define R_r1 1
589#define R_r2 2
590#define R_r3 3
591#define R_r4 4
592#define R_r5 5
593#define R_r6 6
594#define R_r7 7
595#define R_r8 8
596#define R_r9 9
597#define R_r10 10
598#define R_r11 11
599#define R_r12 12
600#define R_r13 13
601#define R_r14 14
602#define R_r15 15
603#define R_r16 16
604#define R_r17 17
605#define R_r18 18
606#define R_r19 19
607#define R_r20 20
608#define R_r21 21
609#define R_r22 22
610#define R_r23 23
611#define R_r24 24
612#define R_r25 25
613#define R_r26 26
614#define R_r27 27
615#define R_r28 28
616#define R_r29 29
617#define R_r30 30
618#define R_r31 31
619#define R_hi 32 /* Hi register */
620#define R_lo 33 /* Lo register */
621
622
623/*
624 *************************************************************************
625 * S O F T W A R E G P R M A S K S *
626 *************************************************************************
627 *
628 * These definitions provide the bit mask corresponding to the GPR number
629 */
630
631#define M_AT (1<<1)
632#define M_v0 (1<<2)
633#define M_v1 (1<<3)
634#define M_a0 (1<<4)
635#define M_a1 (1<<5)
636#define M_a2 (1<<6)
637#define M_a3 (1<<7)
638#define M_t0 (1<<8)
639#define M_t1 (1<<9)
640#define M_t2 (1<<10)
641#define M_t3 (1<<11)
642#define M_t4 (1<<12)
643#define M_t5 (1<<13)
644#define M_t6 (1<<14)
645#define M_t7 (1<<15)
646#define M_s0 (1<<16)
647#define M_s1 (1<<17)
648#define M_s2 (1<<18)
649#define M_s3 (1<<19)
650#define M_s4 (1<<20)
651#define M_s5 (1<<21)
652#define M_s6 (1<<22)
653#define M_s7 (1<<23)
654#define M_t8 (1<<24)
655#define M_t9 (1<<25)
656#define M_k0 (1<<26)
657#define M_k1 (1<<27)
658#define M_gp (1<<28)
659#define M_sp (1<<29)
660#define M_fp (1<<30)
661#define M_ra (1<<31)
662
663
664/*
665 *************************************************************************
666 * C P 0 R E G I S T E R D E F I N I T I O N S *
667 *************************************************************************
668 * Each register has the following definitions:
669 *
670 * C0_rrr The register number (as a $n value)
671 * R_C0_rrr The register index (as an integer corresponding
672 * to the register number)
673 *
674 * Each field in a register has the following definitions:
675 *
676 * S_rrrfff The shift count required to right-justify
677 * the field. This corresponds to the bit
678 * number of the right-most bit in the field.
679 * M_rrrfff The Mask required to isolate the field.
680 *
681 * Register diagrams included below as comments correspond to the
682 * MIPS32 and MIPS64 architecture specifications. Refer to other
683 * sources for register diagrams for older architectures.
684 */
685
686
687/*
688 ************************************************************************
689 * I N D E X R E G I S T E R ( 0 ) *
690 ************************************************************************
691 *
692 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
693 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
694 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
695 * |P| 0 | Index | Index
696 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
697 */
698
699#define C0_Index $0
700#define R_C0_Index 0
701#define C0_INX C0_Index /* OBSOLETE - DO NOT USE IN NEW CODE */
702
703#define S_IndexP 31 /* Probe failure (R)*/
704#define M_IndexP (0x1 << S_IndexP)
705
706#define S_IndexIndex 0 /* TLB index (R/W)*/
707#define M_IndexIndex (0x3f << S_IndexIndex)
708
709#define M_Index0Fields 0x7fffffc0
710#define M_IndexRFields 0x80000000
711
712
713/*
714 ************************************************************************
715 * R A N D O M R E G I S T E R ( 1 ) *
716 ************************************************************************
717 *
718 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
719 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
720 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
721 * | 0 | Index | Random
722 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
723 */
724
725#define C0_Random $1
726#define R_C0_Random 1
727#define C0_RAND $1 /* OBSOLETE - DO NOT USE IN NEW CODE */
728
729#define S_RandomIndex 0 /* TLB random index (R)*/
730#define M_RandomIndex (0x3f << S_RandomIndex)
731
732#define M_Random0Fields 0xffffffc0
733#define M_RandomRFields 0x0000003f
734
735
736/*
737 ************************************************************************
738 * E N T R Y L O 0 R E G I S T E R ( 2 ) *
739 ************************************************************************
740 *
741 * 6 6 6 6 5 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
742 * 3 2 1 0 9 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
743 * +-+-+-+-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
744 * | Fill (0) //| 0 | PFN | C |D|V|G| EntryLo0
745 * +-+-+-+-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
746 */
747
748#define C0_EntryLo0 $2
749#define R_C0_EntryLo0 2
750#define C0_TLBLO_0 C0_EntryLo0 /* OBSOLETE - DO NOT USE IN NEW CODE */
751
752#define S_EntryLoPFN 6 /* PFN (R/W) */
753#define M_EntryLoPFN (0xffffff << S_EntryLoPFN)
754#define S_EntryLoC 3 /* Coherency attribute (R/W) */
755#define M_EntryLoC (0x7 << S_EntryLoC)
756#define S_EntryLoD 2 /* Dirty (R/W) */
757#define M_EntryLoD (0x1 << S_EntryLoD)
758#define S_EntryLoV 1 /* Valid (R/W) */
759#define M_EntryLoV (0x1 << S_EntryLoV)
760#define S_EntryLoG 0 /* Global (R/W) */
761#define M_EntryLoG (0x1 << S_EntryLoG)
762#define M_EntryLoOddPFN (0x1 << S_EntryLoPFN) /* Odd PFN bit */
763#define S_EntryLo_RS K_PageAlign /* Right-justify PFN */
764#define S_EntryLo_LS S_EntryLoPFN /* Position PFN to appropriate position */
765
766#define M_EntryLo0Fields 0x00000000
767#define M_EntryLoRFields 0xc0000000
768#define M_EntryLo0Fields64 UNS64Const(0x0000000000000000)
769#define M_EntryLoRFields64 UNS64Const(0xffffffffc0000000)
770
771/*
772 * Cache attribute values in the C field of EntryLo and the
773 * K0 field of Config
774 */
775#define K_CacheAttrCWTnWA 0 /* Cacheable, write-thru, no write allocate */
776#define K_CacheAttrCWTWA 1 /* Cacheable, write-thru, write allocate */
777#define K_CacheAttrU 2 /* Uncached */
778#define K_CacheAttrC 3 /* Cacheable */
779#define K_CacheAttrCN 3 /* Cacheable, non-coherent */
780#define K_CacheAttrCCE 4 /* Cacheable, coherent, exclusive */
781#define K_CacheAttrCCS 5 /* Cacheable, coherent, shared */
782#define K_CacheAttrCCU 6 /* Cacheable, coherent, update */
783#define K_CacheAttrUA 7 /* Uncached accelerated */
784
785
786/*
787 ************************************************************************
788 * E N T R Y L O 1 R E G I S T E R ( 3 ) *
789 ************************************************************************
790 *
791 * 6 6 6 6 5 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
792 * 3 2 1 0 9 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
793 * +-+-+-+-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
794 * | Fill (0) //| 0 | PFN | C |D|V|G| EntryLo1
795 * +-+-+-+-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
796 */
797
798#define C0_EntryLo1 $3
799#define R_C0_EntryLo1 3
800#define C0_TLBLO_1 C0_EntryLo1 /* OBSOLETE - DO NOT USE IN NEW CODE */
801
802/*
803 * Field definitions are as given for EntryLo0 above
804 */
805
806
807/*
808 ************************************************************************
809 * C O N T E X T R E G I S T E R ( 4 ) *
810 ************************************************************************
811 *
812 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
813 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
814 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
815 * | // PTEBase | BadVPN<31:13> | 0 | Context
816 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
817 */
818
819#define C0_Context $4
820#define R_C0_Context 4
821#define C0_CTXT C0_Context /* OBSOLETE - DO NOT USE IN NEW CODE */
822
823#define S_ContextPTEBase 23 /* PTE base (R/W) */
824#define M_ContextPTEBase (0x1ff << S_ContextPTEBase)
825#define S_ContextBadVPN 4 /* BadVPN2 (R) */
826#define M_ContextBadVPN (0x7ffff << S_ContextBadVPN)
827#define S_ContextBadVPN_LS 9 /* Position BadVPN to bit 31 */
828#define S_ContextBadVPN_RS 13 /* Right-justify shifted BadVPN field */
829
830#define M_Context0Fields 0x0000000f
831#define M_ContextRFields 0x007ffff0
832#define M_Context0Fields64 UNS64Const(0x000000000000000f)
833#define M_ContextRFields64 UNS64Const(0x00000000007ffff0)
834
835
836/*
837 ************************************************************************
838 * P A G E M A S K R E G I S T E R ( 5 ) *
839 ************************************************************************
840 *
841 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
842 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
843 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
844 * | 0 | Mask | 0 | PageMask
845 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
846 */
847
848#define C0_PageMask $5
849#define R_C0_PageMask 5 /* Mask (R/W) */
850#define C0_PGMASK C0_PageMask /* OBSOLETE - DO NOT USE IN NEW CODE */
851
852#define S_PageMaskMask 13
853#define M_PageMaskMask (0xfff << S_PageMaskMask)
854
855#define M_PageMask0Fields 0xfe001fff
856#define M_PageMaskRFields 0x00000000
857
858/*
859 * Values in the Mask field
860 */
861#define K_PageMask4K 0x000 /* K_PageMasknn values are values for use */
862#define K_PageMask16K 0x003 /* with KReqPageAttributes or KReqPageMask macros */
863#define K_PageMask64K 0x00f
864#define K_PageMask256K 0x03f
865#define K_PageMask1M 0x0ff
866#define K_PageMask4M 0x3ff
867#define K_PageMask16M 0xfff
868
869#define M_PageMask4K (K_PageMask4K << S_PageMaskMask) /* M_PageMasknn values are masks */
870#define M_PageMask16K (K_PageMask16K << S_PageMaskMask) /* in position in the PageMask register */
871#define M_PageMask64K (K_PageMask64K << S_PageMaskMask)
872#define M_PageMask256K (K_PageMask256K << S_PageMaskMask)
873#define M_PageMask1M (K_PageMask1M << S_PageMaskMask)
874#define M_PageMask4M (K_PageMask4M << S_PageMaskMask)
875#define M_PageMask16M (K_PageMask16M << S_PageMaskMask)
876
877
878/*
879 ************************************************************************
880 * W I R E D R E G I S T E R ( 6 ) *
881 ************************************************************************
882 *
883 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
884 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
885 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
886 * | 0 | Index | Wired
887 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
888 */
889
890#define C0_Wired $6
891#define R_C0_Wired 6
892#define C0_TLBWIRED C0_Wired /* OBSOLETE - DO NOT USE IN NEW CODE */
893
894#define S_WiredIndex 0 /* TLB wired boundary (R/W) */
895#define M_WiredIndex (0x3f << S_WiredIndex)
896
897#define M_Wired0Fields 0xffffffc0
898#define M_WiredRFields 0x00000000
899
900
901/*
902 ************************************************************************
903 * B A D V A D D R R E G I S T E R ( 8 ) *
904 ************************************************************************
905 *
906 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
907 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
908 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
909 * | // Bad Virtual Address | BadVAddr
910 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
911 */
912
913#define C0_BadVAddr $8
914#define R_C0_BadVAddr 8
915#define C0_BADVADDR C0_BadVAddr /* OBSOLETE - DO NOT USE IN NEW CODE */
916
917#define M_BadVAddrOddPage K_PageSize /* Even/Odd VA bit for pair of PAs */
918
919#define M_BadVAddr0Fields 0x00000000
920#define M_BadVAddrRFields 0xffffffff
921#define M_BadVAddr0Fields64 UNS64Const(0x0000000000000000)
922#define M_BadVAddrRFields64 UNS64Const(0xffffffffffffffff)
923
924/*
925 ************************************************************************
926 * C O U N T R E G I S T E R ( 9 ) *
927 ************************************************************************
928 *
929 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
930 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
931 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
932 * | Count Value | Count
933 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
934 */
935
936#define C0_Count $9
937#define R_C0_Count 9
938#define C0_COUNT C0_Count /* OBSOLETE - DO NOT USE IN NEW CODE */
939
940#define M_Count0Fields 0x00000000
941#define M_CountRFields 0x00000000
942
943
944/*
945 ************************************************************************
946 * E N T R Y H I R E G I S T E R ( 1 0 ) *
947 ************************************************************************
948 *
949 * 6 6 6 6 5 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
950 * 3 2 1 0 9 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
951 * +-+-+-+-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
952 * | R | Fill // VPN2 | 0 | ASID | EntryHi
953 * +-+-+-+-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
954 */
955
956#define C0_EntryHi $10
957#define R_C0_EntryHi 10
958#define C0_TLBHI C0_EntryHi /* OBSOLETE - DO NOT USE IN NEW CODE */
959
960#define S_EntryHiR64 62 /* Region (R/W) */
961#define M_EntryHiR64 UNS64Const(0xc000000000000000)
962#define S_EntryHiVPN2 13 /* VPN/2 (R/W) */
963#define M_EntryHiVPN2 (0x7ffff << S_EntryHiVPN2)
964#define M_EntryHiVPN264 UNS64Const(0x000000ffffffe000)
965#define S_EntryHiASID 0 /* ASID (R/W) */
966#define M_EntryHiASID (0xff << S_EntryHiASID)
967#define S_EntryHiVPN_Shf S_EntryHiVPN2
968
969#define M_EntryHi0Fields 0x00001f00
970#define M_EntryHiRFields 0x00000000
971#define M_EntryHi0Fields64 UNS64Const(0x0000000000001f00)
972#define M_EntryHiRFields64 UNS64Const(0x3fffff0000000000)
973
974
975/*
976 ************************************************************************
977 * C O M P A R E R E G I S T E R ( 1 1 ) *
978 ************************************************************************
979 *
980 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
981 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
982 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
983 * | Compare Value | Compare
984 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
985 */
986
987#define C0_Compare $11
988#define R_C0_Compare 11
989#define C0_COMPARE C0_Compare /* OBSOLETE - DO NOT USE IN NEW CODE */
990
991#define M_Compare0Fields 0x00000000
992#define M_CompareRFields 0x00000000
993
994
995/*
996 ************************************************************************
997 * S T A T U S R E G I S T E R ( 1 2 ) *
998 ************************************************************************
999 *
1000 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1001 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1002 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1003 * |C|C|C|C|R|F|R|M|P|B|T|S|M| | R |I|I|I|I|I|I|I|I|K|S|U|U|R|E|E|I|
1004 * |U|U|U|U|P|R|E|X|X|E|S|R|M| | s |M|M|M|M|M|M|M|M|X|X|X|M|s|R|X|E| Status
1005 * |3|2|1|0| | | | | |V| | |I| | v |7|6|5|4|3|2|1|0| | | | |v|L|L| |
1006 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1007 */
1008
1009#define C0_Status $12
1010#define R_C0_Status 12
1011#define C0_SR C0_Status /* OBSOLETE - DO NOT USE IN NEW CODE */
1012
1013#define S_StatusCU 28 /* Coprocessor enable (R/W) */
1014#define M_StatusCU (0xf << S_StatusCU)
1015#define S_StatusCU3 31
1016#define M_StatusCU3 (0x1 << S_StatusCU3)
1017#define S_StatusCU2 30
1018#define M_StatusCU2 (0x1 << S_StatusCU2)
1019#define S_StatusCU1 29
1020#define M_StatusCU1 (0x1 << S_StatusCU1)
1021#define S_StatusCU0 28
1022#define M_StatusCU0 (0x1 << S_StatusCU0)
1023#define S_StatusRP 27 /* Enable reduced power mode (R/W) */
1024#define M_StatusRP (0x1 << S_StatusRP)
1025#define S_StatusFR 26 /* Enable 64-bit FPRs (MIPS64 only) (R/W) */
1026#define M_StatusFR (0x1 << S_StatusFR)
1027#define S_StatusRE 25 /* Enable reverse endian (R/W) */
1028#define M_StatusRE (0x1 << S_StatusRE)
1029#define S_StatusMX 24 /* Enable access to MDMX resources (MIPS64 only) (R/W) */
1030#define M_StatusMX (0x1 << S_StatusMX)
1031#define S_StatusPX 23 /* Enable access to 64-bit instructions/data (MIPS64 only) (R/W) */
1032#define M_StatusPX (0x1 << S_StatusPX)
1033#define S_StatusBEV 22 /* Enable Boot Exception Vectors (R/W) */
1034#define M_StatusBEV (0x1 << S_StatusBEV)
1035#define S_StatusTS 21 /* Denote TLB shutdown (R/W) */
1036#define M_StatusTS (0x1 << S_StatusTS)
1037#define S_StatusSR 20 /* Denote soft reset (R/W) */
1038#define M_StatusSR (0x1 << S_StatusSR)
1039#define S_StatusNMI 19
1040#define M_StatusNMI (0x1 << S_StatusNMI) /* Denote NMI (R/W) */
1041#define S_StatusIM 8 /* Interrupt mask (R/W) */
1042#define M_StatusIM (0xff << S_StatusIM)
1043#define S_StatusIM7 15
1044#define M_StatusIM7 (0x1 << S_StatusIM7)
1045#define S_StatusIM6 14
1046#define M_StatusIM6 (0x1 << S_StatusIM6)
1047#define S_StatusIM5 13
1048#define M_StatusIM5 (0x1 << S_StatusIM5)
1049#define S_StatusIM4 12
1050#define M_StatusIM4 (0x1 << S_StatusIM4)
1051#define S_StatusIM3 11
1052#define M_StatusIM3 (0x1 << S_StatusIM3)
1053#define S_StatusIM2 10
1054#define M_StatusIM2 (0x1 << S_StatusIM2)
1055#define S_StatusIM1 9
1056#define M_StatusIM1 (0x1 << S_StatusIM1)
1057#define S_StatusIM0 8
1058#define M_StatusIM0 (0x1 << S_StatusIM0)
1059#define S_StatusKX 7 /* Enable access to extended kernel addresses (MIPS64 only) (R/W) */
1060#define M_StatusKX (0x1 << S_StatusKX)
1061#define S_StatusSX 6 /* Enable access to extended supervisor addresses (MIPS64 only) (R/W) */
1062#define M_StatusSX (0x1 << S_StatusSX)
1063#define S_StatusUX 5 /* Enable access to extended user addresses (MIPS64 only) (R/W) */
1064#define M_StatusUX (0x1 << S_StatusUX)
1065#define S_StatusKSU 3 /* Two-bit current mode (R/W) */
1066#define M_StatusKSU (0x3 << S_StatusKSU)
1067#define S_StatusUM 4 /* User mode if supervisor mode not implemented (R/W) */
1068#define M_StatusUM (0x1 << S_StatusUM)
1069#define S_StatusSM 3 /* Supervisor mode (R/W) */
1070#define M_StatusSM (0x1 << S_StatusSM)
1071#define S_StatusERL 2 /* Denotes error level (R/W) */
1072#define M_StatusERL (0x1 << S_StatusERL)
1073#define S_StatusEXL 1 /* Denotes exception level (R/W) */
1074#define M_StatusEXL (0x1 << S_StatusEXL)
1075#define S_StatusIE 0 /* Enables interrupts (R/W) */
1076#define M_StatusIE (0x1 << S_StatusIE)
1077
1078#define M_Status0Fields 0x00040000
1079#define M_StatusRFields 0x058000e0 /* FR, MX, PX, KX, SX, UX unused in MIPS32 */
1080#define M_Status0Fields64 0x00040000
1081#define M_StatusRFields64 0x00000000
1082
1083/*
1084 * Values in the KSU field
1085 */
1086#define K_StatusKSU_U 2 /* User mode in KSU field */
1087#define K_StatusKSU_S 1 /* Supervisor mode in KSU field */
1088#define K_StatusKSU_K 0 /* Kernel mode in KSU field */
1089
1090#define C0_INTCTL $12,1
1091/*
1092 ************************************************************************
1093 * C A U S E R E G I S T E R ( 1 3 ) *
1094 ************************************************************************
1095 *
1096 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1097 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1098 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1099 * |B| | C | |I|W| |I|I|I|I|I|I|I|I| | | R |
1100 * |D| | E | Rsvd |V|P| Rsvd |P|P|P|P|P|P|P|P| | ExcCode | s | Cause
1101 * | | | | | | | |7|6|5|4|3|2|1|0| | | v |
1102 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1103 */
1104
1105#define C0_Cause $13
1106#define R_C0_Cause 13
1107#define C0_CAUSE C0_Cause /* OBSOLETE - DO NOT USE IN NEW CODE */
1108
1109#define S_CauseBD 31
1110#define M_CauseBD (0x1 << S_CauseBD)
1111#define S_CauseCE 28
1112#define M_CauseCE (0x3<< S_CauseCE)
1113#define S_CauseIV 23
1114#define M_CauseIV (0x1 << S_CauseIV)
1115#define S_CauseWP 22
1116#define M_CauseWP (0x1 << S_CauseWP)
1117#define S_CauseIP 8
1118#define M_CauseIP (0xff << S_CauseIP)
1119#define S_CauseIPEXT 10
1120#define M_CauseIPEXT (0x3f << S_CauseIPEXT)
1121#define S_CauseIP7 15
1122#define M_CauseIP7 (0x1 << S_CauseIP7)
1123#define S_CauseIP6 14
1124#define M_CauseIP6 (0x1 << S_CauseIP6)
1125#define S_CauseIP5 13
1126#define M_CauseIP5 (0x1 << S_CauseIP5)
1127#define S_CauseIP4 12
1128#define M_CauseIP4 (0x1 << S_CauseIP4)
1129#define S_CauseIP3 11
1130#define M_CauseIP3 (0x1 << S_CauseIP3)
1131#define S_CauseIP2 10
1132#define M_CauseIP2 (0x1 << S_CauseIP2)
1133#define S_CauseIP1 9
1134#define M_CauseIP1 (0x1 << S_CauseIP1)
1135#define S_CauseIP0 8
1136#define M_CauseIP0 (0x1 << S_CauseIP0)
1137#define S_CauseExcCode 2
1138#define M_CauseExcCode (0x1f << S_CauseExcCode)
1139
1140#define M_Cause0Fields 0x4f3f0083
1141#define M_CauseRFields 0xb000fc7c
1142
1143/*
1144 * Values in the CE field
1145 */
1146#define K_CauseCE0 0 /* Coprocessor 0 in the CE field */
1147#define K_CauseCE1 1 /* Coprocessor 1 in the CE field */
1148#define K_CauseCE2 2 /* Coprocessor 2 in the CE field */
1149#define K_CauseCE3 3 /* Coprocessor 3 in the CE field */
1150
1151/*
1152 * Values in the ExcCode field
1153 */
1154#define EX_INT 0 /* Interrupt */
1155#define EXC_INT (EX_INT << S_CauseExcCode)
1156#define EX_MOD 1 /* TLB modified */
1157#define EXC_MOD (EX_MOD << S_CauseExcCode)
1158#define EX_TLBL 2 /* TLB exception (load or ifetch) */
1159#define EXC_TLBL (EX_TLBL << S_CauseExcCode)
1160#define EX_TLBS 3 /* TLB exception (store) */
1161#define EXC_TLBS (EX_TLBS << S_CauseExcCode)
1162#define EX_ADEL 4 /* Address error (load or ifetch) */
1163#define EXC_ADEL (EX_ADEL << S_CauseExcCode)
1164#define EX_ADES 5 /* Address error (store) */
1165#define EXC_ADES (EX_ADES << S_CauseExcCode)
1166#define EX_IBE 6 /* Instruction Bus Error */
1167#define EXC_IBE (EX_IBE << S_CauseExcCode)
1168#define EX_DBE 7 /* Data Bus Error */
1169#define EXC_DBE (EX_DBE << S_CauseExcCode)
1170#define EX_SYS 8 /* Syscall */
1171#define EXC_SYS (EX_SYS << S_CauseExcCode)
1172#define EX_SYSCALL EX_SYS
1173#define EXC_SYSCALL EXC_SYS
1174#define EX_BP 9 /* Breakpoint */
1175#define EXC_BP (EX_BP << S_CauseExcCode)
1176#define EX_BREAK EX_BP
1177#define EXC_BREAK EXC_BP
1178#define EX_RI 10 /* Reserved instruction */
1179#define EXC_RI (EX_RI << S_CauseExcCode)
1180#define EX_CPU 11 /* CoProcessor Unusable */
1181#define EXC_CPU (EX_CPU << S_CauseExcCode)
1182#define EX_OV 12 /* OVerflow */
1183#define EXC_OV (EX_OV << S_CauseExcCode)
1184#define EX_TR 13 /* Trap instruction */
1185#define EXC_TR (EX_TR << S_CauseExcCode)
1186#define EX_TRAP EX_TR
1187#define EXC_TRAP EXC_TR
1188#define EX_FPE 15 /* floating point exception */
1189#define EXC_FPE (EX_FPE << S_CauseExcCode)
1190#define EX_C2E 18 /* COP2 exception */
1191#define EXC_C2E (EX_C2E << S_CauseExcCode)
1192#define EX_MDMX 22 /* MDMX exception */
1193#define EXC_MDMX (EX_MDMX << S_CauseExcCode)
1194#define EX_WATCH 23 /* Watch exception */
1195#define EXC_WATCH (EX_WATCH << S_CauseExcCode)
1196#define EX_MCHECK 24 /* Machine check exception */
1197#define EXC_MCHECK (EX_MCHECK << S_CauseExcCode)
1198#define EX_CacheErr 30 /* Cache error caused re-entry to Debug Mode */
1199#define EXC_CacheErr (EX_CacheErr << S_CauseExcCode)
1200
1201
1202/*
1203 ************************************************************************
1204 * E P C R E G I S T E R ( 1 4 ) *
1205 ************************************************************************
1206 *
1207 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1208 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1209 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1210 * | // Exception PC | EPC
1211 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1212 */
1213
1214#define C0_EPC $14
1215#define R_C0_EPC 14
1216
1217#define M_EPC0Fields 0x00000000
1218#define M_EPCRFields 0x00000000
1219#define M_EPC0Fields64 UNS64Const(0x0000000000000000)
1220#define M_EPCRFields64 UNS64Const(0x0000000000000000)
1221
1222/*
1223 ************************************************************************
1224 * P R I D R E G I S T E R ( 1 5 ) *
1225 ************************************************************************
1226 *
1227 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1228 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1229 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1230 * | Company Opts | Company ID | Procesor ID | Revision | PRId
1231 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1232 */
1233
1234#define C0_PRId $15
1235#define R_C0_PRId 15
1236#define C0_PRID C0_PRID /* OBSOLETE - DO NOT USE IN NEW CODE */
1237
1238#define S_PRIdCoOpt 24 /* Company options (R) */
1239#define M_PRIdCoOpt (0xff << S_PRIdCoOpt)
1240#define S_PRIdCoID 16 /* Company ID (R) */
1241#define M_PRIdCoID (0xff << S_PRIdCoID)
1242#define S_PRIdImp 8 /* Implementation ID (R) */
1243#define M_PRIdImp (0xff << S_PRIdImp)
1244#define S_PRIdRev 0 /* Revision (R) */
1245#define M_PRIdRev (0xff << S_PRIdRev)
1246
1247#define M_PRId0Fields 0x00000000
1248#define M_PRIdRFields 0xffffffff
1249/*
1250 * Values in the Company ID field
1251 */
1252#define K_PRIdCoID_MIPS 1
1253#define K_PRIdCoID_Broadcom 2
1254#define K_PRIdCoID_Alchemy 3
1255#define K_PRIdCoID_SiByte 4
1256#define K_PRIdCoID_SandCraft 5
1257#define K_PRIdCoID_Philips 6
1258#define K_PRIdCoID_NextAvailable 7 /* Next available encoding */
1259
1260
1261/*
1262 * Values in the implementation number field
1263 */
1264#define K_PRIdImp_Jade 0x80
1265#define K_PRIdImp_Opal 0x81
1266#define K_PRIdImp_Ruby 0x82
1267#define K_PRIdImp_JadeLite 0x83
1268#define K_PRIdImp_4KEc 0x84 /* Emerald with TLB MMU */
1269#define K_PRIdImp_4KEmp 0x85 /* Emerald with FM MMU */
1270#define K_PRIdImp_4KSc 0x86 /* Coral */
1271
1272#define K_PRIdImp_R3000 0x01
1273#define K_PRIdImp_R4000 0x04
1274#define K_PRIdImp_R10000 0x09
1275#define K_PRIdImp_R4300 0x0b
1276#define K_PRIdImp_R5000 0x23
1277#define K_PRIdImp_R5200 0x28
1278#define K_PRIdImp_R5400 0x54
1279
1280#define C0_EBase $15,1
1281#define C0_EBASE C0_EBase
1282/*
1283 ************************************************************************
1284 * C O N F I G R E G I S T E R ( 1 6 ) *
1285 ************************************************************************
1286 *
1287 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1288 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1289 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1290 * |M| |B| A | A | | K | Config
1291 * | | Reserved for Implementations|E| T | R | Reserved | 0 |
1292 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1293 */
1294
1295#define C0_Config $16
1296#define R_C0_Config 16
1297#define C0_CONFIG C0_Config /* OBSOLETE - DO NOT USE IN NEW CODE */
1298
1299#define S_ConfigMore 31 /* Additional config registers present (R) */
1300#define M_ConfigMore (0x1 << S_ConfigMore)
1301#define S_ConfigImpl 16 /* Implementation-specific fields */
1302#define M_ConfigImpl (0x7fff << S_ConfigImpl)
1303#define S_ConfigBE 15 /* Denotes big-endian operation (R) */
1304#define M_ConfigBE (0x1 << S_ConfigBE)
1305#define S_ConfigAT 13 /* Architecture type (R) */
1306#define M_ConfigAT (0x3 << S_ConfigAT)
1307#define S_ConfigAR 10 /* Architecture revision (R) */
1308#define M_ConfigAR (0x7 << S_ConfigAR)
1309#define S_ConfigMT 7 /* MMU Type (R) */
1310#define M_ConfigMT (0x7 << S_ConfigMT)
1311#define S_ConfigK0 0 /* Kseg0 coherency algorithm (R/W) */
1312#define M_ConfigK0 (0x7 << S_ConfigK0)
1313
1314/*
1315 * The following definitions are technically part of the "reserved for
1316 * implementations" field, but are the semi-standard definition used in
1317 * fixed-mapping MMUs to control the cacheability of kuseg and kseg2/3
1318 * references. For that reason, they are included here, but may be
1319 * overridden by true implementation-specific definitions
1320 */
1321#define S_ConfigK23 28 /* Kseg2/3 coherency algorithm (FM MMU only) (R/W) */
1322#define M_ConfigK23 (0x7 << S_ConfigK23)
1323#define S_ConfigKU 25 /* Kuseg coherency algorithm (FM MMU only) (R/W) */
1324#define M_ConfigKU (0x7 << S_ConfigKU)
1325
1326#define M_Config0Fields 0x00000078
1327#define M_ConfigRFields 0x8000ff80
1328
1329/*
1330 * Values in the AT field
1331 */
1332#define K_ConfigAT_MIPS32 0 /* MIPS32 */
1333#define K_ConfigAT_MIPS64S 1 /* MIPS64 with 32-bit addresses */
1334#define K_ConfigAT_MIPS64 2 /* MIPS64 with 32/64-bit addresses */
1335
1336/*
1337 * Values in the MT field
1338 */
1339#define K_ConfigMT_NoMMU 0 /* No MMU */
1340#define K_ConfigMT_TLBMMU 1 /* Standard TLB MMU */
1341#define K_ConfigMT_BATMMU 2 /* Standard BAT MMU */
1342#define K_ConfigMT_FMMMU 3 /* Standard Fixed Mapping MMU */
1343
1344
1345/*
1346 ************************************************************************
1347 * C O N F I G 1 R E G I S T E R ( 1 6, SELECT 1 ) *
1348 ************************************************************************
1349 *
1350 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1351 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1352 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1353 * |M| MMU Size | IS | IL | IA | DS | DL | DA |C|M|P|W|C|E|F| Config1
1354 * | | | | | | | | |2|D|C|R|A|P|P|
1355 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1356 */
1357
1358#define C0_Config1 $16,1
1359#define R_C0_Config1 16
1360
1361#define S_Config1More 31 /* Additional Config registers present (R) */
1362#define M_Config1More (0x1 << S_Config1More)
1363#define S_Config1MMUSize 25 /* Number of MMU entries - 1 (R) */
1364#define M_Config1MMUSize (0x3f << S_Config1MMUSize)
1365#define S_Config1IS 22 /* Icache sets per way (R) */
1366#define M_Config1IS (0x7 << S_Config1IS)
1367#define S_Config1IL 19 /* Icache line size (R) */
1368#define M_Config1IL (0x7 << S_Config1IL)
1369#define S_Config1IA 16 /* Icache associativity - 1 (R) */
1370#define M_Config1IA (0x7 << S_Config1IA)
1371#define S_Config1DS 13 /* Dcache sets per way (R) */
1372#define M_Config1DS (0x7 << S_Config1DS)
1373#define S_Config1DL 10 /* Dcache line size (R) */
1374#define M_Config1DL (0x7 << S_Config1DL)
1375#define S_Config1DA 7 /* Dcache associativity (R) */
1376#define M_Config1DA (0x7 << S_Config1DA)
1377#define S_Config1C2 6 /* Coprocessor 2 present (R) */
1378#define M_Config1C2 (0x1 << S_Config1C2)
1379#define S_Config1MD 5 /* Denotes MDMX present (R) */
1380#define M_Config1MD (0x1 << S_Config1MD)
1381#define S_Config1PC 4 /* Denotes performance counters present (R) */
1382#define M_Config1PC (0x1 << S_Config1PC)
1383#define S_Config1WR 3 /* Denotes watch registers present (R) */
1384#define M_Config1WR (0x1 << S_Config1WR)
1385#define S_Config1CA 2 /* Denotes MIPS-16 present (R) */
1386#define M_Config1CA (0x1 << S_Config1CA)
1387#define S_Config1EP 1 /* Denotes EJTAG present (R) */
1388#define M_Config1EP (0x1 << S_Config1EP)
1389#define S_Config1FP 0 /* Denotes floating point present (R) */
1390#define M_Config1FP (0x1 << S_Config1FP)
1391
1392#define M_Config10Fields 0x00000060
1393#define M_Config1RFields 0x7fffff9f
1394
1395/*
1396 * The following macro generates a table that is indexed
1397 * by the Icache or Dcache sets field in Config1 and
1398 * contains the decoded value of sets per way
1399 */
1400#define Config1CacheSets() \
1401 HALF(64); \
1402 HALF(128); \
1403 HALF(256); \
1404 HALF(512); \
1405 HALF(1024); \
1406 HALF(2048); \
1407 HALF(4096); \
1408 HALF(8192);
1409
1410/*
1411 * The following macro generates a table that is indexed
1412 * by the Icache or Dcache line size field in Config1 and
1413 * contains the decoded value of the cache line size, in bytes
1414 */
1415#define Config1CacheLineSize() \
1416 HALF(0); \
1417 HALF(4); \
1418 HALF(8); \
1419 HALF(16); \
1420 HALF(32); \
1421 HALF(64); \
1422 HALF(128); \
1423 HALF(256);
1424
1425
1426/*
1427 ************************************************************************
1428 * C O N F I G 2 R E G I S T E R ( 1 6, SELECT 2 ) *
1429 ************************************************************************
1430 *
1431 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1432 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1433 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1434 * |M| | | | | | | | | | | | |S|T| Config1
1435 * | | | | | | | | | | | | | |M|L|
1436 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1437 */
1438
1439#define C0_Config2 $16,2
1440#define R_C0_Config2 16
1441
1442#define S_Config2More 31 /* Additional Config registers present (R) */
1443#define M_Config2More (0x1 << S_Config2More)
1444#define S_Config2SM 1 /* Denotes SmartMIPS ASE present (R) */
1445#define M_Config2SM (0x1 << S_Config2SM)
1446#define S_Config2TL 0 /* Denotes Tracing Logic present (R) */
1447#define M_Config2TL (0x1 << S_Config2TL)
1448
1449#define M_Config20Fields 0xfffffffc
1450#define M_Config2RFields 0x00000003
1451
1452/*
1453 ************************************************************************
1454 * L L A D D R R E G I S T E R ( 1 7 ) *
1455 ************************************************************************
1456 *
1457 * 6 6 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1458 * 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1459 * +-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1460 * | // LL Physical Address | LLAddr
1461 * +-+-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1462 */
1463
1464#define C0_LLAddr $17
1465#define R_C0_LLAddr 17
1466#define C0_LLADDR C0_LLAddr /* OBSOLETE - DO NOT USE IN NEW CODE */
1467
1468#define M_LLAddr0Fields 0x00000000
1469#define M_LLAddrRFields 0x00000000
1470#define M_LLAddr0Fields64 UNS64Const(0x0000000000000000)
1471#define M_LLAddrRFields64 UNS64Const(0x0000000000000000)
1472
1473
1474/*
1475 ************************************************************************
1476 * W A T C H L O R E G I S T E R ( 1 8 ) *
1477 ************************************************************************
1478 *
1479 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1480 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1481 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1482 * | // Watch Virtual Address |I|R|W| WatchLo
1483 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1484 */
1485
1486#define C0_WatchLo $18
1487#define R_C0_WatchLo 18
1488#define C0_WATCHLO C0_WatchLo /* OBSOLETE - DO NOT USE IN NEW CODE */
1489
1490#define S_WatchLoVAddr 3 /* Watch virtual address (R/W) */
1491#define M_WatchLoVAddr (0x1fffffff << S_WatchLoVAddr)
1492#define S_WatchLoI 2 /* Enable Istream watch (R/W) */
1493#define M_WatchLoI (0x1 << S_WatchLoI)
1494#define S_WatchLoR 1 /* Enable data read watch (R/W) */
1495#define M_WatchLoR (0x1 << S_WatchLoR)
1496#define S_WatchLoW 0 /* Enable data write watch (R/W) */
1497#define M_WatchLoW (0x1 << S_WatchLoW)
1498
1499#define M_WatchLo0Fields 0x00000000
1500#define M_WatchLoRFields 0x00000000
1501#define M_WatchLo0Fields64 UNS64Const(0x0000000000000000)
1502#define M_WatchLoRFields64 UNS64Const(0x0000000000000000)
1503
1504#define M_WatchLoEnables (M_WatchLoI | M_WatchLoR | M_WatchLoW)
1505
1506
1507/*
1508 ************************************************************************
1509 * W A T C H H I R E G I S T E R ( 1 9 ) *
1510 ************************************************************************
1511 *
1512 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1513 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1514 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1515 * |M|G| Rsvd | ASID | Rsvd | Mask | 0 | WatchHi
1516 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1517 */
1518
1519#define C0_WatchHi $19
1520#define R_C0_WatchHi 19
1521#define C0_WATCHHI C0_WatchHi /* OBSOLETE - DO NOT USE IN NEW CODE */
1522
1523#define S_WatchHiM 31 /* Denotes additional Watch registers present (R) */
1524#define M_WatchHiM (0x1 << S_WatchHiM)
1525#define S_WatchHiG 30 /* Enable ASID-independent Watch match (R/W) */
1526#define M_WatchHiG (0x1 << S_WatchHiG)
1527#define S_WatchHiASID 16 /* ASID value to match (R/W) */
1528#define M_WatchHiASID (0xff << S_WatchHiASID)
1529#define S_WatchHiMask 3 /* Address inhibit mask (R/W) */
1530#define M_WatchHiMask (0x1ff << S_WatchHiMask)
1531
1532#define M_WatchHi0Fields 0x3f00f007
1533#define M_WatchHiRFields 0x80000000
1534
1535
1536/*
1537 ************************************************************************
1538 * X C O N T E X T R E G I S T E R ( 2 0 ) *
1539 ************************************************************************
1540 *
1541 * 6 // 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1542 * 3 // 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1543 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1544 * | // PTEBase | R | BadVPN2<39:13> | 0 | XContext
1545 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1546 */
1547
1548#define C0_XContext $20
1549#define R_C0_XContext 20
1550#define C0_EXTCTXT C0_XContext /* OBSOLETE - DO NOT USE IN NEW CODE */
1551
1552#define S_XContextBadVPN2 4 /* BadVPN2 (R) */
1553#define S_XContextBadVPN S_XContextBadVPN2
1554
1555#define M_XContext0Fields 0x0000000f
1556
1557
1558/*
1559 ************************************************************************
1560 * D E B U G R E G I S T E R ( 2 3 ) *
1561 ************************************************************************
1562 *
1563 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1564 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1565 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1566 * |D|D|N|L|D|H|C|I|M|C|D|I|D|D| | |N|S| |D|D|D|D|D|D|
1567 * |B|M|o|S|o|a|o|B|C|a|B|E|D|D|EJTAG|DExcCode |o|S| |I|I|D|D|B|S|
1568 * |D| |D|N|z|l|u|u|h|c|u|X|B|B| ver | |S|t| |N|B|B|B|p|S|
1569 * | | |C|M|e|t|n|s|e|h|s|I|S|L| | |S| | 0 |T| |S|L| | | Debug
1570 * | | |R| | | |t|E|c|e|E| |I|I| | |t| | | | | | | | |
1571 * | | | | | | |D|P|k|E|P| |m|m| | | | | | | | | | | |
1572 * | | | | | | |M| |P|P| | |p|p| | | | | | | | | | | |
1573 * | | | | | | | | | | | | |r|r| | | | | | | | | | | |
1574 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1575 */
1576
1577#define C0_Debug $23 /* EJTAG */
1578#define R_C0_Debug 23
1579
1580#define S_DebugDBD 31 /* Debug branch delay (R) */
1581#define M_DebugDBD (0x1 << S_DebugDBD)
1582#define S_DebugDM 30 /* Debug mode (R) */
1583#define M_DebugDM (0x1 << S_DebugDM)
1584#define S_DebugNoDCR 29 /* No debug control register present (R) */
1585#define M_DebugNoDCR (0x1 << S_DebugNoDCR)
1586#define S_DebugLSNM 28 /* Load/Store Normal Memory (R/W) */
1587#define M_DebugLSNM (0x1 << S_DebugLSNM)
1588#define S_DebugDoze 27 /* Doze (R) */
1589#define M_DebugDoze (0x1 << S_DebugDoze)
1590#define S_DebugHalt 26 /* Halt (R) */
1591#define M_DebugHalt (0x1 << S_DebugHalt)
1592#define S_DebugCountDM 25 /* Count register behavior in debug mode (R/W) */
1593#define M_DebugCountDM (0x1 << S_DebugCountDM)
1594#define S_DebugIBusEP 24 /* Imprecise Instn Bus Error Pending (R/W) */
1595#define M_DebugIBusEP (0x1 << S_DebugIBusEP)
1596#define S_DebugMCheckP 23 /* Imprecise Machine Check Pending (R/W) */
1597#define M_DebugMCheckP (0x1 << S_DebugMCheckP)
1598#define S_DebugCacheEP 22 /* Imprecise Cache Error Pending (R/W) */
1599#define M_DebugCacheEP (0x1 << S_DebugCacheEP)
1600#define S_DebugDBusEP 21 /* Imprecise Data Bus Error Pending (R/W) */
1601#define M_DebugDBusEP (0x1 << S_DebugDBusEP)
1602#define S_DebugIEXI 20 /* Imprecise Exception Inhibit (R/W) */
1603#define M_DebugIEXI (0x1 << S_DebugIEXI)
1604#define S_DebugDDBSImpr 19 /* Debug data break store imprecise (R) */
1605#define M_DebugDDBSImpr (0x1 << S_DebugDDBSImpr)
1606#define S_DebugDDBLImpr 18 /* Debug data break load imprecise (R) */
1607#define M_DebugDDBLImpr (0x1 << S_DebugDDBLImpr)
1608#define S_DebugEJTAGver 15 /* EJTAG version number (R) */
1609#define M_DebugEJTAGver (0x7 << S_DebugEJTAGver)
1610#define S_DebugDExcCode 10 /* Debug exception code (R) */
1611#define M_DebugDExcCode (0x1f << S_DebugDExcCode)
1612#define S_DebugNoSSt 9 /* No single step implemented (R) */
1613#define M_DebugNoSSt (0x1 << S_DebugNoSSt)
1614#define S_DebugSSt 8 /* Single step enable (R/W) */
1615#define M_DebugSSt (0x1 << S_DebugSSt)
1616#define S_DebugDINT 5 /* Debug interrupt (R) */
1617#define M_DebugDINT (0x1 << S_DebugDINT)
1618#define S_DebugDIB 4 /* Debug instruction break (R) */
1619#define M_DebugDIB (0x1 << S_DebugDIB)
1620#define S_DebugDDBS 3 /* Debug data break store (R) */
1621#define M_DebugDDBS (0x1 << S_DebugDDBS)
1622#define S_DebugDDBL 2 /* Debug data break load (R) */
1623#define M_DebugDDBL (0x1 << S_DebugDDBL)
1624#define S_DebugDBp 1 /* Debug breakpoint (R) */
1625#define M_DebugDBp (0x1 << S_DebugDBp)
1626#define S_DebugDSS 0 /* Debug single step (R) */
1627#define M_DebugDSS (0x1 << S_DebugDSS)
1628
1629#define M_Debug0Fields 0x01f000c0
1630#define M_DebugRFields 0xec0ffe3f
1631
1632
1633/*
1634 ************************************************************************
1635 * D E P C R E G I S T E R ( 2 4 ) *
1636 ************************************************************************
1637 *
1638 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1639 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1640 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1641 * | // EJTAG Debug Exception PC | DEPC
1642 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1643 */
1644
1645
1646#define C0_DEPC $24
1647#define R_C0_DEPC 24
1648
1649#define M_DEEPC0Fields 0x00000000
1650#define M_DEEPCRFields 0x00000000
1651#define M_DEEPC0Fields64 UNS64Const(0x0000000000000000)
1652#define M_DEEPCRFields64 UNS64Const(0x0000000000000000)
1653
1654
1655/*
1656 ************************************************************************
1657 * P E R F C N T R E G I S T E R ( 2 5 ) *
1658 ************************************************************************
1659 *
1660 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1661 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1662 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1663 * | | | |I| | | |E|
1664 * |M| 0 | Event |E|U|S|K|X| PerfCnt
1665 * | | | | | | | |L|
1666 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1667 *
1668 *
1669 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1670 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1671 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1672 * | Event Count | PerfCnt
1673 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1674 */
1675
1676#define C0_PerfCnt $25
1677#define R_C0_PerfCnt 25
1678#define C0_PRFCNT0 C0_PerfCnt /* OBSOLETE - DO NOT USE IN NEW CODE */
1679#define C0_PRFCNT1 C0_PerfCnt /* OBSOLETE - DO NOT USE IN NEW CODE */
1680
1681#define S_PerfCntM 31 /* More performance counters exist (R) */
1682#define M_PerfCntM (1 << S_PerfCntM)
1683#define S_PerfCntEvent 5 /* Enabled event (R/W) */
1684#define M_PerfCntEvent (0x3f << S_PerfCntEvent)
1685#define S_PerfCntIE 4 /* Interrupt Enable (R/W) */
1686#define M_PerfCntIE (1 << S_PerfCntIE)
1687#define S_PerfCntU 3 /* Enable counting in User Mode (R/W) */
1688#define M_PerfCntU (1 << S_PerfCntU)
1689#define S_PerfCntS 2 /* Enable counting in Supervisor Mode (R/W) */
1690#define M_PerfCntS (1 << S_PerfCntS)
1691#define S_PerfCntK 1 /* Enable counting in Kernel Mode (R/W) */
1692#define M_PerfCntK (1 << S_PerfCntK)
1693#define S_PerfCntEXL 0 /* Enable counting while EXL==1 (R/W) */
1694#define M_PerfCntEXL (1 << S_PerfCntEXL)
1695
1696#define M_PerfCnt0Fields 0x7ffff800
1697#define M_PerfCntRFields 0x80000000
1698
1699
1700/*
1701 ************************************************************************
1702 * E R R C T L R E G I S T E R ( 2 6 ) *
1703 ************************************************************************
1704 *
1705 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1706 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1707 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1708 * | Error Control | ErrCtl
1709 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1710 */
1711
1712#define C0_ErrCtl $26
1713#define R_C0_ErrCtl 26
1714#define C0_ECC $26 /* OBSOLETE - DO NOT USE IN NEW CODE */
1715#define R_C0_ECC 26 /* OBSOLETE - DO NOT USE IN NEW CODE */
1716
1717#define M_ErrCtl0Fields 0x00000000
1718#define M_ErrCtlRFields 0x00000000
1719
1720
1721/*
1722 ************************************************************************
1723 * C A C H E E R R R E G I S T E R ( 2 7 ) * CacheErr
1724 ************************************************************************
1725 *
1726 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1727 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1728 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1729 * | Cache Error Control | CacheErr
1730 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1731 */
1732
1733#define C0_CacheErr $27
1734#define R_C0_CacheErr 27
1735#define C0_CACHE_ERR C0_CacheErr /* OBSOLETE - DO NOT USE IN NEW CODE */
1736
1737#define M_CacheErr0Fields 0x00000000
1738#define M_CachErrRFields 0x00000000
1739
1740
1741/*
1742 ************************************************************************
1743 * T A G L O R E G I S T E R ( 2 8 ) * TagLo
1744 ************************************************************************
1745 *
1746 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1747 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1748 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1749 * | TagLo | TagLo
1750 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1751 */
1752
1753#define C0_TagLo $28
1754#define R_C0_TagLo 28
1755#define C0_TAGLO C0_TagLo /* OBSOLETE - DO NOT USE IN NEW CODE */
1756
1757/*
1758 * Some implementations use separate TagLo registers for the
1759 * instruction and data caches. In those cases, the following
1760 * definitions can be used in relevant code
1761 */
1762
1763#define C0_ITagLo $28,0
1764#define C0_DTagLo $28,2
1765
1766#define M_TagLo0Fields 0x00000000
1767#define M_TagLoRFields 0x00000000
1768
1769
1770/*
1771 ************************************************************************
1772 * D A T A L O R E G I S T E R ( 2 8, SELECT 1 ) * DataLo
1773 ************************************************************************
1774 *
1775 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1776 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1777 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1778 * | DataLo | DataLo
1779 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1780 */
1781
1782#define C0_DataLo $28,1
1783#define R_C0_DataLo 28
1784
1785/*
1786 * Some implementations use separate DataLo registers for the
1787 * instruction and data caches. In those cases, the following
1788 * definitions can be used in relevant code
1789 */
1790
1791#define C0_IDataLo $28,1
1792#define C0_DDataLo $28,3
1793
1794#define M_DataLo0Fields 0x00000000
1795#define M_DataLoRFields 0xffffffff
1796
1797
1798/*
1799 ************************************************************************
1800 * T A G H I R E G I S T E R ( 2 9 ) * TagHi
1801 ************************************************************************
1802 *
1803 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1804 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1805 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1806 * | TagHi | TagHi
1807 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1808 */
1809
1810#define C0_TagHi $29
1811#define R_C0_TagHi 29
1812#define C0_TAGHI C0_TagHi /* OBSOLETE - DO NOT USE IN NEW CODE */
1813
1814/*
1815 * Some implementations use separate TagHi registers for the
1816 * instruction and data caches. In those cases, the following
1817 * definitions can be used in relevant code
1818 */
1819
1820#define C0_ITagHi $29,0
1821#define C0_DTagHi $29,2
1822
1823#define M_TagHi0Fields 0x00000000
1824#define M_TagHiRFields 0x00000000
1825
1826
1827/*
1828 ************************************************************************
1829 * D A T A H I R E G I S T E R ( 2 9, SELECT 1 ) * DataHi
1830 ************************************************************************
1831 *
1832 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1833 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1834 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1835 * | DataHi | DataHi
1836 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1837 */
1838
1839#define C0_DataHi $29,1
1840#define R_C0_DataHi 29
1841
1842/*
1843 * Some implementations use separate DataHi registers for the
1844 * instruction and data caches. In those cases, the following
1845 * definitions can be used in relevant code
1846 */
1847
1848#define C0_IDataHi $29,1
1849#define C0_DDataHi $29,3
1850
1851#define M_DataHi0Fields 0x00000000
1852#define M_DataHiRFields 0xffffffff
1853
1854
1855/*
1856 ************************************************************************
1857 * E R R O R E P C R E G I S T E R ( 3 0 ) *
1858 ************************************************************************
1859 *
1860 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1861 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1862 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1863 * | // Error PC | ErrorEPC
1864 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1865 */
1866
1867#define C0_ErrorEPC $30
1868#define R_C0_ErrorEPC 30
1869#define C0_ERROR_EPC C0_ErrorEPC /* OBSOLETE - DO NOT USE IN NEW CODE */
1870
1871#define M_ErrorEPC0Fields 0x00000000
1872#define M_ErrorEPCRFields 0x00000000
1873#define M_ErrorEPC0Fields64 UNS64Const(0x0000000000000000)
1874#define M_ErrorEPCRFields64 UNS64Const(0x0000000000000000)
1875
1876
1877/*
1878 ************************************************************************
1879 * D E S A V E R E G I S T E R ( 3 1 ) *
1880 ************************************************************************
1881 *
1882 * 6 // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1883 * 3 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1884 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1885 * | // EJTAG Register Save Value | DESAVE
1886 * +-+//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1887 */
1888
1889#define C0_DESAVE $31
1890#define R_C0_DESAVE 31
1891
1892#define M_DESAVE0Fields 0x00000000
1893#define M_DESAVERFields 0x00000000
1894#define M_DESAVE0Fields64 UNS64Const(0x0000000000000000)
1895#define M_DESAVERFields64 UNS64Const(0x0000000000000000)
1896
1897
1898/*
1899 *************************************************************************
1900 * C P 1 R E G I S T E R D E F I N I T I O N S *
1901 *************************************************************************
1902 */
1903
1904
1905/*
1906 *************************************************************************
1907 * H A R D W A R E F P R N A M E S *
1908 *************************************************************************
1909 */
1910
1911#define fp0 $f0
1912#define fp1 $f1
1913#define fp2 $f2
1914#define fp3 $f3
1915#define fp4 $f4
1916#define fp5 $f5
1917#define fp6 $f6
1918#define fp7 $f7
1919#define fp8 $f8
1920#define fp9 $f9
1921#define fp10 $f10
1922#define fp11 $f11
1923#define fp12 $f12
1924#define fp13 $f13
1925#define fp14 $f14
1926#define fp15 $f15
1927#define fp16 $f16
1928#define fp17 $f17
1929#define fp18 $f18
1930#define fp19 $f19
1931#define fp20 $f20
1932#define fp21 $f21
1933#define fp22 $f22
1934#define fp23 $f23
1935#define fp24 $f24
1936#define fp25 $f25
1937#define fp26 $f26
1938#define fp27 $f27
1939#define fp28 $f28
1940#define fp29 $f29
1941#define fp30 $f30
1942#define fp31 $f31
1943
1944/*
1945 * The following definitions are used to convert an FPR name
1946 * into the corresponding even or odd name, respectively.
1947 * This is used in macro substitution in the AVPs.
1948 */
1949
1950#define fp1_even $f0
1951#define fp3_even $f2
1952#define fp5_even $f4
1953#define fp7_even $f6
1954#define fp9_even $f8
1955#define fp11_even $f10
1956#define fp13_even $f12
1957#define fp15_even $f14
1958#define fp17_even $f16
1959#define fp19_even $f18
1960#define fp21_even $f20
1961#define fp23_even $f22
1962#define fp25_even $f24
1963#define fp27_even $f26
1964#define fp29_even $f28
1965#define fp31_even $f30
1966
1967#define fp0_odd $f1
1968#define fp2_odd $f3
1969#define fp4_odd $f5
1970#define fp6_odd $f7
1971#define fp8_odd $f9
1972#define fp10_odd $f11
1973#define fp12_odd $f13
1974#define fp14_odd $f15
1975#define fp16_odd $f17
1976#define fp18_odd $f19
1977#define fp20_odd $f21
1978#define fp22_odd $f23
1979#define fp24_odd $f25
1980#define fp26_odd $f27
1981#define fp28_odd $f29
1982#define fp30_odd $f31
1983
1984
1985/*
1986 *************************************************************************
1987 * H A R D W A R E F P R I N D I C E S *
1988 *************************************************************************
1989 *
1990 * These definitions provide the index (number) of the FPR, as opposed
1991 * to the assembler register name ($n).
1992 */
1993
1994#define R_fp0 0
1995#define R_fp1 1
1996#define R_fp2 2
1997#define R_fp3 3
1998#define R_fp4 4
1999#define R_fp5 5
2000#define R_fp6 6
2001#define R_fp7 7
2002#define R_fp8 8
2003#define R_fp9 9
2004#define R_fp10 10
2005#define R_fp11 11
2006#define R_fp12 12
2007#define R_fp13 13
2008#define R_fp14 14
2009#define R_fp15 15
2010#define R_fp16 16
2011#define R_fp17 17
2012#define R_fp18 18
2013#define R_fp19 19
2014#define R_fp20 20
2015#define R_fp21 21
2016#define R_fp22 22
2017#define R_fp23 23
2018#define R_fp24 24
2019#define R_fp25 25
2020#define R_fp26 26
2021#define R_fp27 27
2022#define R_fp28 28
2023#define R_fp29 29
2024#define R_fp30 30
2025#define R_fp31 31
2026
2027
2028/*
2029 *************************************************************************
2030 * H A R D W A R E F C R N A M E S *
2031 *************************************************************************
2032 */
2033
2034#define fc0 $0
2035#define fc25 $25
2036#define fc26 $26
2037#define fc28 $28
2038#define fc31 $31
2039
2040
2041/*
2042 *************************************************************************
2043 * H A R D W A R E F C R I N D I C E S *
2044 *************************************************************************
2045 *
2046 * These definitions provide the index (number) of the FCR, as opposed
2047 * to the assembler register name ($n).
2048 */
2049
2050#define R_fc0 0
2051#define R_fc25 25
2052#define R_fc26 26
2053#define R_fc28 28
2054#define R_fc31 31
2055
2056
2057/*
2058 *************************************************************************
2059 * H A R D W A R E F C C N A M E S *
2060 *************************************************************************
2061 */
2062
2063#define cc0 $fcc0
2064#define cc1 $fcc1
2065#define cc2 $fcc2
2066#define cc3 $fcc3
2067#define cc4 $fcc4
2068#define cc5 $fcc5
2069#define cc6 $fcc6
2070#define cc7 $fcc7
2071
2072
2073/*
2074 *************************************************************************
2075 * H A R D W A R E F C C I N D I C E S *
2076 *************************************************************************
2077 *
2078 * These definitions provide the index (number) of the CC, as opposed
2079 * to the assembler register name ($n).
2080 */
2081
2082#define R_cc0 0
2083#define R_cc1 1
2084#define R_cc2 2
2085#define R_cc3 3
2086#define R_cc4 4
2087#define R_cc5 5
2088#define R_cc6 6
2089#define R_cc7 7
2090
2091
2092/*
2093 ************************************************************************
2094 * I M P L E M E N T A T I O N R E G I S T E R *
2095 ************************************************************************
2096 *
2097 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
2098 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
2099 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2100 * |Reserved for Additional|3|P|D|S| Implementation| Revision | FIR
2101 * | Configuration Bits |D|S| | | | |
2102 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2103 */
2104
2105#define C1_FIR $0
2106#define R_C1_FIR 0
2107
2108#define S_FIRConfigS 16
2109#define M_FIRConfigS (0x1 << S_FIRConfigS)
2110#define S_FIRConfigD 17
2111#define M_FIRConfigD (0x1 << S_FIRConfigD)
2112#define S_FIRConfigPS 18
2113#define M_FIRConfigPS (0x1 << S_FIRConfigPS)
2114#define S_FIRConfig3D 19
2115#define M_FIRConfig3D (0x1 << S_FIRConfig3D)
2116#define M_FIRConfigAll (M_FIRConfigS|M_FIRConfigD|M_FIRConfigPS|M_FIRConfig3D)
2117
2118#define S_FIRImp 8
2119#define M_FIRImp (0xff << S_FIRImp)
2120
2121#define S_FIRRev 0
2122#define M_FIRRev (0xff << S_FIRRev)
2123
2124#define M_FIR0Fields 0xfff00000
2125#define M_FIRRFields 0x000fffff
2126
2127/*
2128 ************************************************************************
2129 * C O N D I T I O N C O D E S R E G I S T E R *
2130 ************************************************************************
2131 *
2132 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
2133 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
2134 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2135 * | 0 | CC | FCCR
2136 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2137 */
2138
2139#define C1_FCCR $25
2140#define R_C1_FCCR 25
2141
2142#define S_FCCRCC 0
2143#define M_FCCRCC (0xff << S_FCCRCC)
2144#define S_FCCRCC7 7
2145#define M_FCCRCC7 (0x1 << S_FCCRCC7)
2146#define S_FCCRCC6 6
2147#define M_FCCRCC6 (0x1 << S_FCCRCC6)
2148#define S_FCCRCC5 5
2149#define M_FCCRCC5 (0x1 << S_FCCRCC5)
2150#define S_FCCRCC4 4
2151#define M_FCCRCC4 (0x1 << S_FCCRCC4)
2152#define S_FCCRCC3 3
2153#define M_FCCRCC3 (0x1 << S_FCCRCC3)
2154#define S_FCCRCC2 2
2155#define M_FCCRCC2 (0x1 << S_FCCRCC2)
2156#define S_FCCRCC1 1
2157#define M_FCCRCC1 (0x1 << S_FCCRCC1)
2158#define S_FCCRCC0 0
2159#define M_FCCRCC0 (0x1 << S_FCCRCC0)
2160
2161#define M_FCCR0Fields 0xffffff00
2162#define M_FCCRRFields 0x000000ff
2163
2164
2165/*
2166 ************************************************************************
2167 * E X C E P T I O N S R E G I S T E R *
2168 ************************************************************************
2169 *
2170 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
2171 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
2172 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2173 * | 0 | Cause | 0 | Flags | 0 | FEXR
2174 * | |E|V|Z|O|U|I| |V|Z|O|U|I| |
2175 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2176 */
2177
2178#define C1_FEXR $26
2179#define R_C1_FEXR 26
2180
2181#define S_FEXRExc 12
2182#define M_FEXRExc (0x3f << S_FEXRExc)
2183#define S_FEXRExcE 17
2184#define M_FEXRExcE (0x1 << S_FEXRExcE)
2185#define S_FEXRExcV 16
2186#define M_FEXRExcV (0x1 << S_FEXRExcV)
2187#define S_FEXRExcZ 15
2188#define M_FEXRExcZ (0x1 << S_FEXRExcZ)
2189#define S_FEXRExcO 14
2190#define M_FEXRExcO (0x1 << S_FEXRExcO)
2191#define S_FEXRExcU 13
2192#define M_FEXRExcU (0x1 << S_FEXRExcU)
2193#define S_FEXRExcI 12
2194#define M_FEXRExcI (0x1 << S_FEXRExcI)
2195
2196#define S_FEXRFlg 2
2197#define M_FEXRFlg (0x1f << S_FEXRFlg)
2198#define S_FEXRFlgV 6
2199#define M_FEXRFlgV (0x1 << S_FEXRFlgV)
2200#define S_FEXRFlgZ 5
2201#define M_FEXRFlgZ (0x1 << S_FEXRFlgZ)
2202#define S_FEXRFlgO 4
2203#define M_FEXRFlgO (0x1 << S_FEXRFlgO)
2204#define S_FEXRFlgU 3
2205#define M_FEXRFlgU (0x1 << S_FEXRFlgU)
2206#define S_FEXRFlgI 2
2207#define M_FEXRFlgI (0x1 << S_FEXRFlgI)
2208
2209#define M_FEXR0Fields 0xfffc0f83
2210#define M_FEXRRFields 0x00000000
2211
2212
2213/*
2214 ************************************************************************
2215 * E N A B L E S R E G I S T E R *
2216 ************************************************************************
2217 *
2218 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
2219 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
2220 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2221 * | 0 | Enables | 0 |F|RM | FENR
2222 * | |V|Z|O|U|I| |S| |
2223 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2224 */
2225
2226#define C1_FENR $28
2227#define R_C1_FENR 28
2228
2229#define S_FENREna 7
2230#define M_FENREna (0x1f << S_FENREna)
2231#define S_FENREnaV 11
2232#define M_FENREnaV (0x1 << S_FENREnaV)
2233#define S_FENREnaZ 10
2234#define M_FENREnaZ (0x1 << S_FENREnaZ)
2235#define S_FENREnaO 9
2236#define M_FENREnaO (0x1 << S_FENREnaO)
2237#define S_FENREnaU 8
2238#define M_FENREnaU (0x1 << S_FENREnaU)
2239#define S_FENREnaI 7
2240#define M_FENREnaI (0x1 << S_FENREnaI)
2241
2242#define S_FENRFS 2
2243#define M_FENRFS (0x1 << S_FENRFS)
2244
2245#define S_FENRRM 0
2246#define M_FENRRM (0x3 << S_FENRRM)
2247
2248#define M_FENR0Fields 0xfffff078
2249#define M_FENRRFields 0x00000000
2250
2251
2252/*
2253 ************************************************************************
2254 * C O N T R O L / S T A T U S R E G I S T E R *
2255 ************************************************************************
2256 *
2257 * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
2258 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
2259 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2260 * | FCC |F|C|Imp| 0 | Cause | Enables | Flags | RM| FCSR
2261 * |7|6|5|4|3|2|1|S|C| | |E|V|Z|O|U|I|V|Z|O|U|I|V|Z|O|U|I| |
2262 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2263 */
2264
2265#define C1_FCSR $31
2266#define R_C1_FCSR 31
2267
2268#define S_FCSRFCC7_1 25 /* Floating point condition codes 7..1 (R/W) */
2269#define M_FCSRFCC7_1 (0x7f << S_FCSRFCC7_1)
2270#define S_FCSRCC7 31
2271#define M_FCSRCC7 (0x1 << S_FCSRCC7)
2272#define S_FCSRCC6 30
2273#define M_FCSRCC6 (0x1 << S_FCSRCC6)
2274#define S_FCSRCC5 29
2275#define M_FCSRCC5 (0x1 << S_FCSRCC5)
2276#define S_FCSRCC4 28
2277#define M_FCSRCC4 (0x1 << S_FCSRCC4)
2278#define S_FCSRCC3 27
2279#define M_FCSRCC3 (0x1 << S_FCSRCC3)
2280#define S_FCSRCC2 26
2281#define M_FCSRCC2 (0x1 << S_FCSRCC2)
2282#define S_FCSRCC1 25
2283#define M_FCSRCC1 (0x1 << S_FCSRCC1)
2284
2285#define S_FCSRFS 24 /* Flush denorms to zero (R/W) */
2286#define M_FCSRFS (0x1 << S_FCSRFS)
2287
2288#define S_FCSRCC0 23 /* Floating point condition code 0 (R/W) */
2289#define M_FCSRCC0 (0x1 << S_FCSRCC0)
2290#define S_FCSRCC S_FCSRCC0
2291#define M_FCSRCC M_FCSRCC0
2292
2293#define S_FCSRImpl 21 /* Implementation-specific control bits (R/W) */
2294#define M_FCSRImpl (0x3 << S_FCSRImpl)
2295
2296#define S_FCSRExc 12 /* Exception cause (R/W) */
2297#define M_FCSRExc (0x3f << S_FCSRExc)
2298#define S_FCSRExcE 17
2299#define M_FCSRExcE (0x1 << S_FCSRExcE)
2300#define S_FCSRExcV 16
2301#define M_FCSRExcV (0x1 << S_FCSRExcV)
2302#define S_FCSRExcZ 15
2303#define M_FCSRExcZ (0x1 << S_FCSRExcZ)
2304#define S_FCSRExcO 14
2305#define M_FCSRExcO (0x1 << S_FCSRExcO)
2306#define S_FCSRExcU 13
2307#define M_FCSRExcU (0x1 << S_FCSRExcU)
2308#define S_FCSRExcI 12
2309#define M_FCSRExcI (0x1 << S_FCSRExcI)
2310
2311#define S_FCSREna 7 /* Exception enable (R/W) */
2312#define M_FCSREna (0x1f << S_FCSREna)
2313#define S_FCSREnaV 11
2314#define M_FCSREnaV (0x1 << S_FCSREnaV)
2315#define S_FCSREnaZ 10
2316#define M_FCSREnaZ (0x1 << S_FCSREnaZ)
2317#define S_FCSREnaO 9
2318#define M_FCSREnaO (0x1 << S_FCSREnaO)
2319#define S_FCSREnaU 8
2320#define M_FCSREnaU (0x1 << S_FCSREnaU)
2321#define S_FCSREnaI 7
2322#define M_FCSREnaI (0x1 << S_FCSREnaI)
2323
2324#define S_FCSRFlg 2 /* Exception flags (R/W) */
2325#define M_FCSRFlg (0x1f << S_FCSRFlg)
2326#define S_FCSRFlgV 6
2327#define M_FCSRFlgV (0x1 << S_FCSRFlgV)
2328#define S_FCSRFlgZ 5
2329#define M_FCSRFlgZ (0x1 << S_FCSRFlgZ)
2330#define S_FCSRFlgO 4
2331#define M_FCSRFlgO (0x1 << S_FCSRFlgO)
2332#define S_FCSRFlgU 3
2333#define M_FCSRFlgU (0x1 << S_FCSRFlgU)
2334#define S_FCSRFlgI 2
2335#define M_FCSRFlgI (0x1 << S_FCSRFlgI)
2336
2337#define S_FCSRRM 0 /* Rounding mode (R/W) */
2338#define M_FCSRRM (0x3 << S_FCSRRM)
2339
2340#define M_FCSR0Fields 0x001c0000
2341#define M_FCSRRFields 0x00000000
2342
2343/*
2344 * Values in the rounding mode field (of both FCSR and FCCR)
2345 */
2346#define K_FCSRRM_RN 0
2347#define K_FCSRRM_RZ 1
2348#define K_FCSRRM_RP 2
2349#define K_FCSRRM_RM 3
2350
2351
2352/* ********************************************************************* */
2353/* Interface function definition */
2354
2355
2356/* ********************************************************************* */
2357
2358#endif /* __ARCHDEFS_H__ */
diff --git a/utils/hwstub/stub/atj213x/mips.h b/utils/hwstub/stub/atj213x/mips.h
new file mode 100644
index 0000000000..aef7bc9dd2
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/mips.h
@@ -0,0 +1,820 @@
1/**************************************************************************
2* *
3* PROJECT : MIPS port for uC/OS-II *
4* *
5* MODULE : MIPS.h *
6* *
7* AUTHOR : Michael Anburaj *
8* URL : http://geocities.com/michaelanburaj/ *
9* EMAIL: michaelanburaj@hotmail.com *
10* *
11* PROCESSOR : MIPS 4Kc (32 bit RISC) - ATLAS board *
12* *
13* TOOL-CHAIN : SDE & Cygnus *
14* *
15* DESCRIPTION : *
16* MIPS processor definitions. *
17* The basic CPU definitions are found in the file archdefs.h, which *
18* is included by mips.h. *
19* *
20* mips.h implements aliases for some of the definitions in archdefs.h *
21* and adds various definitions. *
22* *
23**************************************************************************/
24
25
26#ifndef __MIPS_H__
27#define __MIPS_H__
28
29#include "mips-archdefs.h"
30
31
32/* ********************************************************************* */
33/* Module configuration */
34
35
36/* ********************************************************************* */
37/* Interface macro & data definition */
38
39#ifndef MSK
40#define MSK(n) ((1 << (n)) - 1)
41#endif
42
43/* CPU registers */
44#define SYS_CPUREG_ZERO 0
45#define SYS_CPUREG_AT 1
46#define SYS_CPUREG_V0 2
47#define SYS_CPUREG_V1 3
48#define SYS_CPUREG_A0 4
49#define SYS_CPUREG_A1 5
50#define SYS_CPUREG_A2 6
51#define SYS_CPUREG_A3 7
52#define SYS_CPUREG_T0 8
53#define SYS_CPUREG_T1 9
54#define SYS_CPUREG_T2 10
55#define SYS_CPUREG_T3 11
56#define SYS_CPUREG_T4 12
57#define SYS_CPUREG_T5 13
58#define SYS_CPUREG_T6 14
59#define SYS_CPUREG_T7 15
60#define SYS_CPUREG_S0 16
61#define SYS_CPUREG_S1 17
62#define SYS_CPUREG_S2 18
63#define SYS_CPUREG_S3 19
64#define SYS_CPUREG_S4 20
65#define SYS_CPUREG_S5 21
66#define SYS_CPUREG_S6 22
67#define SYS_CPUREG_S7 23
68#define SYS_CPUREG_T8 24
69#define SYS_CPUREG_T9 25
70#define SYS_CPUREG_K0 26
71#define SYS_CPUREG_K1 27
72#define SYS_CPUREG_GP 28
73#define SYS_CPUREG_SP 29
74#define SYS_CPUREG_S8 30
75#define SYS_CPUREG_FP SYS_CPUREG_S8
76#define SYS_CPUREG_RA 31
77
78
79/* CPU register fp ($30) has an alias s8 */
80#define s8 fp
81
82
83/* Aliases for System Control Coprocessor (CP0) registers */
84#define C0_INDEX C0_Index
85#define C0_RANDOM C0_Random
86#define C0_ENTRYLO0 C0_EntryLo0
87#define C0_ENTRYLO1 C0_EntryLo1
88#define C0_CONTEXT C0_Context
89#define C0_PAGEMASK C0_PageMask
90#define C0_WIRED C0_Wired
91#define C0_BADVADDR C0_BadVAddr
92#define C0_COUNT C0_Count
93#define C0_ENTRYHI C0_EntryHi
94#define C0_COMPARE C0_Compare
95#define C0_STATUS C0_Status
96#define C0_CAUSE C0_Cause
97
98#ifdef C0_PRID /* ArchDefs has an obsolete def. of C0_PRID */
99#undef C0_PRID
100#endif
101#define C0_PRID C0_PRId
102
103#define C0_CONFIG C0_Config
104#define C0_CONFIG1 C0_Config1
105#define C0_LLADDR C0_LLAddr
106#define C0_WATCHLO C0_WatchLo
107#define C0_WATCHHI C0_WatchHi
108#define C0_DEBUG C0_Debug
109#define C0_PERFCNT C0_PerfCnt
110#define C0_ERRCTL C0_ErrCtl
111#define C0_CACHEERR C0_CacheErr
112#define C0_TAGLO C0_TagLo
113#define C0_DATALO C0_DataLo
114#define C0_TAGHI C0_TagHi
115#define C0_DATAHI C0_DataHi
116#define C0_ERROREPC C0_ErrorEPC
117#if 0
118#define C0_DESAVE C0_DESAVE
119#define C0_EPC C0_EPC
120#define C0_DEPC C0_DEPC
121#endif
122
123/* System Control Coprocessor (CP0) registers select fields */
124#define C0_INDEX_SEL 0 /* TLB Index */
125#define C0_RANDOM_SEL 0 /* TLB Random */
126#define C0_TLBLO0_SEL 0 /* TLB EntryLo0 */
127#define C0_TLBLO1_SEL 0 /* TLB EntryLo1 */
128#define C0_CONTEXT_SEL 0 /* Context */
129#define C0_PAGEMASK_SEL 0 /* TLB PageMask */
130#define C0_WIRED_SEL 0 /* TLB Wired */
131#define C0_BADVADDR_SEL 0 /* Bad Virtual Address */
132#define C0_COUNT_SEL 0 /* Count */
133#define C0_ENTRYHI_SEL 0 /* TLB EntryHi */
134#define C0_COMPARE_SEL 0 /* Compare */
135#define C0_STATUS_SEL 0 /* Processor Status */
136#define C0_CAUSE_SEL 0 /* Exception Cause */
137#define C0_EPC_SEL 0 /* Exception PC */
138#define C0_PRID_SEL 0 /* Processor Revision Indentifier */
139#define C0_CONFIG_SEL 0 /* Config */
140#define C0_CONFIG1_SEL 1 /* Config1 */
141#define C0_LLADDR_SEL 0 /* LLAddr */
142#define C0_WATCHLO_SEL 0 /* WatchpointLo */
143#define C0_WATCHHI_SEL 0 /* WatchpointHi */
144#define C0_DEBUG_SEL 0 /* EJTAG Debug Register */
145#define C0_DEPC_SEL 0 /* Program counter at last EJTAG debug exception */
146#define C0_PERFCNT_SEL 0 /* Performance counter interface */
147#define C0_ERRCTL_SEL 0 /* ERRCTL */
148#define C0_CACHEERR_SEL 0 /* CacheErr */
149#define C0_TAGLO_SEL 0 /* TagLo */
150#define C0_DATALO_SEL 1 /* DataLo */
151#define C0_DTAGLO_SEL 2 /* DTagLo */
152#define C0_TAGHI_SEL 0 /* TagHi */
153#define C0_DATAHI_SEL 1 /* DataHi */
154#define C0_DTAGHI_SEL 2 /* DTagHi */
155#define C0_ERROREPC_SEL 0 /* ErrorEPC */
156#define C0_DESAVE_SEL 0 /* EJTAG dbg exc. save register */
157
158
159/* C0_CONFIG register encoding */
160
161#define C0_CONFIG_M_SHF S_ConfigMore
162#define C0_CONFIG_M_MSK M_ConfigMore
163#define C0_CONFIG_M_BIT C0_CONFIG_M_MSK
164
165#define C0_CONFIG_BE_SHF S_ConfigBE
166#define C0_CONFIG_BE_MSK M_ConfigBE
167#define C0_CONFIG_BE_BIT C0_CONFIG_BE_MSK
168
169#define C0_CONFIG_AT_SHF S_ConfigAT
170#define C0_CONFIG_AT_MSK M_ConfigAT
171#define C0_CONFIG_AT_MIPS32 K_ConfigAT_MIPS32
172#define C0_CONFIG_AT_MIPS64_32ADDR K_ConfigAT_MIPS64S
173#define C0_CONFIG_AT_MIPS64 K_ConfigAT_MIPS64
174
175#define C0_CONFIG_AR_SHF S_ConfigAR
176#define C0_CONFIG_AR_MSK M_ConfigAR
177
178#define C0_CONFIG_MT_SHF S_ConfigMT
179#define C0_CONFIG_MT_MSK M_ConfigMT
180#define C0_CONFIG_MT_NONE K_ConfigMT_NoMMU
181#define C0_CONFIG_MT_TLB K_ConfigMT_TLBMMU
182#define C0_CONFIG_MT_BAT K_ConfigMT_BATMMU
183#define C0_CONFIG_MT_NON_STD K_ConfigMT_FMMMU
184
185#define C0_CONFIG_K0_SHF S_ConfigK0
186#define C0_CONFIG_K0_MSK M_ConfigK0
187#define C0_CONFIG_K0_WTHRU_NOALLOC K_CacheAttrCWTnWA
188#define C0_CONFIG_K0_WTHRU_ALLOC K_CacheAttrCWTWA
189#define C0_CONFIG_K0_UNCACHED K_CacheAttrU
190#define C0_CONFIG_K0_NONCOHERENT K_CacheAttrCN
191#define C0_CONFIG_K0_COHERENTXCL K_CacheAttrCCE
192#define C0_CONFIG_K0_COHERENTXCLW K_CacheAttrCCS
193#define C0_CONFIG_K0_COHERENTUPD K_CacheAttrCCU
194#define C0_CONFIG_K0_UNCACHED_ACCEL K_CacheAttrUA
195
196
197/* WC field.
198 *
199 * This feature is present specifically to support configuration
200 * testing of the core in a lead vehicle, and is not supported
201 * in any other environment. Attempting to use this feature
202 * outside of the scope of a lead vehicle is a violation of the
203 * MIPS Architecture, and may cause unpredictable operation of
204 * the processor.
205 */
206#define C0_CONFIG_WC_SHF 19
207#define C0_CONFIG_WC_MSK (MSK(1) << C0_CONFIG_WC_SHF)
208#define C0_CONFIG_WC_BIT C0_CONFIG_WC_MSK
209
210
211/* C0_CONFIG1 register encoding */
212
213#define C0_CONFIG1_MMUSIZE_SHF S_Config1MMUSize
214#define C0_CONFIG1_MMUSIZE_MSK M_Config1MMUSize
215
216#define C0_CONFIG1_IS_SHF S_Config1IS
217#define C0_CONFIG1_IS_MSK M_Config1IS
218
219#define C0_CONFIG1_IL_SHF S_Config1IL
220#define C0_CONFIG1_IL_MSK M_Config1IL
221
222#define C0_CONFIG1_IA_SHF S_Config1IA
223#define C0_CONFIG1_IA_MSK M_Config1IA
224
225#define C0_CONFIG1_DS_SHF S_Config1DS
226#define C0_CONFIG1_DS_MSK M_Config1DS
227
228#define C0_CONFIG1_DL_SHF S_Config1DL
229#define C0_CONFIG1_DL_MSK M_Config1DL
230
231#define C0_CONFIG1_DA_SHF S_Config1DA
232#define C0_CONFIG1_DA_MSK M_Config1DA
233
234#define C0_CONFIG1_WR_SHF S_Config1WR
235#define C0_CONFIG1_WR_MSK M_Config1WR
236#define C0_CONFIG1_WR_BIT C0_CONFIG1_WR_MSK
237
238#define C0_CONFIG1_CA_SHF S_Config1CA
239#define C0_CONFIG1_CA_MSK M_Config1CA
240#define C0_CONFIG1_CA_BIT C0_CONFIG1_CA_MSK
241
242#define C0_CONFIG1_EP_SHF S_Config1EP
243#define C0_CONFIG1_EP_MSK M_Config1EP
244#define C0_CONFIG1_EP_BIT C0_CONFIG1_EP_MSK
245
246#define C0_CONFIG1_FP_SHF S_Config1FP
247#define C0_CONFIG1_FP_MSK M_Config1FP
248#define C0_CONFIG1_FP_BIT C0_CONFIG1_FP_MSK
249
250
251/* C0_STATUS register encoding */
252
253#define C0_STATUS_CU3_SHF S_StatusCU3
254#define C0_STATUS_CU3_MSK M_StatusCU3
255#define C0_STATUS_CU3_BIT C0_STATUS_CU3_MSK
256
257#define C0_STATUS_CU2_SHF S_StatusCU2
258#define C0_STATUS_CU2_MSK M_StatusCU2
259#define C0_STATUS_CU2_BIT C0_STATUS_CU2_MSK
260
261#define C0_STATUS_CU1_SHF S_StatusCU1
262#define C0_STATUS_CU1_MSK M_StatusCU1
263#define C0_STATUS_CU1_BIT C0_STATUS_CU1_MSK
264
265#define C0_STATUS_CU0_SHF S_StatusCU1
266#define C0_STATUS_CU0_MSK M_StatusCU1
267#define C0_STATUS_CU0_BIT C0_STATUS_CU0_MSK
268
269#define C0_STATUS_RP_SHF S_StatusRP
270#define C0_STATUS_RP_MSK M_StatusRP
271#define C0_STATUS_RP_BIT C0_STATUS_RP_MSK
272
273#define C0_STATUS_FR_SHF S_StatusFR
274#define C0_STATUS_FR_MSK M_StatusFR
275#define C0_STATUS_FR_BIT C0_STATUS_FR_MSK
276
277#define C0_STATUS_RE_SHF S_StatusRE
278#define C0_STATUS_RE_MSK M_StatusRE
279#define C0_STATUS_RE_BIT C0_STATUS_RE_MSK
280
281#define C0_STATUS_BEV_SHF S_StatusBEV
282#define C0_STATUS_BEV_MSK M_StatusBEV
283#define C0_STATUS_BEV_BIT C0_STATUS_BEV_MSK
284
285#define C0_STATUS_TS_SHF S_StatusTS
286#define C0_STATUS_TS_MSK M_StatusTS
287#define C0_STATUS_TS_BIT C0_STATUS_TS_MSK
288
289#define C0_STATUS_SR_SHF S_StatusSR
290#define C0_STATUS_SR_MSK M_StatusSR
291#define C0_STATUS_SR_BIT C0_STATUS_SR_MSK
292
293#define C0_STATUS_NMI_SHF S_StatusNMI
294#define C0_STATUS_NMI_MSK M_StatusNMI
295#define C0_STATUS_NMI_BIT C0_STATUS_NMI_MSK
296
297#define C0_STATUS_IM_SHF S_StatusIM
298#define C0_STATUS_IM_MSK M_StatusIM
299/* Note that the the definitions below indicate the interrupt number
300 * rather than the mask.
301 * (0..1 for SW interrupts and 2...7 for HW interrupts)
302 */
303#define C0_STATUS_IM_SW0 (S_StatusIM0 - S_StatusIM)
304#define C0_STATUS_IM_SW1 (S_StatusIM1 - S_StatusIM)
305#define C0_STATUS_IM_HW0 (S_StatusIM2 - S_StatusIM)
306#define C0_STATUS_IM_HW1 (S_StatusIM3 - S_StatusIM)
307#define C0_STATUS_IM_HW2 (S_StatusIM4 - S_StatusIM)
308#define C0_STATUS_IM_HW3 (S_StatusIM5 - S_StatusIM)
309#define C0_STATUS_IM_HW4 (S_StatusIM6 - S_StatusIM)
310#define C0_STATUS_IM_HW5 (S_StatusIM7 - S_StatusIM)
311
312/* Max interrupt code */
313#define C0_STATUS_IM_MAX C0_STATUS_IM_HW5
314
315#define C0_STATUS_KSU_SHF S_StatusKSU
316#define C0_STATUS_KSU_MSK M_StatusKSU
317
318#define C0_STATUS_UM_SHF S_StatusUM
319#define C0_STATUS_UM_MSK M_StatusUM
320#define C0_STATUS_UM_BIT C0_STATUS_UM_MSK
321
322#define C0_STATUS_ERL_SHF S_StatusERL
323#define C0_STATUS_ERL_MSK M_StatusERL
324#define C0_STATUS_ERL_BIT C0_STATUS_ERL_MSK
325
326#define C0_STATUS_EXL_SHF S_StatusEXL
327#define C0_STATUS_EXL_MSK M_StatusEXL
328#define C0_STATUS_EXL_BIT C0_STATUS_EXL_MSK
329
330#define C0_STATUS_IE_SHF S_StatusIE
331#define C0_STATUS_IE_MSK M_StatusIE
332#define C0_STATUS_IE_BIT C0_STATUS_IE_MSK
333
334
335/* C0_PRID register encoding */
336
337#define C0_PRID_OPT_SHF S_PRIdCoOpt
338#define C0_PRID_OPT_MSK M_PRIdCoOpt
339
340#define C0_PRID_COMP_SHF S_PRIdCoID
341#define C0_PRID_COMP_MSK M_PRIdCoID
342#define C0_PRID_COMP_MIPS K_PRIdCoID_MIPS
343#define C0_PRID_COMP_NOT_MIPS32_64 0
344
345#define C0_PRID_PRID_SHF S_PRIdImp
346#define C0_PRID_PRID_MSK M_PRIdImp
347
348/* Jade */
349#define C0_PRID_PRID_4Kc K_PRIdImp_Jade
350#define C0_PRID_PRID_4Kmp K_PRIdImp_JadeLite /* 4Km/4Kp */
351/* Emerald */
352#define C0_PRID_PRID_4KEc K_PRIdImp_4KEc
353#define C0_PRID_PRID_4KEmp K_PRIdImp_4KEmp
354/* Coral */
355#define C0_PRID_PRID_4KSc K_PRIdImp_4KSc
356/* Opal */
357#define C0_PRID_PRID_5K K_PRIdImp_Opal
358/* Ruby */
359#define C0_PRID_PRID_20Kc K_PRIdImp_Ruby
360/* Other CPUs */
361#define C0_PRID_PRID_R4000 K_PRIdImp_R4000
362#define C0_PRID_PRID_RM52XX K_PRIdImp_R5200
363#define C0_PRID_PRID_RM70XX 0x27
364
365#define C0_PRID_REV_SHF S_PRIdRev
366#define C0_PRID_REV_MSK M_PRIdRev
367
368
369#define MIPS_4Kc ( (C0_PRID_COMP_MIPS << \
370 C0_PRID_COMP_SHF) | \
371 (C0_PRID_PRID_4Kc << \
372 C0_PRID_PRID_SHF) \
373 )
374
375#define MIPS_4Kmp ( (C0_PRID_COMP_MIPS << \
376 C0_PRID_COMP_SHF) | \
377 (C0_PRID_PRID_4Kmp << \
378 C0_PRID_PRID_SHF) \
379 )
380
381#define MIPS_4KEc ( (C0_PRID_COMP_MIPS << \
382 C0_PRID_COMP_SHF) | \
383 (C0_PRID_PRID_4KEc << \
384 C0_PRID_PRID_SHF) \
385 )
386
387#define MIPS_4KEmp ( (C0_PRID_COMP_MIPS << \
388 C0_PRID_COMP_SHF) | \
389 (C0_PRID_PRID_4KEmp << \
390 C0_PRID_PRID_SHF) \
391 )
392
393#define MIPS_4KSc ( (C0_PRID_COMP_MIPS << \
394 C0_PRID_COMP_SHF) | \
395 (C0_PRID_PRID_4KSc << \
396 C0_PRID_PRID_SHF) \
397 )
398
399#define MIPS_5K ( (C0_PRID_COMP_MIPS << \
400 C0_PRID_COMP_SHF) | \
401 (C0_PRID_PRID_5K << \
402 C0_PRID_PRID_SHF) \
403 )
404
405#define MIPS_20Kc ( (C0_PRID_COMP_MIPS << \
406 C0_PRID_COMP_SHF) | \
407 (C0_PRID_PRID_20Kc << \
408 C0_PRID_PRID_SHF) \
409 )
410
411#define QED_RM52XX ( (C0_PRID_COMP_NOT_MIPS32_64 << \
412 C0_PRID_COMP_SHF) | \
413 (C0_PRID_PRID_RM52XX << \
414 C0_PRID_PRID_SHF) \
415 )
416
417#define QED_RM70XX ( (C0_PRID_COMP_NOT_MIPS32_64 << \
418 C0_PRID_COMP_SHF) | \
419 (C0_PRID_PRID_RM70XX << \
420 C0_PRID_PRID_SHF) \
421 )
422
423/* C0_ENTRYHI register encoding */
424
425#define C0_ENTRYHI_VPN2_SHF S_EntryHiVPN2
426#define C0_ENTRYHI_VPN2_MSK M_EntryHiVPN2
427
428#define C0_ENTRYHI_ASID_SHF S_EntryHiASID
429#define C0_ENTRYHI_ASID_MSK M_EntryHiASID
430
431
432/* C0_CAUSE register encoding */
433
434#define C0_CAUSE_BD_SHF S_CauseBD
435#define C0_CAUSE_BD_MSK M_CauseBD
436#define C0_CAUSE_BD_BIT C0_CAUSE_BD_MSK
437
438#define C0_CAUSE_CE_SHF S_CauseCE
439#define C0_CAUSE_CE_MSK M_CauseCE
440
441#define C0_CAUSE_IV_SHF S_CauseIV
442#define C0_CAUSE_IV_MSK M_CauseIV
443#define C0_CAUSE_IV_BIT C0_CAUSE_IV_MSK
444
445#define C0_CAUSE_WP_SHF S_CauseWP
446#define C0_CAUSE_WP_MSK M_CauseWP
447#define C0_CAUSE_WP_BIT C0_CAUSE_WP_MSK
448
449#define C0_CAUSE_IP_SHF S_CauseIP
450#define C0_CAUSE_IP_MSK M_CauseIP
451
452#define C0_CAUSE_CODE_SHF S_CauseExcCode
453#define C0_CAUSE_CODE_MSK M_CauseExcCode
454
455#define C0_CAUSE_CODE_INT EX_INT
456#define C0_CAUSE_CODE_MOD EX_MOD
457#define C0_CAUSE_CODE_TLBL EX_TLBL
458#define C0_CAUSE_CODE_TLBS EX_TLBS
459#define C0_CAUSE_CODE_ADEL EX_ADEL
460#define C0_CAUSE_CODE_ADES EX_ADES
461#define C0_CAUSE_CODE_IBE EX_IBE
462#define C0_CAUSE_CODE_DBE EX_DBE
463#define C0_CAUSE_CODE_SYS EX_SYS
464#define C0_CAUSE_CODE_BP EX_BP
465#define C0_CAUSE_CODE_RI EX_RI
466#define C0_CAUSE_CODE_CPU EX_CPU
467#define C0_CAUSE_CODE_OV EX_OV
468#define C0_CAUSE_CODE_TR EV_TR
469#define C0_CAUSE_CODE_FPE EX_FPE
470#define C0_CAUSE_CODE_WATCH EX_WATCH
471#define C0_CAUSE_CODE_MCHECK EX_MCHECK
472
473/* Max cause code */
474#define C0_CAUSE_CODE_MAX EX_MCHECK
475
476
477/* C0_PAGEMASK register encoding */
478#define C0_PAGEMASK_MASK_SHF S_PageMaskMask
479#define C0_PAGEMASK_MASK_MSK M_PageMaskMask
480#define C0_PAGEMASK_MASK_4K K_PageMask4K
481#define C0_PAGEMASK_MASK_16K K_PageMask16K
482#define C0_PAGEMASK_MASK_64K K_PageMask64K
483#define C0_PAGEMASK_MASK_256K K_PageMask256K
484#define C0_PAGEMASK_MASK_1M K_PageMask1M
485#define C0_PAGEMASK_MASK_4M K_PageMask4M
486#define C0_PAGEMASK_MASK_16M K_PageMask16M
487
488
489/* C0_ENTRYLO0 register encoding (equiv. to C0_ENTRYLO1) */
490#define C0_ENTRYLO0_PFN_SHF S_EntryLoPFN
491#define C0_ENTRYLO0_PFN_MSK M_EntryLoPFN
492
493#define C0_ENTRYLO0_C_SHF S_EntryLoC
494#define C0_ENTRYLO0_C_MSK M_EntryLoC
495
496#define C0_ENTRYLO0_D_SHF S_EntryLoD
497#define C0_ENTRYLO0_D_MSK M_EntryLoD
498
499#define C0_ENTRYLO0_V_SHF S_EntryLoV
500#define C0_ENTRYLO0_V_MSK M_EntryLoV
501
502#define C0_ENTRYLO0_G_SHF S_EntryLoG
503#define C0_ENTRYLO0_G_MSK M_EntryLoG
504
505
506/* FPU (CP1) FIR register encoding */
507#define C1_FIR_3D_SHF S_FIRConfig3D
508#define C1_FIR_3D_MSK M_FIRConfig3D
509
510#define C1_FIR_PS_SHF S_FIRConfigPS
511#define C1_FIR_PS_MSK M_FIRConfigPS
512
513#define C1_FIR_D_SHF S_FIRConfigD
514#define C1_FIR_D_MSK M_FIRConfigD
515
516#define C1_FIR_S_SHF S_FIRConfigS
517#define C1_FIR_S_MSK M_FIRConfigS
518
519#define C1_FIR_PRID_SHF S_FIRImp
520#define C1_FIR_PRID_MSK M_FIRImp
521
522#define C1_FIR_REV_SHF S_FIRRev
523#define C1_FIR_REV_MSK M_FIRRev
524
525
526/* FPU (CP1) FCSR control/status register */
527#define C1_FCSR_FCC_SHF S_FCSRFCC7_1
528#define C1_FCSR_FCC_MSK M_FCSRFCC7_1
529
530#define C1_FCSR_FS_SHF S_FCSRFS
531#define C1_FCSR_FS_MSK M_FCSRFS
532#define C1_FCSR_FS_BIT C1_FCSR_FS_MSK
533
534#define C1_FCSR_CC_SHF S_FCSRCC
535#define C1_FCSR_CC_MSK M_FCSRCC
536
537#define C1_FCSR_IMPL_SHF S_FCSRImpl
538#define C1_FCSR_IMPL_MSK M_FCSRImpl
539
540#define C1_FCSR_EXC_SHF S_FCSRExc
541#define C1_FCSR_EXC_MSK M_FCSRExc
542
543#define C1_FCSR_ENA_SHF S_FCSREna
544#define C1_FCSR_ENA_MSK M_FCSREna
545
546#define C1_FCSR_FLG_SHF S_FCSRFlg
547#define C1_FCSR_FLG_MSK M_FCSRFlg
548
549#define C1_FCSR_RM_SHF S_FCSRRM
550#define C1_FCSR_RM_MSK M_FCSRRM
551#define C1_FCSR_RM_RN K_FCSRRM_RN
552#define C1_FCSR_RM_RZ K_FCSRRM_RZ
553#define C1_FCSR_RM_RP K_FCSRRM_RP
554#define C1_FCSR_RM_RM K_FCSRRM_RM
555
556
557
558/* cache operations */
559
560#define CACHE_OP( code, type ) ( ((code) << 2) | (type) )
561
562#define ICACHE_INDEX_INVALIDATE CACHE_OP(0x0, 0)
563#define ICACHE_INDEX_LOAD_TAG CACHE_OP(0x1, 0)
564#define ICACHE_INDEX_STORE_TAG CACHE_OP(0x2, 0)
565#define DCACHE_INDEX_WRITEBACK_INVALIDATE CACHE_OP(0x0, 1)
566#define DCACHE_INDEX_LOAD_TAG CACHE_OP(0x1, 1)
567#define DCACHE_INDEX_STORE_TAG CACHE_OP(0x2, 1)
568#define SCACHE_INDEX_STORE_TAG CACHE_OP(0x2, 3)
569
570#define ICACHE_ADDR_HIT_INVALIDATE CACHE_OP(0x4, 0)
571#define ICACHE_ADDR_FILL CACHE_OP(0x5, 0)
572#define ICACHE_ADDR_FETCH_LOCK CACHE_OP(0x7, 0)
573#define DCACHE_ADDR_HIT_INVALIDATE CACHE_OP(0x4, 1)
574#define DCACHE_ADDR_HIT_WRITEBACK_INVALIDATE CACHE_OP(0x5, 1)
575#define DCACHE_ADDR_HIT_WRITEBACK CACHE_OP(0x6, 1)
576#define DCACHE_ADDR_FETCH_LOCK CACHE_OP(0x7, 1)
577
578#define SCACHE_ADDR_HIT_WRITEBACK_INVALIDATE CACHE_OP(0x5, 3)
579
580/* Workaround for bug in early revisions of MIPS 4K family of
581 * processors. Only relevant in early engineering samples of test
582 * chips (RTL revision <= 3.0).
583 *
584 * The bug is described in :
585 *
586 * MIPS32 4K(tm) Processor Core Family RTL Errata Sheet
587 * MIPS Document No: MD00003
588 *
589 * The bug is identified as : C16
590 */
591#ifndef SET_MIPS0
592#define SET_MIPS0()
593#define SET_PUSH()
594#define SET_POP()
595#endif
596#define ICACHE_INVALIDATE_WORKAROUND(reg) \
597SET_PUSH(); \
598SET_MIPS0(); \
599 la reg, 999f; \
600SET_POP(); \
601 cache ICACHE_ADDR_FILL, 0(reg); \
602 sync; \
603 nop; nop; nop; nop; \
604999:
605
606/* EMPTY_PIPELINE is used for the below cache invalidation operations.
607 * When $I is invalidated, there will still be operations in the
608 * pipeline. We make sure these are 'nop' operations.
609 */
610#define EMPTY_PIPELINE nop; nop; nop; nop
611
612#define ICACHE_INDEX_INVALIDATE_OP(index,scratch) \
613 ICACHE_INVALIDATE_WORKAROUND(scratch); \
614 cache ICACHE_INDEX_INVALIDATE, 0(index); \
615 EMPTY_PIPELINE
616
617#define ICACHE_ADDR_INVALIDATE_OP(addr,scratch) \
618 ICACHE_INVALIDATE_WORKAROUND(scratch); \
619 cache ICACHE_ADDR_HIT_INVALIDATE, 0(addr); \
620 EMPTY_PIPELINE
621
622/* The sync used in the below macro is there in case we are installing
623 * a new instruction (flush $D, sync, invalidate $I sequence).
624 */
625#define SCACHE_ADDR_HIT_WB_INVALIDATE_OP(reg) \
626 cache SCACHE_ADDR_HIT_WRITEBACK_INVALIDATE, 0(reg); \
627 sync; \
628 EMPTY_PIPELINE
629
630/* Config1 cache field decoding */
631#define CACHE_CALC_SPW(s) ( 64 << (s) )
632#define CACHE_CALC_LS(l) ( (l) ? 2 << (l) : 0 )
633#define CACHE_CALC_BPW(l,s) ( CACHE_CALC_LS(l) * CACHE_CALC_SPW(s) )
634#define CACHE_CALC_ASSOC(a) ( (a) + 1 )
635
636
637/**** Move from/to Coprocessor operations ****/
638
639/* We use ssnop instead of nop operations in order to handle
640 * superscalar CPUs.
641 * The "sll zero,zero,1" notation is compiler backwards compatible.
642 */
643#define SSNOP sll zero,zero,1
644#define NOPS SSNOP; SSNOP; SSNOP; SSNOP
645
646#define MFLO(dst) \
647 mflo dst;\
648 NOPS
649
650/* Workaround for bug in early revisions of MIPS 4K family of
651 * processors.
652 *
653 * This concerns the nop instruction before mtc0 in the
654 * MTC0 macro below.
655 *
656 * The bug is described in :
657 *
658 * MIPS32 4K(tm) Processor Core Family RTL Errata Sheet
659 * MIPS Document No: MD00003
660 *
661 * The bug is identified as : C27
662 */
663
664#define MTC0(src, dst) \
665 nop; \
666 mtc0 src,dst;\
667 NOPS
668
669#define DMTC0(src, dst) \
670 nop; \
671 dmtc0 src,dst;\
672 NOPS
673
674#define MFC0(dst, src) \
675 mfc0 dst,src;\
676 NOPS
677
678#define DMFC0(dst, src) \
679 dmfc0 dst,src;\
680 NOPS
681
682#define MFC0_SEL_OPCODE(dst, src, sel)\
683 .##word (0x40000000 | ((dst)<<16) | ((src)<<11) | (sel));\
684 NOPS
685
686#define MTC0_SEL_OPCODE(dst, src, sel)\
687 .##word (0x40800000 | ((dst)<<16) | ((src)<<11) | (sel));\
688 NOPS
689
690#define LDC1(dst, src, offs)\
691 .##word (0xd4000000 | ((src)<<21) | ((dst)<<16) | (offs))
692
693#define SDC1(src, dst, offs)\
694 .##word (0xf4000000 | ((dst)<<21) | ((src)<<16) | (offs))
695
696
697/* Instruction opcode fields */
698#define OPC_SPECIAL 0x0
699#define OPC_REGIM 0x1
700#define OPC_J 0x2
701#define OPC_JAL 0x3
702#define OPC_BEQ 0x4
703#define OPC_BNE 0x5
704#define OPC_BLEZ 0x6
705#define OPC_BGTZ 0x7
706#define OPC_COP1 0x11
707#define OPC_JALX 0x1D
708#define OPC_BEQL 0x14
709#define OPC_BNEL 0x15
710#define OPC_BLEZL 0x16
711#define OPC_BGTZL 0x17
712
713/* Instruction function fields */
714#define FUNC_JR 0x8
715#define FUNC_JALR 0x9
716
717/* Instruction rt fields */
718#define RT_BLTZ 0x0
719#define RT_BGEZ 0x1
720#define RT_BLTZL 0x2
721#define RT_BGEZL 0x3
722#define RT_BLTZAL 0x10
723#define RT_BGEZAL 0x11
724#define RT_BLTZALL 0x12
725#define RT_BGEZALL 0x13
726
727/* Instruction rs fields */
728#define RS_BC1 0x08
729
730/* Access macros for instruction fields */
731#define MIPS_OPCODE( instr) ((instr) >> 26)
732#define MIPS_FUNCTION(instr) ((instr) & MSK(6))
733#define MIPS_RT(instr) (((instr) >> 16) & MSK(5))
734#define MIPS_RS(instr) (((instr) >> 21) & MSK(5))
735#define MIPS_OFFSET(instr) ((instr) & 0xFFFF)
736#define MIPS_TARGET(instr) ((instr) & MSK(26))
737
738/* Instructions */
739#define OPCODE_DERET 0x4200001f
740#define OPCODE_BREAK 0x0005000d
741#define OPCODE_NOP 0
742#define OPCODE_JUMP(addr) ( (OPC_J << 26) | (((addr) >> 2) & 0x3FFFFFF) )
743
744#define DERET .##word OPCODE_DERET
745
746/* MIPS16e opcodes and instruction field access macros */
747
748#define MIPS16E_OPCODE(inst) (((inst) >> 11) & 0x1f)
749#define MIPS16E_I8_FUNCTION(inst) (((inst) >> 8) & 0x7)
750#define MIPS16E_X(inst) (((inst) >> 26) & 0x1)
751#define MIPS16E_RR_FUNCTION(inst) (((inst) >> 0) & 0x1f)
752#define MIPS16E_RY(inst) (((inst) >> 5) & 0x3)
753#define MIPS16E_OPC_EXTEND 0x1e
754#define MIPS16E_OPC_JAL_X 0x03
755#define MIPS16E_OPC_B 0x02
756#define MIPS16E_OPC_BEQZ 0x04
757#define MIPS16E_OPC_BNEZ 0x05
758#define MIPS16E_OPC_I8 0x0c
759#define MIPS16E_I8_FUNC_BTEQZ 0x00
760#define MIPS16E_I8_FUNC_BTNEZ 0x01
761#define MIPS16E_X_JALX 0x01
762#define MIPS16E_OPC_RR 0x1d
763#define MIPS16E_RR_FUNC_JALRC 0x00
764#define MIPS16E_RR_RY_JRRX 0x00
765#define MIPS16E_RR_RY_JRRA 0x01
766#define MIPS16E_RR_RY_JALR 0x02
767#define MIPS16E_RR_RY_JRCRX 0x04
768#define MIPS16E_RR_RY_JRCRA 0x05
769#define MIPS16E_RR_RY_JALRC 0x06
770
771#define MIPS16E_OPCODE_BREAK 0xE805
772#define MIPS16E_OPCODE_NOP 0x6500
773
774/* MIPS reset vector */
775#define MIPS_RESET_VECTOR 0x1fc00000
776
777/* Clock periods per count register increment */
778#define MIPS4K_COUNT_CLK_PER_CYCLE 2
779#define MIPS5K_COUNT_CLK_PER_CYCLE 2
780#define MIPS20Kc_COUNT_CLK_PER_CYCLE 1
781
782
783/**** MIPS 4K/5K families specific fields of CONFIG register ****/
784
785#define C0_CONFIG_MIPS4K5K_K23_SHF S_ConfigK23
786#define C0_CONFIG_MIPS4K5K_K23_MSK (MSK(3) << C0_CONFIG_MIPS4K5K_K23_SHF)
787
788#define C0_CONFIG_MIPS4K5K_KU_SHF S_ConfigKU
789#define C0_CONFIG_MIPS4K5K_KU_MSK (MSK(3) << C0_CONFIG_MIPS4K5K_KU_SHF)
790
791
792/**** MIPS 20Kc specific fields of CONFIG register ****/
793
794#define C0_CONFIG_MIPS20KC_EC_SHF 28
795#define C0_CONFIG_MIPS20KC_EC_MSK (MSK(3) << C0_CONFIG_MIPS20KC_EC_SHF)
796
797#define C0_CONFIG_MIPS20KC_DD_SHF 27
798#define C0_CONFIG_MIPS20KC_DD_MSK (MSK(1) << C0_CONFIG_MIPS20KC_DD_SHF)
799#define C0_CONFIG_MIPS20KC_DD_BIT C0_CONFIG_MIPS20KC_DD_MSK
800
801#define C0_CONFIG_MIPS20KC_LP_SHF 26
802#define C0_CONFIG_MIPS20KC_LP_MSK (MSK(1) << C0_CONFIG_MIPS20KC_LP_SHF)
803#define C0_CONFIG_MIPS20KC_LP_BIT C0_CONFIG_MIPS20KC_LP_MSK
804
805#define C0_CONFIG_MIPS20KC_SP_SHF 25
806#define C0_CONFIG_MIPS20KC_SP_MSK (MSK(1) << C0_CONFIG_MIPS20KC_SP_SHF)
807#define C0_CONFIG_MIPS20KC_SP_BIT C0_CONFIG_MIPS20KC_SP_MSK
808
809#define C0_CONFIG_MIPS20KC_TI_SHF 24
810#define C0_CONFIG_MIPS20KC_TI_MSK (MSK(1) << C0_CONFIG_MIPS20KC_TI_SHF)
811#define C0_CONFIG_MIPS20KC_TI_BIT C0_CONFIG_MIPS20KC_TI_MSK
812
813
814/* ********************************************************************* */
815/* Interface function definition */
816
817
818/* ********************************************************************* */
819
820#endif /* #ifndef __MIPS_H__ */
diff --git a/utils/hwstub/stub/atj213x/target-config.h b/utils/hwstub/stub/atj213x/target-config.h
new file mode 100644
index 0000000000..081cccc581
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/target-config.h
@@ -0,0 +1,12 @@
1#define CONFIG_ATJ213X
2#define IRAM_ORIG 0x94040000 /* KSEG1 cached unmapped */
3#define IRAM_SIZE 0x18000
4#define DRAM_ORIG 0x80000000 /* KSEG1 cached unmapped */
5#define DRAM_SIZE 0x800000
6#define CPU_MIPS
7
8/* something provides define
9 * #define mips 1
10 * which breaks paths badly
11 */
12#undef mips
diff --git a/utils/hwstub/stub/atj213x/target.c b/utils/hwstub/stub/atj213x/target.c
new file mode 100644
index 0000000000..04762bca00
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/target.c
@@ -0,0 +1,113 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2014 by Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include "stddef.h"
21#include "target.h"
22#include "system.h"
23#include "logf.h"
24#include "atj213x.h"
25
26#define CORE_FREQ 7500000
27#define HZ 1000000
28
29static void backlight_init(void)
30{
31 /* backlight clock enable, select backlight clock as 32kHz */
32 CMU_FMCLK = (CMU_FMCLK & ~(CMU_FMCLK_BCLK_MASK)) | CMU_FMCLK_BCKE | CMU_FMCLK_BCLK_32K;
33
34 /* baclight enable */
35 PMU_CTL |= PMU_CTL_BL_EN;
36
37 /* pwm output, phase high, some initial duty cycle set as 24/32 */
38 PMU_CHG = ((PMU_CHG & ~PMU_CHG_PDOUT_MASK)| PMU_CHG_PBLS_PWM | PMU_CHG_PPHS_HIGH | PMU_CHG_PDUT(24));
39
40}
41
42void backlight_set(int level)
43{
44 /* set duty cycle in 1/32 units */
45 PMU_CHG = ((PMU_CHG & ~PMU_CHG_PDOUT_MASK) | PMU_CHG_PDUT(level));
46}
47
48void target_udelay(int us)
49{
50 unsigned int i = us * (CORE_FREQ / 2000000);
51 asm volatile (
52 ".set noreorder \n"
53 "1: \n"
54 "bnez %0, 1b \n"
55 "addiu %0, %0, -1 \n"
56 ".set reorder \n"
57 : "=r" (i)
58 : "0" (i)
59 );
60}
61
62void target_mdelay(int ms)
63{
64 return target_udelay(ms * 1000);
65}
66
67void blink(int cnt)
68{
69 int i;
70
71 for (i=0; i<cnt; i++)
72 {
73 backlight_set(0);
74 target_mdelay(300);
75 backlight_set(24);
76 target_mdelay(300);
77 }
78}
79
80void target_init(void)
81{
82 RTC_WDCTL = (RTC_WDCTL & ~(1<<4))|(1<<6)|1; /* disable WDT */
83
84 /* Configure USB interrupt as IP6. IP6 is unmasked in crt0.S */
85 INTC_CFG0 = 0;
86 INTC_CFG1 = 0;
87 INTC_CFG2 = (1<<4);
88
89 /* mask all interrupts to avoid pending irq servicing */
90 INTC_MSK = 0;
91
92 backlight_init();
93}
94
95struct hwstub_target_desc_t __attribute__((aligned(2))) target_descriptor =
96{
97 sizeof(struct hwstub_target_desc_t),
98 HWSTUB_DT_TARGET,
99 HWSTUB_TARGET_ATJ,
100 "ATJ213X"
101};
102
103void target_get_desc(int desc, void **buffer)
104{
105 (void) desc;
106 *buffer = NULL;
107}
108
109void target_get_config_desc(void *buffer, int *size)
110{
111 (void) buffer;
112 (void) size;
113}
diff --git a/utils/hwstub/stub/atj213x/usb_drv_atj213x.c b/utils/hwstub/stub/atj213x/usb_drv_atj213x.c
new file mode 100644
index 0000000000..ef66766527
--- /dev/null
+++ b/utils/hwstub/stub/atj213x/usb_drv_atj213x.c
@@ -0,0 +1,267 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2014 by Marcin Bukat
10 Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "usb_drv.h"
23#include "config.h"
24#include "memory.h"
25#include "target.h"
26#include "atj213x.h"
27
28#define USB_FULL_SPEED 0
29#define USB_HIGH_SPEED 1
30
31volatile bool setup_data_valid = false;
32volatile int udc_speed = USB_FULL_SPEED;
33
34static void usb_copy_from(void *ptr, volatile void *reg, size_t sz)
35{
36 uint32_t *p = ptr;
37 volatile uint32_t *rp = reg;
38 /* do not overflow the destination buffer ! */
39 while(sz >= 4)
40 {
41 *p++ = *rp++;
42 sz -= 4;
43 }
44
45 if(sz == 0)
46 return;
47
48 /* reminder */
49 uint32_t cache = *rp;
50 uint8_t *p8 = (void *)p;
51 while(sz-- > 0)
52 {
53 *p8++ = cache;
54 cache >>= 8;
55 }
56}
57
58static void usb_copy_to(volatile void *reg, void *ptr, size_t sz)
59{
60 uint32_t *p = ptr;
61 volatile uint32_t *rp = reg;
62 sz = (sz + 3) / 4;
63 /* read may overflow the source buffer but
64 * it will not overwrite anything
65 */
66 while(sz-- > 0)
67 *rp++ = *p++;
68}
69
70void INT_UDC(void)
71{
72 /* get possible sources */
73 unsigned int usbirq = OTG_USBIRQ;
74 unsigned int otgirq = OTG_OTGIRQ;
75#if 0
76 unsigned int usbeirq = OTG_USBEIRQ;
77 unsigned int epinirq = OTG_IN04IRQ;
78 unsigned int epoutirq = OTG_OUT04IRQ;
79#endif
80
81 /* HS, Reset, Setup */
82 if (usbirq)
83 {
84
85 if (usbirq & (1<<5))
86 {
87 /* HS irq */
88 udc_speed = USB_HIGH_SPEED;
89 }
90 else if (usbirq & (1<<4))
91 {
92 /* Reset */
93 udc_speed = USB_FULL_SPEED;
94
95 /* clear all pending irqs */
96 OTG_OUT04IRQ = 0xff;
97 OTG_IN04IRQ = 0xff;
98 }
99 else if (usbirq & (1<<0))
100 {
101 /* Setup data valid */
102 setup_data_valid = true;
103 }
104
105 /* clear irq flags */
106 OTG_USBIRQ = usbirq;
107 }
108
109#if 0
110 if (epoutirq)
111 {
112 OTG_OUT04IRQ = epoutirq;
113 }
114
115 if (epinirq)
116 {
117 OTG_IN04IRQ = epinirq;
118 }
119#endif
120
121 if (otgirq)
122 {
123 OTG_OTGIRQ = otgirq;
124 }
125
126 OTG_USBEIRQ = 0x50;
127}
128
129void usb_drv_init(void)
130{
131 OTG_USBCS |= 0x40; /* soft disconnect */
132
133 OTG_ENDPRST = 0x10; /* reset all ep fifos */
134 OTG_ENDPRST = 0x70;
135 OTG_ENDPRST = 0x00;
136 OTG_ENDPRST = 0x60;
137
138 OTG_USBIRQ = 0xff; /* clear all pending interrupts */
139 OTG_OTGIRQ = 0xff;
140 OTG_IN04IRQ = 0xff;
141 OTG_OUT04IRQ = 0xff;
142 OTG_USBEIRQ = 0x50; /* UDC ? with 0x40 there is irq storm */
143
144 OTG_USBIEN = (1<<5) | (1<<4) | (1<<0); /* HS, Reset, Setup_data */
145 OTG_OTGIEN = 0;
146
147 /* disable interrupts from ep0 */
148 OTG_IN04IEN = 0;
149 OTG_OUT04IEN = 0;
150
151 /* unmask UDC interrupt in interrupt controller */
152 INTC_MSK = (1<<4);
153
154 target_mdelay(100);
155
156 OTG_USBCS &= ~0x40; /* soft connect */
157}
158
159int usb_drv_recv_setup(struct usb_ctrlrequest *req)
160{
161 while (!setup_data_valid)
162 ;
163
164 usb_copy_from(req, &OTG_SETUPDAT, sizeof(struct usb_ctrlrequest));
165 setup_data_valid = false;
166 return 0;
167}
168
169int usb_drv_port_speed(void)
170{
171 return (int)udc_speed;
172}
173
174/* Set the address (usually it's in a register).
175 * There is a problem here: some controller want the address to be set between
176 * control out and ack and some want to wait for the end of the transaction.
177 * In the first case, you need to write some code special code when getting
178 * setup packets and ignore this function (have a look at other drives)
179 */
180void usb_drv_set_address(int address)
181{
182 (void)address;
183 /* UDC sets this automaticaly */
184}
185
186/* TODO: Maybe adapt to irq scheme */
187int usb_drv_send(int endpoint, void *ptr, int length)
188{
189 (void)endpoint;
190
191 int xfer_size, cnt = length;
192
193 while (cnt)
194 {
195 xfer_size = MIN(cnt, 64);
196
197 /* copy data to ep0in buffer */
198 usb_copy_to(&OTG_EP0INDAT, ptr, xfer_size);
199
200 /* this marks data as ready to send */
201 OTG_IN0BC = xfer_size;
202
203 /* wait for the transfer end */
204 while(OTG_EP0CS & 0x04)
205 ;
206
207 cnt -= xfer_size;
208 ptr += xfer_size;
209 }
210
211 /* ZLP stage */
212 if((length % 64) == 0)
213 OTG_EP0CS = 2;
214
215 return 0;
216}
217
218/* TODO: Maybe adapt to irq scheme */
219int usb_drv_recv(int endpoint, void* ptr, int length)
220{
221 (void)endpoint;
222 int xfer_size, cnt = 0;
223
224 while (cnt < length)
225 {
226 /* Arm receiving buffer by writing
227 * any value to OUT0BC. This sets
228 * OUT_BUSY bit in EP0CS until the data
229 * are correctly received and ACK'd
230 */
231 OTG_OUT0BC = 0;
232
233 while (OTG_EP0CS & 0x08)
234 ;
235
236 xfer_size = OTG_OUT0BC;
237
238 usb_copy_from(ptr, &OTG_EP0OUTDAT, xfer_size);
239 cnt += xfer_size;
240 ptr += xfer_size;
241
242 if (xfer_size < 64)
243 break;
244 }
245
246 /* ZLP stage */
247 if (length == 0)
248 OTG_EP0CS = 2;
249
250 return cnt;
251}
252
253void usb_drv_stall(int endpoint, bool stall, bool in)
254{
255 (void)endpoint;
256 (void)in;
257
258 /* only EP0 in hwstub */
259 if (stall)
260 OTG_EP0CS |= 1;
261 else
262 OTG_EP0CS &= ~1;
263}
264
265void usb_drv_exit(void)
266{
267}
diff --git a/utils/hwstub/stub/main.c b/utils/hwstub/stub/main.c
index 8139615239..4e54b8fd89 100644
--- a/utils/hwstub/stub/main.c
+++ b/utils/hwstub/stub/main.c
@@ -178,17 +178,17 @@ static void handle_std_dev_desc(struct usb_ctrlrequest *req)
178 case USB_DT_OTHER_SPEED_CONFIG: 178 case USB_DT_OTHER_SPEED_CONFIG:
179 case USB_DT_CONFIG: 179 case USB_DT_CONFIG:
180 { 180 {
181 int max_packet_size; 181 /* int max_packet_size; */
182 182
183 /* config desc */ 183 /* config desc */
184 if((req->wValue >> 8) ==USB_DT_CONFIG) 184 if((req->wValue >> 8) == USB_DT_CONFIG)
185 { 185 {
186 max_packet_size = (usb_drv_port_speed() ? 512 : 64); 186 /* max_packet_size = (usb_drv_port_speed() ? 512 : 64); */
187 config_descriptor.bDescriptorType = USB_DT_CONFIG; 187 config_descriptor.bDescriptorType = USB_DT_CONFIG;
188 } 188 }
189 else 189 else
190 { 190 {
191 max_packet_size = (usb_drv_port_speed() ? 64 : 512); 191 /* max_packet_size = (usb_drv_port_speed() ? 64 : 512); */
192 config_descriptor.bDescriptorType = USB_DT_OTHER_SPEED_CONFIG; 192 config_descriptor.bDescriptorType = USB_DT_OTHER_SPEED_CONFIG;
193 } 193 }
194 size = sizeof(struct usb_config_descriptor); 194 size = sizeof(struct usb_config_descriptor);
@@ -411,10 +411,13 @@ static void handle_exec(struct usb_ctrlrequest *req)
411 411
412 if(exec->bmFlags & HWSTUB_EXEC_CALL) 412 if(exec->bmFlags & HWSTUB_EXEC_CALL)
413 { 413 {
414#ifdef CPU_ARM 414#if defined(CPU_ARM)
415 /* in case of call, respond after return */ 415 /* in case of call, respond after return */
416 asm volatile("blx %0\n" : : "r"(addr) : "memory"); 416 asm volatile("blx %0\n" : : "r"(addr) : "memory");
417 usb_drv_send(EP_CONTROL, NULL, 0); 417 usb_drv_send(EP_CONTROL, NULL, 0);
418#elif defined(CPU_MIPS)
419 asm volatile("jalr %0\nnop\n" : : "r"(addr) : "memory");
420 usb_drv_send(EP_CONTROL, NULL, 0);
418#else 421#else
419#warning call is unsupported on this platform 422#warning call is unsupported on this platform
420 usb_drv_stall(EP_CONTROL, true, true); 423 usb_drv_stall(EP_CONTROL, true, true);
@@ -425,9 +428,11 @@ static void handle_exec(struct usb_ctrlrequest *req)
425 /* in case of jump, respond immediately and disconnect usb */ 428 /* in case of jump, respond immediately and disconnect usb */
426 usb_drv_send(EP_CONTROL, NULL, 0); 429 usb_drv_send(EP_CONTROL, NULL, 0);
427 usb_drv_exit(); 430 usb_drv_exit();
428#ifdef CPU_ARM 431#if defined(CPU_ARM)
429 asm volatile("bx %0\n" : : "r" (addr) : "memory"); 432 asm volatile("bx %0\n" : : "r" (addr) : "memory");
430#else 433#elif defined(CPU_MIPS)
434 asm volatile("jr %0\nnop\n" : : "r" (addr) : "memory");
435#else
431#warning jump is unsupported on this platform 436#warning jump is unsupported on this platform
432 usb_drv_stall(EP_CONTROL, true, true); 437 usb_drv_stall(EP_CONTROL, true, true);
433#endif 438#endif