summaryrefslogtreecommitdiff
path: root/libcpu/ia32
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-01-08 05:05:02 -0800
committerBernard Xiong <[email protected]>2013-01-08 05:05:02 -0800
commit72782e920325808bbc58fc2344fc52033479b627 (patch)
tree45badbfa9818b8d1722463949beba0f88d1cbd9f /libcpu/ia32
parentb3cf278502e605fa03861a2da5685b4c8d72879e (diff)
convert end of line
Diffstat (limited to 'libcpu/ia32')
-rw-r--r--libcpu/ia32/backtrace.c40
-rw-r--r--libcpu/ia32/hdisr_gcc.S6
-rw-r--r--libcpu/ia32/interrupt.c236
-rw-r--r--libcpu/ia32/showmem.c84
-rw-r--r--libcpu/ia32/stack.c118
-rw-r--r--libcpu/ia32/start_gcc.S194
-rw-r--r--libcpu/ia32/trap.c216
-rw-r--r--libcpu/ia32/trapisr_gcc.S196
8 files changed, 545 insertions, 545 deletions
diff --git a/libcpu/ia32/backtrace.c b/libcpu/ia32/backtrace.c
index d7a152469b..b8f094d90f 100644
--- a/libcpu/ia32/backtrace.c
+++ b/libcpu/ia32/backtrace.c
@@ -1,20 +1,20 @@
-/*
- * File : backtrace.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, 2008 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
- *
- * Change Logs:
- * Date Author Notes
- * 2008-07-29 Bernard first version
- */
-
-#include <rtthread.h>
-
-void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
-{
- /* no implementation */
-}
+/*
+ * File : backtrace.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, 2008 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
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2008-07-29 Bernard first version
+ */
+
+#include <rtthread.h>
+
+void rt_hw_backtrace(rt_uint32_t *fp, rt_uint32_t thread_entry)
+{
+ /* no implementation */
+}
diff --git a/libcpu/ia32/hdisr_gcc.S b/libcpu/ia32/hdisr_gcc.S
index cc622ff52c..29f200772f 100644
--- a/libcpu/ia32/hdisr_gcc.S
+++ b/libcpu/ia32/hdisr_gcc.S
@@ -59,7 +59,7 @@ HDINTERRUPTFNC(irq15, 15)
.globl _hdinterrupts
.type _hdinterrupts,@function
.globl rt_interrupt_enter
-.globl rt_interrupt_leave
+.globl rt_interrupt_leave
.globl isr_table
.globl rt_thread_switch_interrupt_flag
.globl rt_interrupt_from_thread
@@ -73,9 +73,9 @@ _hdinterrupts:
movw %ax, %ds
movw %ax, %es
pushl %esp
-
+
call rt_interrupt_enter
-
+
movl %esp, %eax /* copy esp to eax */
addl $0x2c, %eax /* move to vector address */
movl (%eax), %eax /* vector(eax) = *eax */
diff --git a/libcpu/ia32/interrupt.c b/libcpu/ia32/interrupt.c
index 91df04c0ce..01086a6266 100644
--- a/libcpu/ia32/interrupt.c
+++ b/libcpu/ia32/interrupt.c
@@ -1,118 +1,118 @@
-/*
- * File : interrupt.c
- * 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
- * http://openlab.rt-thread.com/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- */
-
-#include <rtthread.h>
-#include <rthw.h>
-
-#include <bsp.h>
-
-extern rt_uint32_t rt_interrupt_nest;
-extern void rt_hw_idt_init(void);
-
-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];
-rt_uint16_t irq_mask_8259A = 0xFFFF;
-
-/**
- * @addtogroup I386
- */
-/*@{*/
-
-/**
- * This function initializes 8259 interrupt controller
- */
-void rt_hw_pic_init()
-{
- outb(IO_PIC1, 0x11);
- outb(IO_PIC1+1, IRQ_OFFSET);
- outb(IO_PIC1+1, 1<<IRQ_SLAVE);
- outb(IO_PIC1+1, 0x3);
- outb(IO_PIC1+1, 0xff);
- outb(IO_PIC1, 0x68);
- outb(IO_PIC1, 0x0a);
- outb(IO_PIC2, 0x11);
- outb(IO_PIC2+1, IRQ_OFFSET + 8);
- outb(IO_PIC2+1, IRQ_SLAVE);
- outb(IO_PIC2+1, 0x3);
- outb(IO_PIC2+1, 0xff);
- outb(IO_PIC2, 0x68);
- outb(IO_PIC2, 0x0a);
-
- if (irq_mask_8259A != 0xFFFF)
- {
- outb(IO_PIC1+1, (char)irq_mask_8259A);
- outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8));
- }
-
- /* init interrupt nest, and context */
- rt_interrupt_nest = 0;
- rt_interrupt_from_thread = 0;
- rt_interrupt_to_thread = 0;
- rt_thread_switch_interrupt_flag = 0;
-}
-
-void rt_hw_interrupt_handle(int vector)
-{
- rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
-}
-
-/**
- * This function initializes interrupt descript table and 8259 interrupt controller
- *
- */
-void rt_hw_interrupt_init(void)
-{
- rt_hw_idt_init();
- rt_hw_pic_init();
-}
-
-void rt_hw_interrupt_umask(int vector)
-{
- irq_mask_8259A = irq_mask_8259A&~(1<<vector);
- outb(IO_PIC1+1, (char)irq_mask_8259A);
- outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8));
-}
-
-void rt_hw_interrupt_mask(int vector)
-{
- irq_mask_8259A = irq_mask_8259A | (1<<vector);
- outb(IO_PIC1+1, (char)irq_mask_8259A);
- 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)
-{
- 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_base_t rt_hw_interrupt_disable(void)
-{
- rt_base_t level;
-
- __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (level): :"memory");
- return level;
-}
-
-void rt_hw_interrupt_enable(rt_base_t level)
-{
- __asm__ __volatile__("pushl %0 ; popfl": :"g" (level):"memory", "cc");
-}
-
-/*@}*/
+/*
+ * File : interrupt.c
+ * 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
+ * http://openlab.rt-thread.com/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
+#include <rtthread.h>
+#include <rthw.h>
+
+#include <bsp.h>
+
+extern rt_uint32_t rt_interrupt_nest;
+extern void rt_hw_idt_init(void);
+
+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];
+rt_uint16_t irq_mask_8259A = 0xFFFF;
+
+/**
+ * @addtogroup I386
+ */
+/*@{*/
+
+/**
+ * This function initializes 8259 interrupt controller
+ */
+void rt_hw_pic_init()
+{
+ outb(IO_PIC1, 0x11);
+ outb(IO_PIC1+1, IRQ_OFFSET);
+ outb(IO_PIC1+1, 1<<IRQ_SLAVE);
+ outb(IO_PIC1+1, 0x3);
+ outb(IO_PIC1+1, 0xff);
+ outb(IO_PIC1, 0x68);
+ outb(IO_PIC1, 0x0a);
+ outb(IO_PIC2, 0x11);
+ outb(IO_PIC2+1, IRQ_OFFSET + 8);
+ outb(IO_PIC2+1, IRQ_SLAVE);
+ outb(IO_PIC2+1, 0x3);
+ outb(IO_PIC2+1, 0xff);
+ outb(IO_PIC2, 0x68);
+ outb(IO_PIC2, 0x0a);
+
+ if (irq_mask_8259A != 0xFFFF)
+ {
+ outb(IO_PIC1+1, (char)irq_mask_8259A);
+ outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8));
+ }
+
+ /* init interrupt nest, and context */
+ rt_interrupt_nest = 0;
+ rt_interrupt_from_thread = 0;
+ rt_interrupt_to_thread = 0;
+ rt_thread_switch_interrupt_flag = 0;
+}
+
+void rt_hw_interrupt_handle(int vector)
+{
+ rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
+}
+
+/**
+ * This function initializes interrupt descript table and 8259 interrupt controller
+ *
+ */
+void rt_hw_interrupt_init(void)
+{
+ rt_hw_idt_init();
+ rt_hw_pic_init();
+}
+
+void rt_hw_interrupt_umask(int vector)
+{
+ irq_mask_8259A = irq_mask_8259A&~(1<<vector);
+ outb(IO_PIC1+1, (char)irq_mask_8259A);
+ outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8));
+}
+
+void rt_hw_interrupt_mask(int vector)
+{
+ irq_mask_8259A = irq_mask_8259A | (1<<vector);
+ outb(IO_PIC1+1, (char)irq_mask_8259A);
+ 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)
+{
+ 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_base_t rt_hw_interrupt_disable(void)
+{
+ rt_base_t level;
+
+ __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (level): :"memory");
+ return level;
+}
+
+void rt_hw_interrupt_enable(rt_base_t level)
+{
+ __asm__ __volatile__("pushl %0 ; popfl": :"g" (level):"memory", "cc");
+}
+
+/*@}*/
diff --git a/libcpu/ia32/showmem.c b/libcpu/ia32/showmem.c
index c171a9bcd7..38f037f83d 100644
--- a/libcpu/ia32/showmem.c
+++ b/libcpu/ia32/showmem.c
@@ -1,42 +1,42 @@
-/*
- * File : showmem.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, 2008 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
- *
- * Change Logs:
- * Date Author Notes
- * 2008-07-29 Bernard first version from QiuYi implementation
- */
-
-#include <rtthread.h>
-
-void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size)
-{
- int i = 0, j =0;
-
- RT_ASSERT(addr);
-
- addr = addr & ~0xF;
- size = 4*((size + 3)/4);
-
- while(i < size)
- {
- rt_kprintf("0x%08x: ", addr );
-
- for(j=0; j<4; j++)
- {
- rt_kprintf("0x%08x ", *(rt_uint32_t *)addr);
-
- addr += 4;
- i++;
- }
-
- rt_kprintf("\n");
- }
-
- return;
-}
+/*
+ * File : showmem.c
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, 2008 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
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2008-07-29 Bernard first version from QiuYi implementation
+ */
+
+#include <rtthread.h>
+
+void rt_hw_show_memory(rt_uint32_t addr, rt_uint32_t size)
+{
+ int i = 0, j =0;
+
+ RT_ASSERT(addr);
+
+ addr = addr & ~0xF;
+ size = 4*((size + 3)/4);
+
+ while(i < size)
+ {
+ rt_kprintf("0x%08x: ", addr );
+
+ for(j=0; j<4; j++)
+ {
+ rt_kprintf("0x%08x ", *(rt_uint32_t *)addr);
+
+ addr += 4;
+ i++;
+ }
+
+ rt_kprintf("\n");
+ }
+
+ return;
+}
diff --git a/libcpu/ia32/stack.c b/libcpu/ia32/stack.c
index 0331819f71..9d656a73d6 100644
--- a/libcpu/ia32/stack.c
+++ b/libcpu/ia32/stack.c
@@ -1,59 +1,59 @@
-/*
- * File : stack.c
- * 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
- * http://openlab.rt-thread.com/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- */
-
-#include <rtthread.h>
-
-#include <i386.h>
-
-/**
- * @addtogroup I386
- */
-/*@{*/
-
-/**
- * This function will initialize thread stack
- *
- * @param tentry the entry of thread
- * @param parameter the parameter of entry
- * @param stack_addr the beginning stack address
- * @param texit the function will be called when thread exit
- *
- * @return stack address
- */
-rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
- rt_uint8_t *stack_addr, void *texit)
-{
- unsigned long *stk;
-
- stk = (unsigned long *)stack_addr;
- *(--stk) = (unsigned long)parameter;
- *(--stk) = (unsigned long)texit;
- *(--stk) = 0x200; /*flags*/
- *(--stk) = 0x08; /*cs*/
- *(--stk) = (unsigned long)tentry; /*eip*/
- *(--stk) = 0; /*irqno*/
- *(--stk) = 0x10; /*ds*/
- *(--stk) = 0x10; /*es*/
- *(--stk) = 0; /*eax*/
- *(--stk) = 0; /*ecx*/
- *(--stk) = 0; /*edx*/
- *(--stk) = 0; /*ebx*/
- *(--stk) = 0; /*esp*/
- *(--stk) = 0; /*ebp*/
- *(--stk) = 0; /*esi*/
- *(--stk) = 0; /*edi*/
-
- /* return task's current stack address */
- return (rt_uint8_t *)stk;
-}
-/*@}*/
+/*
+ * File : stack.c
+ * 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
+ * http://openlab.rt-thread.com/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
+#include <rtthread.h>
+
+#include <i386.h>
+
+/**
+ * @addtogroup I386
+ */
+/*@{*/
+
+/**
+ * This function will initialize thread stack
+ *
+ * @param tentry the entry of thread
+ * @param parameter the parameter of entry
+ * @param stack_addr the beginning stack address
+ * @param texit the function will be called when thread exit
+ *
+ * @return stack address
+ */
+rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
+ rt_uint8_t *stack_addr, void *texit)
+{
+ unsigned long *stk;
+
+ stk = (unsigned long *)stack_addr;
+ *(--stk) = (unsigned long)parameter;
+ *(--stk) = (unsigned long)texit;
+ *(--stk) = 0x200; /*flags*/
+ *(--stk) = 0x08; /*cs*/
+ *(--stk) = (unsigned long)tentry; /*eip*/
+ *(--stk) = 0; /*irqno*/
+ *(--stk) = 0x10; /*ds*/
+ *(--stk) = 0x10; /*es*/
+ *(--stk) = 0; /*eax*/
+ *(--stk) = 0; /*ecx*/
+ *(--stk) = 0; /*edx*/
+ *(--stk) = 0; /*ebx*/
+ *(--stk) = 0; /*esp*/
+ *(--stk) = 0; /*ebp*/
+ *(--stk) = 0; /*esi*/
+ *(--stk) = 0; /*edi*/
+
+ /* return task's current stack address */
+ return (rt_uint8_t *)stk;
+}
+/*@}*/
diff --git a/libcpu/ia32/start_gcc.S b/libcpu/ia32/start_gcc.S
index 650309a7f3..84adc83fe2 100644
--- a/libcpu/ia32/start_gcc.S
+++ b/libcpu/ia32/start_gcc.S
@@ -1,97 +1,97 @@
-/*
- * File : start.S
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, 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://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2006-09-15 QiuYi The first version.
- * 2012-02-15 aozima update.
- */
-
-/* the magic number for the multiboot header. */
-#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
-
-/* the flags for the multiboot header. */
-#define MULTIBOOT_HEADER_FLAGS 0x00000003
-
-#define CONFIG_STACKSIZE 8192
-
-/**
- * @addtogroup I386
- */
-/*@{*/
-
-.section .init, "ax"
-
-/* the system entry */
-.globl _start
-_start:
- jmp multiboot_entry
-
- /* Align 32 bits boundary. */
- .align 4
-
- /* multiboot header. */
-multiboot_header:
- /* magic */
- .long MULTIBOOT_HEADER_MAGIC
- /* flags */
- .long MULTIBOOT_HEADER_FLAGS
- /* checksum */
- .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
-
-multiboot_entry:
- movl $(_end + 0x1000),%esp
-
- /* reset eflags. */
- pushl $0
- popf
-
- /*rebuild globe describe table*/
- lgdt mygdtdesc
-
- movl $0x10,%eax
- movw %ax,%ds
- movw %ax,%es
- movw %ax,%ss
- ljmp $0x08, $relocated
-
-relocated:
- /* push the pointer to the multiboot information structure. */
- pushl %ebx
-
- /* push the magic value. */
- pushl %eax
-
- call rtthread_startup
-
- /* never get here */
-spin:
- hlt
- jmp spin
-
-.data
-.p2align 2
-mygdt:
- .word 0,0,0,0
-
- .word 0x07FF /* 8Mb - limit=2047 */
- .word 0x0000
- .word 0x9A00 /* code read/exec */
- .word 0x00C0
-
- .word 0x07FF /* 8Mb - limit=2047 */
- .word 0x0000
- .word 0x9200 /* data read/write */
- .word 0x00C0
-
-mygdtdesc:
- .word 0x17
- .long mygdt
-
-/*@}*/
+/*
+ * File : start.S
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006 - 2012, 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://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2006-09-15 QiuYi The first version.
+ * 2012-02-15 aozima update.
+ */
+
+/* the magic number for the multiboot header. */
+#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
+
+/* the flags for the multiboot header. */
+#define MULTIBOOT_HEADER_FLAGS 0x00000003
+
+#define CONFIG_STACKSIZE 8192
+
+/**
+ * @addtogroup I386
+ */
+/*@{*/
+
+.section .init, "ax"
+
+/* the system entry */
+.globl _start
+_start:
+ jmp multiboot_entry
+
+ /* Align 32 bits boundary. */
+ .align 4
+
+ /* multiboot header. */
+multiboot_header:
+ /* magic */
+ .long MULTIBOOT_HEADER_MAGIC
+ /* flags */
+ .long MULTIBOOT_HEADER_FLAGS
+ /* checksum */
+ .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
+
+multiboot_entry:
+ movl $(_end + 0x1000),%esp
+
+ /* reset eflags. */
+ pushl $0
+ popf
+
+ /*rebuild globe describe table*/
+ lgdt mygdtdesc
+
+ movl $0x10,%eax
+ movw %ax,%ds
+ movw %ax,%es
+ movw %ax,%ss
+ ljmp $0x08, $relocated
+
+relocated:
+ /* push the pointer to the multiboot information structure. */
+ pushl %ebx
+
+ /* push the magic value. */
+ pushl %eax
+
+ call rtthread_startup
+
+ /* never get here */
+spin:
+ hlt
+ jmp spin
+
+.data
+.p2align 2
+mygdt:
+ .word 0,0,0,0
+
+ .word 0x07FF /* 8Mb - limit=2047 */
+ .word 0x0000
+ .word 0x9A00 /* code read/exec */
+ .word 0x00C0
+
+ .word 0x07FF /* 8Mb - limit=2047 */
+ .word 0x0000
+ .word 0x9200 /* data read/write */
+ .word 0x00C0
+
+mygdtdesc:
+ .word 0x17
+ .long mygdt
+
+/*@}*/
diff --git a/libcpu/ia32/trap.c b/libcpu/ia32/trap.c
index 10595dc5a1..52b9e65ea3 100644
--- a/libcpu/ia32/trap.c
+++ b/libcpu/ia32/trap.c
@@ -1,108 +1,108 @@
-/*
- * File : trap.c
- * 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
- * http://openlab.rt-thread.com/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- */
-
-#include <rtthread.h>
-#include <rthw.h>
-
-#include <bsp.h>
-
-/* Interrupt descriptor table. (Must be built at run time because
- * shifted function addresses can't be represented in relocation records.)
- */
-struct Gatedesc idt[256] = { {0}, };
-struct Pseudodesc idt_pd =
-{
- 0, sizeof(idt) - 1, (unsigned long) idt,
-};
-
-/* exception and interrupt handler table */
-extern rt_isr_handler_t isr_table[];
-extern rt_isr_handler_t trap_func[];
-extern rt_isr_handler_t hdinterrupt_func[];
-
-/**
- * @addtogroup I386
- */
-/*@{*/
-
-/**
- * this function initializes the interrupt descript table
- *
- */
-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);
-
- /*install trap handler*/
- for(i = 0; i < 16; i++)
- {
- func = (int)trap_func[i];
- SETGATE(idt[i], 0, GD_KT, func, 0);
- }
-
- func = (int)trap_func[3];
- SETGATE(idt[3], 0, GD_KT, func, 3);
-
- i = 0;
-
- /*install exteral interrupt handler*/
- for(j = IRQ_OFFSET; j < IRQ_OFFSET + MAX_HANDLERS; j++)
- {
- func = (int)hdinterrupt_func[i];
- SETGATE(idt[j], 0, GD_KT, func, 0);
- i++;
- }
-
- // Load the IDT
- asm volatile("lidt idt_pd + 2");
-}
-
-/**
- * this function will deal with all kinds of kernel trap
- *
- *@param trapno the trap number
- *
- */
-void rt_hw_trap_irq(int trapno)
-{
- switch(trapno)
- {
- case T_DIVIDE:
- rt_kprintf("Divide error interrupt\n");
- RT_ASSERT(0);
- case T_PGFLT:
- rt_kprintf("Page fault interrupt\n");
- RT_ASSERT(0);
- case T_GPFLT:
- rt_kprintf("General protection interrupt\n");
- RT_ASSERT(0);
- case T_DEFAULT:
- rt_hw_interrupt_handle(T_DEFAULT);
- return;
- }
-
- /*kernel bug if run here*/
- RT_ASSERT(0);
-}
-
-/*@}*/
+/*
+ * File : trap.c
+ * 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
+ * http://openlab.rt-thread.com/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ */
+
+#include <rtthread.h>
+#include <rthw.h>
+
+#include <bsp.h>
+
+/* Interrupt descriptor table. (Must be built at run time because
+ * shifted function addresses can't be represented in relocation records.)
+ */
+struct Gatedesc idt[256] = { {0}, };
+struct Pseudodesc idt_pd =
+{
+ 0, sizeof(idt) - 1, (unsigned long) idt,
+};
+
+/* exception and interrupt handler table */
+extern rt_isr_handler_t isr_table[];
+extern rt_isr_handler_t trap_func[];
+extern rt_isr_handler_t hdinterrupt_func[];
+
+/**
+ * @addtogroup I386
+ */
+/*@{*/
+
+/**
+ * this function initializes the interrupt descript table
+ *
+ */
+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);
+
+ /*install trap handler*/
+ for(i = 0; i < 16; i++)
+ {
+ func = (int)trap_func[i];
+ SETGATE(idt[i], 0, GD_KT, func, 0);
+ }
+
+ func = (int)trap_func[3];
+ SETGATE(idt[3], 0, GD_KT, func, 3);
+
+ i = 0;
+
+ /*install exteral interrupt handler*/
+ for(j = IRQ_OFFSET; j < IRQ_OFFSET + MAX_HANDLERS; j++)
+ {
+ func = (int)hdinterrupt_func[i];
+ SETGATE(idt[j], 0, GD_KT, func, 0);
+ i++;
+ }
+
+ // Load the IDT
+ asm volatile("lidt idt_pd + 2");
+}
+
+/**
+ * this function will deal with all kinds of kernel trap
+ *
+ *@param trapno the trap number
+ *
+ */
+void rt_hw_trap_irq(int trapno)
+{
+ switch(trapno)
+ {
+ case T_DIVIDE:
+ rt_kprintf("Divide error interrupt\n");
+ RT_ASSERT(0);
+ case T_PGFLT:
+ rt_kprintf("Page fault interrupt\n");
+ RT_ASSERT(0);
+ case T_GPFLT:
+ rt_kprintf("General protection interrupt\n");
+ RT_ASSERT(0);
+ case T_DEFAULT:
+ rt_hw_interrupt_handle(T_DEFAULT);
+ return;
+ }
+
+ /*kernel bug if run here*/
+ RT_ASSERT(0);
+}
+
+/*@}*/
diff --git a/libcpu/ia32/trapisr_gcc.S b/libcpu/ia32/trapisr_gcc.S
index d4cda4db7f..be7e97a5fb 100644
--- a/libcpu/ia32/trapisr_gcc.S
+++ b/libcpu/ia32/trapisr_gcc.S
@@ -1,98 +1,98 @@
-/*
- * File : trapisr_gcc.S
- * 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
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2006-09-15 QiuYi The first version.
- */
-
-/**
- * @addtogroup I386
- */
-/*@{*/
-
-#define ENTRY(proc)\
- .align 2;\
- .globl proc;\
- .type proc,@function;\
- proc:
-#define TRAPFNC(name,num)\
- ENTRY(name)\
- pushl $(num);\
- jmp _traps;\
- .data;\
- .long name;\
- .text
-#define TRAPFNC_NOEC(name,num)\
- ENTRY(name)\
- pushl $0;\
- pushl $(num);\
- jmp _traps;\
- .data;\
- .long name;\
- .text
-
-.globl trap_func
- .data
- .align 4
- .type trap_func,@object
- trap_func :
-.text
-
-/* CPU traps */
-TRAPFNC_NOEC(Xdivide, 0)
-TRAPFNC_NOEC(Xdebug, 1)
-TRAPFNC_NOEC(Xnmi, 2)
-TRAPFNC_NOEC(Xbrkpt, 3)
-TRAPFNC_NOEC(Xoflow, 4)
-TRAPFNC_NOEC(Xbound, 5)
-TRAPFNC_NOEC(Xillop, 6)
-TRAPFNC_NOEC(Xdevice, 7)
-TRAPFNC (Xdblflt, 8)
-TRAPFNC (Xtss, 9)
-TRAPFNC (Xsegnp, 10)
-TRAPFNC (Xstack, 11)
-TRAPFNC (Xgpflt, 12)
-TRAPFNC (Xpgflt, 13)
-TRAPFNC_NOEC(Xfperr, 14)
-TRAPFNC (Xalign, 15)
-
-/* default handler -- not for any specific trap */
-TRAPFNC (Xdefault, 500)
-
-.p2align 4,0x90
-.globl _traps
-.type _traps,@function
-.globl rt_interrupt_enter
-.globl rt_interrupt_leave
-
-_traps:
- push %ds
- push %es
- pushal
- movw $0x10,%ax
- movw %ax,%ds
- movw %ax,%es
- pushl %esp
- call rt_interrupt_enter
- movl %esp, %eax
- addl $0x2c,%eax /*get trapno*/
- movl (%eax),%eax
- pushl %eax /*push trapno*/
- call rt_hw_trap_irq
- addl $4,%esp
- call rt_interrupt_leave
- popl %esp
- popal
- pop %es
- pop %ds
- add $8,%esp
- iret
-
-/*@}*/
+/*
+ * File : trapisr_gcc.S
+ * 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
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2006-09-15 QiuYi The first version.
+ */
+
+/**
+ * @addtogroup I386
+ */
+/*@{*/
+
+#define ENTRY(proc)\
+ .align 2;\
+ .globl proc;\
+ .type proc,@function;\
+ proc:
+#define TRAPFNC(name,num)\
+ ENTRY(name)\
+ pushl $(num);\
+ jmp _traps;\
+ .data;\
+ .long name;\
+ .text
+#define TRAPFNC_NOEC(name,num)\
+ ENTRY(name)\
+ pushl $0;\
+ pushl $(num);\
+ jmp _traps;\
+ .data;\
+ .long name;\
+ .text
+
+.globl trap_func
+ .data
+ .align 4
+ .type trap_func,@object
+ trap_func :
+.text
+
+/* CPU traps */
+TRAPFNC_NOEC(Xdivide, 0)
+TRAPFNC_NOEC(Xdebug, 1)
+TRAPFNC_NOEC(Xnmi, 2)
+TRAPFNC_NOEC(Xbrkpt, 3)
+TRAPFNC_NOEC(Xoflow, 4)
+TRAPFNC_NOEC(Xbound, 5)
+TRAPFNC_NOEC(Xillop, 6)
+TRAPFNC_NOEC(Xdevice, 7)
+TRAPFNC (Xdblflt, 8)
+TRAPFNC (Xtss, 9)
+TRAPFNC (Xsegnp, 10)
+TRAPFNC (Xstack, 11)
+TRAPFNC (Xgpflt, 12)
+TRAPFNC (Xpgflt, 13)
+TRAPFNC_NOEC(Xfperr, 14)
+TRAPFNC (Xalign, 15)
+
+/* default handler -- not for any specific trap */
+TRAPFNC (Xdefault, 500)
+
+.p2align 4,0x90
+.globl _traps
+.type _traps,@function
+.globl rt_interrupt_enter
+.globl rt_interrupt_leave
+
+_traps:
+ push %ds
+ push %es
+ pushal
+ movw $0x10,%ax
+ movw %ax,%ds
+ movw %ax,%es
+ pushl %esp
+ call rt_interrupt_enter
+ movl %esp, %eax
+ addl $0x2c,%eax /*get trapno*/
+ movl (%eax),%eax
+ pushl %eax /*push trapno*/
+ call rt_hw_trap_irq
+ addl $4,%esp
+ call rt_interrupt_leave
+ popl %esp
+ popal
+ pop %es
+ pop %ds
+ add $8,%esp
+ iret
+
+/*@}*/