2009-07-03 07:17:11 +08:00
|
|
|
/*
|
2012-02-16 12:19:20 +08:00
|
|
|
* File : hdisr_gcc.S
|
2009-07-03 07:17:11 +08:00
|
|
|
* This file is part of RT-Thread RTOS
|
|
|
|
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
* found in the file LICENSE in this distribution or at
|
2012-02-16 12:19:20 +08:00
|
|
|
* http://www.rt-thread.org/license/LICENSE
|
2009-07-03 07:17:11 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2012-02-16 12:19:20 +08:00
|
|
|
* 2006-09-15 QiuYi The first version
|
2009-07-03 07:17:11 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup I386
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
#define ENTRY(proc)\
|
|
|
|
.align 2;\
|
|
|
|
.globl proc;\
|
|
|
|
.type proc,@function;\
|
|
|
|
proc:
|
|
|
|
#define HDINTERRUPTFNC(name,num) \
|
|
|
|
ENTRY(name)\
|
|
|
|
pushl $(num);\
|
|
|
|
jmp _hdinterrupts;\
|
|
|
|
.data;\
|
|
|
|
.long name;\
|
2012-10-11 00:39:49 +08:00
|
|
|
.text
|
2009-07-03 07:17:11 +08:00
|
|
|
|
|
|
|
.globl hdinterrupt_func
|
|
|
|
.data
|
|
|
|
.align 4
|
|
|
|
.type hdinterrupt_func,@object
|
|
|
|
hdinterrupt_func :
|
|
|
|
.text
|
|
|
|
|
|
|
|
/* the external device interrupts */
|
|
|
|
HDINTERRUPTFNC(irq0, 0)
|
|
|
|
HDINTERRUPTFNC(irq1, 1)
|
|
|
|
HDINTERRUPTFNC(irq2, 2)
|
|
|
|
HDINTERRUPTFNC(irq3, 3)
|
|
|
|
HDINTERRUPTFNC(irq4, 4)
|
|
|
|
HDINTERRUPTFNC(irq5, 5)
|
|
|
|
HDINTERRUPTFNC(irq6, 6)
|
|
|
|
HDINTERRUPTFNC(irq7, 7)
|
|
|
|
HDINTERRUPTFNC(irq8, 8)
|
|
|
|
HDINTERRUPTFNC(irq9, 9)
|
|
|
|
HDINTERRUPTFNC(irq10, 10)
|
|
|
|
HDINTERRUPTFNC(irq11, 11)
|
|
|
|
HDINTERRUPTFNC(irq12, 12)
|
|
|
|
HDINTERRUPTFNC(irq13, 13)
|
|
|
|
HDINTERRUPTFNC(irq14, 14)
|
|
|
|
HDINTERRUPTFNC(irq15, 15)
|
|
|
|
|
|
|
|
.p2align 4,0x90
|
|
|
|
.globl _hdinterrupts
|
|
|
|
.type _hdinterrupts,@function
|
|
|
|
.globl rt_interrupt_enter
|
2012-10-11 00:39:49 +08:00
|
|
|
.globl rt_interrupt_leave
|
2009-07-03 07:17:11 +08:00
|
|
|
.globl isr_table
|
2011-09-19 12:40:50 +08:00
|
|
|
.globl rt_thread_switch_interrupt_flag
|
2009-07-03 07:17:11 +08:00
|
|
|
.globl rt_interrupt_from_thread
|
|
|
|
.globl rt_interrupt_to_thread
|
|
|
|
|
|
|
|
_hdinterrupts:
|
|
|
|
push %ds
|
|
|
|
push %es
|
|
|
|
pushal
|
|
|
|
movw $0x10, %ax
|
|
|
|
movw %ax, %ds
|
|
|
|
movw %ax, %es
|
|
|
|
pushl %esp
|
2012-10-11 00:39:49 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
call rt_interrupt_enter
|
2012-10-11 00:39:49 +08:00
|
|
|
|
|
|
|
movl %esp, %eax /* copy esp to eax */
|
|
|
|
addl $0x2c, %eax /* move to vector address */
|
|
|
|
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] */
|
2009-07-03 07:17:11 +08:00
|
|
|
call *(%ebx)
|
2012-10-11 00:39:49 +08:00
|
|
|
add $4, %esp /* restore argument */
|
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
call rt_interrupt_leave
|
|
|
|
|
2011-09-19 12:40:50 +08:00
|
|
|
/* if rt_thread_switch_interrupt_flag set, jump to _interrupt_thread_switch and don't return */
|
|
|
|
movl $rt_thread_switch_interrupt_flag, %eax
|
2009-07-03 07:17:11 +08:00
|
|
|
movl (%eax), %ebx
|
|
|
|
cmp $0x1, %ebx
|
|
|
|
jz _interrupt_thread_switch
|
2012-10-11 00:39:49 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
popl %esp
|
|
|
|
popal
|
|
|
|
pop %es
|
|
|
|
pop %ds
|
|
|
|
add $4,%esp
|
|
|
|
iret
|
|
|
|
|
|
|
|
_interrupt_thread_switch:
|
|
|
|
popl %esp
|
2012-10-11 00:39:49 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
movl $0x0, %ebx
|
|
|
|
movl %ebx, (%eax)
|
|
|
|
|
|
|
|
movl $rt_interrupt_from_thread, %eax
|
|
|
|
movl (%eax), %ebx
|
|
|
|
movl %esp, (%ebx)
|
|
|
|
|
|
|
|
movl $rt_interrupt_to_thread, %ecx
|
|
|
|
movl (%ecx), %edx
|
|
|
|
movl (%edx), %esp
|
2012-10-11 00:39:49 +08:00
|
|
|
|
2009-07-03 07:17:11 +08:00
|
|
|
popal
|
|
|
|
pop %es
|
|
|
|
pop %ds
|
|
|
|
add $4,%esp
|
|
|
|
iret
|
|
|
|
|
|
|
|
/*@}*/
|