OpenCores
URL https://opencores.org/ocsvn/mb-jpeg/mb-jpeg/trunk

Subversion Repositories mb-jpeg

[/] [mb-jpeg/] [tags/] [STEP1_1/] [microblaze_0/] [code/] [xmdstub.s] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 quickwayne
/*----------------------------------------------------------------------
2
 *
3
 * Copyright (c) 2005 Xilinx, Inc.  All rights reserved.
4
 * Xilinx, Inc.
5
 *
6
 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
7
 * COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
8
 * ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
9
 * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
10
 * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
11
 * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
12
 * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
13
 * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
14
 * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
15
 * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
16
 * AND FITNESS FOR A PARTICULAR PURPOSE.
17
 *
18
 * $Header: /home/marcus/revision_ctrl_test/oc_cvs/cvs/mb-jpeg/microblaze_0/code/xmdstub.s,v 1.1 2006-06-23 18:57:05 quickwayne Exp $
19
 * $Id: xmdstub.s,v 1.1 2006-06-23 18:57:05 quickwayne Exp $
20
 *
21
 *      XMD_stub version 1.0
22
 *      MicroBlaze
23
 *      Author: Göran Bilski
24
 *      Created:  11 Juli 2001
25
 *      Modified: 20 Sept 2001
26
 *      Modified: 08 Nov  2001
27
 *      Modified: 12 Mar  2002 (jece & navanee)
28
 *      Modified: 25 Aug  2004 (navanee)
29
 *      Modified: Jan 2005 (Raj - Added Half Word/Byte Read & Write)
30
 *
31
 ----------------------------------------------------------------------*/
32
 
33
        .globl  _start
34
        .text
35
        .align  2
36
        .globl  xmd_stub
37
        .ent    xmd_stub
38
_start:
39
xmd_stub:
40
        .equ uart_rx_data,         DEBUG_PERIPHERAL_BASEADDRESS
41
        .equ uart_tx_data,         DEBUG_PERIPHERAL_BASEADDRESS +  4
42
        .equ uart_stat,            DEBUG_PERIPHERAL_BASEADDRESS +  8
43
        .equ uart_ctrl,            DEBUG_PERIPHERAL_BASEADDRESS + 12
44
 
45
        .equ uart_tx_buffer_empty, 0b100
46
        .equ uart_rx_data_valid,   0b001
47
 
48
        .equ uart_rst_rx_fifo,      0b010
49
        .equ uart_rst_tx_fifo,      0b001
50
 
51
        .equ Reached_End_Of_Program, 0x00
52
        .equ Reached_Breakpoint,     0x01
53
        .equ Received_brk_signal,    0x02
54
        .equ ProcReset_signal,       0x03
55
        .equ Escape_Char,            0xFC
56
        .equ ReSync_Char,            0xFE
57
        .equ Stub_ID,                0x40
58
 
59
        .equ Reset_TxFifo,           0x01
60
        .equ Reset_RxFifo,           0x02
61
        .equ Clear_ExtBreak,         0x04
62
        .equ Intr_Enabled,           0x10
63
 
64
        .equ version, 3
65
 
66
        /*--------------------------------------------------*/
67
        /* MicroBlaze jump table                            */
68
        /* 0x0  - Reset address                             */
69
        /* 0x8  - Exception address                         */
70
        /* 0x10 - Interrupt address                         */
71
        /* 0x18 - Break signal address (short branch)       */
72
        /* 0x1c - Breakpoint address (short branch)         */
73
        /* 0x20 - Hardware Exception addr (MB ref guide)    */
74
        /* 0x28 - Program Exit(crt1.s) (short branch)       */
75
        /*--------------------------------------------------*/
76
 
77
        brki r16, StartUp_Entry
78
        nop
79
        nop
80
        nop
81
        nop
82
        nop
83
        bri Brk_Signal_Entry
84
        bri Debug_Entry
85
        nop
86
        nop
87
        bri Program_Exit
88
 
89
        /*--------------------------------------------------*/
90
        /* ReSync                                           */
91
        /* - Remove any stale data from the RX and TX fifo  */
92
        /* - Send back the stubID + version number          */
93
        /*--------------------------------------------------*/
94
ReSync:
95
        lwi  r15, r0, uart_stat
96
        andi r15,r15, Intr_Enabled
