2 * pmon.S -- low-level entry points into PMON monitor.
4 * Copyright (c) 1996, 1997, 2002 Cygnus Support
6 * The authors hereby grant permission to use, copy, modify, distribute,
7 * and license this software and its documentation for any purpose, provided
8 * that existing copyright notices are retained in all copies and that this
9 * notice is included verbatim in any distributions. No written agreement,
10 * license, or royalty fee is required for any of the authorized uses.
11 * Modifications to this software may be copyrighted by their authors
12 * and need not follow the licensing terms described here, provided that
13 * the new terms are clearly indicated on the first page of each file where
18 /* This file contains 32 bit assembly code. */
22 #if !defined(__mips64)
23 /* This machine does not support 64-bit operations. */
27 /* This machine supports 64-bit operations. */
38 #define PMON_VECTOR 0xffffffffbfc00200
40 #define PMON_VECTOR 0xffffffffbfc00500
44 /* Provide named functions for entry into the monitor: */
45 #define INDIRECT(name,index) \
49 name: la $2,+(PMON_VECTOR+((index)*4)); \
57 #define INDIRECT(name,index) \
61 name: la $2,+(PMON_VECTOR+((index)*4)); \
77 /* The following magic numbers are for the slots into the PMON monitor */
78 /* The first are used as the lo-level library run-time: */
83 /* The following are useful monitor routines: */
85 INDIRECT(mon_printf,5)
86 INDIRECT(mon_vsprintf,6)
88 INDIRECT(mon_cliexit,8)
89 INDIRECT(mon_getenv,9)
90 INDIRECT(mon_onintr,10)
91 INDIRECT(mon_flush_cache,11)
92 INDIRECT(_flush_cache,11)
93 INDIRECT(mon_exception,12)
95 /* The following routine is required by the "print()" function: */
100 subu sp,sp,0x20 /* allocate stack space for string */
101 sd ra,0x18(sp) /* stack return address */
102 sd fp,0x10(sp) /* stack frame-pointer */
103 move fp,sp /* take a copy of the stack pointer */
104 /* We leave so much space on the stack for the string (16
105 characters), since the call to mon_printf seems to corrupt
106 the 8bytes at offset 8 into the string/stack. */
107 sb a0,0x00(sp) /* character to print */
108 sb z0,0x01(sp) /* NUL terminator */
109 jal mon_printf /* and output the string */
110 move a0,sp /* take a copy of the string pointer {DELAY SLOT} */
112 move sp,fp /* recover stack pointer */
113 ld ra,0x18(sp) /* recover return address */
114 ld fp,0x10(sp) /* recover frame-pointer */
115 j ra /* return to the caller */
116 addu sp,sp,0x20 /* dump the stack space {DELAY SLOT} */
120 /* The following routine is required by the "sbrk()" function: */
125 # in: a0 = pointer to 3 word structure
127 subu sp,sp,0x18 /* create some stack space */
128 sd ra,0x00(sp) /* stack return address */
129 sd fp,0x08(sp) /* stack frame-pointer */
130 sd a0,0x10(sp) /* stack structure pointer */
131 move fp,sp /* take a copy of the stack pointer */
133 # The monitor has already sized memory, but unfortunately we
134 # do not have access to the data location containing the
140 ld a0,0x10(sp) # recover structure pointer
141 sw v0,0(a0) # amount of memory available
143 # Deal with getting the cache size information:
147 andi a2,a1,0x7 << 9 # bits 11..9 for instruction cache size
150 andi a2,a1,0x7 << 6 # bits 8..6 for data cache size
152 sw a2,8(a0) # data cache size
154 move sp,fp /* recover stack pointer */
155 ld ra,0x00(sp) /* recover return address */
156 ld fp,0x08(sp) /* recover frame-pointer */
157 j ra /* return to the caller */
158 addu sp,sp,0x18 /* restore stack pointer {DELAY SLOT} */
164 # For the LSI MiniRISC board, we can safely assume that we have
165 # at least one megabyte of RAM.