Back to home page

LXR

 
 

    


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

0001 /** 
0002  *  @file
0003  *
0004  *  These routines return control to 167Bug after a normal exit from the
0005  *  application.
0006  */
0007 
0008 /*
0009  *  COPYRIGHT (c) 1989-2012.
0010  *  On-Line Applications Research Corporation (OAR).
0011  *
0012  *  The license and distribution terms for this file may be
0013  *  found in the file LICENSE in this distribution or at
0014  *  http://www.rtems.org/license/LICENSE.
0015  *
0016  *  Modifications of respective RTEMS files:
0017  *  Copyright (c) 1998, National Research Council of Canada
0018  */
0019 
0020 #include <bsp.h>
0021 #include <bsp/bootcard.h>
0022 #include <page_table.h>
0023 
0024 extern void start( void );
0025 extern void page_table_teardown( void );
0026 
0027 /**
0028  *  @brief bsp_return_to_monitor_trap
0029  *
0030  *  Switch the VBR back to ROM and make a .RETURN syscall to return control to
0031  *  167 Bug. If 167Bug ever returns, restart the application.
0032  */
0033 static void bsp_return_to_monitor_trap( void )
0034 {
0035   register volatile void *start_addr;
0036 
0037   page_table_teardown();
0038 
0039   lcsr->intr_ena = 0;               /* disable interrupts */
0040   m68k_set_vbr(0xFFE00000);         /* restore 167Bug vectors */
0041   __asm__ volatile( "trap   #15\n\t"    /* trap to 167Bug */
0042                 ".short 0x63" );    /* return to 167Bug (.RETURN) */
0043 
0044   /* restart program */
0045   start_addr = start;
0046   __asm__ volatile( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) );
0047 }
0048 
0049 /*
0050  *  This code was copied from other MC680x0 MVME BSPs.
0051  *  Our guess is that someone was concerned about the CPU no longer being in
0052  *  supervisor mode when they got here. This function forces the CPU back to
0053  *  supervisor mode so the VBR may be changed. It places the address of the
0054  *  function that makes a 167Bug .RETURN syscall in the trap 13 entry in the
0055  *  exception vector, and then issues a trap 13 call. It is also possible that
0056  *  the code was copied from some other OS that does run tasks in user mode.
0057  *  In any case, it appears to be a bit of paranoia, and could lead to
0058  *  problems if 167Bug is invoked before we get to switch the VBR back to
0059  *  167Bug because trap 13 is documented as being reserved for the internal
0060  *  use of the debugger.
0061  */
0062 void bsp_reset( rtems_fatal_source source, rtems_fatal_code code )
0063 {
0064   (void) source;
0065   (void) code;
0066 
0067    M68Kvec[ 45 ] = bsp_return_to_monitor_trap;
0068    __asm__ volatile( "trap #13" );
0069    RTEMS_UNREACHABLE();
0070 }