[BSP] fix x86 bsp compiling issue
This commit is contained in:
parent
811a2ead68
commit
a0de58a008
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
/*@{*/
|
/*@{*/
|
||||||
|
|
||||||
static void rt_timer_handler(int vector)
|
static void rt_timer_handler(int vector, void* param)
|
||||||
{
|
{
|
||||||
rt_tick_increase();
|
rt_tick_increase();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ void rt_hw_board_init(void)
|
||||||
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256);
|
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256);
|
||||||
|
|
||||||
/* install interrupt handler */
|
/* install interrupt handler */
|
||||||
rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL);
|
rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick");
|
||||||
rt_hw_interrupt_umask(INTTIMER0);
|
rt_hw_interrupt_umask(INTTIMER0);
|
||||||
|
|
||||||
#ifdef RT_USING_HOOK
|
#ifdef RT_USING_HOOK
|
||||||
|
|
|
@ -214,19 +214,14 @@ static rt_size_t rt_console_read(rt_device_t dev, rt_off_t pos, void* buffer, rt
|
||||||
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
|
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rt_console_isr(int vector)
|
static void rt_console_isr(int vector, void* param)
|
||||||
{
|
{
|
||||||
// rt_kprintf("rt_console_isr\r\n");
|
|
||||||
// RT_ASSERT(INTKEYBOARD == vector);
|
|
||||||
// finsh_notify();
|
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
c = rt_keyboard_getc();
|
c = rt_keyboard_getc();
|
||||||
// rt_kprintf(" %x", c);
|
|
||||||
|
|
||||||
if(c == 0)
|
if(c == 0)
|
||||||
{
|
{
|
||||||
|
@ -285,11 +280,9 @@ static void rt_console_isr(int vector)
|
||||||
void rt_hw_console_init(void)
|
void rt_hw_console_init(void)
|
||||||
{
|
{
|
||||||
rt_cga_init();
|
rt_cga_init();
|
||||||
// rt_serial_init();
|
|
||||||
|
|
||||||
|
|
||||||
/* install keyboard isr */
|
/* install keyboard isr */
|
||||||
rt_hw_interrupt_install(INTKEYBOARD, rt_console_isr, RT_NULL);
|
rt_hw_interrupt_install(INTKEYBOARD, rt_console_isr, RT_NULL, "kbd");
|
||||||
rt_hw_interrupt_umask(INTKEYBOARD);
|
rt_hw_interrupt_umask(INTKEYBOARD);
|
||||||
|
|
||||||
console_device.type = RT_Device_Class_Char;
|
console_device.type = RT_Device_Class_Char;
|
||||||
|
@ -320,8 +313,6 @@ void rt_hw_console_init(void)
|
||||||
* the name is change to rt_hw_console_output in the v0.3.0
|
* the name is change to rt_hw_console_output in the v0.3.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//void rt_console_puts(const char* str)
|
|
||||||
void rt_hw_console_output(const char* str)
|
void rt_hw_console_output(const char* str)
|
||||||
{
|
{
|
||||||
while (*str)
|
while (*str)
|
||||||
|
@ -330,49 +321,4 @@ void rt_hw_console_output(const char* str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define BY2CONS 512
|
|
||||||
//
|
|
||||||
//static struct
|
|
||||||
//{
|
|
||||||
// rt_uint8_t buf[BY2CONS];
|
|
||||||
// rt_uint32_t rpos;
|
|
||||||
// rt_uint32_t wpos;
|
|
||||||
//} cons;
|
|
||||||
//
|
|
||||||
//static void rt_console_intr(char (*proc)(void))
|
|
||||||
//{
|
|
||||||
// int c;
|
|
||||||
//
|
|
||||||
// while ((c = (*proc)()) != -1)
|
|
||||||
// {
|
|
||||||
// if (c == 0)
|
|
||||||
// continue;
|
|
||||||
// cons.buf[cons.wpos++] = c;
|
|
||||||
// if (cons.wpos == BY2CONS)
|
|
||||||
// cons.wpos = 0;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
///**
|
|
||||||
// * return the next input character from the console,either from serial,
|
|
||||||
// * or keyboard
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//int rt_console_getc(void)
|
|
||||||
//{
|
|
||||||
// int c;
|
|
||||||
//
|
|
||||||
// rt_console_intr(rt_serial_getc);
|
|
||||||
// rt_console_intr(rt_keyboard_getc);
|
|
||||||
//
|
|
||||||
// if (cons.rpos != cons.wpos)
|
|
||||||
// {
|
|
||||||
// c = cons.buf[cons.rpos++];
|
|
||||||
// if (cons.rpos == BY2CONS)
|
|
||||||
// cons.rpos = 0;
|
|
||||||
// return c;
|
|
||||||
// }
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
#ifndef __RTTHREAD_CFG_H__
|
#ifndef __RTTHREAD_CFG_H__
|
||||||
#define __RTTHREAD_CFG_H__
|
#define __RTTHREAD_CFG_H__
|
||||||
|
|
||||||
#define RT_USING_NEWLIB
|
|
||||||
//#define RT_USING_PTHREADS
|
|
||||||
#define RT_USING_DFS_DEVFS
|
|
||||||
|
|
||||||
/* RT_NAME_MAX*/
|
/* RT_NAME_MAX*/
|
||||||
#define RT_NAME_MAX 8
|
#define RT_NAME_MAX 8
|
||||||
|
|
||||||
|
@ -77,6 +73,9 @@
|
||||||
#define FINSH_USING_SYMTAB
|
#define FINSH_USING_SYMTAB
|
||||||
#define FINSH_USING_DESCRIPTION
|
#define FINSH_USING_DESCRIPTION
|
||||||
|
|
||||||
|
// #define RT_USING_LIBC
|
||||||
|
// #define RT_USING_PTHREADS
|
||||||
|
|
||||||
/* SECTION: device filesystem */
|
/* SECTION: device filesystem */
|
||||||
#define RT_USING_DFS
|
#define RT_USING_DFS
|
||||||
|
|
||||||
|
@ -96,6 +95,8 @@
|
||||||
/* the max number of opened files */
|
/* the max number of opened files */
|
||||||
#define DFS_FD_MAX 4
|
#define DFS_FD_MAX 4
|
||||||
|
|
||||||
|
#define RT_USING_DFS_DEVFS
|
||||||
|
|
||||||
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
|
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
|
||||||
//#define RT_USING_LWIP
|
//#define RT_USING_LWIP
|
||||||
/* LwIP uses RT-Thread Memory Management */
|
/* LwIP uses RT-Thread Memory Management */
|
||||||
|
|
|
@ -45,7 +45,7 @@ if PLATFORM == 'gcc':
|
||||||
DEVICE = ' -mtune=generic'
|
DEVICE = ' -mtune=generic'
|
||||||
CFLAGS = DEVICE + ' -Wall'
|
CFLAGS = DEVICE + ' -Wall'
|
||||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||||
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-ia32.map,-cref,-u,_start -T x86_ram.lds'
|
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-ia32.map,-cref,-u,_start -T x86_ram.lds -nostdlib'
|
||||||
|
|
||||||
CPATH = ''
|
CPATH = ''
|
||||||
LPATH = ''
|
LPATH = ''
|
||||||
|
|
|
@ -60,7 +60,7 @@ HDINTERRUPTFNC(irq15, 15)
|
||||||
.type _hdinterrupts,@function
|
.type _hdinterrupts,@function
|
||||||
.globl rt_interrupt_enter
|
.globl rt_interrupt_enter
|
||||||
.globl rt_interrupt_leave
|
.globl rt_interrupt_leave
|
||||||
.globl isr_table
|
.globl rt_hw_isr
|
||||||
.globl rt_thread_switch_interrupt_flag
|
.globl rt_thread_switch_interrupt_flag
|
||||||
.globl rt_interrupt_from_thread
|
.globl rt_interrupt_from_thread
|
||||||
.globl rt_interrupt_to_thread
|
.globl rt_interrupt_to_thread
|
||||||
|
@ -81,10 +81,7 @@ _hdinterrupts:
|
||||||
movl (%eax), %eax /* vector(eax) = *eax */
|
movl (%eax), %eax /* vector(eax) = *eax */
|
||||||
|
|
||||||
pushl %eax /* push argument : int vector */
|
pushl %eax /* push argument : int vector */
|
||||||
shll $0x2, %eax /* each item takes up 4bytes in isr_table. */
|
call rt_hw_isr
|
||||||
movl $isr_table, %ebx /* ebx = &isr_table[0] */
|
|
||||||
addl %eax, %ebx /* eax = &isr_table[vector] */
|
|
||||||
call *(%ebx)
|
|
||||||
add $4, %esp /* restore argument */
|
add $4, %esp /* restore argument */
|
||||||
|
|
||||||
call rt_interrupt_leave
|
call rt_interrupt_leave
|
||||||
|
|
|
@ -1,14 +1,25 @@
|
||||||
/*
|
/*
|
||||||
* File : interrupt.c
|
* File : interrupt.c
|
||||||
* This file is part of RT-Thread RTOS
|
* This file is part of RT-Thread RTOS
|
||||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||||
*
|
*
|
||||||
* The license and distribution terms for this file may be
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* found in the file LICENSE in this distribution or at
|
* it under the terms of the GNU General Public License as published by
|
||||||
* http://openlab.rt-thread.com/license/LICENSE
|
* 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.
|
||||||
*
|
*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
|
* 2015/9/15 Bernard Update to new interrupt framework.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
@ -23,9 +34,12 @@ rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
|
||||||
rt_uint32_t rt_thread_switch_interrupt_flag;
|
rt_uint32_t rt_thread_switch_interrupt_flag;
|
||||||
|
|
||||||
/* exception and interrupt handler table */
|
/* exception and interrupt handler table */
|
||||||
rt_isr_handler_t isr_table[MAX_HANDLERS];
|
struct rt_irq_desc irq_desc[MAX_HANDLERS];
|
||||||
|
|
||||||
rt_uint16_t irq_mask_8259A = 0xFFFF;
|
rt_uint16_t irq_mask_8259A = 0xFFFF;
|
||||||
|
|
||||||
|
void rt_hw_interrupt_handle(int vector, void* param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup I386
|
* @addtogroup I386
|
||||||
*/
|
*/
|
||||||
|
@ -64,19 +78,40 @@ void rt_hw_pic_init()
|
||||||
rt_thread_switch_interrupt_flag = 0;
|
rt_thread_switch_interrupt_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rt_hw_interrupt_handle(int vector)
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function initializes interrupt descript table and 8259 interrupt controller
|
* This function initializes interrupt descript table and 8259 interrupt controller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void rt_hw_interrupt_init(void)
|
void rt_hw_interrupt_init(void)
|
||||||
{
|
{
|
||||||
|
int idx;
|
||||||
|
|
||||||
rt_hw_idt_init();
|
rt_hw_idt_init();
|
||||||
rt_hw_pic_init();
|
rt_hw_pic_init();
|
||||||
|
|
||||||
|
/* init exceptions table */
|
||||||
|
for(idx=0; idx < MAX_HANDLERS; idx++)
|
||||||
|
{
|
||||||
|
irq_desc[idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle;
|
||||||
|
irq_desc[idx].param = RT_NULL;
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
rt_snprintf(irq_desc[idx].name, RT_NAME_MAX - 1, "default");
|
||||||
|
irq_desc[idx].counter = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rt_hw_interrupt_umask(int vector)
|
void rt_hw_interrupt_umask(int vector)
|
||||||
|
@ -93,13 +128,28 @@ void rt_hw_interrupt_mask(int vector)
|
||||||
outb(IO_PIC2+1, (char)(irq_mask_8259A >> 8));
|
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)
|
rt_isr_handler_t rt_hw_interrupt_install(int vector,
|
||||||
|
rt_isr_handler_t handler,
|
||||||
|
void *param,
|
||||||
|
char *name)
|
||||||
{
|
{
|
||||||
|
rt_isr_handler_t old_handler = RT_NULL;
|
||||||
|
|
||||||
if(vector < MAX_HANDLERS)
|
if(vector < MAX_HANDLERS)
|
||||||
{
|
{
|
||||||
if (*old_handler != RT_NULL) *old_handler = isr_table[vector];
|
old_handler = irq_desc[vector].handler;
|
||||||
if (new_handler != RT_NULL) isr_table[vector] = new_handler;
|
if (handler != RT_NULL)
|
||||||
|
{
|
||||||
|
irq_desc[vector].handler = (rt_isr_handler_t)handler;
|
||||||
|
irq_desc[vector].param = param;
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name);
|
||||||
|
irq_desc[vector].counter = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return old_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt_base_t rt_hw_interrupt_disable(void)
|
rt_base_t rt_hw_interrupt_disable(void)
|
||||||
|
|
|
@ -44,11 +44,6 @@ void rt_hw_idt_init(void)
|
||||||
extern void Xdefault;
|
extern void Xdefault;
|
||||||
int i, j, func;
|
int i, j, func;
|
||||||
|
|
||||||
for(i=0; i<MAX_HANDLERS; i++)
|
|
||||||
{
|
|
||||||
isr_table[i] = rt_hw_interrupt_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// install a default handler
|
// install a default handler
|
||||||
for (i = 0; i < sizeof(idt)/sizeof(idt[0]); i++)
|
for (i = 0; i < sizeof(idt)/sizeof(idt[0]); i++)
|
||||||
SETGATE(idt[i], 0, GD_KT, &Xdefault, 0);
|
SETGATE(idt[i], 0, GD_KT, &Xdefault, 0);
|
||||||
|
|
Loading…
Reference in New Issue