xref: /nrf52832-nimble/rt-thread/libcpu/ia32/hdisr_gcc.S (revision 104654410c56c573564690304ae786df310c91fc)
1/*
2 * File      : hdisr_gcc.S
3 * This file is part of RT-Thread RTOS
4 * COPYRIGHT (C) 2006, RT-Thread Development Team
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 * http://www.rt-thread.org/license/LICENSE
9 *
10 * Change Logs:
11 * Date           Author       Notes
12 * 2006-09-15     QiuYi        The first version
13 */
14
15/**
16 * @addtogroup I386
17 */
18/*@{*/
19
20#define ENTRY(proc)\
21	.align 2;\
22	.globl proc;\
23	.type proc,@function;\
24	proc:
25#define HDINTERRUPTFNC(name,num) \
26	ENTRY(name)\
27	pushl $(num);\
28	jmp _hdinterrupts;\
29	.data;\
30	.long name;\
31	.text
32
33.globl hdinterrupt_func
34	.data
35	.align 4
36	.type hdinterrupt_func,@object
37	hdinterrupt_func :
38.text
39
40/* the external device interrupts */
41HDINTERRUPTFNC(irq0, 0)
42HDINTERRUPTFNC(irq1, 1)
43HDINTERRUPTFNC(irq2, 2)
44HDINTERRUPTFNC(irq3, 3)
45HDINTERRUPTFNC(irq4, 4)
46HDINTERRUPTFNC(irq5, 5)
47HDINTERRUPTFNC(irq6, 6)
48HDINTERRUPTFNC(irq7, 7)
49HDINTERRUPTFNC(irq8, 8)
50HDINTERRUPTFNC(irq9, 9)
51HDINTERRUPTFNC(irq10, 10)
52HDINTERRUPTFNC(irq11, 11)
53HDINTERRUPTFNC(irq12, 12)
54HDINTERRUPTFNC(irq13, 13)
55HDINTERRUPTFNC(irq14, 14)
56HDINTERRUPTFNC(irq15, 15)
57
58.p2align 4,0x90
59.globl _hdinterrupts
60.type _hdinterrupts,@function
61.globl rt_interrupt_enter
62.globl rt_interrupt_leave
63.globl rt_hw_isr
64.globl rt_thread_switch_interrupt_flag
65.globl rt_interrupt_from_thread
66.globl rt_interrupt_to_thread
67
68_hdinterrupts:
69	push %ds
70	push %es
71	pushal
72	movw $0x10, %ax
73	movw %ax, %ds
74	movw %ax, %es
75	pushl %esp
76
77	call rt_interrupt_enter
78
79	movl %esp, %eax	      /* copy esp to eax */
80	addl $0x2c, %eax      /* move to vector address */
81	movl (%eax), %eax     /* vector(eax) = *eax */
82
83	pushl %eax            /* push argument : int vector */
84	call rt_hw_isr
85	add $4, %esp          /* restore argument */
86
87	call rt_interrupt_leave
88
89	/* if rt_thread_switch_interrupt_flag set, jump to _interrupt_thread_switch and don't return */
90	movl $rt_thread_switch_interrupt_flag, %eax
91	movl (%eax), %ebx
92	cmp $0x1, %ebx
93	jz _interrupt_thread_switch
94
95	popl %esp
96	popal
97	pop %es
98	pop %ds
99	add $4,%esp
100	iret
101
102_interrupt_thread_switch:
103	popl %esp
104
105	movl $0x0, %ebx
106	movl %ebx, (%eax)
107
108	movl $rt_interrupt_from_thread, %eax
109	movl (%eax), %ebx
110	movl %esp, (%ebx)
111
112	movl $rt_interrupt_to_thread, %ecx
113	movl (%ecx), %edx
114	movl (%edx), %esp
115
116	popal
117	pop %es
118	pop %ds
119	add $4,%esp
120	iret
121
122/*@}*/
123