diff options
| author | Bernard Xiong <[email protected]> | 2015-09-15 11:50:29 +0000 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2015-09-15 11:50:29 +0000 |
| commit | a0de58a008b1a4109491121fe3b342cb33f68250 (patch) | |
| tree | f3c6fbf1271b634f8ca2a13459907279aed7528b /libcpu | |
| parent | 811a2ead68281f0fdc4cfbf0c3adda81ac9d10f4 (diff) | |
[BSP] fix x86 bsp compiling issue
Diffstat (limited to 'libcpu')
| -rw-r--r-- | libcpu/ia32/hdisr_gcc.S | 7 | ||||
| -rw-r--r-- | libcpu/ia32/interrupt.c | 76 | ||||
| -rw-r--r-- | libcpu/ia32/trap.c | 5 |
3 files changed, 65 insertions, 23 deletions
diff --git a/libcpu/ia32/hdisr_gcc.S b/libcpu/ia32/hdisr_gcc.S index 29f200772f..6f79fe4c2a 100644 --- a/libcpu/ia32/hdisr_gcc.S +++ b/libcpu/ia32/hdisr_gcc.S @@ -60,7 +60,7 @@ HDINTERRUPTFNC(irq15, 15) .type _hdinterrupts,@function .globl rt_interrupt_enter .globl rt_interrupt_leave -.globl isr_table +.globl rt_hw_isr .globl rt_thread_switch_interrupt_flag .globl rt_interrupt_from_thread .globl rt_interrupt_to_thread @@ -81,10 +81,7 @@ _hdinterrupts: movl (%eax), %eax /* vector(eax) = *eax */ pushl %eax /* push argument : int vector */ - shll $0x2, %eax /* each item takes up 4bytes in isr_table. */ - movl $isr_table, %ebx /* ebx = &isr_table[0] */ - addl %eax, %ebx /* eax = &isr_table[vector] */ - call *(%ebx) + call rt_hw_isr add $4, %esp /* restore argument */ call rt_interrupt_leave diff --git a/libcpu/ia32/interrupt.c b/libcpu/ia32/interrupt.c index 01086a6266..4d86d593df 100644 --- a/libcpu/ia32/interrupt.c +++ b/libcpu/ia32/interrupt.c @@ -1,16 +1,27 @@ /* * File : interrupt.c * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://openlab.rt-thread.com/license/LICENSE + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Change Logs: * Date Author Notes + * 2015/9/15 Bernard Update to new interrupt framework. */ - + #include <rtthread.h> #include <rthw.h> @@ -23,9 +34,12 @@ rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread; rt_uint32_t rt_thread_switch_interrupt_flag; /* exception and interrupt handler table */ -rt_isr_handler_t isr_table[MAX_HANDLERS]; +struct rt_irq_desc irq_desc[MAX_HANDLERS]; + rt_uint16_t irq_mask_8259A = 0xFFFF; +void rt_hw_interrupt_handle(int vector, void* param); + /** * @addtogroup I386 */ @@ -64,19 +78,40 @@ void rt_hw_pic_init() rt_thread_switch_interrupt_flag = 0; } -void rt_hw_interrupt_handle(int vector) +void rt_hw_interrupt_handle(int vector, void* param) { rt_kprintf("Unhandled interrupt %d occured!!!\n", vector); } +void rt_hw_isr(int vector) +{ + if (vector < MAX_HANDLERS) + { + irq_desc[vector].handler(vector, irq_desc[vector].param); + } +} + /** * This function initializes interrupt descript table and 8259 interrupt controller * */ void rt_hw_interrupt_init(void) { + int idx; + rt_hw_idt_init(); rt_hw_pic_init(); + + /* init exceptions table */ + for(idx=0; idx < MAX_HANDLERS; idx++) + { + irq_desc[idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle; + irq_desc[idx].param = RT_NULL; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[idx].name, RT_NAME_MAX - 1, "default"); + irq_desc[idx].counter = 0; +#endif + } } void rt_hw_interrupt_umask(int vector) @@ -93,13 +128,28 @@ void rt_hw_interrupt_mask(int vector) outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8)); } -void rt_hw_interrupt_install(int vector, rt_isr_handler_t new_handler, rt_isr_handler_t *old_handler) +rt_isr_handler_t rt_hw_interrupt_install(int vector, + rt_isr_handler_t handler, + void *param, + char *name) { - if(vector < MAX_HANDLERS) - { - if (*old_handler != RT_NULL) *old_handler = isr_table[vector]; - if (new_handler != RT_NULL) isr_table[vector] = new_handler; - } + rt_isr_handler_t old_handler = RT_NULL; + + if(vector < MAX_HANDLERS) + { + old_handler = irq_desc[vector].handler; + if (handler != RT_NULL) + { + irq_desc[vector].handler = (rt_isr_handler_t)handler; + irq_desc[vector].param = param; +#ifdef RT_USING_INTERRUPT_INFO + rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name); + irq_desc[vector].counter = 0; +#endif + } + } + + return old_handler; } rt_base_t rt_hw_interrupt_disable(void) diff --git a/libcpu/ia32/trap.c b/libcpu/ia32/trap.c index 52b9e65ea3..5e9a51d6d2 100644 --- a/libcpu/ia32/trap.c +++ b/libcpu/ia32/trap.c @@ -44,11 +44,6 @@ void rt_hw_idt_init(void) extern void Xdefault; int i, j, func; - for(i=0; i<MAX_HANDLERS; i++) - { - isr_table[i] = rt_hw_interrupt_handle; - } - // install a default handler for (i = 0; i < sizeof(idt)/sizeof(idt[0]); i++) SETGATE(idt[i], 0, GD_KT, &Xdefault, 0); |
