|
2
|
1 //============================================================================= |
|
|
2 // |
|
|
3 // hal_startup.c |
|
|
4 // |
|
|
5 // HAL bootstrap code |
|
|
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 // October 31, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //============================================================================= |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): proven |
|
|
33 // Contributors:proven, jskov |
|
|
34 // Date: 1998-10-06 |
|
|
35 // Purpose: HAL diagnostic output |
|
|
36 // Description: Implementations of HAL diagnostic output support. |
|
|
37 // |
|
|
38 //####DESCRIPTIONEND#### |
|
|
39 // |
|
|
40 //============================================================================= |
|
|
41 |
|
|
42 #include <pkgconf/hal.h> |
|
|
43 |
|
|
44 #ifdef CYGPKG_KERNEL |
|
|
45 #include <pkgconf/kernel.h> |
|
|
46 #include <cyg/kernel/kapi.h> // cyg_scheduler_lock |
|
|
47 #endif |
|
|
48 |
|
|
49 #include <cyg/hal/hal_intr.h> // interrupt stuff |
|
|
50 #include <cyg/hal/hal_arch.h> // Architecture specific definitions |
|
|
51 |
|
|
52 #include <cyg/infra/diag.h> // diag_printf |
|
|
53 #include <cyg/infra/cyg_ass.h> // ASSERTION macros |
|
|
54 |
|
|
55 |
|
|
56 //---------------------------------------------------------------------------- |
|
|
57 // ISR tables |
|
|
58 volatile CYG_ADDRESS cyg_hal_interrupt_handlers[CYGNUM_HAL_ISR_COUNT]; |
|
|
59 volatile CYG_ADDRWORD cyg_hal_interrupt_data[CYGNUM_HAL_ISR_COUNT]; |
|
|
60 volatile CYG_ADDRESS cyg_hal_interrupt_objects[CYGNUM_HAL_ISR_COUNT]; |
|
|
61 |
|
|
62 // VSR table |
|
|
63 volatile CYG_ADDRESS cyg_hal_vsr_table[CYGNUM_HAL_VSR_COUNT]; |
|
|
64 |
|
|
65 // Interrupts start disabled |
|
|
66 volatile int cyg_hal_interrupts_disabled = 1; |
|
|
67 volatile int cyg_hal_interrupts_deferred; |
|
|
68 volatile int cyg_hal_interrupts_unhandled[CYGNUM_HAL_ISR_COUNT]; |
|
|
69 |
|
|
70 //----------------------------------------------------------------------------- |
|
|
71 |
|
|
72 typedef cyg_uint32 (*callsig_t)(int vector, cyg_uint32); |
|
|
73 |
|
|
74 externC void interrupt_end(CYG_ADDRESS, CYG_ADDRESS, CYG_ADDRESS); |
|
|
75 extern volatile cyg_uint32 cyg_scheduler_sched_lock; |
|
|
76 |
|
|
77 externC void cyg_hal_default_interrupt_vsr(int vector) |
|
|
78 { |
|
|
79 callsig_t func; |
|
|
80 cyg_uint32 ret; |
|
|
81 |
|
|
82 if (cyg_hal_interrupts_disabled) { |
|
|
83 cyg_hal_interrupts_unhandled[vector] = 1; |
|
|
84 cyg_hal_interrupts_deferred = 1; |
|
|
85 return; |
|
|
86 } |
|
|
87 |
|
|
88 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT |
|
|
89 // Increment the scheduler lock when the kernel is present. |
|
|
90 cyg_scheduler_sched_lock++; |
|
|
91 #endif |
|
|
92 |
|
|
93 cyg_hal_interrupts_unhandled[vector] = 0; |
|
|
94 func = (callsig_t) cyg_hal_interrupt_handlers[vector]; |
|
|
95 ret = func(vector, cyg_hal_interrupt_data[vector]); |
|
|
96 |
|
|
97 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT |
|
|
98 // We only need to call _interrupt_end() when there is a kernel |
|
|
99 // present to do any tidying up. |
|
|
100 interrupt_end(ret, cyg_hal_interrupt_objects[vector], (CYG_ADDRESS) NULL); |
|
|
101 #endif |
|
|
102 } |
|
|
103 |
|
|
104 externC void cyg_hal_default_exception_vsr(int vector) |
|
|
105 { |
|
|
106 #if defined(CYGFUN_HAL_COMMON_KERNEL_SUPPORT) && \ |
|
|
107 defined(CYGPKG_HAL_EXCEPTIONS) |
|
|
108 |
|
|
109 { |
|
|
110 int __pre_state = cyg_hal_interrupts_disabled++; |
|
|
111 |
|
|
112 cyg_hal_deliver_exception( vector, 0 ); |
|
|
113 |
|
|
114 cyg_hal_interrupts_disabled = __pre_state; |
|
|
115 } |
|
|
116 |
|
|
117 #else |
|
|
118 |
|
|
119 CYG_FAIL("Exception!!!"); |
|
|
120 |
|
|
121 #endif |
|
|
122 } |
|
|
123 |
|
|
124 //--------------------------------------------------------------------------- |
|
|
125 // Default ISR |
|
|
126 |
|
|
127 externC cyg_uint32 |
|
|
128 cyg_hal_default_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data) |
|
|
129 { |
|
|
130 diag_printf("Interrupt: %d\n", vector); |
|
|
131 |
|
|
132 CYG_FAIL("Spurious Interrupt!!!"); |
|
|
133 return 0; |
|
|
134 } |
|
|
135 |
|
|
136 //----------------------------------------------------------------------------- |
|
|
137 // Initialization on the VSRs. |
|
|
138 struct hal_sigaction { |
|
|
139 void (*hal_handler)(int); |
|
|
140 long hal_mask; |
|
|
141 int hal_flags; |
|
|
142 void (*hal_bogus)(int); |
|
|
143 } act, oact; |
|
|
144 extern int cyg_hal_sys_sigaction(int, const struct hal_sigaction*, |
|
|
145 struct hal_sigaction*); |
|
|
146 externC void cyg_hal_isr_init(void) |
|
|
147 { |
|
|
148 int i; |
|
|
149 |
|
|
150 // ISR setup |
|
|
151 for (i = 0; i < CYGNUM_HAL_ISR_COUNT; i++) { |
|
|
152 cyg_hal_interrupt_handlers[i] = (CYG_ADDRESS) &cyg_hal_default_isr; |
|
|
153 } |
|
|
154 |
|
|
155 // Interrupt VSR setup |
|
|
156 act.hal_handler = cyg_hal_default_interrupt_vsr; |
|
|
157 act.hal_mask = 0; |
|
|
158 act.hal_flags = 0; |
|
|
159 cyg_hal_sys_sigaction(CYGNUM_HAL_INTERRUPT_RTC, &act, &oact); |
|
|
160 |
|
|
161 // Exception VSR setup |
|
|
162 act.hal_handler = cyg_hal_default_exception_vsr; |
|
|
163 act.hal_mask = 0; |
|
|
164 act.hal_flags = 0; |
|
|
165 cyg_hal_sys_sigaction(CYGNUM_HAL_VECTOR_SIGSEGV, &act, &oact); |
|
|
166 cyg_hal_sys_sigaction(CYGNUM_HAL_VECTOR_SIGBUS, &act, &oact); |
|
|
167 cyg_hal_sys_sigaction(CYGNUM_HAL_VECTOR_SIGFPE, &act, &oact); |
|
|
168 } |
|
|
169 |
|
|
170 //----------------------------------------------------------------------------- |
|
|
171 // End of hal_startup.c |