97
        ori  r15, r15, uart_rst_tx_fifo + uart_rst_rx_fifo
98
        swi  r15, r0, uart_ctrl
99
        brlid r29,Wait_for_TX_space
100
        addi r30,r0,Stub_ID + version
101
        swi  r30,r0,uart_tx_data
102
 
103
        /*--------------------------------------------------*/
104
        /* Main command entry code                          */
105
        /* - Wait for the next command                      */
106
        /*    0 = Download Program                          */
107
        /*    4 = Continue                                  */
108
        /*    8 = Read Registers                            */
109
        /*   12 = Write Register                            */
110
        /*   16 = Read Memory                               */
111
        /*   20 = Write Memory                              */
112
        /*   24 = Resync                                    */
113
        /*   28 = Return Debug Addr - Deprecated            */
114
        /*   32 = Continue                                  */
115
        /*   36 = SingleStep                                */
116
        /*   40 = Read Memory Half Word                     */
117
        /*   44 = Read Memory Byte                          */
118
        /*   48 = Write Memory Half Word                    */
119
        /*   52 = Write Memory Byte                         */
120
        /* - Call the command without any link              */
121
        /*--------------------------------------------------*/
122
Wait_for_command:
123
        brlid r29,Get_Char
124
        nop
125
        lwi r29,r3,jump_table
126
        bra r29
127
 
128
        /*--------------------------------------------------*/
129
        /* This section will end up in the rodata section    */
130
        /* Is place here for helping understanding the code */
131
        /*--------------------------------------------------*/
132
        .rodata
133
        .align 2
134
jump_table:
135
        .int Load_Memory
136
        .int Execute
137
        .int Read_Register
138
        .int Write_Register
139
        .int Read_Memory
140
        .int Write_Memory
141
        .int ReSync
142
        .int Return_Dbg_Addr
143
        .int Continue
144
        .int SingleStep
145
        .int Read_Memory_Half
146
        .int Read_Memory_Byte
147
        .int Write_Memory_Half
148
        .int Write_Memory_Byte
149
 
150
        /*--------------------------------------------------*/
151
        /* Go back to the text section(instruction)         */
152
        /*--------------------------------------------------*/
153
        .text
154
 
155
 
156
        /*--------------------------------------------------*/
157
        /* Read all registers command                       */
158
        /* Get the values of all registers                  */
159
        /*   from the register_dump where the register      */
160
        /*   values are stored                              */
161
        /* - Send all values to the terminal (through UART) */
162
        /*   33 words will be sent: 1-31 and pc and msr     */
163
        /*   Note that the pc value sent is always incorrect*/
164
        /*   It has to be in the table for consistency      */
165
        /* - Jump to the main command entry code            */
166
        /*--------------------------------------------------*/
167
Read_Register:
168
        addi r28, r0, register_dump+4
169
        addi r26, r0, 33
170
Read_Register_1:
171
        brlid r15, Send_32Bit
172
        lw   r5, r28, r0
173
        addi r26,r26,-1
174
        bneid r26, Read_Register_1
175
        addi r28,r28,4
176
        bri Wait_for_command
177
 
178
        /*--------------------------------------------------*/
179
        /* Write to a register value command                */
180
        /* - Get a byte which is the register asked for     */
181
        /*   The byte has to be Register_Number*4,          */
182
        /*   since the value will be used as word address   */
183
        /*   and the addressing is always in byte addresses */
184
        /*   ex. Want to see value of register 15           */
185
        /*       The byte value has to be 4*15 = 60         */
186
        /* - Get 32 bits (4 bytes) which is the new value   */
187
        /*   for the register                               */
188
        /* - Store the new value to the stored value for    */
189
        /*   that register from the register_dump where the */
190
        /*   register values are stored                     */
191
        /* - Jump to the main command entry code            */
192
        /*--------------------------------------------------*/
193
Write_Register:
194
        /* Write a register value                    */
195
        /* Next byte is which register               */
196
        /* Next four bytes is the new register value */
197
        brlid r29,Get_Char
198
        nop
199
        brlid r15,Get_32Bit
200
        or r28,r3,r0
201
        swi r3,r28,register_dump
202
        bri Wait_for_command
203
 
204
 
205
        /*--------------------------------------------------*/
