OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [mvme167/] [fatal/] [bspfatal.c] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  fatal.c
2
 *
3
 *  User-define fatal error handler.
4
 *
5
 *  Copyright (c) 1998, National Research Council of Canada
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  $Id: bspfatal.c,v 1.2 2001-09-27 12:00:19 chris Exp $
12
 */
13
 
14
#include <bsp.h>
15
#include <fatal.h>
16
 
17
/*
18
 *  mystrcat
19
 *
20
 *  Can't rely on libc being operational. So we provide our own strcat-like
21
 *  function.
22
 *
23
 *  Input parameters:
24
 *    destination - string (buffer) to append to
25
 *    source - string to append to the end of destination
26
 *
27
 *  Output parameters:
28
 *    destination - source is appended to the end
29
 *
30
 *  Return values:
31
 *    Number of characters appended.
32
 */
33
static int mystrcat(
34
  char *destination,
35
  const char *source
36
)
37
{
38
  int i;
39
 
40
  for ( i = 0; ( *destination++ = *source++) != '\0'; i++ );
41
  return i;
42
}
43
 
44
 
45
/*
46
 *  bsp_fatal_error_occurred
47
 *
48
 *  Called when rtems_fatal_error_occurred() is called. Returns control to
49
 *  167Bug. The _Internal_error_Occurred() function has already saved the
50
 *  parameters in Internal_errors_What_happened. If the function returns,
51
 *  RTEMS will halt the CPU.
52
 *
53
 *  Make sure the CPU is
54
 *
55
 *  Input parameters:
56
 *    the_source  - what subsystem the error originated in
57
 *    is_internal - if the error was internally generated
58
 *    the_error   - fatal error status code
59
 *
60
 *  Output parameters:
61
 *    output to the 167Bug console
62
 *
63
 *  Return values: NONE.
64
 */
65
User_extensions_routine bsp_fatal_error_occurred(
66
  Internal_errors_Source  the_source,
67
  rtems_boolean           is_internal,
68
  rtems_unsigned32        the_error
69
)
70
{
71
  struct {
72
    char index;         /* First byte is number of chars in strbuf  */
73
    char strbuf[254];   /* In case count is bumped up by one by 167Bug */
74
  } my_p_str;
75
 
76
  my_p_str.index = 0;
77
  my_p_str.index += mystrcat(
78
      my_p_str.strbuf + my_p_str.index,
79
      "\r\nRTEMS Fatal Error Occurred:\r\n    the_source  = " );
80
 
81
  switch ( the_source ) {
82
    case INTERNAL_ERROR_CORE:
83
      my_p_str.index += mystrcat(
84
          my_p_str.strbuf + my_p_str.index,
85
          "INTERNAL_ERROR_CORE\r\n    is_internal = " );
86
      break;
87
 
88
    case INTERNAL_ERROR_RTEMS_API:
89
      my_p_str.index += mystrcat(
90
          my_p_str.strbuf + my_p_str.index,
91
          "INTERNAL_ERROR_RTEMS_API\r\n    is_internal = " );
92
      break;
93
 
94
    case INTERNAL_ERROR_POSIX_API:
95
      my_p_str.index += mystrcat(
96
          my_p_str.strbuf + my_p_str.index,
97
          "INTERNAL_ERROR_POSIX_API\r\n    is_internal = " );
98
      break;
99
 
100
    default:
101
      my_p_str.index += mystrcat(
102
          my_p_str.strbuf + my_p_str.index,
103
          "UNKNOWN\r\n    is_internal = " );
104
      break;
105
  }
106
 
107
  if ( is_internal )
108
    my_p_str.index += mystrcat(
109
        my_p_str.strbuf + my_p_str.index,
110
        "TRUE\r\n    the_error   = 0x|10,8|\r\n" );
111
  else
112
    my_p_str.index += mystrcat(
113
        my_p_str.strbuf + my_p_str.index,
114
        "FALSE\r\n    the_error   = 0x|10,8|\r\n" );
115
 
116
  lcsr->intr_ena = 0;               /* disable interrupts */
117
  m68k_set_vbr(0xFFE00000);         /* restore 167Bug vectors */
118
 
119
  asm volatile( "movel  %0, -(%%a7)
120
                 pea    (%%a7)
121
                 pea    (%1)
122
                 trap   #15         /* trap to 167Bug (.WRITDLN) */
123
                 .short 0x25
124
                 trap   #15
125
                 .short 0x63"
126
    :: "d" (the_error), "a" (&my_p_str) );
127
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.