1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * These routines return control to 167Bug after a normal exit from the |
---|
5 | * application. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2012. |
---|
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 |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | * |
---|
16 | * Modifications of respective RTEMS files: |
---|
17 | * Copyright (c) 1998, National Research Council of Canada |
---|
18 | */ |
---|
19 | |
---|
20 | #include <bsp.h> |
---|
21 | #include <bsp/bootcard.h> |
---|
22 | #include <page_table.h> |
---|
23 | |
---|
24 | extern void start( void ); |
---|
25 | extern void page_table_teardown( void ); |
---|
26 | |
---|
27 | /** |
---|
28 | * @brief bsp_return_to_monitor_trap |
---|
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 */ |
---|
41 | __asm__ volatile( "trap #15\n\t" /* trap to 167Bug */ |
---|
42 | ".short 0x63" ); /* return to 167Bug (.RETURN) */ |
---|
43 | |
---|
44 | /* restart program */ |
---|
45 | start_addr = start; |
---|
46 | __asm__ volatile( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) ); |
---|
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. |
---|
57 | * In any case, it appears to be a bit of paranoia, and could lead to |
---|
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 | */ |
---|
62 | void bsp_fatal_extension( |
---|
63 | rtems_fatal_source source, |
---|
64 | bool is_internal, |
---|
65 | rtems_fatal_code error |
---|
66 | ) |
---|
67 | { |
---|
68 | M68Kvec[ 45 ] = bsp_return_to_monitor_trap; |
---|
69 | __asm__ volatile( "trap #13" ); |
---|
70 | } |
---|