source: rtems/c/src/lib/libbsp/m68k/mvme167/startup/bspclean.c @ 3a1d9c6

4.115
Last change on this file since 3a1d9c6 was 3a1d9c6, checked in by Sebastian Huber <sebastian.huber@…>, on 11/14/12 at 10:14:21

bsps: Include <bsp/bootcard.h>

Use <bsp/bootcard.h> to get prototype for bsp_cleanup(). Fix
bsp_cleanup() definition if necessary.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  bspclean.c
2 *
3 *  These routines return control to 167Bug after a normal exit from the
4 *  application.
5 *
6 *  COPYRIGHT (c) 1989-2010.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  Modifications of respective RTEMS files:
14 *  Copyright (c) 1998, National Research Council of Canada
15 */
16
17#include <bsp.h>
18#include <bsp/bootcard.h>
19#include <page_table.h>
20
21extern void start( void );
22extern void page_table_teardown( void );
23
24/*
25 *  bsp_return_to_monitor_trap
26 *
27 *  Switch the VBR back to ROM and make a .RETURN syscall to return control to
28 *  167 Bug. If 167Bug ever returns, restart the application.
29 *
30 *  Input parameters: NONE
31 *
32 *  Output parameters: NONE
33 *
34 *  Return values: NONE
35 */
36static void bsp_return_to_monitor_trap( void )
37{
38  register volatile void *start_addr;
39
40  page_table_teardown();
41
42  lcsr->intr_ena = 0;               /* disable interrupts */
43  m68k_set_vbr(0xFFE00000);         /* restore 167Bug vectors */
44  __asm__ volatile( "trap   #15\n\t"    /* trap to 167Bug */
45                ".short 0x63" );    /* return to 167Bug (.RETURN) */
46
47  /* restart program */
48  start_addr = start;
49  __asm__ volatile( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) );
50}
51
52/*
53 *  bsp_cleanup
54 *
55 *  This code was copied from other MC680x0 MVME BSPs.
56 *  Our guess is that someone was concerned about the CPU no longer being in
57 *  supervisor mode when they got here. This function forces the CPU back to
58 *  supervisor mode so the VBR may be changed. It places the address of the
59 *  function that makes a 167Bug .RETURN syscall in the trap 13 entry in the
60 *  exception vector, and then issues a trap 13 call. It is also possible that
61 *  the code was copied from some other OS that does run tasks in user mode.
62 *  In any case, it appears to be a bit of paranoia, and could lead to
63 *  problems if 167Bug is invoked before we get to switch the VBR back to
64 *  167Bug because trap 13 is documented as being reserved for the internal
65 *  use of the debugger.
66 *
67 *  Prototyped in rtems/c/src/lib/libbsp/m68k/mvme167/include/bsp.h
68 *
69 *  Input parameters: NONE
70 *
71 *  Output parameters: NONE
72 *
73 *  Return values: DOES NOT RETURN
74 */
75void bsp_cleanup(
76  uint32_t status
77)
78{
79   M68Kvec[ 45 ] = bsp_return_to_monitor_trap;
80   __asm__ volatile( "trap #13" );
81}
Note: See TracBrowser for help on using the repository browser.