OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [vrc437x/] [v2_0/] [src/] [pmon.S] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.