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

4.104.114.84.95
Last change on this file since d110897a was d110897a, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:07

2003-09-04 Joel Sherrill <joel@…>

  • clock/ckinit.c, console/console-recording.c, console/console.c, fatal/bspfatal.c, include/bsp.h, include/coverhd.h, include/fatal.h, include/page_table.h, startup/bspclean.c, startup/bspstart.c, startup/linkcmds, timer/timer.c, timer/timerisr.S: URL for license changed.
  • 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-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.rtems.com/license/LICENSE.
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  extern void page_table_teardown( void );
39
40  register volatile void *start_addr;
41
42  page_table_teardown();
43
44  lcsr->intr_ena = 0;               /* disable interrupts */
45  m68k_set_vbr(0xFFE00000);         /* restore 167Bug vectors */
46  asm volatile( "trap   #15\n\t"    /* trap to 167Bug */
47                ".short 0x63" );    /* return to 167Bug (.RETURN) */
48 
49  /* restart program */
50  start_addr = start;
51  asm volatile( "jmp %0@" : "=a" (start_addr) : "0" (start_addr) );
52}
53
54/*
55 *  bsp_cleanup
56 *
57 *  This code was copied from other MC680x0 MVME BSPs.
58 *  Our guess is that someone was concerned about the CPU no longer being in
59 *  supervisor mode when they got here. This function forces the CPU back to
60 *  supervisor mode so the VBR may be changed. It places the address of the
61 *  function that makes a 167Bug .RETURN syscall in the trap 13 entry in the
62 *  exception vector, and then issues a trap 13 call. It is also possible that
63 *  the code was copied from some other OS that does run tasks in user mode.
64 *  In any case, it appears to be a bit of paranoia, and could lead to
65 *  problems if 167Bug is invoked before we get to switch the VBR back to
66 *  167Bug because trap 13 is documented as being reserved for the internal
67 *  use of the debugger.
68 *
69 *  Prototyped in rtems/c/src/lib/libbsp/m68k/mvme167/include/bsp.h
70 *
71 *  Input parameters: NONE
72 *
73 *  Output parameters: NONE
74 *
75 *  Return values: DOES NOT RETURN
76 */
77void bsp_cleanup( void )
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.