OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [i386/] [arch/] [v2_0/] [src/] [hal_misc.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//===========================================================================
2
//
3
//      hal_misc.c
4
//
5
//      HAL miscellaneous functions
6
//
7
//===========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under
14
// the terms of the GNU General Public License as published by the Free
15
// Software Foundation; either version 2 or (at your option) any later version.
16
//
17
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
// for more details.
21
//
22
// You should have received a copy of the GNU General Public License along
23
// with eCos; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
//
26
// As a special exception, if other files instantiate templates or use macros
27
// or inline functions from this file, or you compile this file and link it
28
// with other works to produce a work based on this file, this file does not
29
// by itself cause the resulting work to be covered by the GNU General Public
30
// License. However the source code for this file must still be made available
31
// in accordance with section (3) of the GNU General Public License.
32
//
33
// This exception does not invalidate any other reasons why a work based on
34
// this file might be covered by the GNU General Public License.
35
//
36
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
// at http://sources.redhat.com/ecos/ecos-license/
38
// -------------------------------------------
39
//####ECOSGPLCOPYRIGHTEND####
40
//===========================================================================
41
//#####DESCRIPTIONBEGIN####
42
//
43
// Author(s):    nickg
44
// Contributors: proven, pjo
45
// Date:        1999-02-20
46
// Purpose:     HAL miscellaneous functions
47
// Description: This file contains miscellaneous functions provided by the
48
//              HAL.
49
//
50
//####DESCRIPTIONEND####
51
//
52
//===========================================================================
53
 
54
#include <pkgconf/hal.h>
55
 
56
#include <cyg/infra/cyg_type.h>
57
#include <cyg/infra/cyg_ass.h>
58
#include <cyg/infra/diag.h>      // diag_printf
59
 
60
#include <cyg/hal/hal_arch.h>
61
 
62
#include <cyg/hal/hal_if.h>
63
 
64
//---------------------------------------------------------------------------
65
 
66
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
67
cyg_bool cyg_hal_stop_constructors;
68
#endif
69
 
70
typedef void (*pfunc) (void);
71
extern pfunc __CTOR_LIST__[];
72
extern pfunc __CTOR_END__[];
73
 
74
void
75
cyg_hal_invoke_constructors (void)
76
{
77
 
78
#ifdef CYGSEM_HAL_STOP_CONSTRUCTORS_ON_FLAG
79
    static pfunc *p = &__CTOR_END__[-1];
80
    cyg_hal_stop_constructors = 0;
81
    for (; p >= __CTOR_LIST__; p--) {
82
        (*p) ();
83
        if (cyg_hal_stop_constructors) {
84
            p--;
85
            break;
86
        }
87
    }
88
#else
89
    pfunc *p;
90
 
91
    for (p = &__CTOR_END__[-1]; p >= __CTOR_LIST__; p--)
92
        (*p) ();
93
#endif
94
}
95
 
96
//---------------------------------------------------------------------------
97
// First level C exception handler.
98
 
99
externC void __handle_exception (void);
100
externC HAL_SavedRegisters *_hal_registers;
101
 
102
externC void* volatile __mem_fault_handler;
103
 
104
void
105
cyg_hal_exception_handler(HAL_SavedRegisters *regs)
106
{
107
#if defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) && !defined(CYGPKG_CYGMON)
108
 
109
    // If we caught an exception inside the stubs, see if we were expecting it
110
    // and if so jump to the saved address
111
    if (__mem_fault_handler) {
112
        regs->pc = (CYG_ADDRWORD)__mem_fault_handler;
113
        return; // Caught an exception inside stubs        
114
    }
115
 
116
    _hal_registers = regs;
117
    __handle_exception();
118
 
119
#elif defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && defined(CYGPKG_HAL_EXCEPTIONS)
120
    // We should decode the vector and pass a more appropriate
121
    // value as the second argument. For now we simply pass a
122
    // pointer to the saved registers. We should also divert
123
    // breakpoint and other debug vectors into the debug stubs.
124
 
125
    cyg_hal_deliver_exception( regs->vector>>8, (CYG_ADDRWORD)regs );
126
 
127
#else
128
    CYG_FAIL("Exception!!!");
129
#endif    
130
    return;
131
}
132
 
133
/*------------------------------------------------------------------------*/
134
/* default architecture ISR                                               */
135
/* The real default ISR is in hal/common/.../src/hal_misc.c               */
136
 
137
externC cyg_uint32 hal_arch_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
138
{
139
    // For some reason I seem to be geting spurious interrupts on
140
    // interrupt 0x27(39). This is the parallel port. This is masked
141
    // in the PIC so the exact reason for these is a mystery. They do
142
    // appear to be real interrupts since they always appear just
143
    // after a clear of the interrupt flag, and the stack shows a
144
    // proper interrupt context being pushed by the hardware. This may
145
    // be some feature of the Celeron CPU I am using. 
146
 
147
    if( vector == 0x27 )
148
        return 2;
149
 
150
    diag_printf("hal_arch_default_isr: %d (data: %d)\n", vector,data);
151
    CYG_FAIL("Spurious Interrupt!!!");
152
 
153
    return 0;
154
}
155
 
156
//---------------------------------------------------------------------------
157
// End of hal_misc.c

powered by: WebSVN 2.1.0

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