Mercurial > ecos
comparison packages/hal/i386/pc/current/src/hal_intr.c @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 /*============================================================================= | |
| 2 // | |
| 3 // hal_intr.c | |
| 4 // | |
| 5 // HAL interrupt support | |
| 6 // | |
| 7 //============================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (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://www.redhat.com/ | |
| 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 Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //============================================================================= | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): pjo | |
| 35 // Contributors: nickg | |
| 36 // Date: 2000-2-10 | |
| 37 // Purpose: HAL interrupt support | |
| 38 // Description: Implementations of HAL interrupt support code. | |
| 39 // | |
| 40 //####DESCRIPTIONEND#### | |
| 41 // | |
| 42 //===========================================================================*/ | |
| 43 | |
| 44 # include <pkgconf/hal.h> | |
| 45 # include <cyg/infra/cyg_type.h> | |
| 46 # include <cyg/infra/cyg_ass.h> | |
| 47 # include <cyg/hal/hal_arch.h> | |
| 48 # include <cyg/hal/hal_intr.h> | |
| 49 # include <cyg/hal/drv_api.h> | |
| 50 | |
| 51 | |
| 52 //===========================================================================*/ | |
| 53 | |
| 54 extern void hal_pc_generic_interrupt(void) ; | |
| 55 extern char hal_pc_generic_interrupt_start ; | |
| 56 extern char hal_pc_generic_interrupt_vector ; | |
| 57 extern char hal_pc_generic_interrupt_end ; | |
| 58 | |
| 59 //===========================================================================*/ | |
| 60 | |
| 61 cyg_uint32 hal_pc_in_interrupt ; | |
| 62 cyg_uint32 hal_pc_interrupt_esp ; | |
| 63 | |
| 64 //===========================================================================*/ | |
| 65 | |
| 66 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK | |
| 67 char __interrupt_stack_base[CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE] ; | |
| 68 char * __interrupt_stack = &(__interrupt_stack_base[CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE]) ; | |
| 69 #endif /* CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK */ | |
| 70 | |
| 71 | |
| 72 //===========================================================================*/ | |
| 73 /* The interrupts are handled by stubs which are copied into | |
| 74 hal_pc_interrupt_routine[vector]. See vectors.S, hal_pc_generic_interrupt, | |
| 75 for the source code which is copied there. | |
| 76 */ | |
| 77 #define HAL_PC_INTERRUPT_ROUTINE_SIZE (16) | |
| 78 typedef char hal_pc_interrupt_routine_t[HAL_PC_INTERRUPT_ROUTINE_SIZE] ; | |
| 79 | |
| 80 hal_pc_interrupt_routine_t hal_pc_interrupt_routine[CYGNUM_HAL_ISR_COUNT] ; | |
| 81 | |
| 82 //===========================================================================*/ | |
| 83 | |
| 84 #if 0 | |
| 85 | |
| 86 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 87 void interrupt_end(cyg_uint32 isr_ret, cyg_interrupt * intr, HAL_SavedRegisters * sr); | |
| 88 #endif /* CYGFUN_HAL_COMMON_KERNEL_SUPPORT */ | |
| 89 | |
| 90 | |
| 91 int hal_pc_interrupt(cyg_uint32 vector, cyg_uint32 * esp) | |
| 92 { | |
| 93 int r ; | |
| 94 cyg_ISR_t * routine ; | |
| 95 HAL_SavedRegisters * regs ; | |
| 96 | |
| 97 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 98 extern cyg_uint32 cyg_scheduler_sched_lock ; | |
| 99 #endif /* CYGFUN_HAL_COMMON_KERNEL_SUPPORT */ | |
| 100 | |
| 101 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 102 cyg_scheduler_sched_lock++ ; | |
| 103 #endif /* CYGFUN_HAL_COMMON_KERNEL_SUPPORT */ | |
| 104 | |
| 105 /* Save the registers into regs. */ | |
| 106 regs = (HAL_SavedRegisters*) esp[0] ; | |
| 107 | |
| 108 routine = (cyg_ISR_t *) cyg_hal_interrupt_handlers[vector] ; | |
| 109 r = routine(vector, cyg_hal_interrupt_data[vector]); | |
| 110 | |
| 111 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 112 interrupt_end(r, (cyg_interrupt*) cyg_hal_interrupt_objects[vector], regs) ; | |
| 113 #endif /* CYGFUN_HAL_COMMON_KERNEL_SUPPORT */ | |
| 114 | |
| 115 #ifdef CYGFUN_HAL_COMMON_KERNEL_SUPPORT | |
| 116 // cyg_scheduler_sched_lock-- ; | |
| 117 #endif /* CYGFUN_HAL_COMMON_KERNEL_SUPPORT */ | |
| 118 | |
| 119 return r ; | |
| 120 } | |
| 121 #endif | |
| 122 | |
| 123 | |
| 124 //===========================================================================*/ | |
| 125 | |
| 126 void hal_pc_interrupt_attach(CYG_ADDRWORD vector, CYG_ADDRESS routine, | |
| 127 CYG_ADDRWORD parameter, void * object) | |
| 128 { | |
| 129 int l ; | |
| 130 char * d ; | |
| 131 short * q ; | |
| 132 CYG_ADDRWORD r ; | |
| 133 cyg_uint32 * id ; | |
| 134 | |
| 135 l = &hal_pc_generic_interrupt_end - &hal_pc_generic_interrupt_start ; | |
| 136 | |
| 137 /* Let's make sure that hal_pc_interrupt_routine entries are large enough. */ | |
| 138 CYG_ASSERT(l <= HAL_PC_INTERRUPT_ROUTINE_SIZE, "HAL_PC_INTERRUPT_ROUTINE_SIZE is too small"); | |
| 139 | |
| 140 /* Put the desired routine and parameter into the table. */ | |
| 141 cyg_hal_interrupt_data[vector] = (cyg_uint32) parameter ; | |
| 142 cyg_hal_interrupt_handlers[vector] = (CYG_ADDRWORD) routine ; | |
| 143 cyg_hal_interrupt_objects[vector] = (CYG_ADDRWORD) object ; | |
| 144 | |
| 145 d = hal_pc_interrupt_routine[vector] ; | |
| 146 | |
| 147 /* Initialize the entry we're interested in using. */ | |
| 148 memset(d, HAL_BREAKINST, HAL_PC_INTERRUPT_ROUTINE_SIZE); | |
| 149 memcpy(d, hal_pc_generic_interrupt, l) ; | |
| 150 | |
| 151 l = &hal_pc_generic_interrupt_vector - &hal_pc_generic_interrupt_start ; | |
| 152 id = (cyg_uint32*) &(d[l]) ; | |
| 153 id[0] = vector ; | |
| 154 | |
| 155 /* Now write the vector into the IDT. */ | |
| 156 q = (short*) (vector * 8) ; | |
| 157 r = (CYG_ADDRWORD) d ; | |
| 158 q[0] = (r & 0xFFFF) ; | |
| 159 q[1] = 8 ; | |
| 160 q[2] = 0x8E00 ; | |
| 161 q[3] = (r >> 16) ; | |
| 162 } | |
| 163 | |
| 164 | |
| 165 /*---------------------------------------------------------------------------*/ | |
| 166 /* End of hal_intr.c */ |