206
        /* Read from memory command                         */
207
        /* - Get 32 bits (4 bytes) which is the memory      */
208
        /*   address.                                       */
209
        /* - Read the value from that memory address        */
210
        /*   for the register                               */
211
        /* - Send that value to the terminal (through UART) */
212
        /* - Jump to the main command entry code            */
213
        /*--------------------------------------------------*/
214
Read_Memory:
215
        /* Next four bytes is the address */
216
        /* The response will be the value in that address */
217
        /* send as four bytes */
218
        brlid r15,Get_32Bit
219
        nop
220
        brlid r15,Send_32Bit
221
        lw r5,r3,r0
222
        bri Wait_for_command
223
 
224
        /*--------------------------------------------------*/
225
        /* Read from memory Half Word command               */
226
        /* - Get 32 bits (4 bytes) which is the memory      */
227
        /*   address.                                       */
228
        /* - Read the value from that memory address        */
229
        /*   for the register                               */
230
        /* - Send that value to the terminal (through UART) */
231
        /* - Jump to the main command entry code            */
232
        /*--------------------------------------------------*/
233
Read_Memory_Half:
234
        /* Next four bytes is the address */
235
        /* The response will be the value in that address */
236
        /* send as two bytes */
237
        brlid r15,Get_32Bit
238
        nop
239
        brlid r15,Send_16Bit
240
        lhu r5,r3,r0
241
        bri Wait_for_command
242
 
243
        /*--------------------------------------------------*/
244
        /* Read from memory Byte command                    */
245
        /* - Get 32 bits (4 bytes) which is the memory      */
246
        /*   address.                                       */
247
        /* - Read the value from that memory address        */
248
        /*   for the register                               */
249
        /* - Send that value to the terminal (through UART) */
250
        /* - Jump to the main command entry code            */
251
        /*--------------------------------------------------*/
252
Read_Memory_Byte:
253
        /* Next four bytes is the address */
254
        /* The response will be the value in that address */
255
        /* send a byte */
256
        brlid r15,Get_32Bit
257
        nop
258
        brid Send_Status
259
        lbu r15,r3,r0
260
 
261
        /*--------------------------------------------------*/
262
        /* Write to memory command                          */
263
        /* - Get 32 bits (4 bytes) which is the memory      */
264
        /*   address.                                       */
265
        /* - Get 32 bits (4 bytes) which is the new value   */
266
        /*   for that memory address.                       */
267
        /* - Write the new value to the memory.             */
268
        /* - Jump to the main command entry code            */
269
        /*--------------------------------------------------*/
270
Write_Memory:
271
        /* Next four byte is the address */
272
        /* Then the next four byte is the new data */
273
        brlid r15,Get_32Bit
274
        nop
275
        brlid r15,Get_32Bit
276
        or r28,r3,r0
277
        swi r3,r28,0
278
        bri Wait_for_command
279
 
280
Write_Memory_Half:
281
        /* Next four bytes is the address */
282
        /* Then the next two bytes is the new data */
283
        brlid r15,Get_32Bit
284
        nop
285
        brlid r15,Get_16Bit
286
        or r28,r3,r0
287
        shi r3,r28,0
288
        bri Wait_for_command
289
 
290
Write_Memory_Byte:
291
        /* Next four byte is the address */
292
        /* Then the next byte is the new data */
293
        brlid r15,Get_32Bit
294
        nop
295
        brlid r29,Get_Char
296
        or r28,r3,r0
297
        sbi r3,r28,0
298
        bri Wait_for_command
299
 
300
        /*--------------------------------------------------*/
301
        /* Download program command                         */
302
        /* - Get 32 bits (4 bytes) which is the start       */
303
        /*   address for the downloading                    */
304
        /* - Get 32 bits (4 bytes) which is the number of   */
305
        /*   bytes in the downloading                       */
306
        /* - Loop                                           */
307
        /*   - Get a byte                                   */
308
        /*   - Store it at the memory address               */
309
        /*   - Increment the memory address with 1          */
310
        /*   - Decrement the number of bytes by 1           */
311
        /*   - Continue until all bytes has been received   */
312
        /* - Jump to the main command entry code            */
313
        /*--------------------------------------------------*/
314
Load_Memory:
315
        /* Next 4 bytes is the start address */
