| 1 |
786 |
skrzyp |
//========================================================================
|
| 2 |
|
|
//
|
| 3 |
|
|
// pmon.S
|
| 4 |
|
|
//
|
| 5 |
|
|
// Low-level entry points into PMON monitor.
|
| 6 |
|
|
//
|
| 7 |
|
|
//========================================================================
|
| 8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
| 9 |
|
|
// -------------------------------------------
|
| 10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
| 11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
| 12 |
|
|
//
|
| 13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
| 14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
| 15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
| 16 |
|
|
// version.
|
| 17 |
|
|
//
|
| 18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
| 19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 21 |
|
|
// for more details.
|
| 22 |
|
|
//
|
| 23 |
|
|
// You should have received a copy of the GNU General Public License
|
| 24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
| 25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 26 |
|
|
//
|
| 27 |
|
|
// As a special exception, if other files instantiate templates or use
|
| 28 |
|
|
// macros or inline functions from this file, or you compile this file
|
| 29 |
|
|
// and link it with other works to produce a work based on this file,
|
| 30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
| 31 |
|
|
// the GNU General Public License. However the source code for this file
|
| 32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
| 33 |
|
|
// General Public License v2.
|
| 34 |
|
|
//
|
| 35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
| 36 |
|
|
// on this file might be covered by the GNU General Public License.
|
| 37 |
|
|
// -------------------------------------------
|
| 38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
| 39 |
|
|
//========================================================================
|
| 40 |
|
|
//#####DESCRIPTIONBEGIN####
|
| 41 |
|
|
//
|
| 42 |
|
|
// Author(s): Red Hat, nickg
|
| 43 |
|
|
// Contributors: Red Hat, nickg
|
| 44 |
|
|
// Date: 1999-04-21
|
| 45 |
|
|
// Purpose:
|
| 46 |
|
|
// Description: Low-level entry points into PMON monitor.
|
| 47 |
|
|
// Usage:
|
| 48 |
|
|
//
|
| 49 |
|
|
//####DESCRIPTIONEND####
|
| 50 |
|
|
//
|
| 51 |
|
|
//========================================================================
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
#ifdef __mips16
|
| 55 |
|
|
/* This file contains 32 bit assembly code. */
|
| 56 |
|
|
.set nomips16
|
| 57 |
|
|
#endif
|
| 58 |
|
|
|
| 59 |
|
|
#if __mips < 3
|
| 60 |
|
|
/* This machine does not support 64-bit operations. */
|
| 61 |
|
|
#define ADDU addu
|
| 62 |
|
|
#define SUBU subu
|
| 63 |
|
|
#else
|
| 64 |
|
|
/* This machine supports 64-bit operations. */
|
| 65 |
|
|
#define ADDU daddu
|
| 66 |
|
|
#define SUBU dsubu
|
| 67 |
|
|
#endif
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
/* Standard MIPS register names: */
|
| 71 |
|
|
#define zero $0
|
| 72 |
|
|
#define z0 $0
|
| 73 |
|
|
#define v0 $2
|
| 74 |
|
|
#define v1 $3
|
| 75 |
|
|
#define a0 $4
|
| 76 |
|
|
#define a1 $5
|
| 77 |
|
|
#define a2 $6
|
| 78 |
|
|
#define a3 $7
|
| 79 |
|
|
#define t0 $8
|
| 80 |
|
|
#define t1 $9
|
| 81 |
|
|
#define t2 $10
|
| 82 |
|
|
#define t3 $11
|
| 83 |
|
|
#define t4 $12
|
| 84 |
|
|
#define t5 $13
|
| 85 |
|
|
#define t6 $14
|
| 86 |
|
|
#define t7 $15
|
| 87 |
|
|
#define s0 $16
|
| 88 |
|
|
#define s1 $17
|
| 89 |
|
|
#define s2 $18
|
| 90 |
|
|
#define s3 $19
|
| 91 |
|
|
#define s4 $20
|
| 92 |
|
|
#define s5 $21
|
| 93 |
|
|
#define s6 $22
|
| 94 |
|
|
#define s7 $23
|
| 95 |
|
|
#define t8 $24
|
| 96 |
|
|
#define t9 $25
|
| 97 |
|
|
#define k0 $26 /* kernel private register 0 */
|
| 98 |
|
|
#define k1 $27 /* kernel private register 1 */
|
| 99 |
|
|
#define gp $28 /* global data pointer */
|
| 100 |
|
|
#define sp $29 /* stack-pointer */
|
| 101 |
|
|
#define fp $30 /* frame-pointer */
|
| 102 |
|
|
#define ra $31 /* return address */
|
| 103 |
|
|
#define pc $pc /* pc, used on mips16 */
|
| 104 |
|
|
|
| 105 |
|
|
#define fp0 $f0
|
| 106 |
|
|
#define fp1 $f1
|
| 107 |
|
|
|
| 108 |
|
|
/* Useful memory constants: */
|
| 109 |
|
|
#define K0BASE 0x80000000
|
| 110 |
|
|
#ifndef __mips64
|
| 111 |
|
|
#define K1BASE 0xA0000000
|
| 112 |
|
|
#else
|
| 113 |
|
|
#define K1BASE 0xFFFFFFFFA0000000LL
|
| 114 |
|
|
#endif
|
| 115 |
|
|
|
| 116 |
|
|
#define PHYS_TO_K1(a) ((unsigned)(a) | K1BASE)
|
| 117 |
|
|
|
| 118 |
|
|
/* Standard Co-Processor 0 register numbers: */
|
| 119 |
|
|
#define C0_COUNT $9 /* Count Register */
|
| 120 |
|
|
#define C0_SR $12 /* Status Register */
|
| 121 |
|
|
#define C0_CAUSE $13 /* last exception description */
|
| 122 |
|
|
#define C0_EPC $14 /* Exception error address */
|
| 123 |
|
|
#define C0_CONFIG $16 /* CPU configuration */
|
| 124 |
|
|
|
| 125 |
|
|
/* Standard Status Register bitmasks: */
|
| 126 |
|
|
#define SR_CU1 0x20000000 /* Mark CP1 as usable */
|
| 127 |
|
|
#define SR_FR 0x04000000 /* Enable MIPS III FP registers */
|
| 128 |
|
|
#define SR_BEV 0x00400000 /* Controls location of exception vectors */
|
| 129 |
|
|
#define SR_PE 0x00100000 /* Mark soft reset (clear parity error) */
|
| 130 |
|
|
|
| 131 |
|
|
#define SR_KX 0x00000080 /* Kernel extended addressing enabled */
|
| 132 |
|
|
#define SR_SX 0x00000040 /* Supervisor extended addressing enabled */
|
| 133 |
|
|
#define SR_UX 0x00000020 /* User extended addressing enabled */
|
| 134 |
|
|
|
| 135 |
|
|
/* Standard (R4000) cache operations. Taken from "MIPS R4000
|
| 136 |
|
|
Microprocessor User's Manual" 2nd edition: */
|
| 137 |
|
|
|
| 138 |
|
|
#define CACHE_I (0) /* primary instruction */
|
| 139 |
|
|
#define CACHE_D (1) /* primary data */
|
| 140 |
|
|
#define CACHE_SI (2) /* secondary instruction */
|
| 141 |
|
|
#define CACHE_SD (3) /* secondary data (or combined instruction/data) */
|
| 142 |
|
|
|
| 143 |
|
|
#define INDEX_INVALIDATE (0) /* also encodes WRITEBACK if CACHE_D or CACHE_SD */
|
| 144 |
|
|
#define INDEX_LOAD_TAG (1)
|
| 145 |
|
|
#define INDEX_STORE_TAG (2)
|
| 146 |
|
|
#define CREATE_DIRTY_EXCLUSIVE (3) /* CACHE_D and CACHE_SD only */
|
| 147 |
|
|
#define HIT_INVALIDATE (4)
|
| 148 |
|
|
#define CACHE_FILL (5) /* CACHE_I only */
|
| 149 |
|
|
#define HIT_WRITEBACK_INVALIDATE (5) /* CACHE_D and CACHE_SD only */
|
| 150 |
|
|
#define HIT_WRITEBACK (6) /* CACHE_I, CACHE_D and CACHE_SD only */
|
| 151 |
|
|
#define HIT_SET_VIRTUAL (7) /* CACHE_SI and CACHE_SD only */
|
| 152 |
|
|
|
| 153 |
|
|
#define BUILD_CACHE_OP(o,c) (((o) << 2) | (c))
|
| 154 |
|
|
|
| 155 |
|
|
/* Individual cache operations: */
|
| 156 |
|
|
#define INDEX_INVALIDATE_I BUILD_CACHE_OP(INDEX_INVALIDATE,CACHE_I)
|
| 157 |
|
|
#define INDEX_WRITEBACK_INVALIDATE_D BUILD_CACHE_OP(INDEX_INVALIDATE,CACHE_D)
|
| 158 |
|
|
#define INDEX_INVALIDATE_SI BUILD_CACHE_OP(INDEX_INVALIDATE,CACHE_SI)
|
| 159 |
|
|
#define INDEX_WRITEBACK_INVALIDATE_SD BUILD_CACHE_OP(INDEX_INVALIDATE,CACHE_SD)
|
| 160 |
|
|
|
| 161 |
|
|
#define INDEX_LOAD_TAG_I BUILD_CACHE_OP(INDEX_LOAD_TAG,CACHE_I)
|
| 162 |
|
|
#define INDEX_LOAD_TAG_D BUILD_CACHE_OP(INDEX_LOAD_TAG,CACHE_D)
|
| 163 |
|
|
#define INDEX_LOAD_TAG_SI BUILD_CACHE_OP(INDEX_LOAD_TAG,CACHE_SI)
|
| 164 |
|
|
#define INDEX_LOAD_TAG_SD BUILD_CACHE_OP(INDEX_LOAD_TAG,CACHE_SD)
|
| 165 |
|
|
|
| 166 |
|
|
#define INDEX_STORE_TAG_I BUILD_CACHE_OP(INDEX_STORE_TAG,CACHE_I)
|
| 167 |
|
|
#define INDEX_STORE_TAG_D BUILD_CACHE_OP(INDEX_STORE_TAG,CACHE_D)
|
| 168 |
|
|
#define INDEX_STORE_TAG_SI BUILD_CACHE_OP(INDEX_STORE_TAG,CACHE_SI)
|
| 169 |
|
|
#define INDEX_STORE_TAG_SD BUILD_CACHE_OP(INDEX_STORE_TAG,CACHE_SD)
|
| 170 |
|
|
|
| 171 |
|
|
#define CREATE_DIRTY_EXCLUSIVE_D BUILD_CACHE_OP(CREATE_DIRTY_EXCLUSIVE,CACHE_D)
|
| 172 |
|
|
#define CREATE_DIRTY_EXCLUSIVE_SD BUILD_CACHE_OP(CREATE_DIRTY_EXCLUSIVE,CACHE_SD)
|
| 173 |
|
|
|
| 174 |
|
|
#define HIT_INVALIDATE_I BUILD_CACHE_OP(HIT_INVALIDATE,CACHE_I)
|
| 175 |
|
|
#define HIT_INVALIDATE_D BUILD_CACHE_OP(HIT_INVALIDATE,CACHE_D)
|
| 176 |
|
|
#define HIT_INVALIDATE_SI BUILD_CACHE_OP(HIT_INVALIDATE,CACHE_SI)
|
| 177 |
|
|
#define HIT_INVALIDATE_SD BUILD_CACHE_OP(HIT_INVALIDATE,CACHE_SD)
|
| 178 |
|
|
|
| 179 |
|
|
#define CACHE_FILL_I BUILD_CACHE_OP(CACHE_FILL,CACHE_I)
|
| 180 |
|
|
#define HIT_WRITEBACK_INVALIDATE_D BUILD_CACHE_OP(HIT_WRITEBACK_INVALIDATE,CACHE_D)
|
| 181 |
|
|
#define HIT_WRITEBACK_INVALIDATE_SD BUILD_CACHE_OP(HIT_WRITEBACK_INVALIDATE,CACHE_SD)
|
| 182 |
|
|
|
| 183 |
|
|
#define HIT_WRITEBACK_I BUILD_CACHE_OP(HIT_WRITEBACK,CACHE_I)
|
| 184 |
|
|
#define HIT_WRITEBACK_D BUILD_CACHE_OP(HIT_WRITEBACK,CACHE_D)
|
| 185 |
|
|
#define HIT_WRITEBACK_SD BUILD_CACHE_OP(HIT_WRITEBACK,CACHE_SD)
|
| 186 |
|
|
|
| 187 |
|
|
#define HIT_SET_VIRTUAL_SI BUILD_CACHE_OP(HIT_SET_VIRTUAL,CACHE_SI)
|
| 188 |
|
|
#define HIT_SET_VIRTUAL_SD BUILD_CACHE_OP(HIT_SET_VIRTUAL,CACHE_SD)
|
| 189 |
|
|
|
| 190 |
|
|
.text
|
| 191 |
|
|
.align 2
|
| 192 |
|
|
|
| 193 |
|
|
#ifdef LSI
|
| 194 |
|
|
#define PMON_VECTOR 0xffffffffbfc00200
|
| 195 |
|
|
#else
|
| 196 |
|
|
#define PMON_VECTOR 0xffffffffbfc00500
|
| 197 |
|
|
#endif
|
| 198 |
|
|
|
| 199 |
|
|
#ifndef __mips_eabi
|
| 200 |
|
|
/* Provide named functions for entry into the monitor: */
|
| 201 |
|
|
#define INDIRECT(name,index) \
|
| 202 |
|
|
.globl name; \
|
| 203 |
|
|
.ent name; \
|
| 204 |
|
|
.set noreorder; \
|
| 205 |
|
|
name: la $2,+(PMON_VECTOR+((index)*4)); \
|
| 206 |
|
|
lw $2,0($2); \
|
| 207 |
|
|
j $2; \
|
| 208 |
|
|
nop; \
|
| 209 |
|
|
.set reorder; \
|
| 210 |
|
|
.end name
|
| 211 |
|
|
|
| 212 |
|
|
#else
|
| 213 |
|
|
#define INDIRECT(name,index) \
|
| 214 |
|
|
.globl name; \
|
| 215 |
|
|
.ent name; \
|
| 216 |
|
|
.set noreorder; \
|
| 217 |
|
|
name: la $2,+(PMON_VECTOR+((index)*4)); \
|
| 218 |
|
|
lw $2,0($2); \
|
| 219 |
|
|
SUBU sp,sp,0x40; \
|
| 220 |
|
|
sd ra,0x38(sp); \
|
| 221 |
|
|
sd fp,0x30(sp); \
|
| 222 |
|
|
jal $2; \
|
| 223 |
|
|
move fp,sp; \
|
| 224 |
|
|
ld ra,0x38(sp); \
|
| 225 |
|
|
ld fp,0x30(sp); \
|
| 226 |
|
|
j ra; \
|
| 227 |
|
|
ADDU sp,sp,0x40; \
|
| 228 |
|
|
.set reorder; \
|
| 229 |
|
|
.end name
|
| 230 |
|
|
#endif
|
| 231 |
|
|
|
| 232 |
|
|
|
| 233 |
|
|
/* The following magic numbers are for the slots into the PMON monitor */
|
| 234 |
|
|
/* The first are used as the lo-level library run-time: */
|
| 235 |
|
|
INDIRECT(pmon_read,0)
|
| 236 |
|
|
INDIRECT(pmon_write,1)
|
| 237 |
|
|
INDIRECT(pmon_open,2)
|
| 238 |
|
|
INDIRECT(pmon_close,3)
|
| 239 |
|
|
/* The following are useful monitor routines: */
|
| 240 |
|
|
INDIRECT(pmon_ioctl,4)
|
| 241 |
|
|
INDIRECT(pmon_printf,5)
|
| 242 |
|
|
INDIRECT(pmon_vsprintf,6)
|
| 243 |
|
|
INDIRECT(pmon_ttctl,7)
|
| 244 |
|
|
INDIRECT(pmon_cliexit,8)
|
| 245 |
|
|
INDIRECT(pmon_getenv,9)
|
| 246 |
|
|
INDIRECT(pmon_onintr,10)
|
| 247 |
|
|
INDIRECT(pmon_flush_cache,11)
|
| 248 |
|
|
INDIRECT(pmon_exception,12)
|
| 249 |
|
|
|
| 250 |
|
|
/* The following routine is required by the "print()" function: */
|
| 251 |
|
|
.globl pmon_outbyte
|
| 252 |
|
|
.ent pmon_outbyte
|
| 253 |
|
|
.set noreorder
|
| 254 |
|
|
pmon_outbyte:
|
| 255 |
|
|
subu sp,sp,0x20 /* allocate stack space for string */
|
| 256 |
|
|
sd ra,0x18(sp) /* stack return address */
|
| 257 |
|
|
sd fp,0x10(sp) /* stack frame-pointer */
|
| 258 |
|
|
move fp,sp /* take a copy of the stack pointer */
|
| 259 |
|
|
/* We leave so much space on the stack for the string (16
|
| 260 |
|
|
characters), since the call to mon_printf seems to corrupt
|
| 261 |
|
|
the 8bytes at offset 8 into the string/stack. */
|
| 262 |
|
|
sb a0,0x00(sp) /* character to print */
|
| 263 |
|
|
sb z0,0x01(sp) /* NUL terminator */
|
| 264 |
|
|
jal pmon_printf /* and output the string */
|
| 265 |
|
|
move a0,sp /* take a copy of the string pointer {DELAY SLOT} */
|
| 266 |
|
|
|
| 267 |
|
|
move sp,fp /* recover stack pointer */
|
| 268 |
|
|
ld ra,0x18(sp) /* recover return address */
|
| 269 |
|
|
ld fp,0x10(sp) /* recover frame-pointer */
|
| 270 |
|
|
j ra /* return to the caller */
|
| 271 |
|
|
addu sp,sp,0x20 /* dump the stack space {DELAY SLOT} */
|
| 272 |
|
|
.set reorder
|
| 273 |
|
|
.end pmon_outbyte
|
| 274 |
|
|
|
| 275 |
|
|
/* EOF pmon.S */
|