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

4.104.114.84.95
Last change on this file since f52111f was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

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