316
        /* The next four bytes is the number of bytes */
317
        brlid r15,Get_32Bit
318
        nop
319
        brlid r15,Get_32Bit
320
        or r28,r3,r0
321
        or r25,r3,r0
322
Load_Memory_1:
323
        brlid r29,Get_Char
324
        addi r25,r25,-1
325
        sb r3,r28,r0
326
        bneid r25,Load_Memory_1
327
        addi r28,r28,1
328
        bri Wait_for_command
329
 
330
 
331
 
332
        /*--------------------------------------------------*/
333
        /* NOTE : EXECUTE FOR THE SAKE OF COMPATIBILITY WITH MDK 2.2 */
334
        /* Execute program command                          */
335
        /* - Get 32 bits (4 bytes) which is the memory      */
336
        /*   address.                                       */
337
        /* - Load all register from the register_dump       */
338
        /*--------------------------------------------------*/
339
Execute:
340
        /* Next four byte is the start address */
341
        brlid r15,Get_32Bit
342
        nop
343
        /* Set the R16 value in the reg dump to the start addr  */
344
        /* When control falls thru to the Continue command      */
345
        /* it will start execution from the addr in the new R16 */
346
        swi r3,r0,register_dump+64
347
        /* Fall thru to the following Continue command */
348
 
349
 
350
        /*--------------------------------------------------*/
351
        /* Continue command                                 */
352
        /* continue at the instruction after the brk        */
353
        /*  - Restore all registers                         */
354
        /*  - jump to the address for the BRK instruction   */
355
        /*--------------------------------------------------*/
356
Continue:
357
        brlid r15, Get_All_Registers
358
        nop
359
        rtbd r16, 0
360
        lwi r15,r0,register_dump+15*4
361
 
362
 
363
        /*--------------------------------------------------*/
364
        /* SingleStep command                               */
365
        /* step single instruction without enabling         */
366
        /* the BIP flag                                     */
367
        /*  - Restore all registers                         */
368
        /*  - jump to the address for the BRK instruction   */
369
        /*--------------------------------------------------*/
370
SingleStep:
371
        brlid r15, Get_All_Registers
372
        nop
373
        rtsd r16, 0
374
        lwi r15,r0,register_dump+15*4
375
 
376
        /*--------------------------------------------------*/
377
        /* When Processor resets                            */
378
        /*   - save all registers to the register_dump      */
379
        /*   - send 0x3 ('Processor reset') to host         */
380
        /*   - Jump to the main command entry code          */
381
        /*--------------------------------------------------*/
382
 
383
StartUp_Entry:
384
        swi r15,r0,register_dump+60
385
        brid Dump_All_Registers
386
        ori r15,r0,ProcReset_signal
387
        /* Control goes to SendStatus from DumpAllRegisters */
388
 
389
 
390
        /*--------------------------------------------------*/
391
        /* Program End entry                                */
392
        /* When control returns from the program or         */
393
        /* on exit()                                        */
394
        /*   - save all register to the register_dump       */
395
        /*   - send 0x0 ('Reached_End_Of_Program') to host  */
396
        /*   - Jump to the main command entry code          */
397
        /*--------------------------------------------------*/
398
 
399
Program_Exit:
400
        swi r15,r0,register_dump+60
401
        brid Dump_All_Registers
402
        ori r15,r0,Reached_End_Of_Program
403
        /* Control goes to SendStatus from DumpAllRegisters */
404
 
405
        /*--------------------------------------------------*/
406
        /* Debug Entry code                                 */
407
        /* The code that breakpoint instruction will call   */
408
        /*  - Will save all registers                       */
409
        /*  - Send 0x01 to the host                         */
410
        /*  - Jump to the main command entry code           */
411
        /*--------------------------------------------------*/
412
Debug_Entry:
413
        swi r15,r0,register_dump+60 /* Dump_All_regs doesnt do this */
414
        brid Dump_All_Registers
415
        ori r15,r0, Reached_Breakpoint
416
        /* Control goes to SendStatus from DumpAllRegisters */
417
 
418
        /*--------------------------------------------------*/
419
        /* Brk signal handler                               */
420
        /*  - Will save all registers                       */
421
        /*  - Send 0x02 to the host                         */
422
        /*  - Jump to the main command entry code           */
423
        /*--------------------------------------------------*/
