Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:51

0001 /*
0002  * pmon.S -- low-level entry points into PMON monitor.
0003  *
0004  * Copyright (c) 1996, 1997 Cygnus Support
0005  *
0006  * The authors hereby grant permission to use, copy, modify, distribute,
0007  * and license this software and its documentation for any purpose, provided
0008  * that existing copyright notices are retained in all copies and that this
0009  * notice is included verbatim in any distributions. No written agreement,
0010  * license, or royalty fee is required for any of the authorized uses.
0011  * Modifications to this software may be copyrighted by their authors
0012  * and need not follow the licensing terms described here, provided that
0013  * the new terms are clearly indicated on the first page of each file where
0014  * they apply.
0015  */
0016 
0017 #ifdef __mips16
0018 /* This file contains 32 bit assembly code.  */
0019     .set nomips16
0020 #endif
0021 
0022 #if __mips < 3
0023   /* This machine does not support 64-bit operations.  */
0024   #define ADDU addu
0025   #define SUBU subu
0026 #else
0027   /* This machine supports 64-bit operations.  */
0028   #define ADDU daddu
0029   #define SUBU dsubu
0030 #endif
0031 
0032 #include <bsp/regs.h>
0033 
0034     .text
0035     .align  2
0036 
0037 #ifdef LSI
0038   #define PMON_VECTOR 0xbfc00200
0039 #else
0040   #define PMON_VECTOR 0xbfc00500
0041 #endif
0042 
0043 #ifndef __mips_eabi
0044 /* Provide named functions for entry into the monitor: */
0045 #define INDIRECT(name,index)                \
0046     .globl  name;                   \
0047     .ent    name;                   \
0048     .set    noreorder;              \
0049 name:   la  $2,+(PMON_VECTOR+((index)*4));      \
0050     lw  $2,0($2);               \
0051     j   $2;                 \
0052     nop;                        \
0053     .set    reorder;                \
0054     .end    name
0055 
0056 #else
0057 #define INDIRECT(name,index)                \
0058     .globl  name;                   \
0059     .ent    name;                   \
0060     .set    noreorder;              \
0061 name:   la  $2,+(PMON_VECTOR+((index)*4));      \
0062     lw  $2,0($2);               \
0063     SUBU    sp,sp,0x40;             \
0064     sd  ra,0x38(sp);                \
0065     sd  fp,0x30(sp);                \
0066     jal $2;                 \
0067     move    fp,sp;                  \
0068     ld  ra,0x38(sp);                \
0069     ld  fp,0x30(sp);                \
0070     j   ra;                 \
0071     ADDU    sp,sp,0x40;             \
0072     .set    reorder;                \
0073     .end    name
0074 #endif
0075 
0076 
0077 /* The following magic numbers are for the slots into the PMON monitor */
0078 /* The first are used as the lo-level library run-time: */
0079 INDIRECT(mon_read,0)
0080 INDIRECT(mon_write,1)
0081 INDIRECT(mon_open,2)
0082 INDIRECT(mon_close,3)
0083 /* The following are useful monitor routines: */
0084 INDIRECT(mon_ioctl,4)
0085 INDIRECT(mon_printf,5)
0086 INDIRECT(mon_vsprintf,6)
0087 INDIRECT(mon_ttctl,7)
0088 INDIRECT(mon_cliexit,8)
0089 INDIRECT(mon_getenv,9)
0090 INDIRECT(mon_onintr,10)
0091 INDIRECT(mon_flush_cache,11)
0092 INDIRECT(mon_exception,12)
0093 INDIRECT(mon_fpgaconfig,21)
0094 
0095 #if 0
0096 
0097 /* The following routine is required by the "print()" function: */
0098     .globl  pmon_outbyte
0099     .ent    pmon_outbyte
0100     .set    noreorder
0101 pmon_outbyte:
0102     subu    sp,sp,0x20  /* allocate stack space for string */
0103     sd  ra,0x18(sp) /* stack return address */
0104     sd  fp,0x10(sp) /* stack frame-pointer */
0105     move    fp,sp       /* take a copy of the stack pointer */
0106     /* We leave so much space on the stack for the string (16
0107        characters), since the call to mon_printf seems to corrupt
0108        the 8bytes at offset 8 into the string/stack. */
0109     sb  a0,0x00(sp) /* character to print */
0110     sb  z0,0x01(sp) /* NUL terminator */
0111     jal mon_printf  /* and output the string */
0112     move    a0,sp       /* take a copy of the string pointer {DELAY SLOT} */
0113 
0114     move    sp,fp       /* recover stack pointer */
0115     ld  ra,0x18(sp) /* recover return address */
0116     ld  fp,0x10(sp) /* recover frame-pointer */
0117     j   ra      /* return to the caller */
0118     addu    sp,sp,0x20  /* dump the stack space {DELAY SLOT} */
0119     .set    reorder
0120     .end    pmon_outbyte
0121 
0122 /* The following routine is required by the "sbrk()" function: */
0123     .globl  get_mem_info
0124     .ent    get_mem_info
0125     .set    noreorder
0126 get_mem_info:
0127     # in:  a0 = pointer to 3 word structure
0128     # out: void
0129     subu    sp,sp,0x18  /* create some stack space */
0130     sd  ra,0x00(sp) /* stack return address */
0131     sd  fp,0x08(sp) /* stack frame-pointer */
0132     sd  a0,0x10(sp) /* stack structure pointer */
0133     move    fp,sp       /* take a copy of the stack pointer */
0134 
0135     # The monitor has already sized memory, but unfortunately we
0136     # do not have access to the data location containing the
0137     # memory size.
0138 
0139     jal __sizemem
0140     nop
0141 
0142     ld  a0,0x10(sp) # recover structure pointer
0143     sw  v0,0(a0)    # amount of memory available
0144 
0145     # Deal with getting the cache size information:
0146     mfc0    a1, C0_CONFIG
0147     nop
0148     nop
0149     andi    a2,a1,0x7 << 9  # bits 11..9 for instruction cache size
0150     sll a2,a2,12 - 8
0151     sw  a2,4(a0)
0152     andi    a2,a1,0x7 << 6  # bits 8..6 for data cache size
0153     sll a2,a2,12 - 5
0154     sw  a2,8(a0)    # data cache size
0155     #
0156     move    sp,fp       /* recover stack pointer */
0157     ld  ra,0x00(sp) /* recover return address */
0158     ld  fp,0x08(sp) /* recover frame-pointer */
0159     j   ra      /* return to the caller */
0160     addu    sp,sp,0x18  /* restore stack pointer {DELAY SLOT} */
0161     .set    reorder
0162     .end    get_mem_info
0163 
0164 #ifdef LSI
0165 
0166 # For the LSI MiniRISC board, we can safely assume that we have
0167 # at least one megabyte of RAM.
0168 
0169     .globl  __sizemem
0170     .ent    __sizemem
0171 __sizemem:
0172     li  v0,0x100000
0173     j   ra
0174     .end    __sizemem
0175 #else
0176 
0177 #endif
0178 
0179 #endif
0180 /* EOF pmon.S */