[72d0926] | 1 | /** |
---|
| 2 | * @file |
---|
[5d02459] | 3 | * |
---|
| 4 | * These routines return control to 167Bug after a normal exit from the |
---|
| 5 | * application. |
---|
[72d0926] | 6 | */ |
---|
| 7 | |
---|
| 8 | /* |
---|
| 9 | * COPYRIGHT (c) 1989-2012. |
---|
[5d02459] | 10 | * On-Line Applications Research Corporation (OAR). |
---|
| 11 | * |
---|
| 12 | * The license and distribution terms for this file may be |
---|
| 13 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 14 | * http://www.rtems.org/license/LICENSE. |
---|
[5d02459] | 15 | * |
---|
| 16 | * Modifications of respective RTEMS files: |
---|
| 17 | * Copyright (c) 1998, National Research Council of Canada |
---|
| 18 | */ |
---|
| 19 | |
---|
| 20 | #include <bsp.h> |
---|
[3a1d9c6] | 21 | #include <bsp/bootcard.h> |
---|
[5d02459] | 22 | #include <page_table.h> |
---|
| 23 | |
---|
[423f7e02] | 24 | extern void start( void ); |
---|
| 25 | extern void page_table_teardown( void ); |
---|
| 26 | |
---|
[72d0926] | 27 | /** |
---|
| 28 | * @brief bsp_return_to_monitor_trap |
---|
[5d02459] | 29 | * |
---|
| 30 | * Switch the VBR back to ROM and make a .RETURN syscall to return control to |
---|
| 31 | * 167 Bug. If 167Bug ever returns, restart the application. |
---|
| 32 | */ |
---|
| 33 | static void bsp_return_to_monitor_trap( void ) |
---|
| 34 | { |
---|
| 35 | register volatile void *start_addr; |
---|
| 36 | |
---|
| 37 | page_table_teardown(); |
---|
| 38 | |
---|
| 39 | lcsr->intr_ena = 0; /* disable interrupts */ |
---|
| 40 | m68k_set_vbr(0xFFE00000); /* restore 167Bug vectors */ |
---|
[1bdfd262] | 41 | __asm__ volatile( "trap #15\n\t" /* trap to 167Bug */ |
---|
[4f38ab05] | 42 | ".short 0x63" ); /* return to 167Bug (.RETURN) */ |
---|
[6128a4a] | 43 | |
---|
[5d02459] | 44 | /* restart program */ |
---|
| 45 | start_addr = start; |
---|
[1bdfd262] | 46 | __asm__ volatile( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) ); |
---|
[5d02459] | 47 | } |
---|
| 48 | |
---|
| 49 | /* |
---|
| 50 | * This code was copied from other MC680x0 MVME BSPs. |
---|
| 51 | * Our guess is that someone was concerned about the CPU no longer being in |
---|
| 52 | * supervisor mode when they got here. This function forces the CPU back to |
---|
| 53 | * supervisor mode so the VBR may be changed. It places the address of the |
---|
| 54 | * function that makes a 167Bug .RETURN syscall in the trap 13 entry in the |
---|
| 55 | * exception vector, and then issues a trap 13 call. It is also possible that |
---|
| 56 | * the code was copied from some other OS that does run tasks in user mode. |
---|
[6128a4a] | 57 | * In any case, it appears to be a bit of paranoia, and could lead to |
---|
[5d02459] | 58 | * problems if 167Bug is invoked before we get to switch the VBR back to |
---|
| 59 | * 167Bug because trap 13 is documented as being reserved for the internal |
---|
| 60 | * use of the debugger. |
---|
| 61 | */ |
---|
[48bff53b] | 62 | void bsp_fatal_extension( |
---|
| 63 | rtems_fatal_source source, |
---|
[6a9282d] | 64 | bool always_set_to_false, |
---|
[48bff53b] | 65 | rtems_fatal_code error |
---|
[f4adc0d1] | 66 | ) |
---|
[5d02459] | 67 | { |
---|
[48bff53b] | 68 | M68Kvec[ 45 ] = bsp_return_to_monitor_trap; |
---|
| 69 | __asm__ volatile( "trap #13" ); |
---|
[5d02459] | 70 | } |
---|