dbmentry.S revision 8008:257eb95aead3
1 2/* taken from ebfw/rom/dbmentry.s */ 3 4#define EB164 5/*#ifndef LINT 6.data 7.asciiz "$Id: dbmentry.s,v 1.1.1.1 1997/10/30 23:27:12 verghese Exp $" 8.text 9#endif 10*/ 11/* 12 * Debug Monitor Entry code 13 */ 14 15#ifndef MAKEDEPEND 16#include "ev5_impure.h" 17#include "cserve.h" 18#include "fromHudsonOsf.h" 19#endif 20 21//#include "paldefs.h" 22#include "regdefs.h" 23#include "eb164.h" 24//#include "ledcodes.h" 25 26 .text 27 28/* return address and padding to octaword align */ 29#define STARTFRM 16 30 31 .globl __start 32 .ent __start, 0 33__start: 34_entry: 35 br t0, 2f # get the current PC 362: ldgp gp, 0(t0) # init gp 37 38 39#ifdef original_xxm 40 lda a2, CSERVE_K_RD_IMPURE 41 call_pal PAL_CSERVE_ENTRY 42 lda v0, CNS_Q_BASE(v0) 43 44 # Add KSEG offset to the impure area 45 subq zero, 1, t0 46 sll t0, 42, t0 47 addq t0, v0, v0 48 49 lda t0, CNS_Q_SIGNATURE(v0) 50 bic t0, 0x07, t0 # Clear bottom 3 bits to avoid 51 # allignment errors if the 52 # impure area is total rubbish 53 ldq t0, 0x00(t0) 54 srl t0, 16, t0 # Shift signature into bottom 16 bits. 55 lda t6, 0xDECB(zero) # Load the expected valid signature. 56 zap t6, 0xFC, t6 # Clear the upper bits. 57 cmpeq t0, t6, t0 # Is this a valid signature? 58 beq t0, 1f # Not valid, don't trust input params. 59 60/* 61 * Init the stack at the first 8K boundary 62 * below the top of memory. 63 */ 64 lda t0, CNS_Q_MEM_SIZE(v0) 65 ldq t0, 0x00(t0) # Load memory size. 66 subq t0, 1, t0 # Last address in memory 67 srl t0, 13, t0 # Align to first 8KB boundary 68 sll t0, 13, sp # below the top of memory. 69 br zero, 2f 70 71/* 72 * If memory size was not passed in via the 73 * PALcode impure data use the system specific 74 * MINIMUM_SYSTEM_MEMORY definition. 75 */ 761: 77 lda sp, (MINIMUM_SYSTEM_MEMORY&0xffff)(zero) 78 ldah sp, ((MINIMUM_SYSTEM_MEMORY+0x8000)>>16)(sp) 79 lda t0, (8*1024)(zero) # Allow for 8KB guard page. 80 subq sp, t0, sp 81 822: 83 84#endif /* original_xxm */ 85 86 87 /* 88 * SimOS. Stack pointer is start of a valid phys or KSEG page 89 */ 90 91 bis sp,sp,s0 /* save sp */ 92 93slave: lda v0,(8*1024)(sp) /* end of page */ 94 95 subq zero, 1, t0 96 sll t0, 42, t0 97 bis t0, v0, sp 98 99#ifdef original_xxm 100 # Add KSEG offset to the stack pointer 101 subq zero, 1, t0 102 sll t0, 42, t0 103 addq t0, sp, sp 104#endif 105 106 lda sp, -STARTFRM(sp) # Create a stack frame 107 stq ra, 0(sp) # Place return address on the stack 108 109 .mask 0x84000000, -8 110 .frame sp, STARTFRM, ra 111 112/* 113 * Enable the Floating Point Unit 114 */ 115 lda a0, 1(zero) 116 call_pal PAL_WRFEN_ENTRY 117 118/* 119 * Every good C program has a main() 120 */ 121 122 beq s0,master 123 124 call_pal PAL_WHAMI_ENTRY 125 bis v0,v0,a0 126 jsr ra, SlaveLoop 127master: 128 jsr ra, main 129 130 131 132/* 133 * The Debug Monitor should never return. 134 * However, just incase... 135 */ 136 ldgp gp, 0(ra) 137 bsr zero, _exit 138 139.end __start 140 141 142 143 .globl _exit 144 .ent _exit, 0 145_exit: 146 147 ldq ra, 0(sp) # restore return address 148 lda sp, STARTFRM(sp) # prune back the stack 149 ret zero, (ra) # Back from whence we came 150.end _exit 151 152 .globl cServe 153 .ent cServe 2 154cServe: 155 .option O1 156 .frame sp, 0, ra 157 call_pal PAL_CSERVE_ENTRY 158 ret zero, (ra) 159 .end cServe 160 161 .globl wrfen 162 .ent wrfen 2 163wrfen: 164 .option O1 165 .frame sp, 0, ra 166 call_pal PAL_WRFEN_ENTRY 167 ret zero, (ra) 168 .end wrfen 169 .globl consoleCallback 170 .ent consoleCallback 2 171consoleCallback: 172 br t0, 2f # get the current PC 1732: ldgp gp, 0(t0) # init gp 174 lda sp,-64(sp) 175 stq ra,0(sp) 176 jsr CallBackDispatcher 177 ldq ra,0(sp) 178 lda sp,64(sp) 179 ret zero,(ra) 180 .end consoleCallback 181 182 183 .globl consoleFixup 184 .ent consoleFixup 2 185consoleFixup: 186 br t0, 2f # get the current PC 1872: ldgp gp, 0(t0) # init gp 188 lda sp,-64(sp) 189 stq ra,0(sp) 190 jsr CallBackFixup 191 ldq ra,0(sp) 192 lda sp,64(sp) 193 ret zero,(ra) 194 .end consoleFixup 195 196 197 198 .globl SpinLock 199 .ent SpinLock 2 200SpinLock: 2011: 202 ldq_l a1,0(a0) # interlock complete lock state 203 subl ra,3,v0 # get calling addr[31:0] + 1 204 blbs a1,2f # branch if lock is busy 205 stq_c v0,0(a0) # attempt to acquire lock 206 beq v0,2f # branch if lost atomicity 207 mb # ensure memory coherence 208 ret zero,(ra) # return to caller (v0 is 1) 2092: 210 br zero,1b 211 .end SpinLock 212 213 .globl loadContext 214 .ent loadContext 2 215loadContext: 216 .option O1 217 .frame sp, 0, ra 218 call_pal PAL_SWPCTX_ENTRY 219 ret zero, (ra) 220 .end loadContext 221 222 223 .globl SlaveSpin # Very carefully spin wait 224 .ent SlaveSpin 2 # and swap context without 225SlaveSpin: # using any stack space 226 .option O1 227 .frame sp, 0, ra 228 mov a0, t0 # cpu number 229 mov a1, t1 # cpu rpb pointer (virtual) 230 mov a2, t2 # what to spin on 231 232test: ldl t3, 0(t2) 233 beq t3, test 234 zapnot t1,0x1f,a0 # make rpb physical 235 call_pal PAL_SWPCTX_ENTRY # switch to pcb 236 mov t0, a0 # setup args for SlaveCmd 237 mov t1, a1 238 jsr SlaveCmd # call SlaveCmd 239 ret zero, (ra) # Should never be reached 240 .end SlaveSpin 241 242 243