summaryrefslogtreecommitdiff
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
parente596921019839fdaf1c0c2c76a1aa13f4c083299 (diff)
[bsp][x86] update x86 with Kconfig and newlib toolchains.
-rw-r--r--bsp/x86/.config535
-rw-r--r--bsp/x86/Kconfig26
-rw-r--r--bsp/x86/Makefile46
-rw-r--r--bsp/x86/SConscript5
-rw-r--r--bsp/x86/applications/application.c86
-rw-r--r--bsp/x86/applications/main.c16
-rw-r--r--bsp/x86/applications/mnt.c17
-rw-r--r--bsp/x86/applications/startup.c103
-rw-r--r--bsp/x86/drivers/board.c75
-rw-r--r--bsp/x86/drivers/board.h8
-rw-r--r--bsp/x86/drivers/console.c98
-rw-r--r--bsp/x86/drivers/dma.h7
-rw-r--r--bsp/x86/drivers/floppy.c65
-rw-r--r--bsp/x86/drivers/floppy.h7
-rw-r--r--bsp/x86/drivers/include/bsp.h120
-rw-r--r--bsp/x86/drivers/include/grub.h80
-rw-r--r--bsp/x86/drivers/include/i386.h170
-rw-r--r--bsp/x86/drivers/keyboard.c8
-rw-r--r--bsp/x86/drivers/keyboard.h7
-rw-r--r--bsp/x86/drivers/keymap.h7
-rw-r--r--bsp/x86/drivers/serial.c48
-rw-r--r--bsp/x86/rtconfig.h276
-rw-r--r--bsp/x86/rtconfig.py20
-rw-r--r--bsp/x86/x86_ram.lds99
-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
35 files changed, 1263 insertions, 1002 deletions
diff --git a/bsp/x86/.config b/bsp/x86/.config
new file mode 100644
index 0000000000..b796f37ae5
--- /dev/null
+++ b/bsp/x86/.config
@@ -0,0 +1,535 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# RT-Thread Configuration
+#
+
+#
+# RT-Thread Kernel
+#
+CONFIG_RT_NAME_MAX=8
+# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
+# CONFIG_RT_USING_SMP is not set
+CONFIG_RT_ALIGN_SIZE=4
+# CONFIG_RT_THREAD_PRIORITY_8 is not set
+CONFIG_RT_THREAD_PRIORITY_32=y
+# CONFIG_RT_THREAD_PRIORITY_256 is not set
+CONFIG_RT_THREAD_PRIORITY_MAX=32
+CONFIG_RT_TICK_PER_SECOND=100
+CONFIG_RT_USING_OVERFLOW_CHECK=y
+CONFIG_RT_USING_HOOK=y
+CONFIG_RT_USING_IDLE_HOOK=y
+CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
+CONFIG_IDLE_THREAD_STACK_SIZE=2048
+CONFIG_RT_USING_TIMER_SOFT=y
+CONFIG_RT_TIMER_THREAD_PRIO=4
+CONFIG_RT_TIMER_THREAD_STACK_SIZE=2048
+CONFIG_RT_DEBUG=y
+CONFIG_RT_DEBUG_COLOR=y
+CONFIG_RT_DEBUG_INIT_CONFIG=y
+CONFIG_RT_DEBUG_INIT=1
+# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
+# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
+# CONFIG_RT_DEBUG_IPC_CONFIG is not set
+# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
+# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
+# CONFIG_RT_DEBUG_MEM_CONFIG is not set
+# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
+# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
+# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
+
+#
+# Inter-Thread communication
+#
+CONFIG_RT_USING_SEMAPHORE=y
+CONFIG_RT_USING_MUTEX=y
+CONFIG_RT_USING_EVENT=y
+CONFIG_RT_USING_MAILBOX=y
+CONFIG_RT_USING_MESSAGEQUEUE=y
+# CONFIG_RT_USING_SIGNALS is not set
+
+#
+# Memory Management
+#
+CONFIG_RT_USING_MEMPOOL=y
+# CONFIG_RT_USING_MEMHEAP is not set
+# CONFIG_RT_USING_NOHEAP is not set
+CONFIG_RT_USING_SMALL_MEM=y
+# CONFIG_RT_USING_SLAB is not set
+# CONFIG_RT_USING_USERHEAP is not set
+CONFIG_RT_USING_MEMTRACE=y
+CONFIG_RT_USING_HEAP=y
+
+#
+# Kernel Device Object
+#
+CONFIG_RT_USING_DEVICE=y
+# CONFIG_RT_USING_DEVICE_OPS is not set
+# CONFIG_RT_USING_INTERRUPT_INFO is not set
+CONFIG_RT_USING_CONSOLE=y
+CONFIG_RT_CONSOLEBUF_SIZE=256
+CONFIG_RT_CONSOLE_DEVICE_NAME="console"
+CONFIG_RT_VER_NUM=0x40003
+# CONFIG_RT_USING_CPU_FFS is not set
+CONFIG_ARCH_IA32=y
+# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set
+
+#
+# RT-Thread Components
+#
+CONFIG_RT_USING_COMPONENTS_INIT=y
+CONFIG_RT_USING_USER_MAIN=y
+CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
+CONFIG_RT_MAIN_THREAD_PRIORITY=10
+
+#
+# C++ features
+#
+# CONFIG_RT_USING_CPLUSPLUS is not set
+
+#
+# Command shell
+#
+CONFIG_RT_USING_FINSH=y
+CONFIG_FINSH_THREAD_NAME="tshell"
+CONFIG_FINSH_USING_HISTORY=y
+CONFIG_FINSH_HISTORY_LINES=5
+CONFIG_FINSH_USING_SYMTAB=y
+CONFIG_FINSH_USING_DESCRIPTION=y
+# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
+CONFIG_FINSH_THREAD_PRIORITY=20
+CONFIG_FINSH_THREAD_STACK_SIZE=4096
+CONFIG_FINSH_CMD_SIZE=80
+# CONFIG_FINSH_USING_AUTH is not set
+CONFIG_FINSH_USING_MSH=y
+CONFIG_FINSH_USING_MSH_DEFAULT=y
+CONFIG_FINSH_USING_MSH_ONLY=y
+CONFIG_FINSH_ARG_MAX=10
+
+#
+# Device virtual file system
+#
+CONFIG_RT_USING_DFS=y
+CONFIG_DFS_USING_WORKDIR=y
+CONFIG_DFS_FILESYSTEMS_MAX=2
+CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
+CONFIG_DFS_FD_MAX=16
+# CONFIG_RT_USING_DFS_MNTTABLE is not set
+CONFIG_RT_USING_DFS_ELMFAT=y
+
+#
+# elm-chan's FatFs, Generic FAT Filesystem Module
+#
+CONFIG_RT_DFS_ELM_CODE_PAGE=437
+CONFIG_RT_DFS_ELM_WORD_ACCESS=y
+# CONFIG_RT_DFS_ELM_USE_LFN_0 is not set
+# CONFIG_RT_DFS_ELM_USE_LFN_1 is not set
+# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
+CONFIG_RT_DFS_ELM_USE_LFN_3=y
+CONFIG_RT_DFS_ELM_USE_LFN=3
+CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
+# CONFIG_RT_DFS_ELM_LFN_UNICODE_1 is not set
+# CONFIG_RT_DFS_ELM_LFN_UNICODE_2 is not set
+# CONFIG_RT_DFS_ELM_LFN_UNICODE_3 is not set
+CONFIG_RT_DFS_ELM_LFN_UNICODE=0
+CONFIG_RT_DFS_ELM_MAX_LFN=255
+CONFIG_RT_DFS_ELM_DRIVES=2
+CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
+# CONFIG_RT_DFS_ELM_USE_ERASE is not set
+CONFIG_RT_DFS_ELM_REENTRANT=y
+CONFIG_RT_USING_DFS_DEVFS=y
+# CONFIG_RT_USING_DFS_ROMFS is not set
+# CONFIG_RT_USING_DFS_RAMFS is not set
+# CONFIG_RT_USING_DFS_UFFS is not set
+# CONFIG_RT_USING_DFS_JFFS2 is not set
+
+#
+# Device Drivers
+#
+CONFIG_RT_USING_DEVICE_IPC=y
+CONFIG_RT_PIPE_BUFSZ=512
+CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
+CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
+CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
+CONFIG_RT_USING_SERIAL=y
+CONFIG_RT_SERIAL_USING_DMA=y
+CONFIG_RT_SERIAL_RB_BUFSZ=64
+# CONFIG_RT_USING_CAN is not set
+# CONFIG_RT_USING_HWTIMER is not set
+# CONFIG_RT_USING_CPUTIME is not set
+# CONFIG_RT_USING_I2C is not set
+# CONFIG_RT_USING_PHY is not set
+CONFIG_RT_USING_PIN=y
+# CONFIG_RT_USING_ADC is not set
+# CONFIG_RT_USING_DAC is not set
+# CONFIG_RT_USING_PWM is not set
+# CONFIG_RT_USING_MTD_NOR is not set
+# CONFIG_RT_USING_MTD_NAND is not set
+# CONFIG_RT_USING_PM is not set
+# CONFIG_RT_USING_RTC is not set
+# CONFIG_RT_USING_SDIO is not set
+# CONFIG_RT_USING_SPI is not set
+# CONFIG_RT_USING_WDT is not set
+# CONFIG_RT_USING_AUDIO is not set
+# CONFIG_RT_USING_SENSOR is not set
+# CONFIG_RT_USING_TOUCH is not set
+# CONFIG_RT_USING_HWCRYPTO is not set
+# CONFIG_RT_USING_PULSE_ENCODER is not set
+# CONFIG_RT_USING_INPUT_CAPTURE is not set
+# CONFIG_RT_USING_WIFI is not set
+
+#
+# Using USB
+#
+# CONFIG_RT_USING_USB_HOST is not set
+# CONFIG_RT_USING_USB_DEVICE is not set
+
+#
+# POSIX layer and C standard library
+#
+CONFIG_RT_USING_LIBC=y
+# CONFIG_RT_USING_PTHREADS is not set
+# CONFIG_RT_USING_POSIX is not set
+# CONFIG_RT_USING_MODULE is not set
+
+#
+# Network
+#
+
+#
+# Socket abstraction layer
+#
+# CONFIG_RT_USING_SAL is not set
+
+#
+# Network interface device
+#
+# CONFIG_RT_USING_NETDEV is not set
+
+#
+# light weight TCP/IP stack
+#
+# CONFIG_RT_USING_LWIP is not set
+
+#
+# AT commands
+#
+# CONFIG_RT_USING_AT is not set
+
+#
+# VBUS(Virtual Software BUS)
+#
+# CONFIG_RT_USING_VBUS is not set
+
+#
+# Utilities
+#
+# CONFIG_RT_USING_RYM is not set
+# CONFIG_RT_USING_ULOG is not set
+# CONFIG_RT_USING_UTEST is not set
+
+#
+# RT-Thread online packages
+#
+
+#
+# IoT - internet of things
+#
+# CONFIG_PKG_USING_LORAWAN_DRIVER is not set
+# CONFIG_PKG_USING_PAHOMQTT is not set
+# CONFIG_PKG_USING_UMQTT is not set
+# CONFIG_PKG_USING_WEBCLIENT is not set
+# CONFIG_PKG_USING_WEBNET is not set
+# CONFIG_PKG_USING_MONGOOSE is not set
+# CONFIG_PKG_USING_MYMQTT is not set
+# CONFIG_PKG_USING_KAWAII_MQTT is not set
+# CONFIG_PKG_USING_BC28_MQTT is not set
+# CONFIG_PKG_USING_WEBTERMINAL is not set
+# CONFIG_PKG_USING_CJSON is not set
+# CONFIG_PKG_USING_JSMN is not set
+# CONFIG_PKG_USING_LIBMODBUS is not set
+# CONFIG_PKG_USING_FREEMODBUS is not set
+# CONFIG_PKG_USING_LJSON is not set
+# CONFIG_PKG_USING_EZXML is not set
+# CONFIG_PKG_USING_NANOPB is not set
+
+#
+# Wi-Fi
+#
+
+#
+# Marvell WiFi
+#
+# CONFIG_PKG_USING_WLANMARVELL is not set
+
+#
+# Wiced WiFi
+#
+# CONFIG_PKG_USING_WLAN_WICED is not set
+# CONFIG_PKG_USING_RW007 is not set
+# CONFIG_PKG_USING_COAP is not set
+# CONFIG_PKG_USING_NOPOLL is not set
+# CONFIG_PKG_USING_NETUTILS is not set
+# CONFIG_PKG_USING_CMUX is not set
+# CONFIG_PKG_USING_PPP_DEVICE is not set
+# CONFIG_PKG_USING_AT_DEVICE is not set
+# CONFIG_PKG_USING_ATSRV_SOCKET is not set
+# CONFIG_PKG_USING_WIZNET is not set
+
+#
+# IoT Cloud
+#
+# CONFIG_PKG_USING_ONENET is not set
+# CONFIG_PKG_USING_GAGENT_CLOUD is not set
+# CONFIG_PKG_USING_ALI_IOTKIT is not set
+# CONFIG_PKG_USING_AZURE is not set
+# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set
+# CONFIG_PKG_USING_JIOT-C-SDK is not set
+# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
+# CONFIG_PKG_USING_JOYLINK is not set
+# CONFIG_PKG_USING_NIMBLE is not set
+# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
+# CONFIG_PKG_USING_IPMSG is not set
+# CONFIG_PKG_USING_LSSDP is not set
+# CONFIG_PKG_USING_AIRKISS_OPEN is not set
+# CONFIG_PKG_USING_LIBRWS is not set
+# CONFIG_PKG_USING_TCPSERVER is not set
+# CONFIG_PKG_USING_PROTOBUF_C is not set
+# CONFIG_PKG_USING_ONNX_PARSER is not set
+# CONFIG_PKG_USING_ONNX_BACKEND is not set
+# CONFIG_PKG_USING_DLT645 is not set
+# CONFIG_PKG_USING_QXWZ is not set
+# CONFIG_PKG_USING_SMTP_CLIENT is not set
+# CONFIG_PKG_USING_ABUP_FOTA is not set
+# CONFIG_PKG_USING_LIBCURL2RTT is not set
+# CONFIG_PKG_USING_CAPNP is not set
+# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set
+# CONFIG_PKG_USING_AGILE_TELNET is not set
+# CONFIG_PKG_USING_NMEALIB is not set
+# CONFIG_PKG_USING_AGILE_JSMN is not set
+# CONFIG_PKG_USING_PDULIB is not set
+# CONFIG_PKG_USING_BTSTACK is not set
+# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
+# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
+
+#
+# security packages
+#
+# CONFIG_PKG_USING_MBEDTLS is not set
+# CONFIG_PKG_USING_libsodium is not set
+# CONFIG_PKG_USING_TINYCRYPT is not set
+# CONFIG_PKG_USING_TFM is not set
+# CONFIG_PKG_USING_YD_CRYPTO is not set
+
+#
+# language packages
+#
+# CONFIG_PKG_USING_LUA is not set
+# CONFIG_PKG_USING_JERRYSCRIPT is not set
+# CONFIG_PKG_USING_MICROPYTHON is not set
+
+#
+# multimedia packages
+#
+# CONFIG_PKG_USING_OPENMV is not set
+# CONFIG_PKG_USING_MUPDF is not set
+# CONFIG_PKG_USING_STEMWIN is not set
+# CONFIG_PKG_USING_WAVPLAYER is not set
+# CONFIG_PKG_USING_TJPGD is not set
+# CONFIG_PKG_USING_HELIX is not set
+# CONFIG_PKG_USING_AZUREGUIX is not set
+# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
+
+#
+# tools packages
+#
+# CONFIG_PKG_USING_CMBACKTRACE is not set
+# CONFIG_PKG_USING_EASYFLASH is not set
+# CONFIG_PKG_USING_EASYLOGGER is not set
+# CONFIG_PKG_USING_SYSTEMVIEW is not set
+# CONFIG_PKG_USING_RDB is not set
+# CONFIG_PKG_USING_QRCODE is not set
+# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
+# CONFIG_PKG_USING_ULOG_FILE is not set
+# CONFIG_PKG_USING_LOGMGR is not set
+# CONFIG_PKG_USING_ADBD is not set
+# CONFIG_PKG_USING_COREMARK is not set
+# CONFIG_PKG_USING_DHRYSTONE is not set
+# CONFIG_PKG_USING_MEMORYPERF is not set
+# CONFIG_PKG_USING_NR_MICRO_SHELL is not set
+# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set
+# CONFIG_PKG_USING_LUNAR_CALENDAR is not set
+# CONFIG_PKG_USING_BS8116A is not set
+# CONFIG_PKG_USING_GPS_RMC is not set
+# CONFIG_PKG_USING_URLENCODE is not set
+# CONFIG_PKG_USING_UMCN is not set
+# CONFIG_PKG_USING_LWRB2RTT is not set
+# CONFIG_PKG_USING_CPU_USAGE is not set
+# CONFIG_PKG_USING_GBK2UTF8 is not set
+# CONFIG_PKG_USING_VCONSOLE is not set
+# CONFIG_PKG_USING_KDB is not set
+# CONFIG_PKG_USING_WAMR is not set
+# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
+# CONFIG_PKG_USING_LWLOG is not set
+# CONFIG_PKG_USING_ANV_TRACE is not set
+# CONFIG_PKG_USING_ANV_MEMLEAK is not set
+# CONFIG_PKG_USING_ANV_TESTSUIT is not set
+# CONFIG_PKG_USING_ANV_BENCH is not set
+
+#
+# system packages
+#
+# CONFIG_PKG_USING_GUIENGINE is not set
+# CONFIG_PKG_USING_CAIRO is not set
+# CONFIG_PKG_USING_PIXMAN is not set
+# CONFIG_PKG_USING_LWEXT4 is not set
+# CONFIG_PKG_USING_PARTITION is not set
+# CONFIG_PKG_USING_FAL is not set
+# CONFIG_PKG_USING_FLASHDB is not set
+# CONFIG_PKG_USING_SQLITE is not set
+# CONFIG_PKG_USING_RTI is not set
+# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
+# CONFIG_PKG_USING_CMSIS is not set
+# CONFIG_PKG_USING_DFS_YAFFS is not set
+# CONFIG_PKG_USING_LITTLEFS is not set
+# CONFIG_PKG_USING_THREAD_POOL is not set
+# CONFIG_PKG_USING_ROBOTS is not set
+# CONFIG_PKG_USING_EV is not set
+# CONFIG_PKG_USING_SYSWATCH is not set
+# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set
+# CONFIG_PKG_USING_PLCCORE is not set
+# CONFIG_PKG_USING_RAMDISK is not set
+# CONFIG_PKG_USING_MININI is not set
+# CONFIG_PKG_USING_QBOOT is not set
+
+#
+# Micrium: Micrium software products porting for RT-Thread
+#
+# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
+# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
+# CONFIG_PKG_USING_UC_CRC is not set
+# CONFIG_PKG_USING_UC_CLK is not set
+# CONFIG_PKG_USING_UC_COMMON is not set
+# CONFIG_PKG_USING_UC_MODBUS is not set
+# CONFIG_PKG_USING_PPOOL is not set
+# CONFIG_PKG_USING_OPENAMP is not set
+# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
+# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
+# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
+# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
+# CONFIG_PKG_USING_QFPLIB_M3 is not set
+# CONFIG_PKG_USING_LPM is not set
+
+#
+# peripheral libraries and drivers
+#
+# CONFIG_PKG_USING_SENSORS_DRIVERS is not set
+# CONFIG_PKG_USING_REALTEK_AMEBA is not set
+# CONFIG_PKG_USING_SHT2X is not set
+# CONFIG_PKG_USING_SHT3X is not set
+# CONFIG_PKG_USING_AS7341 is not set
+# CONFIG_PKG_USING_STM32_SDIO is not set
+# CONFIG_PKG_USING_ICM20608 is not set
+# CONFIG_PKG_USING_U8G2 is not set
+# CONFIG_PKG_USING_BUTTON is not set
+# CONFIG_PKG_USING_PCF8574 is not set
+# CONFIG_PKG_USING_SX12XX is not set
+# CONFIG_PKG_USING_SIGNAL_LED is not set
+# CONFIG_PKG_USING_LEDBLINK is not set
+# CONFIG_PKG_USING_LITTLED is not set
+# CONFIG_PKG_USING_LKDGUI is not set
+# CONFIG_PKG_USING_NRF5X_SDK is not set
+# CONFIG_PKG_USING_NRFX is not set
+# CONFIG_PKG_USING_WM_LIBRARIES is not set
+# CONFIG_PKG_USING_KENDRYTE_SDK is not set
+# CONFIG_PKG_USING_INFRARED is not set
+# CONFIG_PKG_USING_ROSSERIAL is not set
+# CONFIG_PKG_USING_AGILE_BUTTON is not set
+# CONFIG_PKG_USING_AGILE_LED is not set
+# CONFIG_PKG_USING_AT24CXX is not set
+# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set
+# CONFIG_PKG_USING_AD7746 is not set
+# CONFIG_PKG_USING_PCA9685 is not set
+# CONFIG_PKG_USING_I2C_TOOLS is not set
+# CONFIG_PKG_USING_NRF24L01 is not set
+# CONFIG_PKG_USING_TOUCH_DRIVERS is not set
+# CONFIG_PKG_USING_MAX17048 is not set
+# CONFIG_PKG_USING_RPLIDAR is not set
+# CONFIG_PKG_USING_AS608 is not set
+# CONFIG_PKG_USING_RC522 is not set
+# CONFIG_PKG_USING_WS2812B is not set
+# CONFIG_PKG_USING_EMBARC_BSP is not set
+# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set
+# CONFIG_PKG_USING_MULTI_RTIMER is not set
+# CONFIG_PKG_USING_MAX7219 is not set
+# CONFIG_PKG_USING_BEEP is not set
+# CONFIG_PKG_USING_EASYBLINK is not set
+# CONFIG_PKG_USING_PMS_SERIES is not set
+# CONFIG_PKG_USING_CAN_YMODEM is not set
+# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set
+# CONFIG_PKG_USING_QLED is not set
+# CONFIG_PKG_USING_PAJ7620 is not set
+# CONFIG_PKG_USING_AGILE_CONSOLE is not set
+# CONFIG_PKG_USING_LD3320 is not set
+# CONFIG_PKG_USING_WK2124 is not set
+# CONFIG_PKG_USING_LY68L6400 is not set
+# CONFIG_PKG_USING_DM9051 is not set
+# CONFIG_PKG_USING_SSD1306 is not set
+# CONFIG_PKG_USING_QKEY is not set
+# CONFIG_PKG_USING_RS485 is not set
+# CONFIG_PKG_USING_NES is not set
+# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
+# CONFIG_PKG_USING_VDEVICE is not set
+# CONFIG_PKG_USING_SGM706 is not set
+
+#
+# miscellaneous packages
+#
+# CONFIG_PKG_USING_LIBCSV is not set
+# CONFIG_PKG_USING_OPTPARSE is not set
+# CONFIG_PKG_USING_FASTLZ is not set
+# CONFIG_PKG_USING_MINILZO is not set
+# CONFIG_PKG_USING_QUICKLZ is not set
+# CONFIG_PKG_USING_LZMA is not set
+# CONFIG_PKG_USING_MULTIBUTTON is not set
+# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
+# CONFIG_PKG_USING_CANFESTIVAL is not set
+# CONFIG_PKG_USING_ZLIB is not set
+# CONFIG_PKG_USING_DSTR is not set
+# CONFIG_PKG_USING_TINYFRAME is not set
+# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
+# CONFIG_PKG_USING_DIGITALCTRL is not set
+# CONFIG_PKG_USING_UPACKER is not set
+# CONFIG_PKG_USING_UPARAM is not set
+
+#
+# samples: kernel and components samples
+#
+# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
+# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
+# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
+# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
+# CONFIG_PKG_USING_HELLO is not set
+# CONFIG_PKG_USING_VI is not set
+# CONFIG_PKG_USING_KI is not set
+# CONFIG_PKG_USING_NNOM is not set
+# CONFIG_PKG_USING_LIBANN is not set
+# CONFIG_PKG_USING_ELAPACK is not set
+# CONFIG_PKG_USING_ARMv7M_DWT is not set
+# CONFIG_PKG_USING_VT100 is not set
+# CONFIG_PKG_USING_ULAPACK is not set
+# CONFIG_PKG_USING_UKAL is not set
+# CONFIG_PKG_USING_CRCLIB is not set
+
+#
+# games: games run on RT-Thread console
+#
+# CONFIG_PKG_USING_THREES is not set
+# CONFIG_PKG_USING_2048 is not set
+# CONFIG_PKG_USING_SNAKE is not set
+# CONFIG_PKG_USING_TETRIS is not set
+# CONFIG_PKG_USING_LWGPS is not set
+# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
+# CONFIG_PKG_USING_STATE_MACHINE is not set
+# CONFIG_PKG_USING_MCURSES is not set
+# CONFIG_PKG_USING_COWSAY is not set
+CONFIG_IA32=y
diff --git a/bsp/x86/Kconfig b/bsp/x86/Kconfig
new file mode 100644
index 0000000000..e8ac6055e5
--- /dev/null
+++ b/bsp/x86/Kconfig
@@ -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
diff --git a/bsp/x86/Makefile b/bsp/x86/Makefile
deleted file mode 100644
index eb4654193b..0000000000
--- a/bsp/x86/Makefile
+++ /dev/null
@@ -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
diff --git a/bsp/x86/SConscript b/bsp/x86/SConscript
index fe0ae941ae..3d15055d62 100644
--- a/bsp/x86/SConscript
+++ b/bsp/x86/SConscript
@@ -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)
diff --git a/bsp/x86/applications/application.c b/bsp/x86/applications/application.c
deleted file mode 100644
index 8928e6357e..0000000000
--- a/bsp/x86/applications/application.c
+++ /dev/null
@@ -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;
-}
diff --git a/bsp/x86/applications/main.c b/bsp/x86/applications/main.c
new file mode 100644
index 0000000000..86aadd5a7b
--- /dev/null
+++ b/bsp/x86/applications/main.c
@@ -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;
+}
diff --git a/bsp/x86/applications/mnt.c b/bsp/x86/applications/mnt.c
new file mode 100644
index 0000000000..3ca04871f8
--- /dev/null
+++ b/bsp/x86/applications/mnt.c
@@ -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;
+}
diff --git a/bsp/x86/applications/startup.c b/bsp/x86/applications/startup.c
deleted file mode 100644
index 475273267f..0000000000
--- a/bsp/x86/applications/startup.c
+++ /dev/null
@@ -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 ;
-}
-
-/*@}*/
diff --git a/bsp/x86/drivers/board.c b/bsp/x86/drivers/board.c
index 211ae1832a..30aba8be54 100644
--- a/bsp/x86/drivers/board.c
+++ b/bsp/x86/drivers/board.c
@@ -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();
+
+ /* init hardware interrupt */
+ rt_hw_interrupt_init();
- /* install interrupt handler */
- rt_hw_interrupt_install(INTTIMER0, rt_timer_handler, RT_NULL, "tick");
- rt_hw_interrupt_umask(INTTIMER0);
+ /* 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);
/*@}*/
diff --git a/bsp/x86/drivers/board.h b/bsp/x86/drivers/board.h
index bc79f9ccfb..96e1cb15af 100644
--- a/bsp/x86/drivers/board.h
+++ b/bsp/x86/drivers/board.h
@@ -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
diff --git a/bsp/x86/drivers/console.c b/bsp/x86/drivers/console.c
index f5c4fe530b..b783872bae 100644
--- a/bsp/x86/drivers/console.c
+++ b/bsp/x86/drivers/console.c
@@ -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();
-
- ret = rt_keyboard_getc(&c);
- }
+ if(INTUART0_RX == vector)
+ {
+ c = rt_serial_getc();
+ ret = RT_TRUE;
+ }
+ else
+ {
+ rt_keyboard_isr();
+ 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
diff --git a/bsp/x86/drivers/dma.h b/bsp/x86/drivers/dma.h
index f1a8563cb1..3e5e9b08d1 100644
--- a/bsp/x86/drivers/dma.h
+++ b/bsp/x86/drivers/dma.h
@@ -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
diff --git a/bsp/x86/drivers/floppy.c b/bsp/x86/drivers/floppy.c
index c7876a68f8..f4675b9194 100644
--- a/bsp/x86/drivers/floppy.c
+++ b/bsp/x86/drivers/floppy.c
@@ -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();
diff --git a/bsp/x86/drivers/floppy.h b/bsp/x86/drivers/floppy.h
index f619508c43..86de750133 100644
--- a/bsp/x86/drivers/floppy.h
+++ b/bsp/x86/drivers/floppy.h
@@ -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
diff --git a/bsp/x86/drivers/include/bsp.h b/bsp/x86/drivers/include/bsp.h
index 724f518c6e..93e409dbfa 100644
--- a/bsp/x86/drivers/include/bsp.h
+++ b/bsp/x86/drivers/include/bsp.h
@@ -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
}
diff --git a/bsp/x86/drivers/include/grub.h b/bsp/x86/drivers/include/grub.h
index dcfa36b819..d5a84a48da 100644
--- a/bsp/x86/drivers/include/grub.h
+++ b/bsp/x86/drivers/include/grub.h
@@ -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
diff --git a/bsp/x86/drivers/include/i386.h b/bsp/x86/drivers/include/i386.h
index 68c854932b..bde4a95c3b 100644
--- a/bsp/x86/drivers/include/i386.h
+++ b/bsp/x86/drivers/include/i386.h
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ */
#ifndef __I386_H_
#define __I386_H_
@@ -7,138 +14,135 @@ extern "C" {
static __inline unsigned char inb(int port)
{
- unsigned char data;
- __asm __volatile("inb %w1,%0" : "=a" (data) : "d" (port));
- return data;
+ unsigned char data;
+ __asm __volatile("inb %w1,%0" : "=a" (data) : "d" (port));
+ return data;
}
static __inline unsigned char inb_p(unsigned short port)
{
- unsigned char _v;
- __asm__ __volatile__ ("inb %1, %0\n\t"
- // "outb %0,$0x80\n\t"
- // "outb %0,$0x80\n\t"
- // "outb %0,$0x80\n\t"
- "outb %0,$0x80"
- :"=a" (_v)
- :"d" ((unsigned short) port));
- return _v;
+ unsigned char _v;
+ __asm__ __volatile__ ("inb %1, %0\n\t"
+ "outb %0,$0x80"
+ :"=a" (_v)
+ :"d" ((unsigned short) port));
+ return _v;
}
static __inline unsigned short inw(int port)
{
- unsigned short data;
- __asm __volatile("inw %w1,%0" : "=a" (data) : "d" (port));
- return data;
+ unsigned short data;
+ __asm __volatile("inw %w1,%0" : "=a" (data) : "d" (port));
+ return data;
}
static __inline unsigned int inl(int port)
{
- unsigned int data;
- __asm __volatile("inl %w1,%0" : "=a" (data) : "d" (port));
- return data;
+ unsigned int data;
+ __asm __volatile("inl %w1,%0" : "=a" (data) : "d" (port));
+ return data;
}
static __inline void insl(int port, void *addr, int cnt)
{
- __asm __volatile("cld\n\trepne\n\tinsl" :
- "=D" (addr), "=c" (cnt) :
- "d" (port), "0" (addr), "1" (cnt) :
- "memory", "cc");
+ __asm __volatile("cld\n\trepne\n\tinsl" :
+ "=D" (addr), "=c" (cnt) :
+ "d" (port), "0" (addr), "1" (cnt) :
+ "memory", "cc");
}
static __inline void outb(int port, unsigned char data)
{
- __asm __volatile("outb %0,%w1" : : "a" (data), "d" (port));
+ __asm __volatile("outb %0,%w1" : : "a" (data), "d" (port));
}
static __inline void outb_p(char value, unsigned short port)
{
- __asm__ __volatile__ ("outb %0,%1\n\t"
- "outb %0,$0x80"
- ::"a" ((char) value),"d" ((unsigned short) port));
+ __asm__ __volatile__ ("outb %0,%1\n\t"
+ "outb %0,$0x80"
+ ::"a" ((char) value),"d" ((unsigned short) port));
}
static __inline void outw(int port, unsigned short data)
{
- __asm __volatile("outw %0,%w1" : : "a" (data), "d" (port));
+ __asm __volatile("outw %0,%w1" : : "a" (data), "d" (port));
}
static __inline unsigned char readcmos(int reg)
{
- outb(0x70,reg);
- return (unsigned char) inb(0x71);
+ outb(0x70,reg);
+ return (unsigned char) inb(0x71);
}
-#define io_delay() \
- __asm__ __volatile__ ("pushal \n\t"\
- "mov $0x3F6, %dx \n\t" \
- "inb %dx, %al \n\t" \
- "inb %dx, %al \n\t" \
- "inb %dx, %al \n\t" \
- "inb %dx, %al \n\t" \
- "popal")
+#define io_delay() \
+ __asm__ __volatile__ ("pushal \n\t" \
+ "mov $0x3F6, %dx \n\t" \
+ "inb %dx, %al \n\t" \
+ "inb %dx, %al \n\t" \
+ "inb %dx, %al \n\t" \
+ "inb %dx, %al \n\t" \
+ "popal")
/* Gate descriptors are slightly different*/
struct Gatedesc {
- unsigned gd_off_15_0 : 16; // low 16 bits of offset in segment
- unsigned gd_ss : 16; // segment selector
- unsigned gd_args : 5; // # args, 0 for interrupt/trap gates
- unsigned gd_rsv1 : 3; // reserved(should be zero I guess)
- unsigned gd_type :4; // type(STS_{TG,IG32,TG32})
- unsigned gd_s : 1; // must be 0 (system)
- unsigned gd_dpl : 2; // descriptor(meaning new) privilege level
- unsigned gd_p : 1; // Present
- unsigned gd_off_31_16 : 16; // high bits of offset in segment
+ unsigned gd_off_15_0 : 16; // low 16 bits of offset in segment
+ unsigned gd_ss : 16; // segment selector
+ unsigned gd_args : 5; // # args, 0 for interrupt/trap gates
+ unsigned gd_rsv1 : 3; // reserved(should be zero I guess)
+ unsigned gd_type :4; // type(STS_{TG,IG32,TG32})
+ unsigned gd_s : 1; // must be 0 (system)
+ unsigned gd_dpl : 2; // descriptor(meaning new) privilege level
+ unsigned gd_p : 1; // Present
+ unsigned gd_off_31_16 : 16; // high bits of offset in segment
};
/* Pseudo-descriptors used for LGDT, LLDT and LIDT instructions*/
struct Pseudodesc {
- rt_uint16_t pd__garbage; // LGDT supposed to be from address 4N+2
- rt_uint16_t pd_lim; // Limit
- rt_uint32_t pd_base __attribute__ ((packed)); // Base address
+ rt_uint16_t pd__garbage; // LGDT supposed to be from address 4N+2
+ rt_uint16_t pd_lim; // Limit
+ rt_uint32_t pd_base __attribute__ ((packed)); // Base address
};
-#define SETGATE(gate, istrap, sel, off, dpl) \
-{ \
- (gate).gd_off_15_0 = (rt_uint32_t) (off) & 0xffff; \
- (gate).gd_ss = (sel); \
- (gate).gd_args = 0; \
- (gate).gd_rsv1 = 0; \
- (gate).gd_type = (istrap) ? STS_TG32 : STS_IG32; \
- (gate).gd_s = 0; \
- (gate).gd_dpl = dpl; \
- (gate).gd_p = 1; \
- (gate).gd_off_31_16 = (rt_uint32_t) (off) >> 16; \
-}
+#define SETGATE(gate, istrap, sel, off, dpl) \
+ { \
+ (gate).gd_off_15_0 = (rt_uint32_t)(off)&0xffff; \
+ (gate).gd_ss = (sel); \
+ (gate).gd_args = 0; \
+ (gate).gd_rsv1 = 0; \
+ (gate).gd_type = (istrap) ? STS_TG32 : STS_IG32; \
+ (gate).gd_s = 0; \
+ (gate).gd_dpl = dpl; \
+ (gate).gd_p = 1; \
+ (gate).gd_off_31_16 = (rt_uint32_t)(off) >> 16; \
+ }
/* Global descriptor numbers*/
-#define GD_KT 0x08 // kernel text
-#define GD_KD 0x10 // kernel data
-#define GD_UT 0x18 // user text
-#define GD_UD 0x20 // user data
+#define GD_KT 0x08 // kernel text
+#define GD_KD 0x10 // kernel data
+#define GD_UT 0x18 // user text
+#define GD_UD 0x20 // user data
/* Application segment type bits*/
-#define STA_X 0x8 // Executable segment
-#define STA_E 0x4 // Expand down(non-executable segments)
-#define STA_C 0x4 // Conforming code segment(executable only)
-#define STA_W 0x2 // Writeable(non-executable segments)
-#define STA_R 0x2 // Readable(executable segments)
-#define STA_A 0x1 // Accessed
+#define STA_X 0x8 // Executable segment
+#define STA_E 0x4 // Expand down(non-executable segments)
+#define STA_C 0x4 // Conforming code segment(executable only)
+#define STA_W 0x2 // Writeable(non-executable segments)
+#define STA_R 0x2 // Readable(executable segments)
+#define STA_A 0x1 // Accessed
/* System segment type bits*/
-#define STS_T16A 0x1 // Available 16-bit TSS
-#define STS_LDT 0x2 // Local Descriptor Table
-#define STS_T16B 0x3 // Busy 16-bit TSS
-#define STS_CG16 0x4 // 16-bit Call Gate
-#define STS_TG 0x5 // Task Gate / Coum Transmitions
-#define STS_IG16 0x6 // 16-bit Interrupt Gate
-#define STS_TG16 0x7 // 16-bit Trap Gate
-#define STS_T32A 0x9 // Available 32-bit TSS
-#define STS_T32B 0xb // Busy 32-bit TSS
-#define STS_CG32 0xc // 32-bit Call Gate
-#define STS_IG32 0xe // 32-bit Interrupt Gate
-#define STS_TG32 0xf // 32-bit Trap Gate
+#define STS_T16A 0x1 // Available 16-bit TSS
+#define STS_LDT 0x2 // Local Descriptor Table
+#define STS_T16B 0x3 // Busy 16-bit TSS
+#define STS_CG16 0x4 // 16-bit Call Gate
+#define STS_TG 0x5 // Task Gate / Coum Transmitions
+#define STS_IG16 0x6 // 16-bit Interrupt Gate
+#define STS_TG16 0x7 // 16-bit Trap Gate
+#define STS_T32A 0x9 // Available 32-bit TSS
+#define STS_T32B 0xb // Busy 32-bit TSS
+#define STS_CG32 0xc // 32-bit Call Gate
+#define STS_IG32 0xe // 32-bit Interrupt Gate
+#define STS_TG32 0xf // 32-bit Trap Gate
#ifdef __cplusplus
}
diff --git a/bsp/x86/drivers/keyboard.c b/bsp/x86/drivers/keyboard.c
index 3716c367cc..b4ae626261 100644
--- a/bsp/x86/drivers/keyboard.c
+++ b/bsp/x86/drivers/keyboard.c
@@ -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
diff --git a/bsp/x86/drivers/keyboard.h b/bsp/x86/drivers/keyboard.h
index f3e849df96..437d9dfc9f 100644
--- a/bsp/x86/drivers/keyboard.h
+++ b/bsp/x86/drivers/keyboard.h
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
keyboard.h
diff --git a/bsp/x86/drivers/keymap.h b/bsp/x86/drivers/keymap.h
index 3031438a1b..aa9880e295 100644
--- a/bsp/x86/drivers/keymap.h
+++ b/bsp/x86/drivers/keymap.h
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
keymap.h
diff --git a/bsp/x86/drivers/serial.c b/bsp/x86/drivers/serial.c
index 51b7a0d96d..64830135fc 100644
--- a/bsp/x86/drivers/serial.c
+++ b/bsp/x86/drivers/serial.c
@@ -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);
}
/*@}*/
diff --git a/bsp/x86/rtconfig.h b/bsp/x86/rtconfig.h
index c4cdac1fdc..b2a9f6db50 100644
--- a/bsp/x86/rtconfig.h
+++ b/bsp/x86/rtconfig.h
@@ -1,180 +1,186 @@
-/* RT-Thread config file */
-#ifndef __RTTHREAD_CFG_H__
-#define __RTTHREAD_CFG_H__
+#ifndef RT_CONFIG_H__
+#define RT_CONFIG_H__
-/* RT_NAME_MAX*/
-#define RT_NAME_MAX 8
+/* Automatically generated file; DO NOT EDIT. */
+/* RT-Thread Configuration */
-/* RT_ALIGN_SIZE*/
-#define RT_ALIGN_SIZE 8
-
-/* PRIORITY_MAX */
-#define RT_THREAD_PRIORITY_MAX 32
-
-/* Tick per Second */
-#define RT_TICK_PER_SECOND 1000
-
-/* SECTION: RT_DEBUG */
-/* Thread Debug */
-#define RT_DEBUG
-#define RT_DEBUG_COLOR
-#define RT_DEBUG_MODULE 0
+/* RT-Thread Kernel */
+#define RT_NAME_MAX 8
+#define RT_ALIGN_SIZE 4
+#define RT_THREAD_PRIORITY_32
+#define RT_THREAD_PRIORITY_MAX 32
+#define RT_TICK_PER_SECOND 100
#define RT_USING_OVERFLOW_CHECK
-
-/* Using Hook */
#define RT_USING_HOOK
+#define RT_USING_IDLE_HOOK
+#define RT_IDLE_HOOK_LIST_SIZE 4
+#define IDLE_THREAD_STACK_SIZE 2048
+#define RT_USING_TIMER_SOFT
+#define RT_TIMER_THREAD_PRIO 4
+#define RT_TIMER_THREAD_STACK_SIZE 2048
+#define RT_DEBUG
+#define RT_DEBUG_COLOR
+#define RT_DEBUG_INIT_CONFIG
+#define RT_DEBUG_INIT 1
-/* Using Software Timer */
-/* #define RT_USING_TIMER_SOFT */
-#define RT_TIMER_THREAD_PRIO 4
-#define RT_TIMER_THREAD_STACK_SIZE 512
-#define RT_TIMER_TICK_PER_SECOND 10
+/* Inter-Thread communication */
-/* SECTION: IPC */
-/* Using Semaphore*/
#define RT_USING_SEMAPHORE
-
-/* Using Mutex */
#define RT_USING_MUTEX
-
-/* Using Event */
#define RT_USING_EVENT
-
-/* Using MailBox */
#define RT_USING_MAILBOX
-
-/* Using Message Queue */
#define RT_USING_MESSAGEQUEUE
-/* SECTION: Memory Management */
-/* Using Memory Pool Management*/
-#define RT_USING_MEMPOOL
+/* Memory Management */
-/* Using Dynamic Heap Management */
+#define RT_USING_MEMPOOL
+#define RT_USING_SMALL_MEM
+#define RT_USING_MEMTRACE
#define RT_USING_HEAP
-/* Using Small MM */
-#define RT_USING_SMALL_MEM
+/* Kernel Device Object */
-/* SECTION: Device System */
-/* Using Device System */
#define RT_USING_DEVICE
-
-/* SECTION: Console options */
#define RT_USING_CONSOLE
-/* the buffer size of console*/
-#define RT_CONSOLEBUF_SIZE 128
+#define RT_CONSOLEBUF_SIZE 256
+#define RT_CONSOLE_DEVICE_NAME "console"
+#define RT_VER_NUM 0x40003
+#define ARCH_IA32
-#define IDLE_THREAD_STACK_SIZE 1024 /* idle stack 1K */
+/* RT-Thread Components */
+
+#define RT_USING_COMPONENTS_INIT
+#define RT_USING_USER_MAIN
+#define RT_MAIN_THREAD_STACK_SIZE 2048
+#define RT_MAIN_THREAD_PRIORITY 10
+
+/* C++ features */
+
+
+/* Command shell */
-/* SECTION: finsh, a C-Express shell */
#define RT_USING_FINSH
-#define FINSH_USING_MSH
-#define FINSH_USING_MSH_ONLY
-/* Using symbol table */
+#define FINSH_THREAD_NAME "tshell"
+#define FINSH_USING_HISTORY
+#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
+#define FINSH_THREAD_PRIORITY 20
+#define FINSH_THREAD_STACK_SIZE 4096
+#define FINSH_CMD_SIZE 80
+#define FINSH_USING_MSH
+#define FINSH_USING_MSH_DEFAULT
+#define FINSH_USING_MSH_ONLY
+#define FINSH_ARG_MAX 10
-// #define RT_USING_LIBC
-// #define RT_USING_PTHREADS
-
-/* SECTION: device filesystem */
- #define RT_USING_DFS
+/* Device virtual file system */
+#define RT_USING_DFS
+#define DFS_USING_WORKDIR
+#define DFS_FILESYSTEMS_MAX 2
+#define DFS_FILESYSTEM_TYPES_MAX 2
+#define DFS_FD_MAX 16
#define RT_USING_DFS_ELMFAT
+
+/* elm-chan's FatFs, Generic FAT Filesystem Module */
+
+#define RT_DFS_ELM_CODE_PAGE 437
#define RT_DFS_ELM_WORD_ACCESS
-/* Reentrancy (thread safe) of the FatFs module. */
+#define RT_DFS_ELM_USE_LFN_3
+#define RT_DFS_ELM_USE_LFN 3
+#define RT_DFS_ELM_LFN_UNICODE_0
+#define RT_DFS_ELM_LFN_UNICODE 0
+#define RT_DFS_ELM_MAX_LFN 255
+#define RT_DFS_ELM_DRIVES 2
+#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
#define RT_DFS_ELM_REENTRANT
-/* Number of volumes (logical drives) to be used. */
-#define RT_DFS_ELM_DRIVES 2
-/* #define RT_DFS_ELM_USE_LFN 1 */
-#define RT_DFS_ELM_MAX_LFN 255
-/* Maximum sector size to be handled. */
-#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
+#define RT_USING_DFS_DEVFS
-/* the max number of mounted filesystem */
-#define DFS_FILESYSTEMS_MAX 2
-/* the max number of opened files */
-#define DFS_FD_MAX 4
+/* Device Drivers */
+
+#define RT_USING_DEVICE_IPC
+#define RT_PIPE_BUFSZ 512
+#define RT_USING_SYSTEM_WORKQUEUE
+#define RT_SYSTEM_WORKQUEUE_STACKSIZE 2048
+#define RT_SYSTEM_WORKQUEUE_PRIORITY 23
+#define RT_USING_SERIAL
+#define RT_SERIAL_USING_DMA
+#define RT_SERIAL_RB_BUFSZ 64
+#define RT_USING_PIN
+
+/* Using USB */
+
+
+/* POSIX layer and C standard library */
+
+#define RT_USING_LIBC
+
+/* Network */
+
+/* Socket abstraction layer */
+
+
+/* Network interface device */
+
+
+/* light weight TCP/IP stack */
+
+
+/* AT commands */
+
+
+/* VBUS(Virtual Software BUS) */
+
+
+/* Utilities */
+
+
+/* RT-Thread online packages */
+
+/* IoT - internet of things */
+
+
+/* Wi-Fi */
+
+/* Marvell WiFi */
+
+
+/* Wiced WiFi */
+
+
+/* IoT Cloud */
+
+
+/* security packages */
+
+
+/* language packages */
+
+
+/* multimedia packages */
+
+
+/* tools packages */
-#define RT_USING_DFS_DEVFS
-/* SECTION: lwip, a lighwight TCP/IP protocol stack */
-//#define RT_USING_LWIP
-/* Enable ICMP protocol*/
-#define RT_LWIP_ICMP
-/* Enable UDP protocol*/
-#define RT_LWIP_UDP
-/* Enable TCP protocol*/
-#define RT_LWIP_TCP
-/* Enable DNS */
-#define RT_LWIP_DNS
+/* system packages */
-/* the number of simulatenously active TCP connections*/
-#define RT_LWIP_TCP_PCB_NUM 5
-/* Using DHCP */
-/* #define RT_LWIP_DHCP */
+/* Micrium: Micrium software products porting for RT-Thread */
-/* ip address of target*/
-#define RT_LWIP_IPADDR0 192
-#define RT_LWIP_IPADDR1 168
-#define RT_LWIP_IPADDR2 1
-#define RT_LWIP_IPADDR3 30
-/* gateway address of target*/
-#define RT_LWIP_GWADDR0 192
-#define RT_LWIP_GWADDR1 168
-#define RT_LWIP_GWADDR2 1
-#define RT_LWIP_GWADDR3 1
+/* peripheral libraries and drivers */
-/* mask address of target*/
-#define RT_LWIP_MSKADDR0 255
-#define RT_LWIP_MSKADDR1 255
-#define RT_LWIP_MSKADDR2 255
-#define RT_LWIP_MSKADDR3 0
-/* tcp thread options */
-#define RT_LWIP_TCPTHREAD_PRIORITY 12
-#define RT_LWIP_TCPTHREAD_MBOX_SIZE 10
-#define RT_LWIP_TCPTHREAD_STACKSIZE 1024
+/* miscellaneous packages */
-/* ethernet if thread options */
-#define RT_LWIP_ETHTHREAD_PRIORITY 15
-#define RT_LWIP_ETHTHREAD_MBOX_SIZE 10
-#define RT_LWIP_ETHTHREAD_STACKSIZE 512
-/* TCP sender buffer space */
-#define RT_LWIP_TCP_SND_BUF 8192
-/* TCP receive window. */
-#define RT_LWIP_TCP_WND 8192
+/* samples: kernel and components samples */
-/* SECTION: RT-Thread/GUI */
-/* #define RT_USING_RTGUI */
-/* name length of RTGUI object */
-#define RTGUI_NAME_MAX 12
-/* support 16 weight font */
-#define RTGUI_USING_FONT16
-/* support Chinese font */
-#define RTGUI_USING_FONTHZ
-/* use DFS as file interface */
-#define RTGUI_USING_DFS_FILERW
-/* use font file as Chinese font */
-#define RTGUI_USING_HZ_FILE
-/* use Chinese bitmap font */
-#define RTGUI_USING_HZ_BMP
-/* use small size in RTGUI */
-#define RTGUI_USING_SMALL_SIZE
-/* use mouse cursor */
-/* #define RTGUI_USING_MOUSE_CURSOR */
-/* default font size in RTGUI */
-#define RTGUI_DEFAULT_FONT_SIZE 16
+/* games: games run on RT-Thread console */
-/* image support */
-/* #define RTGUI_IMAGE_XPM */
-/* #define RTGUI_IMAGE_BMP */
+#define IA32
-// #define RT_USING_MODULE
#endif
diff --git a/bsp/x86/rtconfig.py b/bsp/x86/rtconfig.py
index b833f4de49..a03f44c39c 100644
--- a/bsp/x86/rtconfig.py
+++ b/bsp/x86/rtconfig.py
@@ -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 = ''
diff --git a/bsp/x86/x86_ram.lds b/bsp/x86/x86_ram.lds
index afac69f04b..089d9973c4 100644
--- a/bsp/x86/x86_ram.lds
+++ b/bsp/x86/x86_ram.lds
@@ -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;
+
+ . = ALIGN(4);
+ .text :
+ {
+ *(.init)
+ *(.text)
+
+ /* 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 = .;
+
+ /* section information for initialization */
+ . = ALIGN(4);
+ __rt_init_start = .;
+ KEEP(*(SORT(.rti_fn*)))
+ __rt_init_end = .;
+ }
+
+ . = ALIGN(4);
+ .rodata : { *(.rodata*) }
- /* 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);
+ .data : { *(.data) }
- . = ALIGN(4);
- .data : { *(.data) }
+ . = ALIGN(4);
+ __bss_start = .;
+ .bss : { *(.bss) }
+ __bss_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 = .;
+ /* 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 = .;
}
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