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

4.115
Last change on this file since 1bdfd262 was 1bdfd262, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/11/11 at 12:37:58

2011-02-11 Ralf Corsépius <ralf.corsepius@…>

  • console/console.c, fatal/bspfatal.c, startup/bspclean.c, startup/page_table.c: Use "asm" instead of "asm" for improved c99-compliance.
  • 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 *  $Id$
17 */
18
19#include <rtems.h>
20#include <bsp.h>
21#include <page_table.h>
22
23extern void start( void );
24extern void page_table_teardown( void );
25
26/*
27 *  bsp_return_to_monitor_trap
28 *
29 *  Switch the VBR back to ROM and make a .RETURN syscall to return control to
30 *  167 Bug. If 167Bug ever returns, restart the application.
31 *
32 *  Input parameters: NONE
33 *
34 *  Output parameters: NONE
35 *
36 *  Return values: NONE
37 */
38static void bsp_return_to_monitor_trap( 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.