summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-02-19 23:55:17 +0800
committerBernard Xiong <[email protected]>2021-02-19 23:55:17 +0800
commit2da5d4a5d6b5e04838b77122410a049e0a10cfa6 (patch)
treedce9f0cb86fefb7a189961f539faac4797e35374 /libcpu
parente596921019839fdaf1c0c2c76a1aa13f4c083299 (diff)
[bsp][x86] update x86 with Kconfig and newlib toolchains.
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/ia32/__udivsi3.c8
-rw-r--r--libcpu/ia32/__umodsi3.c8
-rw-r--r--libcpu/ia32/backtrace.c20
-rw-r--r--libcpu/ia32/context_gcc.S36
-rw-r--r--libcpu/ia32/cpuport.c (renamed from libcpu/ia32/stack.c)42
-rw-r--r--libcpu/ia32/hdisr_gcc.S8
-rw-r--r--libcpu/ia32/interrupt.c111
-rw-r--r--libcpu/ia32/showmem.c42
-rw-r--r--libcpu/ia32/start_gcc.S18
-rw-r--r--libcpu/ia32/trap.c17
-rw-r--r--libcpu/ia32/trapisr_gcc.S26
11 files changed, 101 insertions, 235 deletions
diff --git a/libcpu/ia32/__udivsi3.c b/libcpu/ia32/__udivsi3.c
index ec7c59d1cb..5a5622f883 100644
--- a/libcpu/ia32/__udivsi3.c
+++ b/libcpu/ia32/__udivsi3.c
@@ -1,11 +1,7 @@
/*
- * File : __udivsi3.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/ia32/__umodsi3.c b/libcpu/ia32/__umodsi3.c
index 226a2c0800..d47fe3d295 100644
--- a/libcpu/ia32/__umodsi3.c
+++ b/libcpu/ia32/__umodsi3.c
@@ -1,11 +1,7 @@
/*
- * File : __umodsi3.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Develop Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/ia32/backtrace.c b/libcpu/ia32/backtrace.c
deleted file mode 100644
index b8f094d90f..0000000000
--- a/libcpu/ia32/backtrace.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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/context_gcc.S b/libcpu/ia32/context_gcc.S
index a8ad867b91..32233303c7 100644
--- a/libcpu/ia32/context_gcc.S
+++ b/libcpu/ia32/context_gcc.S
@@ -1,11 +1,7 @@
/*
- * File : context_gcc.S
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -83,31 +79,3 @@ rt_hw_context_switch_to:
pop %ds
add $4, %esp /* skip irqno */
iret
-
-/*
- * void rt_hw_context_switch_interrupt(rt_uint32 from, rt_uint32 to);
- */
-.globl rt_thread_switch_interrupt_flag
-.globl rt_interrupt_from_thread
-.globl rt_interrupt_to_thread
-.globl rt_hw_context_switch_interrupt
-rt_hw_context_switch_interrupt:
- pushl %ebp
- movl %esp, %ebp
- movl 0xc(%ebp), %eax
- movl 0x8(%ebp), %ebx
-
- movl $rt_thread_switch_interrupt_flag, %ecx
- movl (%ecx), %edx
- cmp $0x1, %edx
- jz _reswitch
-
- movl $0x1, %edx /*set rt_thread_switch_interrupt_flag to 1*/
- movl %edx, (%ecx)
- movl $rt_interrupt_from_thread, %edx /*set rt_interrupt_from_thread*/
- movl %ebx, (%edx)
-_reswitch:
- movl $rt_interrupt_to_thread, %edx /*set rt_interrupt_to_thread*/
- movl %eax, (%edx)
- leave
- ret
diff --git a/libcpu/ia32/stack.c b/libcpu/ia32/cpuport.c
index 9d656a73d6..69032c2f87 100644
--- a/libcpu/ia32/stack.c
+++ b/libcpu/ia32/cpuport.c
@@ -1,24 +1,43 @@
/*
- * File : stack.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
+ * 2021/02/19 Bernard Implement rt_hw_context_switch_interrupt in C
*/
+#include <rthw.h>
#include <rtthread.h>
-#include <i386.h>
+volatile rt_ubase_t rt_interrupt_from_thread = 0;
+volatile rt_ubase_t rt_interrupt_to_thread = 0;
+volatile rt_uint32_t rt_thread_switch_interrupt_flag = 0;
-/**
- * @addtogroup I386
- */
-/*@{*/
+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");
+}
+
+void rt_hw_context_switch_interrupt(rt_ubase_t from, rt_ubase_t to)
+{
+ if (rt_thread_switch_interrupt_flag == 0)
+ rt_interrupt_from_thread = from;
+
+ rt_interrupt_to_thread = to;
+ rt_thread_switch_interrupt_flag = 1;
+
+ return ;
+}
/**
* This function will initialize thread stack
@@ -56,4 +75,3 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
/* return task's current stack address */
return (rt_uint8_t *)stk;
}
-/*@}*/
diff --git a/libcpu/ia32/hdisr_gcc.S b/libcpu/ia32/hdisr_gcc.S
index 6f79fe4c2a..24c4c17990 100644
--- a/libcpu/ia32/hdisr_gcc.S
+++ b/libcpu/ia32/hdisr_gcc.S
@@ -1,11 +1,7 @@
/*
- * File : hdisr_gcc.S
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
diff --git a/libcpu/ia32/interrupt.c b/libcpu/ia32/interrupt.c
index e620cbe76c..d597848c52 100644
--- a/libcpu/ia32/interrupt.c
+++ b/libcpu/ia32/interrupt.c
@@ -1,38 +1,20 @@
/*
- * File : interrupt.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
- * 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.
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2015/9/15 Bernard Update to new interrupt framework.
*/
-#include <rtthread.h>
#include <rthw.h>
+#include <rtthread.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 */
struct rt_irq_desc irq_desc[MAX_HANDLERS];
@@ -50,45 +32,39 @@ void rt_hw_interrupt_handle(int vector, void* param);
*/
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);
+ 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;
+ if (irq_mask_8259A != 0xFFFF)
+ {
+ outb(IO_PIC1+1, (char)irq_mask_8259A);
+ outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8));
+ }
}
void rt_hw_interrupt_handle(int vector, void* param)
{
- rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
+ 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);
- }
+ if (vector < MAX_HANDLERS)
+ {
+ irq_desc[vector].handler(vector, irq_desc[vector].param);
+ }
}
/**
@@ -97,10 +73,10 @@ void rt_hw_isr(int vector)
*/
void rt_hw_interrupt_init(void)
{
- int idx;
-
- rt_hw_idt_init();
- rt_hw_pic_init();
+ int idx;
+
+ rt_hw_idt_init();
+ rt_hw_pic_init();
/* init exceptions table */
for(idx=0; idx < MAX_HANDLERS; idx++)
@@ -116,16 +92,16 @@ void rt_hw_interrupt_init(void)
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));
+ 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));
+ 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));
}
rt_isr_handler_t rt_hw_interrupt_install(int vector,
@@ -152,17 +128,4 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector,
return old_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
deleted file mode 100644
index 38f037f83d..0000000000
--- a/libcpu/ia32/showmem.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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/start_gcc.S b/libcpu/ia32/start_gcc.S
index 84adc83fe2..ee7d2787fd 100644
--- a/libcpu/ia32/start_gcc.S
+++ b/libcpu/ia32/start_gcc.S
@@ -1,11 +1,7 @@
/*
- * File : start.S
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -52,8 +48,8 @@ multiboot_entry:
pushl $0
popf
- /*rebuild globe describe table*/
- lgdt mygdtdesc
+ /* rebuild globe describe table */
+ lgdt __gdtdesc
movl $0x10,%eax
movw %ax,%ds
@@ -77,7 +73,7 @@ spin:
.data
.p2align 2
-mygdt:
+__gdt:
.word 0,0,0,0
.word 0x07FF /* 8Mb - limit=2047 */
@@ -90,8 +86,8 @@ mygdt:
.word 0x9200 /* data read/write */
.word 0x00C0
-mygdtdesc:
+__gdtdesc:
.word 0x17
- .long mygdt
+ .long __gdt
/*@}*/
diff --git a/libcpu/ia32/trap.c b/libcpu/ia32/trap.c
index 5e9a51d6d2..172a078273 100644
--- a/libcpu/ia32/trap.c
+++ b/libcpu/ia32/trap.c
@@ -1,18 +1,14 @@
/*
- * File : trap.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
-
-#include <rtthread.h>
+
#include <rthw.h>
+#include <rtthread.h>
#include <bsp.h>
@@ -29,6 +25,7 @@ struct Pseudodesc idt_pd =
extern rt_isr_handler_t isr_table[];
extern rt_isr_handler_t trap_func[];
extern rt_isr_handler_t hdinterrupt_func[];
+extern void rt_hw_interrupt_handle(int vector, void* param);
/**
* @addtogroup I386
@@ -41,7 +38,7 @@ extern rt_isr_handler_t hdinterrupt_func[];
*/
void rt_hw_idt_init(void)
{
- extern void Xdefault;
+ extern void Xdefault(void);
int i, j, func;
// install a default handler
@@ -92,7 +89,7 @@ void rt_hw_trap_irq(int trapno)
rt_kprintf("General protection interrupt\n");
RT_ASSERT(0);
case T_DEFAULT:
- rt_hw_interrupt_handle(T_DEFAULT);
+ rt_hw_interrupt_handle(T_DEFAULT, RT_NULL);
return;
}
diff --git a/libcpu/ia32/trapisr_gcc.S b/libcpu/ia32/trapisr_gcc.S
index be7e97a5fb..82887ecda3 100644
--- a/libcpu/ia32/trapisr_gcc.S
+++ b/libcpu/ia32/trapisr_gcc.S
@@ -1,11 +1,7 @@
/*
- * File : trapisr_gcc.S
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Development Team
+ * Copyright (c) 2006-2021, 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
+ * SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -22,6 +18,7 @@
.globl proc;\
.type proc,@function;\
proc:
+
#define TRAPFNC(name,num)\
ENTRY(name)\
pushl $(num);\
@@ -29,6 +26,7 @@
.data;\
.long name;\
.text
+
#define TRAPFNC_NOEC(name,num)\
ENTRY(name)\
pushl $0;\
@@ -54,17 +52,17 @@ 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 (Xdblflt, 8)
+TRAPFNC (Xtss, 9)
+TRAPFNC (Xsegnp, 10)
+TRAPFNC (Xstack, 11)
+TRAPFNC (Xgpflt, 12)
+TRAPFNC (Xpgflt, 13)
TRAPFNC_NOEC(Xfperr, 14)
-TRAPFNC (Xalign, 15)
+TRAPFNC (Xalign, 15)
/* default handler -- not for any specific trap */
-TRAPFNC (Xdefault, 500)
+TRAPFNC (Xdefault, 500)
.p2align 4,0x90
.globl _traps