|
0
|
1 //============================================================================= |
|
|
2 // |
|
|
3 // hal_misc.c |
|
|
4 // |
|
|
5 // HAL miscellaneous functions |
|
|
6 // |
|
|
7 //============================================================================= |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //============================================================================= |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): nickg |
|
|
33 // Contributors: nickg |
|
|
34 // Date: 1997-11-12 |
|
|
35 // Purpose: HAL miscellaneous functions |
|
|
36 // Description: This file contains miscellaneous functions provided by the |
|
|
37 // HAL. |
|
|
38 // |
|
|
39 //####DESCRIPTIONEND#### |
|
|
40 // |
|
|
41 //============================================================================= |
|
|
42 |
|
|
43 #include <pkgconf/hal.h> |
|
|
44 |
|
|
45 #include <cyg/infra/cyg_type.h> |
|
|
46 #include <cyg/infra/cyg_trac.h> // tracing macros |
|
|
47 #include <cyg/infra/cyg_ass.h> // assertion macros |
|
|
48 |
|
|
49 #include <cyg/hal/hal_arch.h> // HAL header |
|
|
50 |
|
|
51 //--------------------------------------------------------------------------- |
|
|
52 |
|
|
53 void cyg_hal_invoke_constructors (void) |
|
|
54 { |
|
|
55 static int initialized = 0; |
|
|
56 |
|
|
57 if (! initialized) |
|
|
58 { |
|
|
59 typedef void (*pfunc) (void); |
|
|
60 extern pfunc __CTOR_LIST__[]; |
|
|
61 extern pfunc __CTOR_END__[]; |
|
|
62 pfunc *p; |
|
|
63 |
|
|
64 initialized = 1; |
|
|
65 |
|
|
66 for (p = &__CTOR_END__[0]-1; p >= __CTOR_LIST__; p--){ |
|
|
67 (*p) (); |
|
|
68 } |
|
|
69 } |
|
|
70 } |
|
|
71 |
|
|
72 // Override any __eabi the compiler might generate. We don't want |
|
|
73 // constructors to be called twice. |
|
|
74 void __eabi (void) {} |
|
|
75 |
|
|
76 //--------------------------------------------------------------------------- |
|
|
77 // First level C exception handler. |
|
|
78 |
|
|
79 externC void __handle_exception (void); |
|
|
80 |
|
|
81 externC HAL_SavedRegisters *_hal_registers; |
|
|
82 |
|
|
83 void exception_handler(HAL_SavedRegisters *regs) |
|
|
84 { |
|
|
85 #ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS |
|
|
86 |
|
|
87 // Set the pointer to the registers of the current exception |
|
|
88 // context. At entry the GDB stub will expand the |
|
|
89 // HAL_SavedRegisters structure into a (bigger) register array. |
|
|
90 _hal_registers = regs; |
|
|
91 |
|
|
92 __handle_exception(); |
|
|
93 |
|
|
94 #elif defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && defined(CYGPKG_HAL_EXCEPTIONS) |
|
|
95 |
|
|
96 // We should decode the vector and pass a more appropriate |
|
|
97 // value as the second argument. For now we simply pass a |
|
|
98 // pointer to the saved registers. We should also divert |
|
|
99 // breakpoint and other debug vectors into the debug stubs. |
|
|
100 |
|
|
101 deliver_exception( regs->vector>>8, (CYG_ADDRWORD)regs ); |
|
|
102 |
|
|
103 #else |
|
|
104 |
|
|
105 CYG_FAIL("Exception!!!"); |
|
|
106 |
|
|
107 #endif |
|
|
108 |
|
|
109 return; |
|
|
110 } |
|
|
111 |
|
|
112 //--------------------------------------------------------------------------- |
|
|
113 // Default ISR |
|
|
114 |
|
|
115 externC cyg_uint32 hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) |
|
|
116 { |
|
|
117 CYG_TRACE1(true, "Interrupt: %d", vector); |
|
|
118 CYG_FAIL("Spurious Interrupt!!!"); |
|
|
119 return 0; |
|
|
120 } |
|
|
121 |
|
|
122 //--------------------------------------------------------------------------- |
|
|
123 // Idle thread action |
|
|
124 |
|
|
125 void hal_idle_thread_action( cyg_uint32 count ) |
|
|
126 { |
|
|
127 } |
|
|
128 |
|
|
129 //--------------------------------------------------------------------------- |
|
|
130 // End of hal_misc.c |