summaryrefslogtreecommitdiffstats
path: root/c/src/exec/score/cpu/hppa1.1/cpu.c
blob: 282e0e53b66def2367ed370c9362e39099a0941e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 *  HP PA-RISC Dependent Source
 *
 *  COPYRIGHT (c) 1994 by Division Incorporated
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#include <rtems/system.h>
#include <rtems/score/isr.h>
void hppa_cpu_halt(unsigned32 the_error);


/*PAGE
 *
 *  _CPU_ISR_install_raw_handler
 */
 
void _CPU_ISR_install_raw_handler(
  unsigned32  vector,
  proc_ptr    new_handler,
  proc_ptr   *old_handler
)
{
  /*
   *  This is unsupported.  For HPPA this function is handled by BSP
   */

  _CPU_Fatal_halt( 0xdeaddead );
}



/*
 * This is the default handler which is called if
 * _CPU_ISR_install_vector() has not been called for the
 * specified vector.  It simply forwards onto the spurious
 * handler defined in the cpu-table.
 */

static ISR_Handler
hppa_interrupt_report_spurious(ISR_Vector_number vector,
                               void* rtems_isr_frame) /* HPPA extension */
{

    /*
     * If the CPU table defines a spurious_handler, then
     * call it.  If the handler returns halt.
     */
    if ( _CPU_Table.spurious_handler )
        _CPU_Table.spurious_handler(vector, rtems_isr_frame);
    
    hppa_cpu_halt(vector);
}


/*PAGE
 *
 *  _CPU_ISR_Get_level
 */
 
unsigned32 _CPU_ISR_Get_level(void)
{
    int level;
    HPPA_ASM_SSM(0, level);	/* change no bits; just get copy */
    if (level & HPPA_PSW_I)
        return 0;
    return 1;
}

/*PAGE
 *
 *  _CPU_ISR_install_vector
 *
 *  This kernel routine installs the RTEMS handler for the
 *  specified vector.  The handler is a C callable routine.
 *
 *  Input parameters:
 *    vector      - interrupt vector number
 *    old_handler - former ISR for this vector number
 *    new_handler - replacement ISR for this vector number
 *
 *  Output parameters:  NONE
 *
 */

void _CPU_ISR_install_vector(
  unsigned32  vector,
  proc_ptr    new_handler,
  proc_ptr   *old_handler
)
{
    *old_handler = _ISR_Vector_table[vector];

    _ISR_Vector_table[vector] = new_handler;
}

/*  _CPU_Initialize
 *
 *  This routine performs processor dependent initialization.
 *
 *  INPUT PARAMETERS:
 *    cpu_table       - CPU table to initialize
 *    thread_dispatch - address of disptaching routine
 *
 */

void _CPU_Initialize(
  rtems_cpu_table  *cpu_table,
  void      (*thread_dispatch)      /* ignored on this CPU */
)
{
    register unsigned8  *fp_context;
    unsigned32 i;
    proc_ptr   old_handler;

    /*
     * This is the default fp context for all tasks
     * Set it up so that denormalized results go to zero.
     */

    fp_context = (unsigned8*) &_CPU_Null_fp_context;
    for (i=0 ; i<sizeof(Context_Control_fp); i++)
        *fp_context++ = 0;
    *((unsigned32 *) &_CPU_Null_fp_context) = HPPA_FPSTATUS_D;

    /*
     *  Save r27 into _CPU_Default_gr27 so it will hopefully be the correct
     *  global data pointer for the entire system.
     */

    asm volatile( "stw   %%r27,%0" : "=m" (_CPU_Default_gr27): );

    /*
     * Init the 2nd level interrupt handlers
     */

    for (i=0; i < CPU_INTERRUPT_NUMBER_OF_VECTORS; i++)
        _CPU_ISR_install_vector(i,
                                hppa_interrupt_report_spurious,
                                &old_handler);

    _CPU_Table = *cpu_table;
    
}


/*
 * Halt the system.
 * Called by the _CPU_Fatal_halt macro
 *
 * XXX
 * Later on, this will allow us to return to the prom.
 * For now, we just ignore 'type_of_halt'
 *
 * XXX
 * NOTE: for gcc, this function must be at the bottom
 * of the file, that is because if it is at the top
 * of the file, gcc will inline it's calls.  Since
 * the function uses the HPPA_ASM_LABEL() macro, when
 * gcc inlines it, you get two definitions of the same
 * label name, which is an assembly error.
 */


void
hppa_cpu_halt(unsigned32 the_error)
{
    unsigned32 isrlevel;

    _CPU_ISR_Disable(isrlevel);

    /*
     * XXXXX NOTE: This label is only needed that that when
     * the simulator stops, it shows the label name specified
     */
    HPPA_ASM_LABEL("_hppa_cpu_halt");
    HPPA_ASM_BREAK(0, 0);
}