xref: /nrf52832-nimble/rt-thread/libcpu/ia32/trapisr_gcc.S (revision 104654410c56c573564690304ae786df310c91fc)
1/*
2 * File      : trapisr_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 TRAPFNC(name,num)\
26	ENTRY(name)\
27	pushl $(num);\
28	jmp _traps;\
29	.data;\
30	.long name;\
31	.text
32#define TRAPFNC_NOEC(name,num)\
33	ENTRY(name)\
34	pushl $0;\
35	pushl $(num);\
36	jmp _traps;\
37	.data;\
38	.long name;\
39	.text
40
41.globl trap_func
42	.data
43	.align 4
44	.type trap_func,@object
45	trap_func :
46.text
47
48/* CPU traps */
49TRAPFNC_NOEC(Xdivide, 0)
50TRAPFNC_NOEC(Xdebug,  1)
51TRAPFNC_NOEC(Xnmi,    2)
52TRAPFNC_NOEC(Xbrkpt,  3)
53TRAPFNC_NOEC(Xoflow,  4)
54TRAPFNC_NOEC(Xbound,  5)
55TRAPFNC_NOEC(Xillop,  6)
56TRAPFNC_NOEC(Xdevice, 7)
57TRAPFNC     	(Xdblflt, 8)
58TRAPFNC    	(Xtss,    9)
59TRAPFNC     	(Xsegnp,  10)
60TRAPFNC     	(Xstack,  11)
61TRAPFNC     	(Xgpflt,  12)
62TRAPFNC     	(Xpgflt,  13)
63TRAPFNC_NOEC(Xfperr,  14)
64TRAPFNC     	(Xalign,  15)
65
66/* default handler -- not for any specific trap */
67TRAPFNC     (Xdefault, 500)
68
69.p2align 4,0x90
70.globl	_traps
71.type	_traps,@function
72.globl rt_interrupt_enter
73.globl rt_interrupt_leave
74
75_traps:
76	push %ds
77	push %es
78	pushal
79	movw $0x10,%ax
80	movw %ax,%ds
81	movw %ax,%es
82	pushl %esp
83	call rt_interrupt_enter
84	movl %esp, %eax
85	addl $0x2c,%eax		/*get trapno*/
86	movl (%eax),%eax
87	pushl %eax			/*push trapno*/
88	call rt_hw_trap_irq
89	addl $4,%esp
90	call rt_interrupt_leave
91	popl %esp
92	popal
93	pop %es
94	pop %ds
95	add $8,%esp
96	iret
97
98/*@}*/
99