source: rtems/c/src/lib/libbsp/mips/rbtx4938/liblnk/pmon.S @ 4ba5ac6

4.104.114.84.9
Last change on this file since 4ba5ac6 was 4ba5ac6, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 16, 2006 at 5:41:28 PM

New (Submission by Bruce Robinson <brucer@…>).

  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * pmon.S -- low-level entry points into PMON monitor.
3 *
4 * Copyright (c) 1996, 1997 Cygnus Support
5 *
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
14 * they apply.
15 */
16
17#ifdef __mips16
18/* This file contains 32 bit assembly code.  */
19        .set nomips16
20#endif
21
22#if __mips < 3
23  /* This machine does not support 64-bit operations.  */
24  #define ADDU addu
25  #define SUBU subu
26#else
27  /* This machine supports 64-bit operations.  */
28  #define ADDU daddu
29  #define SUBU dsubu
30#endif
31
32#include "regs.S"
33
34        .text
35        .align  2
36
37#ifdef LSI
38  #define PMON_VECTOR 0xbfc00200
39#else
40  #define PMON_VECTOR 0xbfc00500
41#endif
42
43#ifndef __mips_eabi
44/* Provide named functions for entry into the monitor: */
45#define INDIRECT(name,index)                            \
46        .globl  name;                                   \
47        .ent    name;                                   \
48        .set    noreorder;                              \
49name:   la      $2,+(PMON_VECTOR+((index)*4));          \
50        lw      $2,0($2);                               \
51        j       $2;                                     \
52        nop;                                            \
53        .set    reorder;                                \
54        .end    name
55
56#else
57#define INDIRECT(name,index)                            \
58        .globl  name;                                   \
59        .ent    name;                                   \
60        .set    noreorder;                              \
61name:   la      $2,+(PMON_VECTOR+((index)*4));          \
62        lw      $2,0($2);                               \
63        SUBU    sp,sp,0x40;                             \
64        sd      ra,0x38(sp);                            \
65        sd      fp,0x30(sp);                            \
66        jal     $2;                                     \
67        move    fp,sp;                                  \
68        ld      ra,0x38(sp);                            \
69        ld      fp,0x30(sp);                            \
70        j       ra;                                     \
71        ADDU    sp,sp,0x40;                             \
72        .set    reorder;                                \
73        .end    name
74#endif
75
76
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: */
79INDIRECT(mon_read,0)
80INDIRECT(mon_write,1)
81INDIRECT(mon_open,2)
82INDIRECT(mon_close,3)
83/* The following are useful monitor routines: */
84INDIRECT(mon_ioctl,4)
85INDIRECT(mon_printf,5)
86INDIRECT(mon_vsprintf,6)
87INDIRECT(mon_ttctl,7)
88INDIRECT(mon_cliexit,8)
89INDIRECT(mon_getenv,9)
90INDIRECT(mon_onintr,10)
91INDIRECT(mon_flush_cache,11)
92INDIRECT(mon_exception,12)
93INDIRECT(mon_fpgaconfig,21)
94
95#if 0
96
97/* The following routine is required by the "print()" function: */
98        .globl  pmon_outbyte
99        .ent    pmon_outbyte
100        .set    noreorder
101pmon_outbyte:
102        subu    sp,sp,0x20      /* allocate stack space for string */
103        sd      ra,0x18(sp)     /* stack return address */
104        sd      fp,0x10(sp)     /* stack frame-pointer */
105        move    fp,sp           /* take a copy of the stack pointer */
106        /* We leave so much space on the stack for the string (16
107           characters), since the call to mon_printf seems to corrupt
108           the 8bytes at offset 8 into the string/stack. */
109        sb      a0,0x00(sp)     /* character to print */
110        sb      z0,0x01(sp)     /* NUL terminator */
111        jal     mon_printf      /* and output the string */
112        move    a0,sp           /* take a copy of the string pointer {DELAY SLOT} */
113
114        move    sp,fp           /* recover stack pointer */
115        ld      ra,0x18(sp)     /* recover return address */
116        ld      fp,0x10(sp)     /* recover frame-pointer */
117        j       ra              /* return to the caller */
118        addu    sp,sp,0x20      /* dump the stack space {DELAY SLOT} */
119        .set    reorder
120        .end    pmon_outbyte
121
122/* The following routine is required by the "sbrk()" function: */
123        .globl  get_mem_info
124        .ent    get_mem_info
125        .set    noreorder
126get_mem_info:
127        # in:  a0 = pointer to 3 word structure
128        # out: void
129        subu    sp,sp,0x18      /* create some stack space */
130        sd      ra,0x00(sp)     /* stack return address */
131        sd      fp,0x08(sp)     /* stack frame-pointer */
132        sd      a0,0x10(sp)     /* stack structure pointer */
133        move    fp,sp           /* take a copy of the stack pointer */
134
135        # The monitor has already sized memory, but unfortunately we
136        # do not have access to the data location containing the
137        # memory size.
138
139        jal     __sizemem
140        nop
141
142        ld      a0,0x10(sp)     # recover structure pointer
143        sw      v0,0(a0)        # amount of memory available
144
145        # Deal with getting the cache size information:
146        mfc0    a1, C0_CONFIG
147        nop
148        nop
149        andi    a2,a1,0x7 << 9  # bits 11..9 for instruction cache size
150        sll     a2,a2,12 - 8
151        sw      a2,4(a0)
152        andi    a2,a1,0x7 << 6  # bits 8..6 for data cache size
153        sll     a2,a2,12 - 5
154        sw      a2,8(a0)        # data cache size
155        #
156        move    sp,fp           /* recover stack pointer */
157        ld      ra,0x00(sp)     /* recover return address */
158        ld      fp,0x08(sp)     /* recover frame-pointer */
159        j       ra              /* return to the caller */
160        addu    sp,sp,0x18      /* restore stack pointer {DELAY SLOT} */
161        .set    reorder
162        .end    get_mem_info
163
164#ifdef LSI
165
166# For the LSI MiniRISC board, we can safely assume that we have
167# at least one megabyte of RAM.
168
169        .globl  __sizemem
170        .ent    __sizemem
171__sizemem:
172        li      v0,0x100000
173        j       ra
174        .end    __sizemem
175#else
176
177#endif
178
179#endif
180/* EOF pmon.S */
Note: See TracBrowser for help on using the repository browser.