Merge pull request #4356 from BernardXiong/master

[bsp][x86] update x86 with Kconfig and newlib toolchains.
This commit is contained in:
Bernard Xiong authored and GitHub committed 2021-02-20 12:13:48 +08:00
commit 3b459e8297
35 files changed
+1264 -1003

No files matched your search

+535
View File
File diff suppressed because it is too large. Load diff
+26
View File
@@ -0,0 +1,26 @@
mainmenu "RT-Thread Configuration"
config $BSP_DIR
string
option env="BSP_ROOT"
default "."
config $RTT_DIR
string
option env="RTT_ROOT"
default "../.."
config $PKGS_DIR
string
option env="PKGS_ROOT"
default "packages"
source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
config IA32
bool
select ARCH_IA32
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
default y
-46
View File
@@ -1,46 +0,0 @@
CC = gcc -O0 -m32 -fno-builtin -fno-stack-protector -nostdinc -nostdlib
LD = ld -melf_i386 -nostdlib
all: rtthread rtsym exe dll floppy.img
@mkdir -p tmp
@sudo mount -t vfat floppy.img tmp -o loop
@sudo cp -fv rtthread.elf tmp/boot/oskernel
@sudo rm tmp/bin/* -fr
@sudo cp out/*.mo tmp/bin/ -fv
@sudo umount tmp
rtthread:
@scons
rtsym:
@./src/extract.sh ./rtthread-ia32.map ./src/rt_thread_sym.h
obj:
mkdir -p obj
out:
mkdir -p out
dll: obj out
$(CC) -c -fPIC -Isrc src/hello.c -o out/hello.o
$(CC) -s -Wl,-shared,-melf_i386,--entry=main -o out/hello.mo out/hello.o
disasm: obj out
$(CC) -shared -S -fPIC -Isrc src/hello.c -o obj/hello.s
cat obj/hello.s
objdump --disassemble out/hello.mo
exe: obj out
clean:
scons -c clean
rm -fr build rtthread* out obj
floppy.img:
wget https://github.com/bajdcc/tinix/raw/master/floppy.img
# https://en.wikibooks.org/wiki/QEMU/Devices/Network
run:
qemu-system-i386 -fda floppy.img -boot a -m 64M -serial stdio -net nic,model=ne2k_pci
+2 -3
View File
@@ -1,8 +1,7 @@
# for module compiling
import os
Import('RTT_ROOT')
from building import *
cwd = str(Dir('#'))
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
-86
View File
@@ -1,86 +0,0 @@
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2015, 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.
*
* Change Logs:
* Date Author Notes
* 2009-01-05 Bernard the first version
*/
#include <rtthread.h>
#ifdef RT_USING_DFS
#include <dfs_fs.h>
#include <dfs.h>
#include "floppy.h"
#ifdef RT_USING_MODULE
#include <rtm.h>
#endif
extern int elm_init(void);
#endif
/* components initialization for simulator */
void components_init(void)
{
#ifdef RT_USING_DFS
rt_floppy_init();
/* initialize the device file system */
dfs_init();
#ifdef RT_USING_DFS_ELMFAT
/* initialize the elm chan FatFS file system*/
elm_init();
#endif
#ifdef RT_USING_MODULE
rt_system_dlmodule_init();
#endif
#endif
}
void rt_init_thread_entry(void *parameter)
{
components_init();
/* File system Initialization */
#ifdef RT_USING_DFS
{
#ifdef RT_USING_DFS_ELMFAT
/* mount sd card fatfs as root directory */
if (dfs_mount("floppy", "/", "elm", 0, 0) == 0)
rt_kprintf("fatfs initialized!\n");
else
rt_kprintf("fatfs initialization failed!\n");
#endif
}
#endif
}
int rt_application_init()
{
rt_thread_t tid;
tid = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, RT_THREAD_PRIORITY_MAX / 3, 20);
if (tid != RT_NULL)
rt_thread_startup(tid);
return 0;
}
+16
View File
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("hello!\n");
return 0;
}
+17
View File
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
#include <rtthread.h>
extern int rt_floppy_init(void);
int mnt_init(void)
{
rt_floppy_init();
return 0;
}
-103
View File
@@ -1,103 +0,0 @@
/*
* File : startup.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2012, RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.fayfayspace.org/license/LICENSE.
*
* Change Logs:
* Date Author Notes
* 2006-09-15 QiuYi the first version
* 2006-10-10 Bernard update to 0.2.2 version
*/
#include <rtthread.h>
#include <rthw.h>
#include "board.h"
extern void rt_hw_console_init(void);
extern void rt_hw_board_init(void);
extern int rt_application_init(void);
//extern void rt_hw_interrupt_init(void);
//extern void rt_system_timer_init(void);
//extern void rt_system_scheduler_init(void);
//extern void rt_thread_idle_init(void);
#ifdef RT_USING_FINSH
extern int finsh_system_init(void);
extern void finsh_set_device(const char *device);
#endif
extern unsigned char __bss_start[];
extern unsigned char __bss_end[];
/**
* @addtogroup QEMU
*/
/*@{*/
/* clear .bss */
void rt_hw_clear_bss(void)
{
unsigned char *dst;
dst = __bss_start;
while (dst < __bss_end)
*dst++ = 0;
}
/**
* This function will startup RT-Thread RTOS
*/
void rtthread_startup(void)
{
/* clear .bss */
rt_hw_clear_bss();
/* init hardware interrupt */
rt_hw_interrupt_init();
/* init the console */
rt_hw_console_init();
rt_console_set_device("console");
/* init board */
rt_hw_board_init();
rt_show_version();
/* init timer system */
rt_system_timer_init();
/* init memory system */
#ifdef RT_USING_HEAP
/* RAM 16M */
rt_system_heap_init((void *)&__bss_end, (void *)(1024UL*1024*8));
#endif
/* init scheduler system */
rt_system_scheduler_init();
/* init application */
rt_application_init();
#ifdef RT_USING_FINSH
/* init finsh */
finsh_system_init();
finsh_set_device("console");
#endif
/* init idle thread */
rt_thread_idle_init();
/* start scheduler */
rt_system_scheduler_start();
/* never reach here */
return ;
}
/*@}*/
+45 -30
View File
@@ -1,11 +1,7 @@
/*
* File : board.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://www.fayfayspace.org/license/LICENSE.
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
@@ -13,62 +9,81 @@
* 2006-10-10 Bernard add hardware related of finsh
*/
#include <rtthread.h>
#include <rthw.h>
#include <rtthread.h>
#include <bsp.h>
extern unsigned char __bss_start[];
extern unsigned char __bss_end[];
extern void rt_hw_console_init(void);
/**
* @addtogroup QEMU
*/
/*@{*/
static void rt_timer_handler(int vector, void* param)
{
rt_tick_increase();
rt_tick_increase();
}
#ifdef RT_USING_HOOK
static void idle_hook(void)
{
asm volatile("sti; hlt": : :"memory");
asm volatile("sti; hlt": : :"memory");
}
#endif
/* clear .bss */
void rt_hw_clear_bss(void)
{
unsigned char *dst;
dst = __bss_start;
while (dst < __bss_end)
*dst++ = 0;
}
/**
* This function will init QEMU
*
*/
void rt_hw_board_init(void)
{
/* initialize 8253 clock to interrupt 1000 times/sec */
outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) % 256);
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256);
/* clear .bss */
rt_hw_clear_bss();
/* install interrupt handler */
rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask(INTTIMER0);
/* init hardware interrupt */
rt_hw_interrupt_init();
/* init the console */
rt_hw_console_init();
rt_console_set_device("console");
/* initialize 8253 clock to interrupt 1000 times/sec */
outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) % 256);
outb(IO_TIMER1, TIMER_DIV(RT_TICK_PER_SECOND) / 256);
/* install interrupt handler */
rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick");
rt_hw_interrupt_umask(INTTIMER0);
/* init memory system */
#ifdef RT_USING_HEAP
/* RAM 16M */
rt_system_heap_init((void *)&__bss_end, (void *)(1024UL*1024*8));
#endif
#ifdef RT_USING_HOOK
rt_thread_idle_sethook(idle_hook);
rt_thread_idle_sethook(idle_hook);
#endif
}
void restart(void)
static int reboot(void)
{
outb(KBSTATP, 0xFE); /* pulse reset low */
while(1);
}
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT(restart, reboot PC)
void reboot(void)
{
restart();
return 0;
}
FINSH_FUNCTION_EXPORT(reboot, reboot PC)
#endif
MSH_CMD_EXPORT(reboot, reboot system);
/*@}*/
+2 -6
View File
@@ -1,11 +1,7 @@
/*
* File : board.h
* 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
+46 -52
View File
@@ -1,11 +1,7 @@
/*
* File : console.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
@@ -218,47 +214,46 @@ static rt_size_t rt_console_read(rt_device_t dev, rt_off_t pos, void* buffer, rt
static void rt_console_isr(int vector, void* param)
{
char c;
rt_bool_t ret;
rt_bool_t ret;
rt_base_t level;
if(INTUART0_RX == vector)
{
c = rt_serial_getc();
ret = RT_TRUE;
}
else
{
rt_keyboard_isr();
if(INTUART0_RX == vector)
{
c = rt_serial_getc();
ret = RT_TRUE;
}
else
{
rt_keyboard_isr();
ret = rt_keyboard_getc(&c);
}
ret = rt_keyboard_getc(&c);
}
if(ret == RT_FALSE)
{
/* do nothing */
}
else
{
/* disable interrupt */
level = rt_hw_interrupt_disable();
if(ret == RT_FALSE)
{
/* do nothing */
}
else
{
/* disable interrupt */
level = rt_hw_interrupt_disable();
/* save character */
rx_buffer[save_index] = c;
save_index ++;
if (save_index >= CONSOLE_RX_BUFFER_SIZE)
save_index = 0;
/* save character */
rx_buffer[save_index] = c;
save_index ++;
if (save_index >= CONSOLE_RX_BUFFER_SIZE)
save_index = 0;
/* if the next position is read index, discard this 'read char' */
if (save_index == read_index)
{
read_index ++;
if (read_index >= CONSOLE_RX_BUFFER_SIZE)
read_index = 0;
}
/* if the next position is read index, discard this 'read char' */
if (save_index == read_index)
{
read_index ++;
if (read_index >= CONSOLE_RX_BUFFER_SIZE)
read_index = 0;
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
}
/* invoke callback */
if (console_device.rx_indicate != RT_NULL)
@@ -267,29 +262,25 @@ static void rt_console_isr(int vector, void* param)
/* get rx length */
rx_length = read_index > save_index ?
CONSOLE_RX_BUFFER_SIZE - read_index + save_index :
save_index - read_index;
CONSOLE_RX_BUFFER_SIZE - read_index + save_index :
save_index - read_index;
if(rx_length > 0)
{
console_device.rx_indicate(&console_device, rx_length);
}
}
else
{
}
}
/**
* This function initializes console
*
*/
void rt_hw_console_init(void)
int rt_hw_console_init(void)
{
rt_cga_init();
rt_serial_init();
init_keyboard();
rt_serial_init();
init_keyboard();
/* install keyboard isr */
rt_hw_interrupt_install(INTKEYBOARD, rt_console_isr, RT_NULL, "kbd");
@@ -311,9 +302,12 @@ void rt_hw_console_init(void)
/* register a character device */
rt_device_register(&console_device,
"console",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM);
"console",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM);
return 0;
}
INIT_DEVICE_EXPORT(rt_hw_console_init);
/**
* This function is used to display a string on console, normally, it's
+7
View File
@@ -1,3 +1,10 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
#ifndef _DMA_H
#define _DMA_H
+35 -30
View File
@@ -1,4 +1,10 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
#include <rtthread.h>
#include <rthw.h>
@@ -17,7 +23,6 @@ typedef rt_int32_t s32;
#include "floppy.h"
#include "dma.h"
#define NULL RT_NULL
#define SECTOR_SIZE 512
#define panic(str,...) do { rt_kprintf("panic::" str,##__VA_ARGS__); while(1); } while(0)
@@ -128,17 +133,17 @@ u32 floppy_get_info(void)
{
case 0x02: // 1.2MB
floppy_type = "1.2MB";
floppy_size = 2458*512;
floppy_size = 2458*512;
break;
case 0x04: // 1.44MB 标准软盘
floppy_type = "1.44MB";
floppy_size = 2880*512;
floppy_size = 2880*512;
break;
case 0x05: // 2.88MB
floppy_type = "2.88MB";
floppy_size = 2*2880*512;
floppy_size = 2*2880*512;
break;
}
return 1;
@@ -261,32 +266,32 @@ static rt_err_t rt_floppy_close(rt_device_t dev)
*/
static rt_size_t rt_floppy_read(rt_device_t device, rt_off_t position, void *buffer, rt_size_t size)
{
rt_size_t doSize = size;
rt_size_t doSize = size;
rt_mutex_take(&lock, RT_WAITING_FOREVER);
while(size>0)
{
floppy_read_cmd(position);
while(size>0)
{
floppy_read_cmd(position);
rt_sem_take(&sem, RT_WAITING_FOREVER); /* waiting isr sem forever */
rt_sem_take(&sem, RT_WAITING_FOREVER); /* waiting isr sem forever */
floppy_result();
io_delay();
floppy_result();
io_delay();
if(ST1 != 0 || ST2 != 0)
{
panic("ST0 %d ST1 %d ST2 %d\n",ST0,ST1,ST2);
}
if(ST1 != 0 || ST2 != 0)
{
panic("ST0 %d ST1 %d ST2 %d\n",ST0,ST1,ST2);
}
rt_memcpy(buffer, floppy_buffer, 512);
rt_memcpy(buffer, floppy_buffer, 512);
floppy_motorOff();
io_delay();
position += 1;
size -= 1;
}
rt_mutex_release(&lock);
floppy_motorOff();
io_delay();
position += 1;
size -= 1;
}
rt_mutex_release(&lock);
return doSize;
}
@@ -298,7 +303,7 @@ static rt_size_t rt_floppy_read(rt_device_t device, rt_off_t position, void *buf
static rt_size_t rt_floppy_write(rt_device_t device, rt_off_t position, const void *buffer, rt_size_t size)
{
rt_mutex_take(&lock, RT_WAITING_FOREVER);
panic("FIXME:I don't know how!\n");
panic("FIXME:I don't know how!\n");
rt_mutex_release(&lock);
return size;
}
@@ -325,9 +330,9 @@ static rt_err_t rt_floppy_control(rt_device_t dev, int cmd, void *args)
static void rt_floppy_isr(int vector, void* param)
{
(void)vector;
(void)param;
rt_sem_release(&sem);
(void)vector;
(void)param;
rt_sem_release(&sem);
}
void rt_floppy_init(void)
@@ -335,9 +340,9 @@ void rt_floppy_init(void)
struct rt_device *device;
rt_mutex_init(&lock,"fdlock", RT_IPC_FLAG_FIFO);
rt_sem_init(&sem, "fdsem", 0, RT_IPC_FLAG_FIFO);
rt_sem_init(&sem, "fdsem", 0, RT_IPC_FLAG_FIFO);
rt_hw_interrupt_install(FLOPPY_IRQ, rt_floppy_isr, RT_NULL, "floppy");
rt_hw_interrupt_install(FLOPPY_IRQ, rt_floppy_isr, RT_NULL, "floppy");
rt_hw_interrupt_umask(FLOPPY_IRQ);
floppy_get_info();
+7
View File
@@ -1,3 +1,10 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
#ifndef _FLOPPY_H
#define _FLOPPY_H
+58 -62
View File
@@ -1,11 +1,7 @@
/*
* File : bsp.h
* 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
@@ -60,86 +56,86 @@ extern "C" {
#define T_DEVICE 7 /* device not available */
#define T_DBLFLT 8 /* double fault */
/* 9 is reserved */
#define T_TSS 10 /* invalid task switch segment */
#define T_SEGNP 11 /* segment not present */
#define T_STACK 12 /* stack exception */
#define T_GPFLT 13 /* genernal protection fault */
#define T_PGFLT 14 /* page fault */
#define T_TSS 10 /* invalid task switch segment */
#define T_SEGNP 11 /* segment not present */
#define T_STACK 12 /* stack exception */
#define T_GPFLT 13 /* genernal protection fault */
#define T_PGFLT 14 /* page fault */
/* 15 is reserved */
#define T_FPERR 16 /* floating point error */
#define T_ALIGN 17 /* aligment check */
#define T_MCHK 18 /* machine check */
#define T_DEFAULT 500 /* catchall */
#define T_FPERR 16 /* floating point error */
#define T_ALIGN 17 /* aligment check */
#define T_MCHK 18 /* machine check */
#define T_DEFAULT 500 /* catchall */
#define INTTIMER0 0
#define INTKEYBOARD 1
#define INTUART0_RX 4
#define CLOCK_IRQ 0
#define INTTIMER0 0
#define INTKEYBOARD 1
#define INTUART0_RX 4
#define CLOCK_IRQ 0
#define KEYBOARD_IRQ 1
#define CASCADE_IRQ 2 /* cascade enable for 2nd AT controller */
#define ETHER_IRQ 3 /* default ethernet interrupt vector */
#define CASCADE_IRQ 2 /* cascade enable for 2nd AT controller */
#define ETHER_IRQ 3 /* default ethernet interrupt vector */
#define SECONDARY_IRQ 3 /* RS232 interrupt vector for port 2 */
#define RS232_IRQ 4 /* RS232 interrupt vector for port 1 */
#define XT_WINI_IRQ 5 /* xt winchester */
#define FLOPPY_IRQ 6 /* floppy disk */
#define PRINTER_IRQ 7
#define AT_WINI_IRQ 14 /* at winchester */
#define RS232_IRQ 4 /* RS232 interrupt vector for port 1 */
#define XT_WINI_IRQ 5 /* xt winchester */
#define FLOPPY_IRQ 6 /* floppy disk */
#define PRINTER_IRQ 7
#define AT_WINI_IRQ 14 /* at winchester */
/* I/O Addresses of the two 8259A programmable interrupt controllers */
#define IO_PIC1 0x20 /* Master(IRQs 0-7) */
#define IO_PIC2 0xa0 /* Slave(IRQs 8-15) */
#define IRQ_SLAVE 0x2 /* IRQ at which slave connects to master */
#define IRQ_OFFSET 0x20 /* IRQ 0 corresponds to int IRQ_OFFSET */
#define IO_PIC1 0x20 /* Master(IRQs 0-7) */
#define IO_PIC2 0xa0 /* Slave(IRQs 8-15) */
#define IRQ_SLAVE 0x2 /* IRQ at which slave connects to master */
#define IRQ_OFFSET 0x20 /* IRQ 0 corresponds to int IRQ_OFFSET */
#define MAX_HANDLERS 16 /*max number of isr handler*/
#define MAX_HANDLERS 16 /*max number of isr handler*/
/*******************************************************************/
/* CRT Register */
/*******************************************************************/
#define MONO_BASE 0x3b4
#define MONO_BUF 0xb0000
#define CGA_BASE 0x3d4
#define CGA_BUF 0xb8000
#define MONO_BASE 0x3b4
#define MONO_BUF 0xb0000
#define CGA_BASE 0x3d4
#define CGA_BUF 0xb8000
#define CRT_ROWS 25
#define CRT_COLS 80
#define CRT_SIZE (CRT_ROWS * CRT_COLS)
#define CRT_ROWS 25
#define CRT_COLS 80
#define CRT_SIZE (CRT_ROWS * CRT_COLS)
/*******************************************************************/
/* Keyboard Register */
/*******************************************************************/
#define KBSTATP 0x64 /* kbd controller status port(I) */
#define KBS_DIB 0x01 /* kbd data in buffer */
#define KBDATAP 0x60 /* kbd data port(I) */
#define KBSTATP 0x64 /* kbd controller status port(I) */
#define KBS_DIB 0x01 /* kbd data in buffer */
#define KBDATAP 0x60 /* kbd data port(I) */
/* AT keyboard */
/* 8042 ports */
#define KB_DATA 0x60 /* I/O port for keyboard data
Read : Read Output Buffer
Write: Write Input Buffer(8042 Data&8048 Command) */
#define KB_CMD 0x64 /* I/O port for keyboard command
Read : Read Status Register
Write: Write Input Buffer(8042 Command) */
#define LED_CODE 0xED
#define KB_ACK 0xFA
#define KB_DATA 0x60 /* I/O port for keyboard data
* Read : Read Output Buffer
* Write: Write Input Buffer(8042 Data&8048 Command) */
#define KB_CMD 0x64 /* I/O port for keyboard command
* Read : Read Status Register
* Write: Write Input Buffer(8042 Command) */
#define LED_CODE 0xED
#define KB_ACK 0xFA
/*******************************************************************/
/* Serial Register */
/*******************************************************************/
/*Serial I/O code */
#define COM1 0x3F8
#define COMSTATUS 5
#define COMDATA 0x01
#define COMREAD 0
#define COMWRITE 0
#define COM1 0x3F8
#define COMSTATUS 5
#define COMDATA 0x01
#define COMREAD 0
#define COMWRITE 0
/* Bits definition of the Line Status Register (LSR)*/
#define DR 0x01 /* Data Ready */
#define OE 0x02 /* Overrun Error */
#define PE 0x04 /* Parity Error */
#define FE 0x08 /* Framing Error */
#define BI 0x10 /* Break Interrupt */
#define THRE 0x20 /* Transmitter Holding Register Empty */
#define TEMT 0x40 /* Transmitter Empty */
#define ERFIFO 0x80 /* Error receive Fifo */
#define DR 0x01 /* Data Ready */
#define OE 0x02 /* Overrun Error */
#define PE 0x04 /* Parity Error */
#define FE 0x08 /* Framing Error */
#define BI 0x10 /* Break Interrupt */
#define THRE 0x20 /* Transmitter Holding Register Empty */
#define TEMT 0x40 /* Transmitter Empty */
#define ERFIFO 0x80 /* Error receive Fifo */
#ifdef __cplusplus
}
+38 -42
View File
@@ -1,11 +1,7 @@
/*
* File : grub.h
* 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
@@ -29,63 +25,63 @@
/* the multiboot header. */
typedef struct multiboot_header
{
unsigned long magic;
unsigned long flags;
unsigned long checksum;
unsigned long header_addr;
unsigned long load_addr;
unsigned long load_end_addr;
unsigned long bss_end_addr;
unsigned long entry_addr;
unsigned long magic;
unsigned long flags;
unsigned long checksum;
unsigned long header_addr;
unsigned long load_addr;
unsigned long load_end_addr;
unsigned long bss_end_addr;
unsigned long entry_addr;
} multiboot_header_t;
/* the section header table for elf. */
typedef struct elf_section_header_table
{
unsigned long num;
unsigned long size;
unsigned long addr;
unsigned long shndx;
unsigned long num;
unsigned long size;
unsigned long addr;
unsigned long shndx;
} elf_section_header_table_t;
/* the multiboot information. */
typedef struct multiboot_info
{
unsigned long flags;
unsigned long mem_lower;
unsigned long mem_upper;
unsigned long boot_device;
unsigned long cmdline;
unsigned long mods_count;
unsigned long mods_addr;
union
{
aout_symbol_table_t aout_sym;
elf_section_header_table_t elf_sec;
} u;
unsigned long mmap_length;
unsigned long mmap_addr;
unsigned long flags;
unsigned long mem_lower;
unsigned long mem_upper;
unsigned long boot_device;
unsigned long cmdline;
unsigned long mods_count;
unsigned long mods_addr;
union
{
aout_symbol_table_t aout_sym;
elf_section_header_table_t elf_sec;
} u;
unsigned long mmap_length;
unsigned long mmap_addr;
} multiboot_info_t;
/* the module structure. */
typedef struct module
{
unsigned long mod_start;
unsigned long mod_end;
unsigned long string;
unsigned long reserved;
unsigned long mod_start;
unsigned long mod_end;
unsigned long string;
unsigned long reserved;
} module_t;
/* the memory map. be careful that the offset 0 is base_addr_low
but no size. */
typedef struct memory_map
{
unsigned long size;
unsigned long base_addr_low;
unsigned long base_addr_high;
unsigned long length_low;
unsigned long length_high;
unsigned long type;
unsigned long size;
unsigned long base_addr_low;
unsigned long base_addr_high;
unsigned long length_low;
unsigned long length_high;
unsigned long type;
} memory_map_t;
#endif
File diff suppressed because it is too large. Load diff
+2 -6
View File
@@ -1,11 +1,7 @@
/*
* File : keyboard.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* Copyright (c) 2006-2018, 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
+7
View File
@@ -1,3 +1,10 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
keyboard.h
+7
View File
@@ -1,3 +1,10 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
keymap.h
+21 -27
View File
@@ -1,18 +1,14 @@
/*
* File : serial.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* Copyright (c) 2006-2018, 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
* 2006-09-15 QiuYi the first version
* 2006-10-10 Bernard use keyboard instead of serial
*/
#include <rtthread.h>
#include <rthw.h>
@@ -28,13 +24,13 @@
*/
void rt_serial_init(void)
{
outb(COM1+3,0x80); /* set DLAB of line control reg */
outb(COM1,0x0c); /* LS of divisor (48 -> 2400 bps */
outb(COM1+1,0x00); /* MS of divisor */
outb(COM1+3,0x03); /* reset DLAB */
outb(COM1+4,0x0b); /* set DTR,RTS, OUT_2 */
outb(COM1+1,0x0d); /* enable all intrs but writes */
inb(COM1); /* read data port to reset things (?) */
outb(COM1+3,0x80); /* set DLAB of line control reg */
outb(COM1,0x0c); /* LS of divisor (48 -> 2400 bps */
outb(COM1+1,0x00); /* MS of divisor */
outb(COM1+3,0x03); /* reset DLAB */
outb(COM1+4,0x0b); /* set DTR,RTS, OUT_2 */
outb(COM1+1,0x0d); /* enable all intrs but writes */
inb(COM1); /* read data port to reset things (?) */
}
/**
@@ -44,11 +40,9 @@ void rt_serial_init(void)
*/
char rt_serial_getc(void)
{
while(!(inb(COM1+COMSTATUS) & COMDATA));
while(!(inb(COM1+COMSTATUS) & COMDATA));
return inb(COM1+COMREAD);
return inb(COM1+COMREAD);
}
/**
@@ -58,15 +52,15 @@ char rt_serial_getc(void)
*/
void rt_serial_putc(const char c)
{
int val;
while(1)
{
if ((val = inb(COM1+COMSTATUS)) & THRE)
break;
}
outb(COM1+COMWRITE, c&0xff);
int val;
while(1)
{
if ((val = inb(COM1+COMSTATUS)) & THRE)
break;
}
outb(COM1+COMWRITE, c&0xff);
}
/*@}*/
+142 -136
View File
File diff suppressed because it is too large. Load diff
+10 -10
View File
@@ -6,14 +6,14 @@ CPU=''
CROSS_TOOL='gcc'
if os.getenv('RTT_CC'):
CROSS_TOOL = os.getenv('RTT_CC')
CROSS_TOOL = os.getenv('RTT_CC')
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path, for example, CodeSourcery,
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
EXEC_PATH = 'E:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_IA32_ELF/bin'
PLATFORM = 'gcc'
EXEC_PATH = 'E:/Program Files/CodeSourcery/Sourcery_CodeBench_Lite_for_IA32_ELF/bin'
elif CROSS_TOOL == 'keil':
print('================ERROR============================')
print('Not support keil yet!')
@@ -26,26 +26,26 @@ elif CROSS_TOOL == 'iar':
exit(0)
if os.getenv('RTT_EXEC_PATH'):
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
BUILD = 'debug'
if PLATFORM == 'gcc':
# toolchains
PREFIX = ''
CC = PREFIX + 'gcc -m32 -fno-builtin -fno-stack-protector -nostdinc'
AS = PREFIX + 'gcc -m32'
PREFIX = 'i686-elf-'
CC = PREFIX + 'gcc'
AS = PREFIX + 'gcc'
AR = PREFIX + 'ar'
LINK = PREFIX + 'ld -melf_i386'
LINK = PREFIX + 'gcc'
TARGET_EXT = 'elf'
SIZE = PREFIX + 'size'
OBJDUMP = PREFIX + 'objdump'
OBJCPY = PREFIX + 'objcopy'
DEVICE = ''
DEVICE = ' -mtune=generic'
CFLAGS = DEVICE + ' -Wall'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
LFLAGS = DEVICE + ' -Map rtthread-ia32.map -T x86_ram.lds -nostdlib'
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T x86_ram.lds -nostartfiles'
CPATH = ''
LPATH = ''
+53 -46
View File
@@ -1,55 +1,62 @@
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
. = 0x00100000;
. = ALIGN(4);
.text :
{
*(.init)
*(.text)
. = 0x00100000;
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(4);
__rtmsymtab_start = .;
KEEP(*(RTMSymTab));
__rtmsymtab_end = .;
}
. = ALIGN(4);
.rodata : { *(.rodata*) }
. = ALIGN(4);
.text :
{
*(.init)
*(.text)
. = ALIGN(4);
.data : { *(.data) }
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
. = ALIGN(4);
__rtmsymtab_start = .;
KEEP(*(RTMSymTab));
__rtmsymtab_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
__bss_end = .;
/* stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
_end = .;
/* section information for initialization */
. = ALIGN(4);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
}
. = ALIGN(4);
.rodata : { *(.rodata*) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
__bss_end = .;
/* stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
_end = .;
}
+2 -6
View File
@@ -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
+2 -6
View File
@@ -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
-20
View File
@@ -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 */
}
+2 -34
View File
@@ -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
+30 -12
View File
@@ -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;
}
/*@}*/
+2 -6
View File
@@ -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
+37 -74
View File
@@ -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");
}
/*@}*/
-42
View File
@@ -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;
}
+7 -11
View File
@@ -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
/*@}*/
+7 -10
View File
@@ -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;
}
+12 -14
View File
@@ -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