424
Brk_Signal_Entry:
425
        swi r15,r0,register_dump+60 /* Dump_All_regs doesnt do this */
426
        lwi r15, r0, uart_stat
427
        andi r15,r15, Intr_Enabled
428
        ori r15, r15, Clear_ExtBreak
429
        swi r15, r0, uart_ctrl
430
        brid Dump_All_Registers
431
        ori r15,r0, Received_brk_signal
432
        /* Control goes to SendStatus from DumpAllRegisters */
433
 
434
 
435
        /*  Send the status to the host                     */
436
Send_Status:
437
        brlid r29,Wait_for_TX_space
438
        nop
439
        swi  r15,r0,uart_tx_data
440
        bri Wait_for_command
441
 
442
 
443
 
444
        /*--------------------------------------------------*/
445
        /* NOTE : ADDED FOR THE SAKE OF COMPATIBILITY WITH MDK 2.2 */
446
        /* Return Debug Address Entry command               */
447
        /* The code will return the address for the         */
448
        /* Debug_Entry code section as four bytes           */
449
        /*--------------------------------------------------*/
450
Return_Dbg_Addr:
451
        brlid r15,Send_32Bit
452
        addi r5,r0,Debug_Entry
453
        bri Wait_for_command
454
 
455
 
456
/*--------------------------------------------------*/
457
/* Low Level Helper routines                        */
458
/*--------------------------------------------------*/
459
 
460
 
461
        /*--------------------------------------------------*/
462
        /* Get a byte function                              */
463
        /*  - loop until a character has been received      */
464
        /*  - read the character                            */
465
        /* Uses: R3                                         */
466
        /* Parameters: None                                 */
467
        /* Returns using R27                                */
468
        /* Result in: R3                                    */
469
        /*--------------------------------------------------*/
470
Get_Byte:
471
        /* Get 1 byte and return it in r3 */
472
        lwi  r3,r0,uart_stat
473
        andi r3,r3,uart_rx_data_valid     /* rx data present */
474
        beqi r3, Get_Byte
475
        lwi  r3,r0,uart_rx_data
476
        rtsd r27,8
477
        nop
478
 
479
        /*--------------------------------------------------*/
480
        /* Get a char function                              */
481
        /*  - Get a byte from the UART                      */
482
        /*  - Check if it's an escape character             */
483
        /*  - if it is                                      */
484
        /* Uses: R3, R26, R27                               */
485
        /* Parameters: None                                 */
486
        /* Returns using R29                                */
487
        /* Result in: R3                                    */
488
        /*--------------------------------------------------*/
489
Get_Char:
490
        brlid r27,Get_Byte
491
        nop
492
        xori r26,r3,Escape_Char
493
        bnei r26,No_Escape
494
        brlid r27,Get_Byte
495
        nop
496
Get_Char_Return:
497
        rtsd r29,8
498
        nop
499
No_Escape:
500
        xori r26,r3,ReSync_Char
501
        beqi r26,ReSync
502
        bri Get_Char_Return
503
 
504
        /*--------------------------------------------------*/
505
        /* Get a half word function                         */
506
        /*  - Get 2 bytes using Get_Char function           */
507
        /*  - Store each byte in a memory location,temp_mem */
508
        /*    using store byte SBI instruction              */
509
        /*    stores the received byte in the order         */
510
        /*    addr+1,addr+0                                 */
511
        /* Uses: R3,R29,R30,R31                             */
512
        /* Parameters: None                                 */
513
        /* Returns using R15                                */
514
        /* Result in: R3                                    */
515
        /*--------------------------------------------------*/
516
Get_16Bit:
517
        and  r30,r0,r0
518
        addi r31,r0,1
519
Get_16Bit_1:
520
        /* Get the next byte */
521
        brlid r29,Get_Char
522
        nop
523
        sbi r3,r31,temp_mem
524
        addi r31,r31,-1
525
        bgei r31,Get_16Bit_1
526
        rtsd r15,8
527
        lhui r3,r0,temp_mem
528
 
529
        /*--------------------------------------------------*/
530
        /* Get a word function                              */
531
        /*  - Get 4 bytes using Get_Char function           */
532
        /*  - Store each byte in a memory location,temp_mem */
533
        /*    using store byte SBI instruction              */
534
        /*    stores the received byte in the order         */
535
        /*    addr+3,addr+2,addr+1,addr+0                   */
536
        /* Uses: R3,R29,R30,R31                             */
537
        /* Parameters: None                                 */
538
        /* Returns using R15                                */
539
        /* Result in: R3                                    */
540
        /*--------------------------------------------------*/
541
Get_32Bit:
542
        and  r30,r0,r0
543
        addi r31,r0,3
544
Get_32Bit_1:
545
        /* Get the next byte */
546
        brlid r29,Get_Char
547
        nop
548
        sbi r3,r31,temp_mem
549
        addi r31,r31,-1
550
        bgei r31,Get_32Bit_1
551
        rtsd r15,8
552
        lwi r3,r0,temp_mem
553
 
554
 
555
        /*--------------------------------------------------*/
556
        /* Wait for UART TX is become empty function        */
557
        /*  - loop until UART TXC buffer is empty           */
558
        /* Uses: R25                                        */
559
        /* Parameters: None                                 */
560
        /* Returns using R29                                */
561
        /* Result in: no result                             */
562
        /*--------------------------------------------------*/
563
Wait_for_TX_space:
564
        lwi  r25,r0,uart_stat
565
        andi r25,r25,uart_tx_buffer_empty   /* tx buffer empty */
566
        beqi r25, Wait_for_TX_space
567
        rtsd r29,8
568
        nop
569
 
570
        /*--------------------------------------------------*/
571
        /* Send a half word function                        */
572
        /*  - Store the half word to send in temp_mem       */
573
        /*  - loop                                          */
574
        /*     - Wait for TX to become empty                */
575
        /*     - Read a byte out of temp_mem                */
576
        /*       reads the bytes in the order               */
577
        /*       addr+1,addr+0                              */
578
        /*     - Send that byte (Write to the UART_TX fifo) */
579
        /*     - Repeat for all 2 bytes                     */
580
        /* Uses: R3,R25,R29,R30,R31                         */
581
        /* Parameters: R5 Half Word to send                 */
582
        /* Returns using R15                                */
583
        /* Result in: No result                             */
584
        /*--------------------------------------------------*/
585
Send_16Bit:
586
        addi r31,r0,1
587
        brid Send_32Bit_1
588
        shi r5,r0,temp_mem
589
 
590
        /*--------------------------------------------------*/
591
        /* Send a word function                             */
592
        /*  - Store the word to send in temp_mem            */
593
        /*  - loop                                          */
594
        /*     - Wait for TX to become empty                */
595
        /*     - Read a byte out of temp_mem                */
596
        /*       reads the bytes in the order               */
597
        /*       addr+3,addr+2,addr+1,addr+0                */
598
        /*     - Send that byte (Write to the UART_TX fifo) */
599
        /*     - Repeat for all 4 bytes                     */
600
        /* Uses: R3,R25,R29,R30,R31                         */
601
        /* Parameters: R5 Word to send                      */
602
        /* Returns using R15                                */
603
        /* Result in: No result                             */
604
        /*--------------------------------------------------*/
605
Send_32Bit:
606
        addi r31,r0,3
607
        swi r5,r0,temp_mem
608
 
609
Send_32Bit_1:
610
        /* Wait for free space in the transmit buffer */
611
        brlid r29, Wait_for_TX_space
612
 
613
        /* Get the right byte from the word to transmit */
614
        lbui r30,r31,temp_mem
615
        swi  r30,r0,uart_tx_data
616
 
617
        addi r31,r31,-1
618
        bgei r31, Send_32Bit_1
619
 
620
        rtsd r15,8
621
        nop
622
 
623
        /*--------------------------------------------------*/
624
        /* Save register to register_dump function          */
625
        /*  - Store all registers to the register dump      */
626
        /*    except R0  : makes no sense always zero       */
627
        /*           R15 : needed for the return address    */
628
        /*  - R15 has to saved before calling this function */
629
        /*    to the address register_dump+15*4             */
630
        /* Uses:                                            */
631
        /* Parameters:                                      */
632
        /* Returns using R15                                */
633
        /* Result in: No result                             */
634
        /*--------------------------------------------------*/
635
Dump_All_Registers:
636
/*      swi r0,r0,register_dump + 0 */
637
        swi r1,r0,register_dump + 4
638
        swi r2,r0,register_dump + 8
639
        swi r3,r0,register_dump+12
640
        swi r4,r0,register_dump+16
641
        swi r5,r0,register_dump+20
642
        swi r6,r0,register_dump+24
643
        swi r7,r0,register_dump+28
644
        swi r8,r0,register_dump+32
645
        swi r9,r0,register_dump+36
646
        swi r10,r0,register_dump+40
647
        swi r11,r0,register_dump+44
648
        swi r12,r0,register_dump+48
649
        swi r13,r0,register_dump+52
650
        swi r14,r0,register_dump+56
651
/*      swi r15,r0,register_dump+60 */
652
        swi r16,r0,register_dump+64
653
        swi r17,r0,register_dump+68
654
        swi r18,r0,register_dump+72
655
        swi r19,r0,register_dump+76
656
        swi r20,r0,register_dump+80
657
        swi r21,r0,register_dump+84
658
        swi r22,r0,register_dump+88
659
        swi r23,r0,register_dump+92
660
        swi r24,r0,register_dump+96
661
        swi r25,r0,register_dump+100
662
        swi r26,r0,register_dump+104
663
        swi r27,r0,register_dump+108
664
        swi r28,r0,register_dump+112
665
        swi r29,r0,register_dump+116
666
        swi r30,r0,register_dump+120
667
        swi r31,r0,register_dump+124
668
        mfs r31, rmsr
669
        brid Send_Status
670
        swi r31,r0,register_dump+132
671
 
672
        /*--------------------------------------------------*/
673
        /* Read registers from register_dump function       */
674
        /*  - Read all registers to the register dump       */
675
        /*    except R0  : makes no sense always zero       */
676
        /*           R15 : needed for the return address    */
677
        /*           R16 : contains the debug return address*/
678
        /*                 and can't be overwritten         */
679
        /*           R29 : is used by the eXecute command   */
680
        /*                 for storing the execution address*/
681
        /* Uses:                                            */
682
        /* Parameters:                                      */
683
        /* Returns using R15                                */
684
        /* Result in: No result                             */
685
        /*--------------------------------------------------*/
686
Get_All_Registers:
687
        /* lwi r0,r0,register_dump + 0 */
688
        lwi r1,r0,register_dump + 4
689
        lwi r2,r0,register_dump + 8
690
        lwi r3,r0,register_dump+12
691
        lwi r4,r0,register_dump+16
692
        lwi r5,r0,register_dump+20
693
        lwi r6,r0,register_dump+24
694
        lwi r7,r0,register_dump+28
695
        lwi r8,r0,register_dump+32
696
        lwi r9,r0,register_dump+36
697
        lwi r10,r0,register_dump+40
698
        lwi r11,r0,register_dump+44
699
        lwi r12,r0,register_dump+48
700
        lwi r13,r0,register_dump+52
701
        lwi r14,r0,register_dump+56
702
        /* lwi r15,r0,register_dump+60 */
703
        lwi r16,r0,register_dump+64
704
        lwi r17,r0,register_dump+68
705
        lwi r18,r0,register_dump+72
706
        lwi r19,r0,register_dump+76
707
        lwi r20,r0,register_dump+80
708
        lwi r21,r0,register_dump+84
709
        lwi r22,r0,register_dump+88
710
        lwi r23,r0,register_dump+92
711
        lwi r24,r0,register_dump+96
712
        lwi r25,r0,register_dump+100
713
        lwi r26,r0,register_dump+104
714
        lwi r27,r0,register_dump+108
715
        lwi r28,r0,register_dump+112
716
        lwi r29,r0,register_dump+116
717
        lwi r30,r0,register_dump+120
718
        lwi r31,r0,register_dump+132
719
        mts rmsr, r31
720
        rtsd r15,8
721
        lwi r31,r0,register_dump+124
722
 
723
        /* Temporary memory needed for the byte-to-word */
724
        /* and word-to-byte translation                 */
725
        .data
726
        .align 2
727
temp_mem:
728
        .int 0
729
 
730
        /* 34 words containing the register_dump (32 regs + pc + msr)       */
731
        .align 2
732
register_dump:
733
        .fill 34, 4, 0
734
 
735
        .end    xmd_stub
736
 

powered by: WebSVN 2.1.0

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