From 97f28a8a4f678fec98fc3e2cf7227d71efe16efc Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 28 Jun 2022 00:38:32 +0800 Subject: [PATCH 1/6] feat: split the platform into multiple projects --- .gitignore | 2 +- Makefile | 7 +- src/.gitignore | 2 + src/platform/d1/.gitignore | 2 - src/platform/d1/Kconfig | 4 - src/platform/d1/Makefile | 2 - src/platform/d1/README.md | 1 - src/platform/d1/cmd.mk | 87 --- src/platform/d1/compile.mk | 17 - src/platform/d1/connect.gdb | 1 - src/platform/d1/defconfig | 70 -- src/platform/d1/drivers/Makefile | 1 - src/platform/d1/drivers/direct_uart.c | 79 --- src/platform/d1/hal/init.c | 54 -- src/platform/d1/hal/main.c | 21 - src/platform/d1/include/drivers/direct_uart.h | 31 - src/platform/d1/include/nx_configure.h | 33 - src/platform/d1/include/platform.h | 75 --- src/platform/d1/nxos.ld | 125 ---- src/platform/d1/nxos.mk | 19 - src/platform/hifive_unmached/.gitignore | 2 - src/platform/hifive_unmached/Kconfig | 8 - src/platform/hifive_unmached/Makefile | 2 - src/platform/hifive_unmached/README.md | 1 - src/platform/hifive_unmached/cmd.mk | 63 -- src/platform/hifive_unmached/compile.mk | 17 - src/platform/hifive_unmached/connect.gdb | 1 - src/platform/hifive_unmached/defconfig | 71 -- src/platform/hifive_unmached/drivers/Makefile | 1 - .../hifive_unmached/drivers/direct_uart.c | 94 --- src/platform/hifive_unmached/hal/init.c | 54 -- src/platform/hifive_unmached/hal/main.c | 21 - .../include/drivers/direct_uart.h | 37 -- .../hifive_unmached/include/nx_configure.h | 34 - .../hifive_unmached/include/platform.h | 77 --- src/platform/hifive_unmached/nxos.ld | 129 ---- src/platform/hifive_unmached/nxos.mk | 19 - src/platform/i386/.gitignore | 2 - src/platform/i386/Kconfig | 41 -- src/platform/i386/Makefile | 2 - src/platform/i386/README.md | 73 --- src/platform/i386/cmd.mk | 107 --- src/platform/i386/compile.mk | 16 - src/platform/i386/connect.gdb | 1 - src/platform/i386/defconfig | 77 --- src/platform/i386/drivers/Makefile | 1 - src/platform/i386/drivers/direct_uart.c | 262 -------- src/platform/i386/drivers/framebuffer.c | 142 ---- src/platform/i386/drivers/pio.c | 143 ---- src/platform/i386/drivers/ps2_keyboard.c | 434 ------------- src/platform/i386/drivers/ps2_keyboard.h | 612 ------------------ src/platform/i386/drivers/ps2_keyboard_irq.c | 244 ------- src/platform/i386/drivers/ps2_mouse.c | 568 ---------------- src/platform/i386/drivers/ps2_mouse_irq.c | 242 ------- src/platform/i386/drivers/rtc.c | 160 ----- src/platform/i386/hal/Makefile | 2 - src/platform/i386/hal/boot_setting.c | 137 ---- src/platform/i386/hal/init.c | 51 -- src/platform/i386/hal/main.c | 21 - src/platform/i386/hal/multiboot2.S | 91 --- src/platform/i386/include/boot.h | 67 -- .../i386/include/drivers/direct_uart.h | 23 - src/platform/i386/include/drivers/vbe.h | 88 --- src/platform/i386/include/multiboot2.h | 427 ------------ src/platform/i386/include/nx_configure.h | 34 - src/platform/i386/include/platform.h | 66 -- src/platform/i386/nxos.ld | 112 ---- src/platform/i386/nxos.mk | 21 - src/platform/k210/.gitignore | 2 - src/platform/k210/Kconfig | 4 - src/platform/k210/Makefile | 2 - src/platform/k210/README.md | 12 - src/platform/k210/cmd.mk | 80 --- src/platform/k210/compile.mk | 17 - src/platform/k210/connect.gdb | 1 - src/platform/k210/defconfig | 70 -- src/platform/k210/drivers/Makefile | 1 - src/platform/k210/drivers/direct_uart.c | 67 -- src/platform/k210/hal/init.c | 52 -- src/platform/k210/hal/main.c | 21 - .../k210/include/drivers/direct_uart.h | 28 - src/platform/k210/include/nx_configure.h | 33 - src/platform/k210/include/platform.h | 78 --- src/platform/k210/nxos.ld | 128 ---- src/platform/k210/nxos.mk | 18 - src/platform/qemu_riscv64/.gitignore | 2 - src/platform/qemu_riscv64/Kconfig | 8 - src/platform/qemu_riscv64/Makefile | 2 - src/platform/qemu_riscv64/README.md | 28 - src/platform/qemu_riscv64/cmd.mk | 97 --- src/platform/qemu_riscv64/compile.mk | 17 - src/platform/qemu_riscv64/connect.gdb | 1 - src/platform/qemu_riscv64/defconfig | 71 -- src/platform/qemu_riscv64/drivers/Makefile | 1 - .../qemu_riscv64/drivers/direct_uart.c | 127 ---- src/platform/qemu_riscv64/hal/init.c | 54 -- src/platform/qemu_riscv64/hal/main.c | 21 - .../include/drivers/direct_uart.h | 28 - .../qemu_riscv64/include/nx_configure.h | 34 - src/platform/qemu_riscv64/include/platform.h | 78 --- src/platform/qemu_riscv64/nxos.ld | 129 ---- src/platform/qemu_riscv64/nxos.mk | 18 - src/platform/qemu_riscv64/riscv64-virtio.dts | 193 ------ 103 files changed, 7 insertions(+), 7047 deletions(-) delete mode 100644 src/platform/d1/.gitignore delete mode 100644 src/platform/d1/Kconfig delete mode 100644 src/platform/d1/Makefile delete mode 100644 src/platform/d1/README.md delete mode 100644 src/platform/d1/cmd.mk delete mode 100644 src/platform/d1/compile.mk delete mode 100644 src/platform/d1/connect.gdb delete mode 100644 src/platform/d1/defconfig delete mode 100644 src/platform/d1/drivers/Makefile delete mode 100644 src/platform/d1/drivers/direct_uart.c delete mode 100644 src/platform/d1/hal/init.c delete mode 100644 src/platform/d1/hal/main.c delete mode 100644 src/platform/d1/include/drivers/direct_uart.h delete mode 100644 src/platform/d1/include/nx_configure.h delete mode 100644 src/platform/d1/include/platform.h delete mode 100644 src/platform/d1/nxos.ld delete mode 100644 src/platform/d1/nxos.mk delete mode 100644 src/platform/hifive_unmached/.gitignore delete mode 100644 src/platform/hifive_unmached/Kconfig delete mode 100644 src/platform/hifive_unmached/Makefile delete mode 100644 src/platform/hifive_unmached/README.md delete mode 100644 src/platform/hifive_unmached/cmd.mk delete mode 100644 src/platform/hifive_unmached/compile.mk delete mode 100644 src/platform/hifive_unmached/connect.gdb delete mode 100644 src/platform/hifive_unmached/defconfig delete mode 100644 src/platform/hifive_unmached/drivers/Makefile delete mode 100644 src/platform/hifive_unmached/drivers/direct_uart.c delete mode 100644 src/platform/hifive_unmached/hal/init.c delete mode 100644 src/platform/hifive_unmached/hal/main.c delete mode 100644 src/platform/hifive_unmached/include/drivers/direct_uart.h delete mode 100644 src/platform/hifive_unmached/include/nx_configure.h delete mode 100644 src/platform/hifive_unmached/include/platform.h delete mode 100644 src/platform/hifive_unmached/nxos.ld delete mode 100644 src/platform/hifive_unmached/nxos.mk delete mode 100644 src/platform/i386/.gitignore delete mode 100644 src/platform/i386/Kconfig delete mode 100644 src/platform/i386/Makefile delete mode 100644 src/platform/i386/README.md delete mode 100644 src/platform/i386/cmd.mk delete mode 100644 src/platform/i386/compile.mk delete mode 100644 src/platform/i386/connect.gdb delete mode 100644 src/platform/i386/defconfig delete mode 100644 src/platform/i386/drivers/Makefile delete mode 100644 src/platform/i386/drivers/direct_uart.c delete mode 100644 src/platform/i386/drivers/framebuffer.c delete mode 100644 src/platform/i386/drivers/pio.c delete mode 100644 src/platform/i386/drivers/ps2_keyboard.c delete mode 100644 src/platform/i386/drivers/ps2_keyboard.h delete mode 100644 src/platform/i386/drivers/ps2_keyboard_irq.c delete mode 100644 src/platform/i386/drivers/ps2_mouse.c delete mode 100644 src/platform/i386/drivers/ps2_mouse_irq.c delete mode 100644 src/platform/i386/drivers/rtc.c delete mode 100644 src/platform/i386/hal/Makefile delete mode 100644 src/platform/i386/hal/boot_setting.c delete mode 100644 src/platform/i386/hal/init.c delete mode 100644 src/platform/i386/hal/main.c delete mode 100644 src/platform/i386/hal/multiboot2.S delete mode 100644 src/platform/i386/include/boot.h delete mode 100644 src/platform/i386/include/drivers/direct_uart.h delete mode 100644 src/platform/i386/include/drivers/vbe.h delete mode 100644 src/platform/i386/include/multiboot2.h delete mode 100644 src/platform/i386/include/nx_configure.h delete mode 100644 src/platform/i386/include/platform.h delete mode 100644 src/platform/i386/nxos.ld delete mode 100644 src/platform/i386/nxos.mk delete mode 100644 src/platform/k210/.gitignore delete mode 100644 src/platform/k210/Kconfig delete mode 100644 src/platform/k210/Makefile delete mode 100644 src/platform/k210/README.md delete mode 100644 src/platform/k210/cmd.mk delete mode 100644 src/platform/k210/compile.mk delete mode 100644 src/platform/k210/connect.gdb delete mode 100644 src/platform/k210/defconfig delete mode 100644 src/platform/k210/drivers/Makefile delete mode 100644 src/platform/k210/drivers/direct_uart.c delete mode 100644 src/platform/k210/hal/init.c delete mode 100644 src/platform/k210/hal/main.c delete mode 100644 src/platform/k210/include/drivers/direct_uart.h delete mode 100644 src/platform/k210/include/nx_configure.h delete mode 100644 src/platform/k210/include/platform.h delete mode 100644 src/platform/k210/nxos.ld delete mode 100644 src/platform/k210/nxos.mk delete mode 100644 src/platform/qemu_riscv64/.gitignore delete mode 100644 src/platform/qemu_riscv64/Kconfig delete mode 100644 src/platform/qemu_riscv64/Makefile delete mode 100644 src/platform/qemu_riscv64/README.md delete mode 100644 src/platform/qemu_riscv64/cmd.mk delete mode 100644 src/platform/qemu_riscv64/compile.mk delete mode 100644 src/platform/qemu_riscv64/connect.gdb delete mode 100644 src/platform/qemu_riscv64/defconfig delete mode 100644 src/platform/qemu_riscv64/drivers/Makefile delete mode 100644 src/platform/qemu_riscv64/drivers/direct_uart.c delete mode 100644 src/platform/qemu_riscv64/hal/init.c delete mode 100644 src/platform/qemu_riscv64/hal/main.c delete mode 100644 src/platform/qemu_riscv64/include/drivers/direct_uart.h delete mode 100644 src/platform/qemu_riscv64/include/nx_configure.h delete mode 100644 src/platform/qemu_riscv64/include/platform.h delete mode 100644 src/platform/qemu_riscv64/nxos.ld delete mode 100644 src/platform/qemu_riscv64/nxos.mk delete mode 100644 src/platform/qemu_riscv64/riscv64-virtio.dts diff --git a/.gitignore b/.gitignore index 3083fdb..6843fcd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ scripts/kconfiglib/kconfiglib.pyc src/platform/Kconfig src/include/nx_configure.h platform.mk -romdisk.cpio \ No newline at end of file +romdisk.cpio diff --git a/Makefile b/Makefile index f97a58a..e712337 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ sinclude platform.mk # # Tools name # +GIT :=git # # Use build dir for target @@ -137,10 +138,10 @@ run: all @$(MAKE) -s -C src/platform/$(PLATFORM) -f cmd.mk run # -# Prepare platform tools +# Prepare platform # -prepare: - @$(MAKE) -s -C src/platform/$(PLATFORM) -f cmd.mk prepare +prepare: + $(GIT) clone https://gitee.com/BookOS/nxos-platform-$(PLATFORM) src/platform/$(PLATFORM) # # GDB command diff --git a/src/.gitignore b/src/.gitignore index 25e471b..85d1e6c 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -64,3 +64,5 @@ fixdep init/rootfs.c build drivers/block/romdisk.S +!.gitkeep +platform \ No newline at end of file diff --git a/src/platform/d1/.gitignore b/src/platform/d1/.gitignore deleted file mode 100644 index 7404244..0000000 --- a/src/platform/d1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tools/ -*.S diff --git a/src/platform/d1/Kconfig b/src/platform/d1/Kconfig deleted file mode 100644 index 4c10418..0000000 --- a/src/platform/d1/Kconfig +++ /dev/null @@ -1,4 +0,0 @@ -config NX_PLATFORM_D1 - bool - default y - select NX_CPU_64BITS diff --git a/src/platform/d1/Makefile b/src/platform/d1/Makefile deleted file mode 100644 index e326730..0000000 --- a/src/platform/d1/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -SRC += drivers/ -SRC += hal/ \ No newline at end of file diff --git a/src/platform/d1/README.md b/src/platform/d1/README.md deleted file mode 100644 index 677c4c7..0000000 --- a/src/platform/d1/README.md +++ /dev/null @@ -1 +0,0 @@ -# 基于riscv64处理器的全志D1平台支持 diff --git a/src/platform/d1/cmd.mk b/src/platform/d1/cmd.mk deleted file mode 100644 index 7e13347..0000000 --- a/src/platform/d1/cmd.mk +++ /dev/null @@ -1,87 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for run d1 Platform -# -# Change Logs: -# Date Author Notes -# 2022-4-17 JasonHu Init -## - -# -# Tools -# -TOOL_DIR := ./tools -SBI := $(TOOL_DIR)/SBI/opensbi-d1.bin - -ifeq ($(HOSTOS), windows) -XFEL := $(TOOL_DIR)/xfel/xfel.exe -else -XFEL := $(TOOL_DIR)/xfel/xfel -endif - -RM := rm -MAKE := make -SU := sudo -PYTHON := python -CP := cp -DD := dd -DEBUGER := $(CROSS_COMPILE)gdb -DUMP := $(CROSS_COMPILE)objdump -OC := $(CROSS_COMPILE)objcopy - -# -# Args for make -# -.PHONY: run clean - -# -# flush into d1 devboard -# -run: - $(OC) $(NXOS_NAME).elf --strip-all -O binary $(NXOS_NAME).bin - echo "allwinner-d1 run..." - $(XFEL) version - $(XFEL) ddr d1 - $(XFEL) write 0x40000000 $(SBI) - $(XFEL) write 0x40200000 $(NXOS_NAME).bin - $(XFEL) exec 0x40000000 - echo "start d1 done." - -# run d1 with xfel - -# -# Clear target file -# -clean: - -$(RM) $(NXOS_NAME).elf - -$(RM) $(NXOS_NAME).dump.S - -$(RM) $(NXOS_NAME).bin - -# -# prepare tools -# -prepare: - -$(RM) -rf $(TOOL_DIR) - git clone https://gitee.com/BookOS/nxos-platform-d1-tools $(TOOL_DIR) -ifeq ($(HOSTOS), linux) # install libusb in linux - @echo install libusb. - sudo apt install libusb-1.0-0-dev -endif - echo "parpare done." - -# -# gdb debug -# -gdb: - @echo gdb load file from $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DEBUGER) $(NXOS_NAME).elf -x connect.gdb - -# -# dump kernel -# -dump: - @echo dump kernel $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DUMP) -D -S $(NXOS_NAME).elf > $(NXOS_NAME).dump.S - \ No newline at end of file diff --git a/src/platform/d1/compile.mk b/src/platform/d1/compile.mk deleted file mode 100644 index 50f3de3..0000000 --- a/src/platform/d1/compile.mk +++ /dev/null @@ -1,17 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for d1 Platform -# -# Change Logs: -# Date Author Notes -# 2022-4-17 JasonHu Init -## - -# modify compiler here -ifeq ($(HOSTOS), windows) -CROSS_COMPILE := riscv-none-embed- -else -CROSS_COMPILE := riscv64-unknown-elf- -endif diff --git a/src/platform/d1/connect.gdb b/src/platform/d1/connect.gdb deleted file mode 100644 index 90f7c83..0000000 --- a/src/platform/d1/connect.gdb +++ /dev/null @@ -1 +0,0 @@ -target remote localhost:10001 \ No newline at end of file diff --git a/src/platform/d1/defconfig b/src/platform/d1/defconfig deleted file mode 100644 index 44d15f3..0000000 --- a/src/platform/d1/defconfig +++ /dev/null @@ -1,70 +0,0 @@ -CONFIG_NX_CPU_64BITS=y - -# -# OS Kernel -# - -# -# Debug -# -CONFIG_NX_DEBUG=y -CONFIG_NX_LOG_LEVEL=3 -CONFIG_NX_DEBUG_COLOR=y -CONFIG_NX_DEBUG_TIMELINE=y -# CONFIG_NX_DEBUG_LINENUMBER is not set -# end of Debug - -CONFIG_NX_PLATFORM_NAME="riscv64-d1" -CONFIG_NX_MULTI_CORES_NR=1 -CONFIG_NX_ENABLE_PLATFORM_MAIN=y -CONFIG_NX_IRQ_NAME_LEN=48 -CONFIG_NX_NR_IRQS=256 -CONFIG_NX_KVADDR_OFFSET=0x00000000 -CONFIG_NX_PAGE_SHIFT=12 -CONFIG_NX_MAX_THREAD_NR=256 -CONFIG_NX_THREAD_NAME_LEN=32 -CONFIG_NX_THREAD_STACK_SIZE=8192 -CONFIG_NX_ENABLE_SCHED=y -CONFIG_NX_THREAD_MAX_PRIORITY_NR=16 -CONFIG_NX_PORCESS_ENV_ARGS=1024 -CONFIG_NX_TICKS_PER_SECOND=100 -# end of OS Kernel - -# -# Platform -# -CONFIG_NX_PLATFORM_D1=y -# end of Platform - -# -# Device -# -CONFIG_NX_DRIVER_CONSOLE=y -CONFIG_NX_PRINT_BUF_LEN=256 -# CONFIG_NX_DRIVER_ROMDISK is not set -# CONFIG_NX_DRIVER_DUMMY is not set -CONFIG_NX_DRIVER_NULL=y -CONFIG_NX_DRIVER_ZERO=y -CONFIG_NX_DRIVER_MEMINFO=y -CONFIG_NX_DRIVER_CPUINFO=y -# end of Device - -# -# File System -# -# CONFIG_NX_FS_CPIO is not set -# CONFIG_NX_FS_DEVFS is not set -# CONFIG_NX_ENABLE_EXECUTE_USER is not set -# CONFIG_NX_ENABLE_MOUNT_TABLE is not set -CONFIG_NX_VFS_MAX_PATH=512 -CONFIG_NX_VFS_MAX_NAME=256 -CONFIG_NX_VFS_MAX_FD=256 -CONFIG_NX_VFS_NODE_HASH_SIZE=256 -# end of File System - -# -# Tests -# -# CONFIG_NX_ENABLE_TEST_UTEST is not set -# CONFIG_NX_ENABLE_TEST_INTEGRATION is not set -# end of Tests diff --git a/src/platform/d1/drivers/Makefile b/src/platform/d1/drivers/Makefile deleted file mode 100644 index 28afb05..0000000 --- a/src/platform/d1/drivers/Makefile +++ /dev/null @@ -1 +0,0 @@ -SRC += *.c \ No newline at end of file diff --git a/src/platform/d1/drivers/direct_uart.c b/src/platform/d1/drivers/direct_uart.c deleted file mode 100644 index ff191b9..0000000 --- a/src/platform/d1/drivers/direct_uart.c +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart driver - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -void NX_HalDirectUartPutc(char ch) -{ - sbi_console_putchar(ch); -} - -int NX_HalDirectUartGetc(void) -{ - if(!(Read32(UART0_LSR) & UART0_LSR_DR)) - { - return -1; - } - return (int)Read32(UART0_RBR); -} - -NX_INTERFACE void NX_ConsoleSendData(char ch) -{ - NX_HalDirectUartPutc(ch); -} - -void NX_HalDirectUartInit(void) -{ -} - -/** - * default handler -*/ -NX_WEAK_SYM void NX_HalDirectUartGetcHandler(char data) -{ - NX_ConsoleReceveData(data); -} - -NX_PRIVATE NX_Error UartPollHandler(void) -{ - int data = NX_HalDirectUartGetc(); - if (data != -1) - { - if (NX_HalDirectUartGetcHandler != NX_NULL) - { - NX_HalDirectUartGetcHandler(data); - } - } - return data != -1 ? NX_EOK : NX_EIO; -} - -NX_PRIVATE void NX_UartRxPollThread(void *arg) -{ - while (1) - { - UartPollHandler(); - NX_ThreadSleep(10); - } -} - -void NX_HalDirectUartStage2(void) -{ - NX_Thread *thread = NX_ThreadCreate("uart_rx", NX_UartRxPollThread, NX_NULL, NX_THREAD_PRIORITY_RT_MIN); - NX_ThreadStart(thread); -} diff --git a/src/platform/d1/hal/init.c b/src/platform/d1/hal/init.c deleted file mode 100644 index 5d3d98a..0000000 --- a/src/platform/d1/hal/init.c +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Init allwinner-d1 platfrom - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NX_LOG_LEVEL NX_LOG_INFO -#define NX_LOG_NAME "INIT" -#include - -NX_INTERFACE NX_Error NX_HalPlatformInit(NX_UArch coreId) -{ - /* NOTE: init trap first before do anything */ - CPU_InitTrap(coreId); - - NX_HalDirectUartInit(); - - sbi_init(); - sbi_print_version(); - - NX_LOG_I("Hello, Allwinner-D1!"); - - PLIC_Init(NX_True); - - NX_HalPageZoneInit(); - - return NX_EOK; -} - -NX_INTERFACE NX_Error NX_HalPlatformStage2(void) -{ - NX_LOG_I("stage2!"); - - NX_HalDirectUartStage2(); - - return NX_EOK; -} diff --git a/src/platform/d1/hal/main.c b/src/platform/d1/hal/main.c deleted file mode 100644 index 3a07f58..0000000 --- a/src/platform/d1/hal/main.c +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom main - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#include -#define NX_LOG_NAME "Hal Main" -#include - -#ifdef CONFIG_NX_ENABLE_PLATFORM_MAIN -NX_INTERFACE void NX_HalPlatformMain(void) -{ - NX_LOG_I("d1 platform main running...\n"); -} -#endif /* CONFIG_NX_ENABLE_PLATFORM_MAIN */ diff --git a/src/platform/d1/include/drivers/direct_uart.h b/src/platform/d1/include/drivers/direct_uart.h deleted file mode 100644 index d0362b9..0000000 --- a/src/platform/d1/include/drivers/direct_uart.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#ifndef __DIRECT_UART_HEADER__ -#define __DIRECT_UART_HEADER__ - -#include - -#define UART0_PHY_ADDR 0x02500000UL - -#define UART0_RBR (UART0_PHY_ADDR + 0x00) /* receive buffer register */ -#define UART0_LSR (UART0_PHY_ADDR + 0x14) /* line status register */ -#define UART0_LSR_DR 0x01 /* LSR data ready */ - -/* direct means not use driver framework */ - -void NX_HalDirectUartInit(void); -void NX_HalDirectUartStage2(void); - -void NX_HalDirectUartPutc(char ch); -int NX_HalDirectUartGetc(void); - -#endif /* __DIRECT_UART_HEADER__ */ diff --git a/src/platform/d1/include/nx_configure.h b/src/platform/d1/include/nx_configure.h deleted file mode 100644 index 6ce4e2f..0000000 --- a/src/platform/d1/include/nx_configure.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __NX_CONFIG__ -#define __NX_CONFIG__ -#define CONFIG_NX_CPU_64BITS 1 -#define CONFIG_NX_DEBUG 1 -#define CONFIG_NX_LOG_LEVEL 3 -#define CONFIG_NX_DEBUG_COLOR 1 -#define CONFIG_NX_DEBUG_TIMELINE 1 -#define CONFIG_NX_PLATFORM_NAME "riscv64-d1" -#define CONFIG_NX_MULTI_CORES_NR 1 -#define CONFIG_NX_ENABLE_PLATFORM_MAIN 1 -#define CONFIG_NX_IRQ_NAME_LEN 48 -#define CONFIG_NX_NR_IRQS 256 -#define CONFIG_NX_KVADDR_OFFSET 0x00000000 -#define CONFIG_NX_PAGE_SHIFT 12 -#define CONFIG_NX_MAX_THREAD_NR 256 -#define CONFIG_NX_THREAD_NAME_LEN 32 -#define CONFIG_NX_THREAD_STACK_SIZE 8192 -#define CONFIG_NX_ENABLE_SCHED 1 -#define CONFIG_NX_THREAD_MAX_PRIORITY_NR 16 -#define CONFIG_NX_PORCESS_ENV_ARGS 1024 -#define CONFIG_NX_TICKS_PER_SECOND 100 -#define CONFIG_NX_PLATFORM_D1 1 -#define CONFIG_NX_DRIVER_CONSOLE 1 -#define CONFIG_NX_PRINT_BUF_LEN 256 -#define CONFIG_NX_DRIVER_NULL 1 -#define CONFIG_NX_DRIVER_ZERO 1 -#define CONFIG_NX_DRIVER_MEMINFO 1 -#define CONFIG_NX_DRIVER_CPUINFO 1 -#define CONFIG_NX_VFS_MAX_PATH 512 -#define CONFIG_NX_VFS_MAX_NAME 256 -#define CONFIG_NX_VFS_MAX_FD 256 -#define CONFIG_NX_VFS_NODE_HASH_SIZE 256 -#endif diff --git a/src/platform/d1/include/platform.h b/src/platform/d1/include/platform.h deleted file mode 100644 index 03a0f3b..0000000 --- a/src/platform/d1/include/platform.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom header - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#ifndef __PLATFORM_HEADER__ -#define __PLATFORM_HEADER__ - -#include - -#define DRAM_SIZE_DEFAULT (512 * NX_MB) - -#define MEM_SBI_BASE 0x40000000UL -#define MEM_SBI_SZ (2 * NX_MB) - -#define MEM_KERNEL_BASE (MEM_SBI_BASE + MEM_SBI_SZ) -#define MEM_KERNEL_SZ (30 * NX_MB) - -#define MEM_NORMAL_BASE (MEM_KERNEL_BASE + MEM_KERNEL_SZ) - -#define MEM_MIN_SIZE (128 * NX_MB) - -#define MEM_KERNEL_SPACE_SZ (128 * NX_MB) - -#define MEM_KERNEL_TOP (MEM_SBI_BASE + MEM_KERNEL_SPACE_SZ) - -/* max cpus for qemu */ -#define PLATFORM_MAX_NR_MULTI_CORES 1 - -/** - * Physical memory layout: - * - * +------------------------+ <- MAX PHY SIZE (TOP to 3GB) - * | AVALIABLE PAGES | - * +------------------------+ <- 0x42000000 (1GB + 32MB) - * | KERNEL | - * +------------------------+ <- 0x40200000 (1GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x40000000 (1GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -/** - * Virtual memory layout: - * - * @: delay map - * - * +------------------------+ <- 0x400000000 (16GB) - * | @USER | - * +------------------------+ <- 0xFFFFFFFF (4GB) - * | @RESERVED | - * +------------------------+ <- 0x88000000 (2GB + 128MB) - * | @KMAP | - * +------------------------+ <- 0x84000000 (2GB + 64MB) - * | KHEAP | - * +------------------------+ <- 0x42000000 (1GB + 32MB) - * | KCODE & KDATA & KBSS | - * +------------------------+ <- 0x40200000 (1GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x40000000 (1GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -NX_IMPORT void MMU_EarlyMap(void); -void *NX_HalGetKernelPageTable(void); - -#endif /* __PLATFORM_HEADER__ */ diff --git a/src/platform/d1/nxos.ld b/src/platform/d1/nxos.ld deleted file mode 100644 index 0debeff..0000000 --- a/src/platform/d1/nxos.ld +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Link script for allwinner-d1 Platform - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") -OUTPUT_ARCH(riscv) -ENTRY(_Start) - -MEMORY -{ - /* opensbi jump to 0x40200000 */ - SRAM : ORIGIN = 0x40200000, LENGTH = 0x1E00000 -} - -SECTIONS -{ - /* code segment */ - .text : - { - __NX_TextStart = .; - *(.text.start) - *(.text) - *(.init.text) - *(.exit.text) - - *(.rodata) - *(.rodata.*) - - . = ALIGN(8); - PROVIDE(__NX_InitCallStart = .); - KEEP(*(.initCall0.text)) - KEEP(*(.initCall1.text)) - KEEP(*(.initCall2.text)) - KEEP(*(.initCall3.text)) - KEEP(*(.initCall4.text)) - KEEP(*(.initCall5.text)) - KEEP(*(.initCall6.text)) - KEEP(*(.initCall7.text)) - KEEP(*(.initCall8.text)) - KEEP(*(.initCall9.text)) - PROVIDE(__NX_InitCallEnd = .); - - . = ALIGN(8); - PROVIDE(__NX_ExitCallStart = .); - KEEP(*(.exitcall0.text)) - KEEP(*(.exitcall1.text)) - KEEP(*(.exitcall2.text)) - KEEP(*(.exitcall3.text)) - KEEP(*(.exitcall4.text)) - KEEP(*(.exitcall5.text)) - KEEP(*(.exitcall6.text)) - KEEP(*(.exitcall7.text)) - KEEP(*(.exitcall8.text)) - KEEP(*(.exitcall9.text)) - PROVIDE(__NX_ExitCallEnd = .); - - /* section information for utest */ - . = ALIGN(8); - PROVIDE(__NX_UTestCaseTableStart = .); - KEEP(*(UTestCaseTable)) - PROVIDE(__NX_UTestCaseTableEnd = .); - - /* section information for integration */ - . = ALIGN(8); - PROVIDE(__NX_IntegrationTableStart = .); - KEEP(*(IntegrationTable)) - PROVIDE(__NX_IntegrationTableEnd = .); - - __NX_TextEnd = .; - } > SRAM - - - /* data segment */ - . = ALIGN(8); - - .data : - { - __NX_DataStart = .; - *(.data) - *(.data.*) - - . = ALIGN(8); - PROVIDE( __global_pointer$ = . + 0x800 ); - - *(.sdata) - *(.sdata.*) - } > SRAM - - .romdisk ALIGN(8) : - { - PROVIDE(__NX_RomdiskStart = .); - KEEP(*(.romdisk)) - PROVIDE(__NX_RomdiskEnd = .); - __NX_DataEnd = .; - } > SRAM - . = ALIGN(8); - - /* bss segement */ - - .sbss : - { - __NX_BssStart = .; - *(.sbss) - *(.sbss.*) - *(.dynsbss) - *(.scommon) - } > SRAM - - .bss : - { - *(.bss) - *(.bss.*) - *(.dynbss) - *(COMMON) - . = ALIGN(8); - __NX_BssEnd = .; - } > SRAM -} \ No newline at end of file diff --git a/src/platform/d1/nxos.mk b/src/platform/d1/nxos.mk deleted file mode 100644 index 5decc1d..0000000 --- a/src/platform/d1/nxos.mk +++ /dev/null @@ -1,19 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for d1 Platform -# -# Change Logs: -# Date Author Notes -# 2022-4-17 JasonHu Init -## - -# -# Override default variables. -# - -CFLAGS += -fvar-tracking -mno-relax -ASFLAGS += -ffunction-sections -fdata-sections -ffreestanding -MCFLAGS += -march=rv64imafdc -mabi=lp64d -mcmodel=medany -LDFLAGS += -no-pie -nostartfile -n diff --git a/src/platform/hifive_unmached/.gitignore b/src/platform/hifive_unmached/.gitignore deleted file mode 100644 index 7404244..0000000 --- a/src/platform/hifive_unmached/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tools/ -*.S diff --git a/src/platform/hifive_unmached/Kconfig b/src/platform/hifive_unmached/Kconfig deleted file mode 100644 index 7449b8a..0000000 --- a/src/platform/hifive_unmached/Kconfig +++ /dev/null @@ -1,8 +0,0 @@ -config NX_PLATFORM_HIFIVE_UNMACHED - bool - default y - select NX_CPU_64BITS - -config NX_UART0_FROM_SBI - bool "Uart0 get/set from SBI" - default n diff --git a/src/platform/hifive_unmached/Makefile b/src/platform/hifive_unmached/Makefile deleted file mode 100644 index e326730..0000000 --- a/src/platform/hifive_unmached/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -SRC += drivers/ -SRC += hal/ \ No newline at end of file diff --git a/src/platform/hifive_unmached/README.md b/src/platform/hifive_unmached/README.md deleted file mode 100644 index 7a6055b..0000000 --- a/src/platform/hifive_unmached/README.md +++ /dev/null @@ -1 +0,0 @@ -# 基于sifive u740处理器的hifive-unmached平台支持 diff --git a/src/platform/hifive_unmached/cmd.mk b/src/platform/hifive_unmached/cmd.mk deleted file mode 100644 index 5519b26..0000000 --- a/src/platform/hifive_unmached/cmd.mk +++ /dev/null @@ -1,63 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for run hifive unmached Platform -# -# Change Logs: -# Date Author Notes -# 2022-05-02 JasonHu Init -## - -RM := rm -CP := cp -LYNX := lynx -SSH_CP := scp -DUMP := $(CROSS_COMPILE)objdump -REMOTE_IP ?= 183.173.21.114 -SSH_PORT ?= 8122 -HTTP_PORT ?= 8182 - -ACTION ?= reboot # poweron, powerff, reboot -MACHINE_ID ?= 1 # 1, 2 - -# -# Args for make -# -.PHONY: run clean - -# -# upload nxos.elf to remote hifive_unmached -# -run: - echo "hifive_unmached run..." - scp -P $(SSH_PORT) $(NXOS_NAME).elf ubuntu@$(REMOTE_IP):/srv/tftp/nxos.elf - $(LYNX) http://$(REMOTE_IP):$(HTTP_PORT)/$(ACTION)$(MACHINE_ID) - echo "start hifive_unmached done." - -# -# Clear target file -# -clean: - -$(RM) $(NXOS_NAME).elf - -$(RM) $(NXOS_NAME).dump.S - -# -# prepare tools -# -prepare: - sudo apt-get install lynx - echo "parpare done." - -# -# gdb debug -# -gdb: - echo "gdb not supported!" - -# -# dump kernel -# -dump: - @echo dump kernel $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DUMP) -D -S $(NXOS_NAME).elf > $(NXOS_NAME).dump.S diff --git a/src/platform/hifive_unmached/compile.mk b/src/platform/hifive_unmached/compile.mk deleted file mode 100644 index 1bc50af..0000000 --- a/src/platform/hifive_unmached/compile.mk +++ /dev/null @@ -1,17 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for hifive unmached Platform -# -# Change Logs: -# Date Author Notes -# 2022-4-17 JasonHu Init -## - -# modify compiler here -ifeq ($(HOSTOS), windows) -CROSS_COMPILE := riscv-none-embed- -else -CROSS_COMPILE := riscv64-linux-gnu- -endif diff --git a/src/platform/hifive_unmached/connect.gdb b/src/platform/hifive_unmached/connect.gdb deleted file mode 100644 index 90f7c83..0000000 --- a/src/platform/hifive_unmached/connect.gdb +++ /dev/null @@ -1 +0,0 @@ -target remote localhost:10001 \ No newline at end of file diff --git a/src/platform/hifive_unmached/defconfig b/src/platform/hifive_unmached/defconfig deleted file mode 100644 index 01694d2..0000000 --- a/src/platform/hifive_unmached/defconfig +++ /dev/null @@ -1,71 +0,0 @@ -CONFIG_NX_CPU_64BITS=y - -# -# OS Kernel -# - -# -# Debug -# -CONFIG_NX_DEBUG=y -CONFIG_NX_LOG_LEVEL=3 -CONFIG_NX_DEBUG_COLOR=y -CONFIG_NX_DEBUG_TIMELINE=y -# CONFIG_NX_DEBUG_LINENUMBER is not set -# end of Debug - -CONFIG_NX_PLATFORM_NAME="riscv64-hifive_unmached" -CONFIG_NX_MULTI_CORES_NR=5 -CONFIG_NX_ENABLE_PLATFORM_MAIN=y -CONFIG_NX_IRQ_NAME_LEN=48 -CONFIG_NX_NR_IRQS=70 -CONFIG_NX_KVADDR_OFFSET=0x00000000 -CONFIG_NX_PAGE_SHIFT=12 -CONFIG_NX_MAX_THREAD_NR=256 -CONFIG_NX_THREAD_NAME_LEN=32 -CONFIG_NX_THREAD_STACK_SIZE=8192 -CONFIG_NX_ENABLE_SCHED=y -CONFIG_NX_THREAD_MAX_PRIORITY_NR=16 -CONFIG_NX_PORCESS_ENV_ARGS=1024 -CONFIG_NX_TICKS_PER_SECOND=100 -# end of OS Kernel - -# -# Platform -# -CONFIG_NX_PLATFORM_HIFIVE_UNMACHED=y -CONFIG_NX_UART0_FROM_SBI=y -# end of Platform - -# -# Device -# -CONFIG_NX_DRIVER_CONSOLE=y -CONFIG_NX_PRINT_BUF_LEN=256 -# CONFIG_NX_DRIVER_ROMDISK is not set -# CONFIG_NX_DRIVER_DUMMY is not set -CONFIG_NX_DRIVER_NULL=y -CONFIG_NX_DRIVER_ZERO=y -CONFIG_NX_DRIVER_MEMINFO=y -CONFIG_NX_DRIVER_CPUINFO=y -# end of Device - -# -# File System -# -# CONFIG_NX_FS_CPIO is not set -# CONFIG_NX_FS_DEVFS is not set -# CONFIG_NX_ENABLE_EXECUTE_USER is not set -# CONFIG_NX_ENABLE_MOUNT_TABLE is not set -CONFIG_NX_VFS_MAX_PATH=512 -CONFIG_NX_VFS_MAX_NAME=256 -CONFIG_NX_VFS_MAX_FD=256 -CONFIG_NX_VFS_NODE_HASH_SIZE=256 -# end of File System - -# -# Tests -# -# CONFIG_NX_ENABLE_TEST_UTEST is not set -# CONFIG_NX_ENABLE_TEST_INTEGRATION is not set -# end of Tests diff --git a/src/platform/hifive_unmached/drivers/Makefile b/src/platform/hifive_unmached/drivers/Makefile deleted file mode 100644 index 28afb05..0000000 --- a/src/platform/hifive_unmached/drivers/Makefile +++ /dev/null @@ -1 +0,0 @@ -SRC += *.c \ No newline at end of file diff --git a/src/platform/hifive_unmached/drivers/direct_uart.c b/src/platform/hifive_unmached/drivers/direct_uart.c deleted file mode 100644 index e64e878..0000000 --- a/src/platform/hifive_unmached/drivers/direct_uart.c +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart driver - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -void NX_HalDirectUartPutc(char ch) -{ -#ifdef CONFIG_NX_UART0_FROM_SBI - sbi_console_putchar(ch); -#else - while(UART0_TX & UART0_TX_FULL); /* wait fifo empty */ - UART0_TX = (NX_U32)ch; -#endif -} - -int NX_HalDirectUartGetc(void) -{ -#ifdef CONFIG_NX_UART0_FROM_SBI - return sbi_console_getchar(); -#else - NX_U32 data = UART0_RX & 0xff; - return data; -#endif -} - -NX_INTERFACE void NX_ConsoleSendData(char ch) -{ - if (ch == '\n') /* send '\r' ahead */ - { - NX_HalDirectUartPutc('\r'); - } - NX_HalDirectUartPutc(ch); -} - -void NX_HalDirectUartInit(void) -{ -#ifndef CONFIG_NX_UART0_FROM_SBI - UART0_TXCTL = UART0_TXCTL_ENABLE; /* enable uart tx */ -#endif -} - -/** - * default handler -*/ -NX_WEAK_SYM void NX_HalDirectUartGetcHandler(char data) -{ - NX_ConsoleReceveData(data); -} - -NX_PRIVATE NX_Error UartIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - int data = NX_HalDirectUartGetc(); - if (data != -1) - { - if (data == 127) /* backspace was 127? override as '\b' */ - { - data = '\b'; - } - if (NX_HalDirectUartGetcHandler != NX_NULL) - { - NX_HalDirectUartGetcHandler(data); - } - } - return data != -1 ? NX_EOK : NX_EIO; -} - -void NX_HalDirectUartStage2(void) -{ -#ifndef CONFIG_NX_UART0_FROM_SBI - UART0_RXCTL = UART0_RXCTL_ENABLE; /* enable uart rx */ -#endif - UART0_IE = UART0_IE_RXWM; /* enable rx interrupt */ - - /* register interrup */ - NX_ASSERT(NX_IRQ_Bind(UART0_IRQ, UartIrqHandler, NX_NULL, "Uart0", 0) == NX_EOK); - NX_ASSERT(NX_IRQ_Unmask(UART0_IRQ) == NX_EOK); -} diff --git a/src/platform/hifive_unmached/hal/init.c b/src/platform/hifive_unmached/hal/init.c deleted file mode 100644 index bd7ed4f..0000000 --- a/src/platform/hifive_unmached/hal/init.c +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Init platfrom - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NX_LOG_LEVEL NX_LOG_INFO -#define NX_LOG_NAME "INIT" -#include - -NX_INTERFACE NX_Error NX_HalPlatformInit(NX_UArch coreId) -{ - /* NOTE: init trap first before do anything */ - CPU_InitTrap(coreId); - - NX_HalDirectUartInit(); - - sbi_init(); - sbi_print_version(); - - NX_LOG_I("Hello, Hifve-Unmached! on core %d", coreId); - - PLIC_Init(NX_True); - - NX_HalPageZoneInit(); - - return NX_EOK; -} - -NX_INTERFACE NX_Error NX_HalPlatformStage2(void) -{ - NX_LOG_I("stage2!"); - - NX_HalDirectUartStage2(); - - return NX_EOK; -} diff --git a/src/platform/hifive_unmached/hal/main.c b/src/platform/hifive_unmached/hal/main.c deleted file mode 100644 index e207767..0000000 --- a/src/platform/hifive_unmached/hal/main.c +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom main - * - * Change Logs: - * Date Author Notes - * 2022-05-01 JasonHu Init - */ - -#include -#define NX_LOG_NAME "Hal Main" -#include - -#ifdef CONFIG_NX_ENABLE_PLATFORM_MAIN -NX_INTERFACE void NX_HalPlatformMain(void) -{ - NX_LOG_I("Hifive Unmached platform main running...\n"); -} -#endif /* CONFIG_NX_ENABLE_PLATFORM_MAIN */ diff --git a/src/platform/hifive_unmached/include/drivers/direct_uart.h b/src/platform/hifive_unmached/include/drivers/direct_uart.h deleted file mode 100644 index 7978e45..0000000 --- a/src/platform/hifive_unmached/include/drivers/direct_uart.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart - * - * Change Logs: - * Date Author Notes - * 2022-4-17 JasonHu Init - */ - -#ifndef __DIRECT_UART_HEADER__ -#define __DIRECT_UART_HEADER__ - -#include - -#define UART0_PHY_ADDR 0x10010000UL - -#define UART0_IRQ 39 - -#define UART0_TX (*(NX_U32 volatile *)(UART0_PHY_ADDR + 0x00)) -#define UART0_TX_FULL (1UL << 31) /* transmit FIFO full */ -#define UART0_TXCTL (*(NX_U32 volatile *)(UART0_PHY_ADDR + 0x08)) -#define UART0_TXCTL_ENABLE 0x01 /* transmit enable */ -#define UART0_RX (*(NX_U32 volatile *)(UART0_PHY_ADDR + 0x04)) -#define UART0_RXCTL (*(NX_U32 volatile *)(UART0_PHY_ADDR + 0x0c)) -#define UART0_RXCTL_ENABLE 0x01 /* receive enable */ -#define UART0_IE (*(NX_U32 volatile *)(UART0_PHY_ADDR + 0x10)) -#define UART0_IE_RXWM 0X02 /* receive interrupt wartermark interrupt enable */ - -void NX_HalDirectUartInit(void); -void NX_HalDirectUartStage2(void); - -void NX_HalDirectUartPutc(char ch); -int NX_HalDirectUartGetc(void); - -#endif /* __DIRECT_UART_HEADER__ */ diff --git a/src/platform/hifive_unmached/include/nx_configure.h b/src/platform/hifive_unmached/include/nx_configure.h deleted file mode 100644 index f738efc..0000000 --- a/src/platform/hifive_unmached/include/nx_configure.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __NX_CONFIG__ -#define __NX_CONFIG__ -#define CONFIG_NX_CPU_64BITS 1 -#define CONFIG_NX_DEBUG 1 -#define CONFIG_NX_LOG_LEVEL 3 -#define CONFIG_NX_DEBUG_COLOR 1 -#define CONFIG_NX_DEBUG_TIMELINE 1 -#define CONFIG_NX_PLATFORM_NAME "riscv64-hifive_unmached" -#define CONFIG_NX_MULTI_CORES_NR 5 -#define CONFIG_NX_ENABLE_PLATFORM_MAIN 1 -#define CONFIG_NX_IRQ_NAME_LEN 48 -#define CONFIG_NX_NR_IRQS 70 -#define CONFIG_NX_KVADDR_OFFSET 0x00000000 -#define CONFIG_NX_PAGE_SHIFT 12 -#define CONFIG_NX_MAX_THREAD_NR 256 -#define CONFIG_NX_THREAD_NAME_LEN 32 -#define CONFIG_NX_THREAD_STACK_SIZE 8192 -#define CONFIG_NX_ENABLE_SCHED 1 -#define CONFIG_NX_THREAD_MAX_PRIORITY_NR 16 -#define CONFIG_NX_PORCESS_ENV_ARGS 1024 -#define CONFIG_NX_TICKS_PER_SECOND 100 -#define CONFIG_NX_PLATFORM_HIFIVE_UNMACHED 1 -#define CONFIG_NX_UART0_FROM_SBI 1 -#define CONFIG_NX_DRIVER_CONSOLE 1 -#define CONFIG_NX_PRINT_BUF_LEN 256 -#define CONFIG_NX_DRIVER_NULL 1 -#define CONFIG_NX_DRIVER_ZERO 1 -#define CONFIG_NX_DRIVER_MEMINFO 1 -#define CONFIG_NX_DRIVER_CPUINFO 1 -#define CONFIG_NX_VFS_MAX_PATH 512 -#define CONFIG_NX_VFS_MAX_NAME 256 -#define CONFIG_NX_VFS_MAX_FD 256 -#define CONFIG_NX_VFS_NODE_HASH_SIZE 256 -#endif diff --git a/src/platform/hifive_unmached/include/platform.h b/src/platform/hifive_unmached/include/platform.h deleted file mode 100644 index c673371..0000000 --- a/src/platform/hifive_unmached/include/platform.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom header - * - * Change Logs: - * Date Author Notes - * 2021-10-18 JasonHu Init - */ - -#ifndef __PLATFORM_HEADER__ -#define __PLATFORM_HEADER__ - -#include - -#define DRAM_SIZE_DEFAULT (256 * NX_MB) - -#define MEM_SBI_BASE 0x80000000UL -#define MEM_SBI_SZ (2 * NX_MB) - -#define MEM_KERNEL_BASE (MEM_SBI_BASE + MEM_SBI_SZ) -#define MEM_KERNEL_SZ (30 * NX_MB) - -#define MEM_NORMAL_BASE (MEM_KERNEL_BASE + MEM_KERNEL_SZ) - -#define MEM_MIN_SIZE (128 * NX_MB) - -#define MEM_KERNEL_SPACE_SZ (128 * NX_MB) - -#define MEM_KERNEL_TOP (MEM_SBI_BASE + MEM_KERNEL_SPACE_SZ) - -/* max cpus for hifive unmached (1: u540, 4: u740) */ -#define PLATFORM_MAX_NR_MULTI_CORES 5 - -/** - * Physical memory layout: - * - * +------------------------+ <- MAX PHY SIZE (TOP to 4GB) - * | L3 PAGES | - * +------------------------+ <- KERNEL PAGES (TOP to 2GB + 128MB) - * | L3(K) & L0/1/2 PAGES | - * +------------------------+ <- 0x82000000 (2GB + 32MB) - * | KERNEL | - * +------------------------+ <- 0x80200000 (2GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x80000000 (2GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -/** - * Virtual memory layout: - * - * @: delay map - * - * +------------------------+ <- 0x400000000 (16GB) - * | @USER | - * +------------------------+ <- 0xFFFFFFFF (4GB) - * | @RESERVED | - * +------------------------+ <- 0x88000000 (2GB + 128MB) - * | @KMAP | - * +------------------------+ <- 0x84000000 (2GB + 64MB) - * | KHEAP | - * +------------------------+ <- 0x82000000 (2GB + 32MB) - * | KCODE & KDATA & KBSS | - * +------------------------+ <- 0x80200000 (2GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x80000000 (2GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -NX_IMPORT void MMU_EarlyMap(void); -void *NX_HalGetKernelPageTable(void); - -#endif /* __PLATFORM_HEADER__ */ diff --git a/src/platform/hifive_unmached/nxos.ld b/src/platform/hifive_unmached/nxos.ld deleted file mode 100644 index 85cec62..0000000 --- a/src/platform/hifive_unmached/nxos.ld +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Link script for hifive unmached Platform - * - * Change Logs: - * Date Author Notes - * 2021-10-1 JasonHu Init - * 2021-12-1 JasonHu Update symbol - * 2022-4-18 JasonHu update and add __global_pointer$ - */ - -OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") -OUTPUT_ARCH(riscv) -ENTRY(_Start) - -MEMORY -{ - /* u-boot jump to 0x80200000 */ - SRAM : ORIGIN = 0x80200000, LENGTH = 0x1E00000 -} - -SECTIONS -{ - /* code segment */ - . = ALIGN(8); - .text : - { - __NX_TextStart = .; - *(.text.start) - *(.text) - *(.init.text) - *(.exit.text) - - *(.rodata) - *(.rodata.*) - - . = ALIGN(8); - PROVIDE(__NX_InitCallStart = .); - KEEP(*(.initCall0.text)) - KEEP(*(.initCall1.text)) - KEEP(*(.initCall2.text)) - KEEP(*(.initCall3.text)) - KEEP(*(.initCall4.text)) - KEEP(*(.initCall5.text)) - KEEP(*(.initCall6.text)) - KEEP(*(.initCall7.text)) - KEEP(*(.initCall8.text)) - KEEP(*(.initCall9.text)) - PROVIDE(__NX_InitCallEnd = .); - - . = ALIGN(8); - PROVIDE(__NX_ExitCallStart = .); - KEEP(*(.exitcall0.text)) - KEEP(*(.exitcall1.text)) - KEEP(*(.exitcall2.text)) - KEEP(*(.exitcall3.text)) - KEEP(*(.exitcall4.text)) - KEEP(*(.exitcall5.text)) - KEEP(*(.exitcall6.text)) - KEEP(*(.exitcall7.text)) - KEEP(*(.exitcall8.text)) - KEEP(*(.exitcall9.text)) - PROVIDE(__NX_ExitCallEnd = .); - - /* section information for utest */ - . = ALIGN(8); - PROVIDE(__NX_UTestCaseTableStart = .); - KEEP(*(UTestCaseTable)) - PROVIDE(__NX_UTestCaseTableEnd = .); - - /* section information for integration */ - . = ALIGN(8); - PROVIDE(__NX_IntegrationTableStart = .); - KEEP(*(IntegrationTable)) - PROVIDE(__NX_IntegrationTableEnd = .); - __NX_TextEnd = .; - } > SRAM - - /* data segment */ - . = ALIGN(8); - - .data : - { - __NX_DataStart = .; - *(.data) - *(.data.*) - - . = ALIGN(8); - PROVIDE( __global_pointer$ = . + 0x800 ); - - *(.sdata) - *(.sdata.*) - } > SRAM - - .romdisk ALIGN(8) : - { - PROVIDE(__NX_RomdiskStart = .); - KEEP(*(.romdisk)) - PROVIDE(__NX_RomdiskEnd = .); - __NX_DataEnd = .; - } > SRAM - - . = ALIGN(8); - - __NX_DataEnd = .; - - /* bss segement */ - - .sbss : - { - __NX_BssStart = .; - *(.sbss) - *(.sbss.*) - *(.dynsbss) - *(.scommon) - } > SRAM - - .bss : - { - *(.bss) - *(.bss.*) - *(.dynbss) - *(COMMON) - . = ALIGN(8); - __NX_BssEnd = .; - } > SRAM -} \ No newline at end of file diff --git a/src/platform/hifive_unmached/nxos.mk b/src/platform/hifive_unmached/nxos.mk deleted file mode 100644 index 6e48b94..0000000 --- a/src/platform/hifive_unmached/nxos.mk +++ /dev/null @@ -1,19 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for hifive unmached Platform -# -# Change Logs: -# Date Author Notes -# 2022-4-17 JasonHu Init -## - -# -# Override default variables. -# - -CFLAGS += -fvar-tracking -ASFLAGS += -ffunction-sections -fdata-sections -ffreestanding -MCFLAGS += -march=rv64imafdc -mabi=lp64d -mcmodel=medany -LDFLAGS += -no-pie -nostartfile -n diff --git a/src/platform/i386/.gitignore b/src/platform/i386/.gitignore deleted file mode 100644 index 7404244..0000000 --- a/src/platform/i386/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tools/ -*.S diff --git a/src/platform/i386/Kconfig b/src/platform/i386/Kconfig deleted file mode 100644 index 01181b4..0000000 --- a/src/platform/i386/Kconfig +++ /dev/null @@ -1,41 +0,0 @@ -config NX_PLATFORM_I386_PC32 - bool - default y - -config NX_HARDWARE_VBE - bool "probe vbe hardware" - default n - - if NX_HARDWARE_VBE - config NX_HARDWARE_VBE_WIDTH - int "vbe width" - default 800 - - config NX_HARDWARE_VBE_HEIGHT - int "vbe height" - default 600 - - config NX_HARDWARE_VBE_BPP - int "vbe bits per pixel" - default 32 - endif - -config NX_DRIVER_FRAMEBUFFER - bool "enable framebuffer driver" - default n - -config NX_DRIVER_PS2_MOUSE - bool "enable ps/2 mouse driver" - default n - -config NX_DRIVER_PS2_KEYBOARD - bool "enable ps/2 keyboard driver" - default n - -config NX_DRIVER_PS2_KEYBOARD_IRQ - bool "enable ps/2 keyboard irq driver" - default n - -config NX_DRIVER_PS2_MOUSE_IRQ - bool "enable ps/2 mouse irq driver" - default n diff --git a/src/platform/i386/Makefile b/src/platform/i386/Makefile deleted file mode 100644 index e326730..0000000 --- a/src/platform/i386/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -SRC += drivers/ -SRC += hal/ \ No newline at end of file diff --git a/src/platform/i386/README.md b/src/platform/i386/README.md deleted file mode 100644 index e37e0cc..0000000 --- a/src/platform/i386/README.md +++ /dev/null @@ -1,73 +0,0 @@ -# 基于i386处理器的PC 32位电脑的平台支持 - -# TODO - -- [x] 添加格式化输出 - -- [x] 添加错误号处理 - -- [x] 添加架构特性 - -- [x] 添加中断管理 - -- [x] 添加上下文切换 - -- [x] 添加链表 - -- [x] 添加物理内存管理 - -- [x] 从硬件获取内存大小 - -- [x] 添加MMU - -- [x] 添加内核内存管理 - - - [x] Page heap - - - [x] Mem Cache - -- [x] 添加调试日志 - -- [x] 添加单元测试 - - [x] 添加EXPECT - - [x] 对已有函数进行单元测试 - -- [ ] 添加多线程管理 - - [x] BUG on thread id alloc - - [x] 简单的线程管理,简单的单核调度。 - - [x] 添加原子操作。 - - [x] 线程间的同步,自旋锁,互斥 - - [x] 添加print格式化输出 - - [x] 整理代码,初步优化代码组织结构 - - [x] 为内存管理接口和线程接口添加锁 - - [x] 添加menuconfig - - [x] 为需要配置的目录添加KCONFIG,并且生成正确的Configure.h - - [x] 根据Configure.h设置代码配置,并测试配置通过 - - [x] 添加menuconfig相关文档说明 - - - [x] 添加定时器 - - [x] 对定时器做单元测试 - - [x] 使用定时器实现休眠和唤醒功能 - - [x] 完善中断处理,添加软中断机制。 - - [x] 添加中断下半部分。 - - [x] 添加串口中断,测试输入 - -- [ ] 添加SMP - - [ ] 添加多核启动,中断管理。 - - [ ] 添加多核调度,简单的多个核获取线程执行。 - - [ ] 多核均衡负载,绑定核,线程核间迁移。 - - [ ] 完善调度器,添加优先级。 - - [ ] 进行整体的多线程调度优化。 - -- [x] gdb+vscode图形化调试 - -- [ ] 添加多进程管理 - - [ ] 添加用户态进程的调度,完善MMU管理,增加进程地址空间相关的内容。 - -- [ ] 添加rom文件系统 - -- [ ] 添加用户程序 - -- [ ] 添加简单的shell程序 - -- [ ] 添加多平台支持 diff --git a/src/platform/i386/cmd.mk b/src/platform/i386/cmd.mk deleted file mode 100644 index 9babb58..0000000 --- a/src/platform/i386/cmd.mk +++ /dev/null @@ -1,107 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for run PC32 Platform -# -# Change Logs: -# Date Author Notes -# 2021-9-20 JasonHu Init -## - -# -# Config graphic window ? (y/n) -# -GUI ?= n - -# -# Config kernel vm ? (y/n) -# -KVM ?= n - -# -# Tools for PC32 -# -TOOL_DIR := tools/ -GRUB_DIR := $(TOOL_DIR)grub-2.04 -BIOS_FW_DIR := $(TOOL_DIR)bios_fw -RM := rm - -# -# Tools name -# -MAKE := make -QEMU := qemu-system-i386 -DEBUGER := $(CROSS_COMPILE)gdb -DUMP := $(CROSS_COMPILE)objdump - -QEMU_KVM := # no virutal - -ifeq ($(KVM),y) -ifeq ($(HOSTOS),windows) -QEMU_KVM := -accel hax -else -QEMU_KVM := -enable-kvm -endif -endif - -# -# Qemu args configure -# -QEMU_ARGS := -m 512m $(QEMU_KVM) \ - -name "NXOS - Plartform PC32 - Arch x86" \ - -rtc base=localtime \ - -boot d \ - -cdrom $(NXOS_NAME).iso \ - -ifeq ($(GUI),y) - QEMU_ARGS += -serial stdio -else - QEMU_ARGS += -nographic -endif - -ifeq ($(G),y) - QEMU_ARGS += -S -gdb tcp::10001,ipv4 -endif - -# -# Args for make -# -.PHONY: run clean - -# -# Run OS in QEMU -# -run: - @$(MAKE) -s -C $(GRUB_DIR) KERNEL=$(NXOS_NAME).elf OS_NAME=$(NXOS_NAME) - $(QEMU) $(QEMU_ARGS) - -# -# Clear target file -# -clean: - @$(MAKE) -s -C $(GRUB_DIR) clean - -$(RM) $(NXOS_NAME).elf - -# -# prepare tools -# -prepare: - -$(RM) -rf $(TOOL_DIR) - git clone https://gitee.com/BookOS/nxos-platform-pc32-tools $(TOOL_DIR) - echo "parpare done." - -# -# gdb debug -# -gdb: - @echo gdb load file from $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DEBUGER) $(NXOS_NAME).elf -x connect.gdb - -# -# dump kernel -# -dump: - @echo dump kernel $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DUMP) -D -S $(NXOS_NAME).elf > $(NXOS_NAME).dump.S - \ No newline at end of file diff --git a/src/platform/i386/compile.mk b/src/platform/i386/compile.mk deleted file mode 100644 index 9f68b96..0000000 --- a/src/platform/i386/compile.mk +++ /dev/null @@ -1,16 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for QEMU Riscv64 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -ifeq ($(HOSTOS), windows) -CROSS_COMPILE := x86_64-elf- -else -CROSS_COMPILE := -endif diff --git a/src/platform/i386/connect.gdb b/src/platform/i386/connect.gdb deleted file mode 100644 index 90f7c83..0000000 --- a/src/platform/i386/connect.gdb +++ /dev/null @@ -1 +0,0 @@ -target remote localhost:10001 \ No newline at end of file diff --git a/src/platform/i386/defconfig b/src/platform/i386/defconfig deleted file mode 100644 index 901d62c..0000000 --- a/src/platform/i386/defconfig +++ /dev/null @@ -1,77 +0,0 @@ - -# -# OS Kernel -# - -# -# Debug -# -CONFIG_NX_DEBUG=y -CONFIG_NX_LOG_LEVEL=3 -CONFIG_NX_DEBUG_COLOR=y -CONFIG_NX_DEBUG_TIMELINE=y -# CONFIG_NX_DEBUG_LINENUMBER is not set -# end of Debug - -CONFIG_NX_PLATFORM_NAME="x86-i386" -CONFIG_NX_MULTI_CORES_NR=1 -CONFIG_NX_ENABLE_PLATFORM_MAIN=y -CONFIG_NX_IRQ_NAME_LEN=48 -CONFIG_NX_NR_IRQS=16 -CONFIG_NX_KVADDR_OFFSET=0x00000000 -CONFIG_NX_PAGE_SHIFT=12 -CONFIG_NX_MAX_THREAD_NR=256 -CONFIG_NX_THREAD_NAME_LEN=32 -CONFIG_NX_THREAD_STACK_SIZE=8192 -CONFIG_NX_ENABLE_SCHED=y -CONFIG_NX_THREAD_MAX_PRIORITY_NR=16 -CONFIG_NX_PORCESS_ENV_ARGS=1024 -CONFIG_NX_TICKS_PER_SECOND=100 -# end of OS Kernel - -# -# Platform -# -CONFIG_NX_PLATFORM_I386_PC32=y -# CONFIG_NX_HARDWARE_VBE is not set -# CONFIG_NX_DRIVER_FRAMEBUFFER is not set -# CONFIG_NX_DRIVER_PS2_MOUSE is not set -# CONFIG_NX_DRIVER_PS2_KEYBOARD is not set -# CONFIG_NX_DRIVER_PS2_KEYBOARD_IRQ is not set -# CONFIG_NX_DRIVER_PS2_MOUSE_IRQ is not set -# end of Platform - -# -# Device -# -CONFIG_NX_DRIVER_CONSOLE=y -CONFIG_NX_PRINT_BUF_LEN=256 -# CONFIG_NX_DRIVER_ROMDISK is not set -# CONFIG_NX_DRIVER_DUMMY is not set -CONFIG_NX_DRIVER_NULL=y -CONFIG_NX_DRIVER_ZERO=y -CONFIG_NX_DRIVER_MEMINFO=y -CONFIG_NX_DRIVER_CPUINFO=y -CONFIG_NX_DRIVER_PMEM=y -CONFIG_NX_DRIVER_VMEM=y -# end of Device - -# -# File System -# -# CONFIG_NX_FS_CPIO is not set -# CONFIG_NX_FS_DEVFS is not set -# CONFIG_NX_ENABLE_EXECUTE_USER is not set -# CONFIG_NX_ENABLE_MOUNT_TABLE is not set -CONFIG_NX_VFS_MAX_PATH=512 -CONFIG_NX_VFS_MAX_NAME=256 -CONFIG_NX_VFS_MAX_FD=256 -CONFIG_NX_VFS_NODE_HASH_SIZE=256 -# end of File System - -# -# Tests -# -# CONFIG_NX_ENABLE_TEST_UTEST is not set -# CONFIG_NX_ENABLE_TEST_INTEGRATION is not set -# end of Tests diff --git a/src/platform/i386/drivers/Makefile b/src/platform/i386/drivers/Makefile deleted file mode 100644 index 28afb05..0000000 --- a/src/platform/i386/drivers/Makefile +++ /dev/null @@ -1 +0,0 @@ -SRC += *.c \ No newline at end of file diff --git a/src/platform/i386/drivers/direct_uart.c b/src/platform/i386/drivers/direct_uart.c deleted file mode 100644 index 9d6b4ea..0000000 --- a/src/platform/i386/drivers/direct_uart.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart driver - * - * Change Logs: - * Date Author Notes - * 2021-10-1 JasonHu first version - */ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#define UART_SEND_TIMEOUT 1 - -/* I/O port base addr */ -#define UART0_BASE 0X3F8 -#define BAUD_VALUE_MAX 115200 -#define BAUD_VALUE_DEFAULT 115200 -#define BAUD_DIVISOR_DEFAULT (BAUD_VALUE_MAX / BAUD_VALUE_DEFAULT) - -enum UartFifoControl -{ - FIFO_ENABLE = 1, /* Enable FIFOs */ - FIFO_CLEAR_RECEIVE = (1 << 1), /* Clear Receive FIFO */ - FIFO_CLEAR_TRANSMIT = (1 << 2), /* Clear Transmit FIFO */ - FIFO_DMA_MODE_SELECT = (1 << 3), /* DMA Mode Select */ - FIFO_RESERVED = (1 << 4), /* Reserved */ - FIFO_ENABLE_64 = (1 << 5), /* Enable 64 Byte FIFO(16750) */ - /* Interrupt Trigger Level/Trigger Level */ - FIFO_TRIGGER_1 = (0 << 6), /* 1 Byte */ - FIFO_TRIGGER_4 = (1 << 6), /* 4 Byte */ - FIFO_TRIGGER_8 = (1 << 7), /* 8 Byte */ - FIFO_TRIGGER_14 = (1 << 6) | (1 << 7), /* 14 Byte */ -}; - -enum UartLineControl -{ - /* Word Length */ - LINE_WORD_LENGTH_5 = 0, /* 5 Bits */ - LINE_WORD_LENGTH_6 = 1, /* 6 Bits */ - LINE_WORD_LENGTH_7 = (1 << 1), /* 7 Bits */ - LINE_WORD_LENGTH_8 = ((1 << 1) | 1), /* 8 Bits */ - LINE_STOP_BIT_1 = (0 << 2), /* One Stop Bit */ - LINE_STOP_BIT_2 = (1 << 2), /* 1.5 Stop Bits or 2 Stop Bits */ - /* Parity Select */ - LINE_PARITY_NO = (0 << 3), /* No Parity */ - LINE_PARITY_ODD = (1 << 3), /* Odd Parity */ - LINE_PARITY_EVEN = (1 << 3) | (1 << 4), /* Even Parity */ - LINE_PARITY_MARK = (1 << 3) | (1 << 5), /* Mark */ - LINE_PARITY_SPACE = (1 << 3) | (1 << 4) | (1 << 5), /* Space */ - LINE_BREAK_ENABLE = (1 << 6), /* Set Break Enable */ - LINE_DLAB = (1 << 7), /* Divisor Latch Access Bit */ -}; - -enum UartInterruptEnable -{ - INTR_RECV_DATA_AVALIABLE = 1, /* Enable Received Data Available Interrupt */ - INTR_TRANSMIT_HOLDING = (1 << 1), /* Enable Transmitter Holding Register Empty Interrupt */ - INTR_STATUS_CHANGED = (1 << 2), /* Enable Receiver Line Status Interrupt */ - INTR_MODEM_STATUS = (1 << 3), /* Enable Modem Status Interrupt */ - INTR_SLEEP_MODE = (1 << 4), /* Enable Sleep Mode(16750) */ - INTR_LOW_POWER_MODE = (1 << 5), /* Enable Low Power Mode(16750) */ - INTR_RESERVED1 = (1 << 6), /* Reserved */ - INTR_RESERVED2 = (1 << 7), /* Reserved */ -}; - -enum UartLineStatus -{ - LINE_STATUS_DATA_READY = 1, /* Data Ready */ - LINE_STATUS_OVERRUN_ERROR = (1 << 1), /* Overrun Error */ - LINE_STATUS_PARITY_ERROR = (1 << 2), /* Parity Error */ - LINE_STATUS_FRAMING_ERROR = (1 << 3), /* Framing Error */ - LINE_STATUS_BREAK_INTERRUPT = (1 << 4), /* Break Interrupt */ - LINE_STATUS_EMPTY_TRANSMITTER_HOLDING = (1 << 5), /* Empty Transmitter Holding Register */ - LINE_STATUS_EMPTY_DATA_HOLDING = (1 << 6), /* Empty Data Holding Registers */ - LINE_STATUS_ERROR_RECEIVE_FIFO = (1 << 7), /* Error in Received FIFO */ -}; - -enum UartIntrIndenty -{ - INTR_STATUS_PENDING_FLAG = 1, /* Interrupt Pending Flag */ - INTR_STATUS_MODEM = (0 << 1), /* Transmitter Holding Register Empty Interrupt */ - INTR_STATUS_TRANSMITTER_HOLDING = (1 << 1), /* Received Data Available Interrupt */ - INTR_STATUS_RECEIVE_DATA = (1 << 2), /* Received Data Available Interrupt */ - INTR_STATUS_RECEIVE_LINE = (1 << 1) | (1 << 2), /* Receiver Line Status Interrupt */ - INTR_STATUS_TIME_OUT_PENDING = (1 << 2) | (1 << 3), /* Time-out Interrupt Pending (16550 & later) */ - INTR_STATUS_64BYTE_FIFO = (1 << 5), /* 64 Byte FIFO Enabled (16750 only) */ - INTR_STATUS_NO_FIFO = (0 << 6), /* No FIFO on chip */ - INTR_STATUS_RESERVED_CONDITION = (1 << 6), /* Reserved condition */ - INTR_STATUS_FIFO_NOT_FUNC = (1 << 7), /* FIFO enabled, but not functioning */ - INTR_STATUS_FIFO = (1 << 6) | (1 << 7), /* FIFO enabled */ -}; - -enum UartModemControl -{ - MCR_DTR = 1, /* Programs -DTR. If set, -DTR is low and the DTR pin of the port goes 'high'. */ - MCR_RTS = (1 << 1), /* Programs -RTS. dito. */ - MCR_OUT1 = (1 << 2), /* Programs -OUT1. Normally not used in a PC, but used with some - multi-port serial adapters to enable or disable a port. Best - thing is to write a '1' to this bit. */ - MCR_OUT2 = (1 << 3), /* Programs -OUT2. If set to 1, interrupts generated by the UART - are transferred to the ICU (Interrupt Control Unit) while 0 - sets the interrupt output of the card to high impedance. - (This is PC-only). */ - MCR_LOOPBACK = (1 << 4), /* '1': local loopback. All outputs disabled. This is a means of - testing the chip: you 'receive' all the data you send. */ -}; - -struct DirectUart -{ - NX_U16 iobase; - NX_IRQ_Number irqno; - - NX_U16 data; - NX_U16 divisorLow; - NX_U16 intrEnable; - NX_U16 divisorHigh; - NX_U16 intrIndenty; - NX_U16 fifo; - NX_U16 lineCtrl; - NX_U16 modemCtrl; - NX_U16 lineStatus; - NX_U16 modem_status; - NX_U16 scratch; -}; - -NX_PRIVATE struct DirectUart directUart; -NX_PRIVATE NX_IRQ_DelayWork uartWork; - -NX_PRIVATE void UartSent(struct DirectUart *uart, char data) -{ -#if UART_SEND_TIMEOUT == 1 - int timeout = 0x100000; - while (!(IO_In8(uart->lineStatus) & LINE_STATUS_EMPTY_TRANSMITTER_HOLDING) && timeout--) - { - } -#else - while (!(IO_In8(uart->lineStatus) & LINE_STATUS_EMPTY_TRANSMITTER_HOLDING)) - { - } -#endif - IO_Out8(uart->data, data); -} - -void NX_HalDirectUartPutc(char ch) -{ - if(ch == '\n') { - UartSent(&directUart, '\r'); - } - UartSent(&directUart, ch); -} - -NX_INTERFACE void NX_ConsoleSendData(char ch) -{ - NX_HalDirectUartPutc(ch); -} - -void NX_HalDirectUartInit(void) -{ - struct DirectUart *uart = &directUart; - NX_U16 iobase = UART0_BASE; - - uart->irqno = IRQ_SERIAL1; - - uart->iobase = iobase; - uart->data = iobase + 0; - uart->divisorLow = iobase + 0; - uart->intrEnable = iobase + 1; - uart->divisorHigh = iobase + 1; - uart->intrIndenty = iobase + 2; - uart->lineCtrl = iobase + 3; - uart->modemCtrl = iobase + 4; - uart->lineStatus = iobase + 5; - uart->modem_status = iobase + 6; - uart->scratch = iobase + 7; - - IO_Out8(uart->lineCtrl, LINE_DLAB); - - IO_Out8(uart->divisorLow, (BAUD_DIVISOR_DEFAULT) & 0xff); - IO_Out8(uart->divisorHigh, ((BAUD_DIVISOR_DEFAULT) >> 8) & 0xff); - - IO_Out8(uart->lineCtrl, LINE_WORD_LENGTH_8 | - LINE_STOP_BIT_1 | LINE_PARITY_NO); - - /* enable recv intr */ - IO_Out8(uart->intrEnable, INTR_RECV_DATA_AVALIABLE | - INTR_STATUS_CHANGED | INTR_LOW_POWER_MODE); - - /* - * Set FIFO, open FIFO, clear receive FIFO, clear transmit FIFO Open 64Byte FIFO, - * interrupt trigger level is 14Byte - */ - IO_Out8(uart->fifo, FIFO_ENABLE | FIFO_CLEAR_TRANSMIT | - FIFO_CLEAR_RECEIVE | FIFO_ENABLE_64 | - FIFO_TRIGGER_14); - - /* IRQs enabled, RTS/DSR set */ - IO_Out8(uart->modemCtrl, MCR_DTR | MCR_RTS | MCR_OUT2); - IO_Out8(uart->scratch, 0x00); -} - -/** - * default handler -*/ -NX_WEAK_SYM void NX_HalDirectUartGetcHandler(char data) -{ - NX_ConsoleReceveData(data); -} - -int NX_HalDirectUartGetc(void) -{ - struct DirectUart *uart = &directUart; - - int timeout = 100000; - while (!(IO_In8(uart->lineStatus) & LINE_STATUS_DATA_READY) && timeout--) - { - } - int data = -1; - if (timeout > 0) - { - data = IO_In8(uart->data); - } - return data; -} - -NX_PRIVATE void UartWorkHandler(void *arg) -{ - int data = NX_HalDirectUartGetc(); - if (data != -1) - { - if (NX_HalDirectUartGetcHandler != NX_NULL) - { - NX_HalDirectUartGetcHandler(data); - } - } -} - -NX_PRIVATE NX_Error UartIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - NX_IRQ_DelayWorkHandle(&uartWork); - return NX_EOK; -} - -void NX_HalDirectUartStage2(void) -{ - struct DirectUart *uart = &directUart; - - NX_ASSERT(NX_IRQ_DelayWorkInit(&uartWork, UartWorkHandler, NX_NULL, NX_IRQ_WORK_NOREENTER) == NX_EOK); - NX_ASSERT(NX_IRQ_DelayQueueEnter(NX_IRQ_NORMAL_QUEUE, &uartWork) == NX_EOK); - - NX_ASSERT(NX_IRQ_Bind(uart->irqno, UartIrqHandler, NX_NULL, "Uart", 0) == NX_EOK); - NX_ASSERT(NX_IRQ_Unmask(uart->irqno) == NX_EOK); -} diff --git a/src/platform/i386/drivers/framebuffer.c b/src/platform/i386/drivers/framebuffer.c deleted file mode 100644 index d888e52..0000000 --- a/src/platform/i386/drivers/framebuffer.c +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: framebuffer driver - * - * Change Logs: - * Date Author Notes - * 2022-06-03 JasonHu Init - */ - -#define NX_LOG_NAME "framebuffer" -#include - -#ifdef NX_DRIVER_FRAMEBUFFER - -#include -#include -#include -#include - -#include - -#include - -#define DRV_NAME "framebuffer driver" -#define DRV_VERSION "0.1" - -#define DEV_NAME "fb0" - -#define VBE_INFO_ADDR (NX_Phy2Virt(VBE_BASE_INFO_ADDR)) -#define VBE_MODE_ADDR (NX_Phy2Virt(VBE_BASE_MODE_ADDR)) - -NX_PRIVATE NX_FramebufferInfo fb0Info; - -NX_PRIVATE NX_Error FB_Control(struct NX_Device *device, NX_U32 cmd, void *arg) -{ - NX_FramebufferInfo * info; - NX_FramebufferInfo * fbInfo; - - fbInfo = device->extension; - NX_ASSERT(fbInfo); - - switch (cmd) - { - case NX_FRAMEBUFFER_CMD_GETINFO: - info = (NX_FramebufferInfo *) arg; - if (info) { - info->bitsPerPixel = fbInfo->bitsPerPixel; - info->bytesPerScanLine = fbInfo->bytesPerScanLine; - info->xResolution = fbInfo->xResolution; - info->yResolution = fbInfo->yResolution; - info->phyBasePtr = fbInfo->phyBasePtr; - } - break; - default: - return NX_EINVAL; - } - - return NX_EOK; -} - -NX_PRIVATE NX_Error FB_Mappable(struct NX_Device *device, NX_Size length, NX_U32 prot, NX_Addr * outPhyAddr) -{ - NX_FramebufferInfo * fbInfo; - - fbInfo = device->extension; - NX_ASSERT(fbInfo); - - if (!fbInfo->phyBasePtr) - { - return NX_ENORES; - } - - if (length > fbInfo->bytesPerScanLine * fbInfo->yResolution) - { - return NX_EPERM; - } - - *outPhyAddr = fbInfo->phyBasePtr; - - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps FB_DriverOps = { - .control = FB_Control, - .mappable = FB_Mappable, -}; - -NX_PRIVATE void FB_DriverInit(void) -{ - NX_Device *device; - - struct VbeInfoBlock * vbeInfo = (struct VbeInfoBlock *)VBE_INFO_ADDR; - struct VbeModeInfoBlock * modeInfo = (struct VbeModeInfoBlock *)VBE_MODE_ADDR; - - /* check vbe version */ - if (vbeInfo->vbeVeision < 0x0200) { - NX_LOG_E("vbe: version %x not supported!", vbeInfo->vbeVeision); - return; - } - - fb0Info.bitsPerPixel = modeInfo->bitsPerPixel; - fb0Info.bytesPerScanLine = modeInfo->bytesPerScanLine; - fb0Info.xResolution = modeInfo->xResolution; - fb0Info.yResolution = modeInfo->yResolution; - fb0Info.phyBasePtr = modeInfo->phyBasePtr; - - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_SCREEN, 0, &FB_DriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DEV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - device->extension = &fb0Info; - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } -} - -NX_PRIVATE void FB_DriverExit(void) -{ - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(FB_DriverInit); -NX_DRV_EXIT(FB_DriverExit); - -#endif /* NX_DRIVER_FRAMEBUFFER */ diff --git a/src/platform/i386/drivers/pio.c b/src/platform/i386/drivers/pio.c deleted file mode 100644 index 3bbae7a..0000000 --- a/src/platform/i386/drivers/pio.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: port io driver - * - * Change Logs: - * Date Author Notes - * 2022-06-11 JasonHu Init - */ - -#define NX_LOG_NAME "port io" -#include - -#ifndef CONFIG_NX_DRIVER_PIO -#define CONFIG_NX_DRIVER_PIO -#endif - -#ifdef CONFIG_NX_DRIVER_PIO - -#include -#include -#include -#include - -#define DRV_NAME "port io driver" -#define DRV_VERSION "0.1" - -#define DEV_NAME "pio" - -#define MAX_PORTS_ID 65535 - -NX_PRIVATE NX_Error PIO_Read(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - NX_U32 data; - - if (off < 0 || off > MAX_PORTS_ID) /* valid port */ - { - return NX_EINVAL; - } - - switch (len) - { - case 1: - data = IO_In8(off); - NX_CopyToUser(buf, (char *)&data, len); - break; - case 2: - data = IO_In16(off); - NX_CopyToUser(buf, (char *)&data, len); - break; - case 4: - data = IO_In32(off); - NX_CopyToUser(buf, (char *)&data, len); - break; - - default: - return NX_EINVAL; - } - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_Error PIO_Write(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - NX_U32 data = 0; - - if (off < 0 || off > MAX_PORTS_ID) /* valid port */ - { - return NX_EINVAL; - } - - switch (len) - { - case 1: - NX_CopyFromUser((char *)&data, buf, len); - IO_Out8(off, data); - break; - case 2: - NX_CopyFromUser((char *)&data, buf, len); - IO_Out16(off, data); - break; - case 4: - NX_CopyFromUser((char *)&data, buf, len); - IO_Out32(off, data); - break; - - default: - return NX_EINVAL; - } - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps PIO_DriverOps = { - .read = PIO_Read, - .write = PIO_Write, -}; - -NX_PRIVATE void PIO_DriverInit(void) -{ - NX_Device *device; - - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_SCREEN, 0, &PIO_DriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DEV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } -} - -NX_PRIVATE void PIO_DriverExit(void) -{ - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(PIO_DriverInit); -NX_DRV_EXIT(PIO_DriverExit); - -#endif /* CONFIG_NX_DRIVER_PIO */ diff --git a/src/platform/i386/drivers/ps2_keyboard.c b/src/platform/i386/drivers/ps2_keyboard.c deleted file mode 100644 index fd61ef5..0000000 --- a/src/platform/i386/drivers/ps2_keyboard.c +++ /dev/null @@ -1,434 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: keyboard driver - * - * Change Logs: - * Date Author Notes - * 2022-06-03 JasonHu Init - */ - -#define NX_LOG_NAME "ps2keyboard" -#define NX_LOG_LEVEL NX_LOG_INFO -#include - -#ifdef CONFIG_NX_DRIVER_PS2_KEYBOARD - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include "ps2_keyboard.h" - -#define DRV_NAME "ps2 keyboard driver" -#define DRV_VERSION "0.1" - -#define DEV_NAME "keyboard0" - -#define KBD_EVENT_QUEUE_MAX_SZ 32 -#define KBD_FIFO_MAX_SZ 32 - -typedef struct HalDeviceExtension -{ - char irq; /* irq号 */ - - int code_with_e0; /* 携带E0的值 */ - int shift_left; /* l shift state */ - int shift_right; /* r shift state */ - int alt_left; /* l alt state */ - int alt_right; /* r left state */ - int ctl_left; /* l ctrl state */ - int ctl_right; /* l ctrl state */ - int caps_lock; /* Caps Lock */ - int num_lock; /* Num Lock */ - int scroll_lock; /* Scroll Lock */ - int column; /* 数据位于哪一列 */ - - NX_Fifo * fifo; - NX_Semaphore fifoSem; - NX_InputEventQueue eventQueue; - - NX_U32 flags; -} HalDeviceExtension; - -NX_PRIVATE HalDeviceExtension halKeyboardExtension; - -NX_PRIVATE NX_U16 ScanCode2EventCode(int key) -{ - int i; - for (i = 0; i < NX_ARRAY_SIZE(map_table); i++) { - if (i % 2 == 0) { /* 偶数:源键值码 */ - if (map_table[i] == key) { - return map_table[i + 1]; - } - } - }; - return NX_KEY_UNKNOWN; /* 未知编码 */ -} - -NX_PRIVATE void WAIT_KBC_ACK(void) -{ - unsigned char read; - do { - read = IO_In8(KBC_READ_DATA); - } while ((read != KBC_RET_ACK)); -} - -NX_PRIVATE void SetLeds(HalDeviceExtension *ext) -{ - /* 先合成成为一个数据,后面写入寄存器 */ - unsigned char leds = (ext->caps_lock << 2) | - (ext->num_lock << 1) | ext->scroll_lock; - - /* 数据指向led */ - WAIT_KBC_WRITE(); - IO_Out8(KBC_WRITE_DATA, KEY_CMD_LED_CODE); - WAIT_KBC_ACK(); - /* 写入新的led值 */ - WAIT_KBC_WRITE(); - IO_Out8(KBC_WRITE_DATA, leds); - WAIT_KBC_ACK(); -} - -NX_PRIVATE NX_U8 GetScanCodeFromFifo(HalDeviceExtension *ext) -{ - NX_U8 scan_code = 0; - NX_SemaphoreWait(&ext->fifoSem); - NX_ASSERT(NX_FifoGet(ext->fifo, &scan_code, 1) > 0); - return scan_code; -} - -NX_PRIVATE NX_U32 ParseKeyboard(HalDeviceExtension * ext) -{ - NX_U8 scan_code; - int make; - - NX_U32 key = 0; - NX_U32 *keyrow; - - ext->code_with_e0 = 0; - - scan_code = GetScanCodeFromFifo(ext); - - /* 检查是否是0xe1打头的数据 */ - if(scan_code == 0xe1){ - int i; - NX_U8 pausebrk_scode[] = {0xE1, 0x1D, 0x45, 0xE1, 0x9D, 0xC5}; - int is_pausebreak = 1; - for(i = 1; i < 6; i++){ - if (GetScanCodeFromFifo(ext) != pausebrk_scode[i]) { - is_pausebreak = 0; - break; - } - } - if (is_pausebreak) { - key = KBD_PAUSEBREAK; - } - } else if(scan_code == 0xe0){ - /* 检查是否是0xe0打头的数据 */ - scan_code = GetScanCodeFromFifo(ext); - - //PrintScreen 被按下 - if (scan_code == 0x2A) { - if (GetScanCodeFromFifo(ext) == 0xE0) { - if (GetScanCodeFromFifo(ext) == 0x37) { - key = KBD_PRINTSCREEN; - make = 1; - } - } - } - //PrintScreen 被释放 - if (scan_code == 0xB7) { - if (GetScanCodeFromFifo(ext) == 0xE0) { - if (GetScanCodeFromFifo(ext) == 0xAA) { - key = KBD_PRINTSCREEN; - make = 0; - } - } - } - //不是PrintScreen, 此时scan_code为0xE0紧跟的那个值. - if (key == 0) { - ext->code_with_e0 = 1; - } - } - - if ((key != KBD_PAUSEBREAK) && (key != KBD_PRINTSCREEN)) { - /* 处理一般字符 */ - make = (scan_code & KBD_FLAG_BREAK_MASK ? 0 : 1); - - //先定位到 kbd_keymap 中的行 - keyrow = &kbd_keymap[(scan_code & 0x7F) * KEYMAP_COLS]; - - ext->column = 0; - int caps = ext->shift_left || ext->shift_right; - if (ext->caps_lock) { - if ((keyrow[0] >= 'a') && (keyrow[0] <= 'z')){ - caps = !caps; - } - } - /* 如果大写打开 */ - if (caps) { - ext->column = 1; - } - - /* 如果有0xE0数据 */ - if (ext->code_with_e0) { - ext->column = 2; - } - /* 读取列中的数据 */ - key = keyrow[ext->column]; - - /* shift,ctl,alt变量设置, - caps,num,scroll锁设置 */ - switch(key) { - case KBD_SHIFT_L: - ext->shift_left = make; - break; - case KBD_SHIFT_R: - ext->shift_right = make; - break; - case KBD_CTRL_L: - ext->ctl_left = make; - break; - case KBD_CTRL_R: - ext->ctl_right = make; - break; - case KBD_ALT_L: - ext->alt_left = make; - break; - case KBD_ALT_R: - ext->alt_left = make; - break; - case KBD_CAPS_LOCK: - if (make) { - ext->caps_lock = !ext->caps_lock; - SetLeds(ext); - } - break; - case KBD_NUM_LOCK: - if (make) { - ext->num_lock = !ext->num_lock; - SetLeds(ext); - } - break; - case KBD_SCROLL_LOCK: - if (make) { - ext->scroll_lock = !ext->scroll_lock; - SetLeds(ext); - } - break; - default: - break; - } - int pad = 0; - //首先处理小键盘 - if ((key >= KBD_PAD_SLASH) && (key <= KBD_PAD_9)) { - pad = 1; - } - /* 如果有组合件,就需要合成成为组合后的按钮,可以是ctl+alt+shift+按键的格式 */ - key |= ext->shift_left ? KBD_FLAG_SHIFT_L : 0; - key |= ext->shift_right ? KBD_FLAG_SHIFT_R : 0; - key |= ext->ctl_left ? KBD_FLAG_CTRL_L : 0; - key |= ext->ctl_right ? KBD_FLAG_CTRL_R : 0; - key |= ext->alt_left ? KBD_FLAG_ALT_L : 0; - key |= ext->alt_right ? KBD_FLAG_ALT_R : 0; - key |= pad ? KBD_FLAG_PAD : 0; - - /* 如果是BREAK,就需要添加BREAK标志 */ - key |= make ? 0: KBD_FLAG_BREAK; - - /* 设置锁标志 */ - key |= ext->num_lock ? KBD_FLAG_NUM : 0; - key |= ext->caps_lock ? KBD_FLAG_CAPS : 0; - - /* 把按键输出 */ - return key; - } - return KEYCODE_NONE; -} - -NX_PRIVATE NX_Error KeyboardRead(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - HalDeviceExtension * ext = device->extension; - - NX_InputEvent e; - - if (!len || len != sizeof(NX_InputEvent)) - { - return NX_EINVAL; - } - - if (NX_InputEventQueueGet(&ext->eventQueue, &e) != NX_EOK) - { - return NX_EAGAIN; - } - - NX_MemCopy(buf, &e, sizeof(NX_InputEvent)); - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_Error KeyboardControl(struct NX_Device *device, NX_U32 cmd, void *arg) -{ - HalDeviceExtension * ext = device->extension; - NX_U32 leds; - - NX_ASSERT(ext); - - switch (cmd) - { - case NX_INPUT_EVENT_CMD_GETLED: - leds = ext->num_lock | (ext->caps_lock << 1) | (ext->scroll_lock << 2); - NX_MemCopy(arg, &leds, sizeof(leds)); - break; - default: - return NX_EINVAL; - } - - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps KeyboardDriverOps = { - .read = KeyboardRead, - .control = KeyboardControl -}; - -NX_PRIVATE NX_Error KeyboardIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - HalDeviceExtension * kbd = (HalDeviceExtension *)arg; - - NX_U8 scan_code = IO_In8(KBC_READ_DATA); - /* save scan code to fifo buffer */ - NX_FifoPut(kbd->fifo, &scan_code, 1); - NX_SemaphoreSignal(&kbd->fifoSem); - return NX_EOK; -} - -NX_PRIVATE void KeyboardWorkerThread(void *arg) -{ - HalDeviceExtension *ext = (HalDeviceExtension *) arg; - NX_U32 key; - while (1) { - key = 0; - key = ParseKeyboard(ext); - if (key > 0 && (key & KBD_KEY_MASK)) - { - NX_InputEvent e; - e.type = NX_EV_KEY; - if (key & KBD_FLAG_BREAK) { - e.value = 0; - } else { - e.value = 1; - } - e.code = ScanCode2EventCode(key & KBD_KEY_MASK); - - NX_InputEventQueuePut(&ext->eventQueue, &e); - - NX_LOG_D("key even set: type=%d code=%x value=%d", e.type, e.code, e.value); - NX_LOG_D("key even buf: head=%d tail=%d", ext->eventQueue.head, ext->eventQueue.tail); - NX_LOG_D("kbd_thread: key:%c", key); - } - } -} - -NX_PRIVATE void KeyboardDriverInit(void) -{ - NX_Device *device; - HalDeviceExtension * kbd; - - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_INPUT, 0, &KeyboardDriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DEV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - kbd = &halKeyboardExtension; - device->extension = kbd; - - kbd->irq = IRQ_KEYBOARD; - kbd->flags = 0; - - /* 初始化私有数据 */ - kbd->code_with_e0 = 0; - - kbd->shift_left = kbd->shift_right = 0; - kbd->alt_left = kbd->alt_right = 0; - kbd->ctl_left = kbd->ctl_right = 0; - - kbd->caps_lock = 0; - kbd->num_lock = 1; - kbd->scroll_lock = 0; - - kbd->fifo = NX_FifoCreate(KBD_FIFO_MAX_SZ); - if (kbd->fifo == NX_NULL) - { - NX_LOG_E("create %s fifo failed!", DEV_NAME); - - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } - NX_SemaphoreInit(&kbd->fifoSem, 0); - NX_InputEventQueueInit(&kbd->eventQueue, KBD_EVENT_QUEUE_MAX_SZ); - - /* 发送写配置命令 */ - WAIT_KBC_WRITE(); - IO_Out8(KBC_CMD, KBC_CMD_WRITE_CONFIG); - - /* 往数据端口写入配置值 */ - WAIT_KBC_WRITE(); - IO_Out8(KBC_WRITE_DATA, KBC_CONFIG); - - NX_ASSERT(NX_IRQ_Bind(kbd->irq, KeyboardIrqHandler, kbd, "Keyboard", 0) == NX_EOK); - NX_ASSERT(NX_IRQ_Unmask(kbd->irq) == NX_EOK); - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - - NX_FifoDestroy(kbd->fifo); - - NX_ASSERT(NX_IRQ_Mask(kbd->irq) == NX_EOK); - NX_ASSERT(NX_IRQ_Unbind(kbd->irq, kbd) == NX_EOK); - NX_InputEventQueueExit(&kbd->eventQueue); - - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } - NX_ASSERT(NX_ThreadStart(NX_ThreadCreate("kbd_worker", KeyboardWorkerThread, kbd, NX_THREAD_PRIORITY_RT_MIN)) == NX_EOK); -} - -NX_PRIVATE void KeyboardDriverExit(void) -{ - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(KeyboardDriverInit); -NX_DRV_EXIT(KeyboardDriverExit); - -#endif /* CONFIG_NX_DRIVER_PS2_KEYBOARD */ diff --git a/src/platform/i386/drivers/ps2_keyboard.h b/src/platform/i386/drivers/ps2_keyboard.h deleted file mode 100644 index 8ffe78a..0000000 --- a/src/platform/i386/drivers/ps2_keyboard.h +++ /dev/null @@ -1,612 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: ps2 keyboard header - * - * Change Logs: - * Date Author Notes - * 2022-06-05 JasonHu Init - */ - -#ifndef __PS2_KEYBOARD_DRIVER_H__ -#define __PS2_KEYBOARD_DRIVER_H__ - -#include - -#include - -/* 键盘控制器端口 */ -enum kbd_controller_port { - KBC_READ_DATA = 0x60, /* 读取数据端口(R) */ - KBC_WRITE_DATA = 0x60, /* 写入数据端口(W) */ - KBC_STATUS = 0x64, /* 获取控制器状态(R) */ - KBC_CMD = 0x64, /* 向控制器发送命令(W) */ -}; - -/* 键盘控制器的命令 */ -enum kbd_controller_cmds { - KBC_CMD_READ_CONFIG = 0x20, /* 读取配置命令 */ - KBC_CMD_WRITE_CONFIG = 0x60, /* 写入配置命令 */ - KBC_CMD_DISABLE_MOUSE = 0xA7, /* 禁止鼠标端口 */ - KBC_CMD_ENABLE_MOUSE = 0xA8, /* 开启鼠标端口 */ - KBC_CMD_DISABLE_KEY = 0xAD, /* 禁止键盘通信,自动复位1控制器状态的第4位 */ - KBC_CMD_ENABLE_KEY = 0xAE, /* 开启键盘通信,自动置位0控制器状态的第4位 */ - KBC_CMD_SEND_TO_MOUSE = 0xD4, /* 向鼠标发送数据 */ - KBC_CMD_REBOOT_SYSTEM = 0xFE, /* 系统重启 */ -}; - -/* 键盘配置位 */ -enum kbd_controller_config { - KBC_CFG_ENABLE_KEY_INTR = (1 << 0), /* bit 0=1: 使能键盘中断IRQ1(IBE) */ - KBC_CFG_ENABLE_MOUSE_INTR = (1 << 1), /* bit 1=1: 使能鼠标中断IRQ12(MIBE) */ - KBC_CFG_INIT_DONE = (1 << 2), /* bit 2=1: 设置状态寄存器的位2 */ - KBC_CFG_IGNORE_STATUS_BIT4 = (1 << 3), /* bit 3=1: 忽略状态寄存器中的位4 */ - KBC_CFG_DISABLE_KEY = (1 << 4), /* bit 4=1: 禁止键盘 */ - KBC_CFG_DISABLE_MOUSE = (1 << 5), /* bit 5=1: 禁止鼠标 */ - KBC_CFG_SCAN_CODE_TRANS = (1 << 6), /* bit 6=1: 将第二套扫描码翻译为第一套 */ - /* bit 7 保留为0 */ -}; - -/* 键盘控制器状态位 */ -enum kbd_controller_status { - KBC_STATUS_OUT_BUF_FULL = (1 << 0), /* OUT_BUF_FULL: 输出缓冲器满置1,CPU读取后置0 */ - KBC_STATUS_INPUT_BUF_FULL = (1 << 1), /* INPUT_BUF_FULL: 输入缓冲器满置1,i8042 取走后置0 */ - KBC_STATUS_SYS_FLAG = (1 << 2), /* SYS_FLAG: 系统标志,加电启动置0,自检通过后置1 */ - KBC_STATUS_CMD_DATA = (1 << 3), /* CMD_DATA: 为1,输入缓冲器中的内容为命令,为0,输入缓冲器中的内容为数据。 */ - KBC_STATUS_KYBD_INH = (1 << 4), /* KYBD_INH: 为1,键盘没有被禁止。为0,键盘被禁止。 */ - KBC_STATUS_TRANS_TMOUT = (1 << 5), /* TRANS_TMOUT: 发送超时,置1 */ - KBC_STATUS_RCV_TMOUT = (1 << 6), /* RCV-TMOUT: 接收超时,置1 */ - KBC_STATUS_PARITY_EVEN = (1 << 7), /* PARITY-EVEN: 从键盘获得的数据奇偶校验错误 */ -}; - -/* 键盘控制器发送命令后 */ -enum kbd_controller_return_code { - /* 当击键或释放键时检测到错误时,则在Output Bufer后放入此字节, - 如果Output Buffer已满,则会将Output Buffer的最后一个字节替代为此字节。 - 使用Scan code set 1时使用00h,Scan code 2和Scan Code 3使用FFh。 */ - KBC_RET_KEY_ERROR_00 = 0x00, - KBC_RET_KEY_ERROR_FF = 0xFF, - - /* AAH, BAT完成代码。如果键盘检测成功,则会将此字节发送到8042 Output Register中。 */ - KBC_RET_BAT_OK = 0xAA, - - /* EEH, Echo响应。Keyboard使用EEh响应从60h发来的Echo请求。 */ - KBC_RET_ECHO = 0xEE, - - /* F0H, 在Scan code set 2和Scan code set 3中,被用作Break Code的前缀。*/ - KBC_RET_BREAK = 0xF0, - /* FAH, ACK。当Keyboard任何时候收到一个来自于60h端口的合法命令或合法数据之后, - 都回复一个FAh。 */ - KBC_RET_ACK = 0xFA, - - /* FCH, BAT失败代码。如果键盘检测失败,则会将此字节发送到8042 Output Register中。 */ - KBC_RET_BAT_BAD = 0xFC, - - /* FEH, 当Keyboard任何时候收到一个来自于60h端口的非法命令或非法数据之后, - 或者数据的奇偶交验错误,都回复一个FEh,要求系统重新发送相关命令或数据。 */ - KBC_RET_RESEND = 0xFE, -}; - -/* 单独发送给键盘的命令,有别于键盘控制器命令 -这些命令是发送到数据端口0x60,而不是命令0x64, -如果有参数,就在发送一次到0x60即可。 - */ -enum kbd_cmds { - /* LED灯亮/灭,参数如下: - 位2:Caps Lock灯 1(亮)/0(灭) - 位1:Num Lock灯 1(亮)/0(灭) - 位0:Scroll Lock灯 1(亮)/0(灭) - */ - KEY_CMD_LED_CODE = 0xED, /* 控制LED灯 */ - - /* 扫码集的参数: - 0x01: 取得当前扫描码(有返回值) - 0x02: 代表第一套扫描码 - 0x03: 代表第二套扫描码 - 0x04: 代表第三套扫描码 - */ - KEY_CMD_SET_SCAN_CODE = 0xF0, /* 设置键盘使用的扫码集*/ - KEY_CMD_GET_DEVICE_ID = 0xF2, /* 获取键盘设备的ID号(2B) */ - KEY_CMD_START_SCAN = 0xF4, /* 开启键盘扫描 */ - KEY_CMD_STOP_SCAN = 0xF5, /* 停止键盘扫描 */ - KEY_CMD_RESTART = 0xFF, /* 重启键盘 */ -}; - -/* 键盘控制器配置 */ -#define KBC_CONFIG (KBC_CFG_ENABLE_KEY_INTR | KBC_CFG_ENABLE_MOUSE_INTR | \ - KBC_CFG_INIT_DONE | KBC_CFG_SCAN_CODE_TRANS) - -/* 等待键盘控制器可写入,当输入缓冲区为空后才可以写入 */ -#define WAIT_KBC_WRITE() while(IO_In8(KBC_STATUS) & KBC_STATUS_INPUT_BUF_FULL); -/* 等待键盘控制器可读取,当输出缓冲区为空后才可以读取 */ -#define WAIT_KBC_READ() while(IO_In8(KBC_STATUS) & KBC_STATUS_OUT_BUF_FULL); - -#define KEYMAP_COLS 3 /* Number of columns in keymap */ -#define MAX_SCAN_CODE_NR 0x80 /* Number of scan codes (rows in keymap) */ - -/* raw key value = code passed to keyboard & MASK_RAW -the value can be found either in the keymap column 0 -or in the list below */ -#define KBD_MASK_RAW 0x01FF - -/* 键盘值屏蔽,通过key和mask与,就可以得出数值 */ -#define KBD_KEY_MASK 0x01FF - -#define KBD_FLAG_EXT 0x0100 /* Normal function keys */ - -/* 按键的一些标志 */ -#define KBD_FLAG_BREAK_MASK 0x0080 /* Break Code */ - -/* Special keys */ -#define KBD_ESC (0x01 + KBD_FLAG_EXT) /* Esc */ -#define KBD_TAB (0x02 + KBD_FLAG_EXT) /* Tab */ -#define KBD_ENTER (0x03 + KBD_FLAG_EXT) /* Enter */ -#define KBD_BACKSPACE (0x04 + KBD_FLAG_EXT) /* BackSpace */ - -/* Shift, Ctrl, Alt */ -#define KBD_SHIFT_L (0x05 + KBD_FLAG_EXT) /* L Shift */ -#define KBD_SHIFT_R (0x06 + KBD_FLAG_EXT) /* R Shift */ -#define KBD_CTRL_L (0x07 + KBD_FLAG_EXT) /* L Ctrl */ -#define KBD_CTRL_R (0x08 + KBD_FLAG_EXT) /* R Ctrl */ -#define KBD_ALT_L (0x09 + KBD_FLAG_EXT) /* L Alt */ -#define KBD_ALT_R (0x0a + KBD_FLAG_EXT) /* R Alt */ - -#define KBD_GUI_L (0x0b + KBD_FLAG_EXT) /* L GUI */ -#define KBD_GUI_R (0x0c + KBD_FLAG_EXT) /* R GUI */ -#define KBD_APPS (0x0d + KBD_FLAG_EXT) /* APPS */ - -/* Lock keys */ -#define KBD_CAPS_LOCK (0x0E + KBD_FLAG_EXT) /* Caps Lock */ -#define KBD_NUM_LOCK (0x0F + KBD_FLAG_EXT) /* Number Lock */ -#define KBD_SCROLL_LOCK (0x10 + KBD_FLAG_EXT) /* Scroll Lock */ - -/* Function keys */ -#define KBD_F1 (0x11 + KBD_FLAG_EXT) /* F1 */ -#define KBD_F2 (0x12 + KBD_FLAG_EXT) /* F2 */ -#define KBD_F3 (0x13 + KBD_FLAG_EXT) /* F3 */ -#define KBD_F4 (0x14 + KBD_FLAG_EXT) /* F4 */ -#define KBD_F5 (0x15 + KBD_FLAG_EXT) /* F5 */ -#define KBD_F6 (0x16 + KBD_FLAG_EXT) /* F6 */ -#define KBD_F7 (0x17 + KBD_FLAG_EXT) /* F7 */ -#define KBD_F8 (0x18 + KBD_FLAG_EXT) /* F8 */ -#define KBD_F9 (0x19 + KBD_FLAG_EXT) /* F9 */ -#define KBD_F10 (0x1A + KBD_FLAG_EXT) /* F10 */ -#define KBD_F11 (0x1B + KBD_FLAG_EXT) /* F11 */ -#define KBD_F12 (0x1C + KBD_FLAG_EXT) /* F12 */ - -/* Control Pad */ -#define KBD_PRINTSCREEN (0x1D + KBD_FLAG_EXT) /* Print Screen */ -#define KBD_PAUSEBREAK (0x1E + KBD_FLAG_EXT) /* Pause/Break */ -#define KBD_INSERT (0x1F + KBD_FLAG_EXT) /* Insert */ -#define KBD_DELETE (0x20 + KBD_FLAG_EXT) /* Delete */ -#define KBD_HOME (0x21 + KBD_FLAG_EXT) /* Home */ -#define KBD_END (0x22 + KBD_FLAG_EXT) /* End */ -#define KBD_PAGEUP (0x23 + KBD_FLAG_EXT) /* Page Up */ -#define KBD_PAGEDOWN (0x24 + KBD_FLAG_EXT) /* Page Down */ -#define KBD_UP (0x25 + KBD_FLAG_EXT) /* Up */ -#define KBD_DOWN (0x26 + KBD_FLAG_EXT) /* Down */ -#define KBD_LEFT (0x27 + KBD_FLAG_EXT) /* Left */ -#define KBD_RIGHT (0x28 + KBD_FLAG_EXT) /* Right */ - -/* ACPI keys */ -#define KBD_POWER (0x29 + KBD_FLAG_EXT) /* Power */ -#define KBD_SLEEP (0x2A + KBD_FLAG_EXT) /* Sleep */ -#define KBD_WAKE (0x2B + KBD_FLAG_EXT) /* Wake Up */ - -/* Num Pad */ -#define KBD_PAD_SLASH (0x2C + KBD_FLAG_EXT) /* / */ -#define KBD_PAD_STAR (0x2D + KBD_FLAG_EXT) /* * */ -#define KBD_PAD_MINUS (0x2E + KBD_FLAG_EXT) /* - */ -#define KBD_PAD_PLUS (0x2F + KBD_FLAG_EXT) /* + */ -#define KBD_PAD_ENTER (0x30 + KBD_FLAG_EXT) /* Enter */ -#define KBD_PAD_DOT (0x31 + KBD_FLAG_EXT) /* . */ -#define KBD_PAD_0 (0x32 + KBD_FLAG_EXT) /* 0 */ -#define KBD_PAD_1 (0x33 + KBD_FLAG_EXT) /* 1 */ -#define KBD_PAD_2 (0x34 + KBD_FLAG_EXT) /* 2 */ -#define KBD_PAD_3 (0x35 + KBD_FLAG_EXT) /* 3 */ -#define KBD_PAD_4 (0x36 + KBD_FLAG_EXT) /* 4 */ -#define KBD_PAD_5 (0x37 + KBD_FLAG_EXT) /* 5 */ -#define KBD_PAD_6 (0x38 + KBD_FLAG_EXT) /* 6 */ -#define KBD_PAD_7 (0x39 + KBD_FLAG_EXT) /* 7 */ -#define KBD_PAD_8 (0x3A + KBD_FLAG_EXT) /* 8 */ -#define KBD_PAD_9 (0x3B + KBD_FLAG_EXT) /* 9 */ -#define KBD_PAD_UP KBD_PAD_8 /* Up */ -#define KBD_PAD_DOWN KBD_PAD_2 /* Down */ -#define KBD_PAD_LEFT KBD_PAD_4 /* Left */ -#define KBD_PAD_RIGHT KBD_PAD_6 /* Right */ -#define KBD_PAD_HOME KBD_PAD_7 /* Home */ -#define KBD_PAD_END KBD_PAD_1 /* End */ -#define KBD_PAD_PAGEUP KBD_PAD_9 /* Page Up */ -#define KBD_PAD_PAGEDOWN KBD_PAD_3 /* Page Down */ -#define KBD_PAD_INS KBD_PAD_0 /* Ins */ -#define KBD_PAD_MID KBD_PAD_5 /* Middle key */ -#define KBD_PAD_DEL KBD_PAD_DOT /* Del */ - -/* 按键码 */ -#define KEYCODE_NONE 0 /* 没有按键 */ - -/* 控制标志 */ -enum InputKeycodeFlags { - KBD_FLAG_KEY_MASK = 0x1FF, /* 键值的mask值 */ - KBD_FLAG_SHIFT_L = 0x0200, /* Shift key */ - KBD_FLAG_SHIFT_R = 0x0400, /* Shift key */ - KBD_FLAG_CTRL_L = 0x0800, /* Control key */ - KBD_FLAG_CTRL_R = 0x1000, /* Control key */ - KBD_FLAG_ALT_L = 0x2000, /* Alternate key */ - KBD_FLAG_ALT_R = 0x4000, /* Alternate key */ - KBD_FLAG_PAD = 0x8000, /* keys in num pad */ - KBD_FLAG_NUM = 0x10000, /* 数字锁 */ - KBD_FLAG_CAPS = 0x20000, /* 数字锁 */ - KBD_FLAG_BREAK = 0x40000, /* Break Code */ -}; - -/* Keymap for US MF-2 ext-> */ -static NX_U32 kbd_keymap[MAX_SCAN_CODE_NR * KEYMAP_COLS] = { - -/* scan-code !Shift Shift E0 XX */ -/* ==================================================================== */ -/* 0x00 - none */ 0, 0, 0, -/* 0x01 - ESC */ KBD_ESC, KBD_ESC, 0, -/* 0x02 - '1' */ '1', '!', 0, -/* 0x03 - '2' */ '2', '@', 0, -/* 0x04 - '3' */ '3', '#', 0, -/* 0x05 - '4' */ '4', '$', 0, -/* 0x06 - '5' */ '5', '%', 0, -/* 0x07 - '6' */ '6', '^', 0, -/* 0x08 - '7' */ '7', '&', 0, -/* 0x09 - '8' */ '8', '*', 0, -/* 0x0A - '9' */ '9', '(', 0, -/* 0x0B - '0' */ '0', ')', 0, -/* 0x0C - '-' */ '-', '_', 0, -/* 0x0D - '=' */ '=', '+', 0, -/* 0x0E - BS */ KBD_BACKSPACE, KBD_BACKSPACE, 0, -/* 0x0F - TAB */ KBD_TAB, KBD_TAB, 0, -/* 0x10 - 'q' */ 'q', 'Q', 0, -/* 0x11 - 'w' */ 'w', 'W', 0, -/* 0x12 - 'e' */ 'e', 'E', 0, -/* 0x13 - 'r' */ 'r', 'R', 0, -/* 0x14 - 't' */ 't', 'T', 0, -/* 0x15 - 'y' */ 'y', 'Y', 0, -/* 0x16 - 'u' */ 'u', 'U', 0, -/* 0x17 - 'i' */ 'i', 'I', 0, -/* 0x18 - 'o' */ 'o', 'O', 0, -/* 0x19 - 'p' */ 'p', 'P', 0, -/* 0x1A - '[' */ '[', '{', 0, -/* 0x1B - ']' */ ']', '}', 0, -/* 0x1C - CR/LF */ KBD_ENTER, KBD_ENTER, 0, -/* 0x1D - l. Ctrl */ KBD_CTRL_L, KBD_CTRL_L, KBD_CTRL_R, -/* 0x1E - 'a' */ 'a', 'A', 0, -/* 0x1F - 's' */ 's', 'S', 0, -/* 0x20 - 'd' */ 'd', 'D', 0, -/* 0x21 - 'f' */ 'f', 'F', 0, -/* 0x22 - 'g' */ 'g', 'G', 0, -/* 0x23 - 'h' */ 'h', 'H', 0, -/* 0x24 - 'j' */ 'j', 'J', 0, -/* 0x25 - 'k' */ 'k', 'K', 0, -/* 0x26 - 'l' */ 'l', 'L', 0, -/* 0x27 - ';' */ ';', ':', 0, -/* 0x28 - '\'' */ '\'', '"', 0, -/* 0x29 - '`' */ '`', '~', 0, -/* 0x2A - l. SHIFT */ KBD_SHIFT_L, KBD_SHIFT_L, 0, -/* 0x2B - '\' */ '\\', '|', 0, -/* 0x2C - 'z' */ 'z', 'Z', 0, -/* 0x2D - 'x' */ 'x', 'X', 0, -/* 0x2E - 'c' */ 'c', 'C', 0, -/* 0x2F - 'v' */ 'v', 'V', 0, -/* 0x30 - 'b' */ 'b', 'B', 0, -/* 0x31 - 'n' */ 'n', 'N', 0, -/* 0x32 - 'm' */ 'm', 'M', 0, -/* 0x33 - ',' */ ',', '<', 0, -/* 0x34 - '.' */ '.', '>', 0, -/* 0x35 - '/' */ '/', '?', KBD_PAD_SLASH, -/* 0x36 - r. SHIFT */ KBD_SHIFT_R, KBD_SHIFT_R, 0, -/* 0x37 - '*' */ KBD_PAD_STAR, '*', 0, -/* 0x38 - ALT */ KBD_ALT_L, KBD_ALT_L, KBD_ALT_R, -/* 0x39 - ' ' */ ' ', ' ', 0, -/* 0x3A - caps_lock */ KBD_CAPS_LOCK, KBD_CAPS_LOCK, 0, -/* 0x3B - F1 */ KBD_F1, KBD_F1, 0, -/* 0x3C - F2 */ KBD_F2, KBD_F2, 0, -/* 0x3D - F3 */ KBD_F3, KBD_F3, 0, -/* 0x3E - F4 */ KBD_F4, KBD_F4, 0, -/* 0x3F - F5 */ KBD_F5, KBD_F5, 0, -/* 0x40 - F6 */ KBD_F6, KBD_F6, 0, -/* 0x41 - F7 */ KBD_F7, KBD_F7, 0, -/* 0x42 - F8 */ KBD_F8, KBD_F8, 0, -/* 0x43 - F9 */ KBD_F9, KBD_F9, 0, -/* 0x44 - F10 */ KBD_F10, KBD_F10, 0, -/* 0x45 - num_lock */ KBD_NUM_LOCK, KBD_NUM_LOCK, 0, -/* 0x46 - ScrLock */ KBD_SCROLL_LOCK, KBD_SCROLL_LOCK, 0, -/* 0x47 - Home */ KBD_PAD_HOME, '7', KBD_HOME, -/* 0x48 - CurUp */ KBD_PAD_UP, '8', KBD_UP, -/* 0x49 - PgUp */ KBD_PAD_PAGEUP, '9', KBD_PAGEUP, -/* 0x4A - '-' */ KBD_PAD_MINUS, '-', 0, -/* 0x4B - Left */ KBD_PAD_LEFT, '4', KBD_LEFT, -/* 0x4C - MID */ KBD_PAD_MID, '5', 0, -/* 0x4D - Right */ KBD_PAD_RIGHT, '6', KBD_RIGHT, -/* 0x4E - '+' */ KBD_PAD_PLUS, '+', 0, -/* 0x4F - End */ KBD_PAD_END, '1', KBD_END, -/* 0x50 - Down */ KBD_PAD_DOWN, '2', KBD_DOWN, -/* 0x51 - PgDown */ KBD_PAD_PAGEDOWN, '3', KBD_PAGEDOWN, -/* 0x52 - Insert */ KBD_PAD_INS, '0', KBD_INSERT, -/* 0x53 - Delete */ KBD_PAD_DOT, '.', KBD_DELETE, -/* 0x54 - Enter */ KBD_PAD_ENTER, KBD_ENTER, KBD_ENTER, -/* 0x55 - ??? */ 0, 0, 0, -/* 0x56 - ??? */ 0, 0, 0, -/* 0x57 - F11 */ KBD_F11, KBD_F11, 0, -/* 0x58 - F12 */ KBD_F12, KBD_F12, 0, -/* 0x59 - ??? */ 0, 0, 0, -/* 0x5A - ??? */ 0, 0, 0, -/* 0x5B - ??? */ 0, 0, KBD_GUI_L, -/* 0x5C - ??? */ 0, 0, KBD_GUI_R, -/* 0x5D - ??? */ 0, 0, KBD_APPS, -/* 0x5E - ??? */ 0, 0, 0, -/* 0x5F - ??? */ 0, 0, 0, -/* 0x60 - ??? */ 0, 0, 0, -/* 0x61 - ??? */ 0, 0, 0, -/* 0x62 - ??? */ 0, 0, 0, -/* 0x63 - ??? */ 0, 0, 0, -/* 0x64 - ??? */ 0, 0, 0, -/* 0x65 - ??? */ 0, 0, 0, -/* 0x66 - ??? */ 0, 0, 0, -/* 0x67 - ??? */ 0, 0, 0, -/* 0x68 - ??? */ 0, 0, 0, -/* 0x69 - ??? */ 0, 0, 0, -/* 0x6A - ??? */ 0, 0, 0, -/* 0x6B - ??? */ 0, 0, 0, -/* 0x6C - ??? */ 0, 0, 0, -/* 0x6D - ??? */ 0, 0, 0, -/* 0x6E - ??? */ 0, 0, 0, -/* 0x6F - ??? */ 0, 0, 0, -/* 0x70 - ??? */ 0, 0, 0, -/* 0x71 - ??? */ 0, 0, 0, -/* 0x72 - ??? */ 0, 0, 0, -/* 0x73 - ??? */ 0, 0, 0, -/* 0x74 - ??? */ 0, 0, 0, -/* 0x75 - ??? */ 0, 0, 0, -/* 0x76 - ??? */ 0, 0, 0, -/* 0x77 - ??? */ 0, 0, 0, -/* 0x78 - ??? */ 0, 0, 0, -/* 0x78 - ??? */ 0, 0, 0, -/* 0x7A - ??? */ 0, 0, 0, -/* 0x7B - ??? */ 0, 0, 0, -/* 0x7C - ??? */ 0, 0, 0, -/* 0x7D - ??? */ 0, 0, 0, -/* 0x7E - ??? */ 0, 0, 0, -/* 0x7F - ??? */ 0, 0, 0 -}; - -/*====================================================================================* - Appendix: Scan code set 1 - *====================================================================================* - -KEY MAKE BREAK ----- KEY MAKE BREAK ----- KEY MAKE BREAK --------------------------------------------------------------------------------------- -A 1E 9E 9 0A 8A [ 1A 9A -B 30 B0 ` 29 89 INSERT E0,52 E0,D2 -C 2E AE - 0C 8C HOME E0,47 E0,C7 -D 20 A0 = 0D 8D PG UP E0,49 E0,C9 -E 12 92 \ 2B AB DELETE E0,53 E0,D3 -F 21 A1 BKSP 0E 8E END E0,4F E0,CF -G 22 A2 SPACE 39 B9 PG DN E0,51 E0,D1 -H 23 A3 TAB 0F 8F U ARROW E0,48 E0,C8 -I 17 97 CAPS 3A BA L ARROW E0,4B E0,CB -J 24 A4 L SHFT 2A AA D ARROW E0,50 E0,D0 -K 25 A5 L CTRL 1D 9D R ARROW E0,4D E0,CD -L 26 A6 L GUI E0,5B E0,DB NUM 45 C5 -M 32 B2 L ALT 38 B8 KP / E0,35 E0,B5 -N 31 B1 R SHFT 36 B6 KP * 37 B7 -O 18 98 R CTRL E0,1D E0,9D KP - 4A CA -P 19 99 R GUI E0,5C E0,DC KP + 4E CE -Q 10 19 R ALT E0,38 E0,B8 KP EN E0,1C E0,9C -R 13 93 APPS E0,5D E0,DD KP . 53 D3 -S 1F 9F ENTER 1C 9C KP 0 52 D2 -T 14 94 ESC 01 81 KP 1 4F CF -U 16 96 F1 3B BB KP 2 50 D0 -V 2F AF F2 3C BC KP 3 51 D1 -W 11 91 F3 3D BD KP 4 4B CB -X 2D AD F4 3E BE KP 5 4C CC -Y 15 95 F5 3F BF KP 6 4D CD -Z 2C AC F6 40 C0 KP 7 47 C7 -0 0B 8B F7 41 C1 KP 8 48 C8 -1 02 82 F8 42 C2 KP 9 49 C9 -2 03 83 F9 43 C3 ] 1B 9B -3 04 84 F10 44 C4 ; 27 A7 -4 05 85 F11 57 D7 ' 28 A8 -5 06 86 F12 58 D8 , 33 B3 - -6 07 87 PRTSCRN E0,2A E0,B7 . 34 B4 - E0,37 E0,AA - -7 08 88 SCROLL 46 C6 / 35 B5 - -8 09 89 PAUSE E1,1D,45 -NONE- - E1,9D,C5 ------------------ -ACPI Scan Codes: -------------------------------------------- -Key Make Code Break Code -------------------------------------------- -Power E0, 5E E0, DE -Sleep E0, 5F E0, DF -Wake E0, 63 E0, E3 -------------------------------- -Windows Multimedia Scan Codes: -------------------------------------------- -Key Make Code Break Code -------------------------------------------- -Next Track E0, 19 E0, 99 -Previous Track E0, 10 E0, 90 -Stop E0, 24 E0, A4 -Play/Pause E0, 22 E0, A2 -Mute E0, 20 E0, A0 -Volume Up E0, 30 E0, B0 -Volume Down E0, 2E E0, AE -Media Select E0, 6D E0, ED -E-Mail E0, 6C E0, EC -Calculator E0, 21 E0, A1 -My Computer E0, 6B E0, EB -WWW Search E0, 65 E0, E5 -WWW Home E0, 32 E0, B2 -WWW Back E0, 6A E0, EA -WWW Forward E0, 69 E0, E9 -WWW Stop E0, 68 E0, E8 -WWW Refresh E0, 67 E0, E7 -WWW Favorites E0, 66 E0, E6 -*=====================================================================================*/ - -/* 键值表,和InputKeycode对应 */ -static const unsigned short map_table[] = { - KBD_PAUSEBREAK, NX_KEY_PAUSE, - KBD_UP, NX_KEY_UP, - KBD_DOWN, NX_KEY_DOWN, - KBD_LEFT, NX_KEY_LEFT, - KBD_RIGHT, NX_KEY_RIGHT, - KBD_BACKSPACE, NX_KEY_BACKSPACE, - KBD_TAB, NX_KEY_TAB, - KBD_INSERT, NX_KEY_INSERT, - KBD_HOME, NX_KEY_HOME, - KBD_END, NX_KEY_END, - KBD_ENTER, NX_KEY_ENTER, - KBD_PAGEUP, NX_KEY_PAGEUP, - KBD_PAGEDOWN, NX_KEY_PAGEDOWN, - KBD_F1, NX_KEY_F1, - KBD_F2, NX_KEY_F2, - KBD_F3, NX_KEY_F3, - KBD_F4, NX_KEY_F4, - KBD_F5, NX_KEY_F5, - KBD_F6, NX_KEY_F6, - KBD_F7, NX_KEY_F7, - KBD_F8, NX_KEY_F8, - KBD_F9, NX_KEY_F9, - KBD_F10, NX_KEY_F10, - KBD_F11, NX_KEY_F11, - KBD_ESC, NX_KEY_ESCAPE, - KBD_F12, NX_KEY_F12, - ' ', NX_KEY_SPACE, - '!', NX_KEY_EXCLAIM, - '"', NX_KEY_QUOTEDBL, - '#', NX_KEY_HASH, - '$', NX_KEY_DOLLAR, - '%', NX_KEY_PERSENT, - '&', NX_KEY_AMPERSAND, - '\'', NX_KEY_QUOTE, - '(', NX_KEY_LEFTPAREN, - ')', NX_KEY_RIGHTPAREN, - '*', NX_KEY_ASTERISK, - '+', NX_KEY_PLUS, - ',', NX_KEY_COMMA, - '-', NX_KEY_MINUS, - '.', NX_KEY_PERIOD, - '/', NX_KEY_SLASH, - '0', NX_KEY_0, - '1', NX_KEY_1, - '2', NX_KEY_2, - '3', NX_KEY_3, - '4', NX_KEY_4, - '5', NX_KEY_5, - '6', NX_KEY_6, - '7', NX_KEY_7, - '8', NX_KEY_8, - '9', NX_KEY_9, - ':', NX_KEY_COLON, - ';', NX_KEY_SEMICOLON, - '<', NX_KEY_LESS, - '=', NX_KEY_EQUALS, - '>', NX_KEY_GREATER, - '?', NX_KEY_QUESTION, - '@', NX_KEY_AT, - 'A', NX_KEY_A, - 'B', NX_KEY_B, - 'C', NX_KEY_C, - 'D', NX_KEY_D, - 'E', NX_KEY_E, - 'F', NX_KEY_F, - 'G', NX_KEY_G, - 'H', NX_KEY_H, - 'I', NX_KEY_I, - 'J', NX_KEY_J, - 'K', NX_KEY_K, - 'L', NX_KEY_L, - 'M', NX_KEY_M, - 'N', NX_KEY_N, - 'O', NX_KEY_O, - 'P', NX_KEY_P, - 'Q', NX_KEY_Q, - 'R', NX_KEY_R, - 'S', NX_KEY_S, - 'T', NX_KEY_T, - 'U', NX_KEY_U, - 'V', NX_KEY_V, - 'W', NX_KEY_W, - 'X', NX_KEY_X, - 'Y', NX_KEY_Y, - 'Z', NX_KEY_Z, - '[', NX_KEY_LEFTSQUAREBRACKET, - '\\', NX_KEY_BACKSLASH, - ']', NX_KEY_RIGHTSQUAREBRACKET, - '^', NX_KEY_CARET, - '_', NX_KEY_UNDERSCRE, - '`', NX_KEY_BACKQUOTE, - 'a', NX_KEY_a, - 'b', NX_KEY_b, - 'c', NX_KEY_c, - 'd', NX_KEY_d, - 'e', NX_KEY_e, - 'f', NX_KEY_f, - 'g', NX_KEY_g, - 'h', NX_KEY_h, - 'i', NX_KEY_i, - 'j', NX_KEY_j, - 'k', NX_KEY_k, - 'l', NX_KEY_l, - 'm', NX_KEY_m, - 'n', NX_KEY_n, - 'o', NX_KEY_o, - 'p', NX_KEY_p, - 'q', NX_KEY_q, - 'r', NX_KEY_r, - 's', NX_KEY_s, - 't', NX_KEY_t, - 'u', NX_KEY_u, - 'v', NX_KEY_v, - 'w', NX_KEY_w, - 'x', NX_KEY_x, - 'y', NX_KEY_y, - 'z', NX_KEY_z, - '{', NX_KEY_LEFTBRACKET, - '|', NX_KEY_VERTICAL, - '}', NX_KEY_RIGHTBRACKET, - '~', NX_KEY_TILDE, - KBD_DELETE, NX_KEY_DELETE, - KBD_PAD_0, NX_KEY_KP0, - KBD_PAD_1, NX_KEY_KP1, - KBD_PAD_2, NX_KEY_KP2, - KBD_PAD_3, NX_KEY_KP3, - KBD_PAD_4, NX_KEY_KP4, - KBD_PAD_5, NX_KEY_KP5, - KBD_PAD_6, NX_KEY_KP6, - KBD_PAD_7, NX_KEY_KP7, - KBD_PAD_8, NX_KEY_KP8, - KBD_PAD_9, NX_KEY_KP9, - KBD_PAD_DOT, NX_KEY_KP_PERIOD, - KBD_PAD_SLASH, NX_KEY_KP_DIVIDE, - KBD_PAD_STAR, NX_KEY_KP_MULTIPLY, - KBD_PAD_MINUS, NX_KEY_KP_MINUS, - KBD_PAD_PLUS, NX_KEY_KP_PLUS, - KBD_PAD_ENTER, NX_KEY_KP_ENTER, - KBD_PAD_ENTER, NX_KEY_KP_EQUALS, - KBD_NUM_LOCK, NX_KEY_NUMLOCK, - KBD_CAPS_LOCK, NX_KEY_CAPSLOCK, - KBD_SCROLL_LOCK, NX_KEY_SCROLLOCK, - KBD_SHIFT_R, NX_KEY_RSHIFT, - KBD_SHIFT_L, NX_KEY_LSHIFT, - KBD_CTRL_R, NX_KEY_RCTRL, - KBD_CTRL_L, NX_KEY_LCTRL, - KBD_ALT_R, NX_KEY_RALT, - KBD_ALT_L, NX_KEY_LALT, - KBD_PRINTSCREEN, NX_KEY_PRINT, - KBD_PAUSEBREAK, NX_KEY_BREAK -}; - -#endif /* __PS2_KEYBOARD_DRIVER_H__ */ diff --git a/src/platform/i386/drivers/ps2_keyboard_irq.c b/src/platform/i386/drivers/ps2_keyboard_irq.c deleted file mode 100644 index 1fd8f45..0000000 --- a/src/platform/i386/drivers/ps2_keyboard_irq.c +++ /dev/null @@ -1,244 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: keyboard driver - * - * Change Logs: - * Date Author Notes - * 2022-06-03 JasonHu Init - */ - -#define NX_LOG_NAME "ps2keyboard irq" -#define NX_LOG_LEVEL NX_LOG_INFO -#include - -#ifdef CONFIG_NX_DRIVER_PS2_KEYBOARD_IRQ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#define DRV_NAME "ps2 keyboard irq driver" -#define DRV_VERSION "0.1" - -#define DEV_NAME "ps2keyboard_irq" - -#define KBD_FIFO_MAX_SZ 32 - -#define KBC_READ_DATA 0x60 - -typedef struct HalDeviceExtension -{ - char irq; /* irq号 */ - NX_Fifo * fifo; - NX_Semaphore fifoSem; - NX_Bool opened; /* irq driver opened */ -} HalDeviceExtension; - -NX_PRIVATE HalDeviceExtension halPs2KeyboardIrqExtension; - -NX_PRIVATE NX_Error Ps2KeyboardIrqOpen(struct NX_Device *device, NX_U32 flags) -{ - HalDeviceExtension * kbd = (HalDeviceExtension *)device->extension; - - NX_LOG_D("KBD IRQ OPEN"); - NX_FifoReset(kbd->fifo); - NX_SemaphoreInit(&kbd->fifoSem, 0); - - kbd->opened = NX_True; - - return NX_EOK; -} - -NX_PRIVATE NX_Error Ps2KeyboardIrqClose(struct NX_Device *device) -{ - HalDeviceExtension * kbd = (HalDeviceExtension *)device->extension; - NX_LOG_D("KBD IRQ CLOSE"); - /* disable irq */ - kbd->opened = NX_False; - NX_SemaphoreInit(&kbd->fifoSem, 0); - NX_FifoReset(kbd->fifo); - NX_IRQ_Mask(kbd->irq); - - return NX_EOK; -} - -/* read irq data */ -NX_PRIVATE NX_Error Ps2KeyboardIrqRead(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - HalDeviceExtension * ext = device->extension; - - if (!len || len != 1) - { - return NX_EINVAL; - } - - if (ext->opened == NX_False) - { - NX_LOG_W("kbd irq not open\n"); - if (outLen) - { - *outLen = 0; - } - return NX_ENORES; - } - - NX_U8 scan_code = 0; - if (NX_SemaphoreWait(&ext->fifoSem) != NX_EOK) - { - NX_LOG_D("kbd irq wait intr\n"); - if (outLen) - { - *outLen = 0; - } - return NX_EINTR; - } - - if (!NX_FifoGet(ext->fifo, &scan_code, 1)) - { - NX_LOG_W("kbd irq fifo no data\n"); - if (outLen) - { - *outLen = 0; - } - return NX_ENORES; - } - - NX_MemCopy(buf, &scan_code, 1); - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_Error Ps2KeyboardIrqControl(struct NX_Device *device, NX_U32 cmd, void *arg) -{ - HalDeviceExtension * ext = device->extension; - - switch (cmd) - { - case NX_IRQ_CMD_MASK: - NX_IRQ_Mask(ext->irq); - break; - case NX_IRQ_CMD_UNMASK: - NX_IRQ_Unmask(ext->irq); - break; - - default: - break; - } - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps ps2KeyboardIrqDriverOps = { - .read = Ps2KeyboardIrqRead, - .open = Ps2KeyboardIrqOpen, - .close = Ps2KeyboardIrqClose, - .control = Ps2KeyboardIrqControl, -}; - -NX_PRIVATE NX_Error Ps2KeyboardIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - HalDeviceExtension * kbd = (HalDeviceExtension *)arg; - NX_U8 scan_code = IO_In8(KBC_READ_DATA); - NX_LOG_D("KBD IRQ OCCUR"); - /* save scan code to fifo buffer */ - if (kbd->opened) - { - NX_FifoPut(kbd->fifo, &scan_code, 1); - NX_SemaphoreSignal(&kbd->fifoSem); - } - return NX_EOK; -} - -NX_PRIVATE void Ps2KeyboardIrqDriverInit(void) -{ - NX_Device *device; - HalDeviceExtension * kbd; - - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_IRQ, 0, &ps2KeyboardIrqDriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DEV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - kbd = &halPs2KeyboardIrqExtension; - device->extension = kbd; - - kbd->opened = NX_False; - kbd->irq = IRQ_KEYBOARD; - kbd->fifo = NX_FifoCreate(KBD_FIFO_MAX_SZ); - if (kbd->fifo == NX_NULL) - { - NX_LOG_E("create %s fifo failed!", DEV_NAME); - - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } - NX_SemaphoreInit(&kbd->fifoSem, 0); - - NX_ASSERT(NX_IRQ_Bind(kbd->irq, Ps2KeyboardIrqHandler, kbd, "ps2Keyboard", 0) == NX_EOK); - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - - NX_FifoDestroy(kbd->fifo); - - NX_ASSERT(NX_IRQ_Mask(kbd->irq) == NX_EOK); - NX_ASSERT(NX_IRQ_Unbind(kbd->irq, kbd) == NX_EOK); - - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } -} - -NX_PRIVATE void Ps2KeyboardIrqDriverExit(void) -{ - NX_Device * dev; - HalDeviceExtension * kbd; - - dev = NX_DeviceSearch(DEV_NAME); - if (dev) - { - kbd = (HalDeviceExtension *)dev->extension; - - if (kbd->fifo) - { - NX_FifoDestroy(kbd->fifo); - } - - NX_IRQ_Mask(kbd->irq); - NX_IRQ_Unbind(kbd->irq, kbd); - } - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(Ps2KeyboardIrqDriverInit); -NX_DRV_EXIT(Ps2KeyboardIrqDriverExit); - -#endif /* CONFIG_NX_DRIVER_PS2_KEYBOARD_IRQ */ diff --git a/src/platform/i386/drivers/ps2_mouse.c b/src/platform/i386/drivers/ps2_mouse.c deleted file mode 100644 index a186f46..0000000 --- a/src/platform/i386/drivers/ps2_mouse.c +++ /dev/null @@ -1,568 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: mouse driver - * - * Change Logs: - * Date Author Notes - * 2022-06-05 JasonHu Init - */ - -#define NX_LOG_NAME "ps2mouse" -#define NX_LOG_LEVEL NX_LOG_INFO -#include - -#ifdef CONFIG_NX_DRIVER_PS2_MOUSE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#define DRV_NAME "ps2 mouse driver" -#define DRV_VERSION "0.1" - -#define DNX_EV_NAME "mouse0" - -#define I8042_BUFFER 0x60 -#define I8042_STATUS 0x64 -#define I8042_ACK 0xFA -#define I8042_BUFFER_FULL 0x01 -#define I8042_WHICH_BUFFER 0x20 -#define I8042_MOUSE_BUFFER 0x20 -#define I8042_KEYBOARD_BUFFER 0x00 - -#define PS2MOUSE_SET_RESOLUTION 0xE8 -#define PS2MOUSE_STATUS_REQUEST 0xE9 -#define PS2MOUSE_REQUEST_SINGLE_PACKET 0xEB -#define PS2MOUSE_GET_DEVICE_ID 0xF2 -#define PS2MOUSE_SET_SAMPLE_RATE 0xF3 -#define PS2MOUSE_ENABLE_PACKET_STREAMING 0xF4 -#define PS2MOUSE_DISABLE_PACKET_STREAMING 0xF5 -#define PS2MOUSE_SET_DEFAULTS 0xF6 -#define PS2MOUSE_RESEND 0xFE -#define PS2MOUSE_RESET 0xFF - -#define PS2MOUSE_LEFT_CLICK 0x01 -#define PS2MOUSE_RIGHT_CLICK 0x02 -#define PS2MOUSE_MIDDLE_CLICK 0x04 - -#define PS2MOUSE_INTELLIMOUSE_ID 0x03 - -#define MOUSE_EVENT_QUEUE_MAX_SZ 64 - -/* -mouse data packet: -data0: 7: y overflow, 6: x overflow, 5: y sign bit, 4: x sign bit, - 3: alawys 1 , 2: middle btn, 1: right btn , 0: left btn . -data1: x 移动值 -data2: y 移动值 -data3: z 移动值 (如果设备支持) -data4: 7: y always 0, 6: always 0, 5: 鼠标第5键, 4: 鼠标第4键, - 3: 滚轮水平左滚动, 2: 滚轮水平右滚动, 1: 滚轮垂直下滚动, 0: 滚轮垂直上滚动. - (如果设备支持) -*/ -typedef struct HalDeviceExtension -{ - char irq; /* irq号 */ - NX_InputEventQueue eventQueue; - /* 按键记录: - bit 0 置1表示左键已经按下。 - bit 1 置1表示右键已经按下。 - bit 2 置1表示中键已经按下。 - */ - NX_U8 button_record; - NX_Bool has_wheel; /* device has wheel ? */ - NX_Bool device_present; /* does device exist ? */ - NX_U8 data_state; /* mouse data state, index in data table */ - NX_U8 data[4]; /* mouse data get from hardware */ - NX_U32 flags; -} HalDeviceExtension; - -NX_PRIVATE HalDeviceExtension halMouseExtension; - -NX_PRIVATE NX_U8 ps2mouse_read_data(); -NX_PRIVATE void ps2mouse_write_data(NX_U8 data); -NX_PRIVATE void ps2mouse_prepare_for_output(); -NX_PRIVATE void ps2mouse_prepare_for_input(); -NX_PRIVATE void ps2mouse_expect_ack(); -NX_PRIVATE void ps2mouse_initialize_device(HalDeviceExtension *devext); -NX_PRIVATE void ps2mouse_check_device_presence(HalDeviceExtension *devext); -NX_PRIVATE void ps2mouse_initialize(HalDeviceExtension *devext); -NX_PRIVATE NX_U8 ps2mouse_wait_then_read(NX_U8 port); -NX_PRIVATE void ps2mouse_wait_then_write(NX_U8 port, NX_U8 data); -NX_PRIVATE NX_Error MouseIrqHandler(NX_IRQ_Number irqno, void *arg); - -NX_PRIVATE void parse_data_packet(HalDeviceExtension *devext) -{ - int x = devext->data[1]; - int y = devext->data[2]; - int z = 0; - if (devext->has_wheel) - { - z = (char)devext->data[3]; - } - NX_Bool x_overflow = devext->data[0] & 0x40; - NX_Bool y_overflow = devext->data[0] & 0x80; - NX_Bool x_sign = devext->data[0] & 0x10; - NX_Bool y_sign = devext->data[0] & 0x20; - if (x && x_sign) - { - x -= 0x100; - } - if (y && y_sign) - { - y -= 0x100; - } - if (x_overflow || y_overflow) - { - x = 0; - y = 0; - } - - NX_InputEvent e; - /* 水平方向 */ - if (x) { /* x轴有变化 */ - e.type = NX_EV_REL; - e.code = NX_REL_X; - e.value = x; - - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - /* 垂直方向 */ - if (y) { /* x轴有变化 */ - e.type = NX_EV_REL; - e.code = NX_REL_Y; - y = -y; /* y是倒立的 */ - e.value = y; - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - /* 纵深方向 */ - if (z) { /* z轴有变化 */ - e.type = NX_EV_REL; - e.code = NX_REL_WHEEL; - e.value = z; - - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - /* 同步鼠标移动 */ - e.type = NX_EV_SYNC; - e.code = 0; - e.value = 0; - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - - /* 按钮 */ - devext->data[0] &= 0x07; /* 只取低3位 */ - if (devext->data[0] & PS2MOUSE_LEFT_CLICK) - { /* left button */ - if (!(devext->button_record & PS2MOUSE_LEFT_CLICK)) - { /* left button not pressed */ - devext->button_record |= 0x01; /* record */ - - /* 鼠标左键按下 */ - e.type = NX_EV_KEY; - e.code = NX_KEY_MOUSE_LEFT; - e.value = 1; /* 1表示按下 */ - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - } - else - { /* no left button */ - /* 如果上次是按下,这次又没有按下,就是弹起 */ - if (devext->button_record & PS2MOUSE_LEFT_CLICK) - { - devext->button_record &= ~PS2MOUSE_LEFT_CLICK; /* clear record */ - - /* 鼠标左键弹起 */ - e.type = NX_EV_KEY; - e.code = NX_KEY_MOUSE_LEFT; - e.value = 0; /* 0表示弹起 */ - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - } - if (devext->data[0] & PS2MOUSE_RIGHT_CLICK) - { /* right button */ - if (!(devext->button_record & PS2MOUSE_RIGHT_CLICK)) - { /* right button not pressed */ - devext->button_record |= PS2MOUSE_RIGHT_CLICK; /* record */ - - /* 鼠标右键按下 */ - e.type = NX_EV_KEY; - e.code = NX_KEY_MOUSE_RIGHT; - e.value = 1; /* 1表示按下 */ - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - } - else - { /* no right button */ - /* 如果上次是按下,这次又没有按下,就是弹起 */ - if (devext->button_record & PS2MOUSE_RIGHT_CLICK) - { - devext->button_record &= ~PS2MOUSE_RIGHT_CLICK; /* clear record */ - - /* 鼠标左键弹起 */ - e.type = NX_EV_KEY; - e.code = NX_KEY_MOUSE_RIGHT; - e.value = 0; /* 0表示弹起 */ - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - } - if (devext->data[0] & PS2MOUSE_MIDDLE_CLICK) - { /* middle button */ - if (!(devext->button_record & PS2MOUSE_MIDDLE_CLICK)) - { /* middle button not pressed */ - devext->button_record |= PS2MOUSE_MIDDLE_CLICK; /* record */ - - /* 鼠标中键按下 */ - e.type = NX_EV_KEY; - e.code = NX_KEY_MOUSE_MIDDLE; - e.value = 1; /* 1表示按下 */ - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - } - else - { /* no middle button */ - /* 如果上次是按下,这次又没有按下,就是弹起 */ - if (devext->button_record & PS2MOUSE_MIDDLE_CLICK) - { - devext->button_record &= ~PS2MOUSE_MIDDLE_CLICK; /* clear record */ - - /* 鼠标左键弹起 */ - e.type = NX_EV_KEY; - e.code = NX_KEY_MOUSE_MIDDLE; - e.value = 0; /* 0表示弹起 */ - /* 推送事件 */ - NX_InputEventQueuePut(&devext->eventQueue, &e); - } - } - - NX_LOG_D("PS2 Mouse: Buttons %x", devext->data[0] & 0x07); - NX_LOG_D("Mouse: X %d, Y %d, Z %d", x, y, z); -} - -NX_PRIVATE void ps2mouse_commit_packet(HalDeviceExtension *devext) { - devext->data_state = 0; - NX_LOG_D("PS2Mouse: raw data: %d, %d %s %s", - devext->data[1], - devext->data[2], - (devext->data[0] & 1) ? "Left" : "", - (devext->data[0] & 2) ? "Right" : ""); - parse_data_packet(devext); -}; - -NX_PRIVATE void ps2mouse_wait_then_write(NX_U8 port, NX_U8 data) -{ - ps2mouse_prepare_for_output(); - IO_Out8(port, data); -} - -NX_PRIVATE NX_U8 ps2mouse_wait_then_read(NX_U8 port) -{ - ps2mouse_prepare_for_input(); - return IO_In8(port); -} - -NX_PRIVATE void ps2mouse_initialize(HalDeviceExtension *devext) -{ - // Enable PS aux port - ps2mouse_wait_then_write(I8042_STATUS, 0xa8); - - ps2mouse_check_device_presence(devext); - - if (devext->device_present) - { - ps2mouse_initialize_device(devext); - } -} - -NX_PRIVATE void ps2mouse_check_device_presence(HalDeviceExtension *devext) -{ - ps2mouse_write_data(PS2MOUSE_REQUEST_SINGLE_PACKET); - NX_U8 maybe_ack = ps2mouse_read_data(); - if (maybe_ack == I8042_ACK) - { - devext->device_present = NX_True; - NX_LOG_I("ps2mouse: Device detected\n"); - - // the mouse will send a packet of data, since that's what we asked - // for. we don't care about the content. - ps2mouse_read_data(); - ps2mouse_read_data(); - ps2mouse_read_data(); - } - else - { - devext->device_present = NX_False; - NX_LOG_I("ps2mouse: Device not detected\n"); - } -} - -NX_PRIVATE void ps2mouse_initialize_device(HalDeviceExtension *devext) -{ - if (!devext->device_present) - { - return; - } - - // Enable interrupts - ps2mouse_wait_then_write(I8042_STATUS, 0x20); - - // Enable the PS/2 mouse IRQ (12). - // NOTE: The keyboard uses IRQ 1 (and is enabled by bit 0 in this register). - NX_U8 status = ps2mouse_wait_then_read(I8042_BUFFER) | 2; - ps2mouse_wait_then_write(I8042_STATUS, 0x60); - ps2mouse_wait_then_write(I8042_BUFFER, status); - - // Set default settings. - ps2mouse_write_data(PS2MOUSE_SET_DEFAULTS); - ps2mouse_expect_ack(); - - // Enable. - ps2mouse_write_data(PS2MOUSE_ENABLE_PACKET_STREAMING); - ps2mouse_expect_ack(); - ps2mouse_write_data(PS2MOUSE_GET_DEVICE_ID); - ps2mouse_expect_ack(); - NX_U8 device_id = ps2mouse_read_data(); - - if (device_id != PS2MOUSE_INTELLIMOUSE_ID) - { - // Send magical wheel initiation sequence. - ps2mouse_write_data(PS2MOUSE_SET_SAMPLE_RATE); - ps2mouse_expect_ack(); - ps2mouse_write_data(200); - ps2mouse_expect_ack(); - ps2mouse_write_data(PS2MOUSE_SET_SAMPLE_RATE); - ps2mouse_expect_ack(); - ps2mouse_write_data(100); - ps2mouse_expect_ack(); - ps2mouse_write_data(PS2MOUSE_SET_SAMPLE_RATE); - ps2mouse_expect_ack(); - ps2mouse_write_data(80); - ps2mouse_expect_ack(); - - ps2mouse_write_data(PS2MOUSE_GET_DEVICE_ID); - ps2mouse_expect_ack(); - device_id = ps2mouse_read_data(); - } - - if (device_id == PS2MOUSE_INTELLIMOUSE_ID) - { - devext->has_wheel = NX_True; - NX_LOG_I("ps2mouse: Mouse wheel enabled!\n"); - } - else - { - NX_LOG_I("ps2mouse: No mouse wheel detected!\n"); - } - - NX_ASSERT(NX_IRQ_Bind(devext->irq, MouseIrqHandler, devext, "ps/2 mouse", 0) == NX_EOK); - NX_ASSERT(NX_IRQ_Unmask(devext->irq) == NX_EOK); -} - -NX_PRIVATE void ps2mouse_expect_ack() -{ - NX_U8 data = ps2mouse_read_data(); - NX_ASSERT(data == I8042_ACK); -} - -NX_PRIVATE void ps2mouse_prepare_for_input() -{ - int timeout = 10000; - for (;timeout > 0; --timeout) - { - if (IO_In8(I8042_STATUS) & 1) - { - return; - } - } -} - -NX_PRIVATE void ps2mouse_prepare_for_output() -{ - int timeout = 10000; - for (;timeout > 0; --timeout) - { - if (!(IO_In8(I8042_STATUS) & 2)) - { - return; - } - } -} - -NX_PRIVATE void ps2mouse_write_data(NX_U8 data) -{ - ps2mouse_prepare_for_output(); - IO_Out8(I8042_STATUS, 0xd4); - ps2mouse_prepare_for_output(); - IO_Out8(I8042_BUFFER, data); -} - -NX_PRIVATE NX_U8 ps2mouse_read_data() -{ - ps2mouse_prepare_for_input(); - return IO_In8(I8042_BUFFER); -} - -NX_PRIVATE NX_Error MouseRead(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - HalDeviceExtension * ext = device->extension; - - NX_InputEvent e; - - if (!len || len != sizeof(NX_InputEvent)) - { - return NX_EINVAL; - } - - if (NX_InputEventQueueGet(&ext->eventQueue, &e) != NX_EOK) - { - return NX_EAGAIN; - } - - NX_MemCopy(buf, &e, sizeof(NX_InputEvent)); - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps MouseDriverOps = { - .read = MouseRead, -}; - -NX_PRIVATE NX_Error MouseIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - HalDeviceExtension * devext = (HalDeviceExtension *)arg; - - while (1) - { - NX_U8 status = IO_In8(I8042_STATUS); - if (!(((status & I8042_WHICH_BUFFER) == I8042_MOUSE_BUFFER) && (status & I8042_BUFFER_FULL))) - { - return NX_ERROR; - } - - NX_U8 data = IO_In8(I8042_BUFFER); - devext->data[devext->data_state] = data; - - switch (devext->data_state) { - case 0: - if (!(data & 0x08)) { - NX_LOG_E("PS2Mouse: Stream out of sync.\n"); - break; - } - ++devext->data_state; - break; - case 1: - ++devext->data_state; - break; - case 2: - if (devext->has_wheel) { - ++devext->data_state; - break; - } - ps2mouse_commit_packet(devext); - break; - case 3: - NX_ASSERT(devext->has_wheel); - ps2mouse_commit_packet(devext); - break; - } - } - return NX_EOK; -} - -NX_PRIVATE void MouseDriverInit(void) -{ - NX_Device *device; - HalDeviceExtension * devext; - - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_INPUT, 0, &MouseDriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DNX_EV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DNX_EV_NAME); - NX_DriverDestroy(driver); - return; - } - - devext = &halMouseExtension; - device->extension = devext; - - devext->irq = IRQ_MOUSE; - - NX_InputEventQueueInit(&devext->eventQueue, MOUSE_EVENT_QUEUE_MAX_SZ); - - devext->button_record = 0; - devext->flags = 0; - devext->has_wheel = NX_False; - devext->device_present = NX_False; - devext->data_state = 0; - int i; - for (i = 0; i < 4; i++) - { - devext->data[i] = 0; - } - - ps2mouse_initialize(devext); - - if (!devext->device_present) { /* device not exist! */ - NX_ASSERT(NX_IRQ_Mask(devext->irq) == NX_EOK); - NX_ASSERT(NX_IRQ_Unbind(devext->irq, NX_NULL) == NX_EOK); - NX_InputEventQueueExit(&devext->eventQueue); - - NX_DriverDetachDevice(driver, DNX_EV_NAME); - NX_DriverDestroy(driver); - return; - } - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - - NX_ASSERT(NX_IRQ_Mask(devext->irq) == NX_EOK); - NX_ASSERT(NX_IRQ_Unbind(devext->irq, NX_NULL) == NX_EOK); - NX_InputEventQueueExit(&devext->eventQueue); - - NX_DriverDetachDevice(driver, DNX_EV_NAME); - NX_DriverDestroy(driver); - return; - } -} - -NX_PRIVATE void MouseDriverExit(void) -{ - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(MouseDriverInit); -NX_DRV_EXIT(MouseDriverExit); - -#endif /* CONFIG_NX_DRIVER_PS2_MOUSE */ diff --git a/src/platform/i386/drivers/ps2_mouse_irq.c b/src/platform/i386/drivers/ps2_mouse_irq.c deleted file mode 100644 index 78b6205..0000000 --- a/src/platform/i386/drivers/ps2_mouse_irq.c +++ /dev/null @@ -1,242 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: ps2 mouse irq driver - * - * Change Logs: - * Date Author Notes - * 2022-06-20 JasonHu Init - */ - -#define NX_LOG_NAME "ps2mouse irq" -#define NX_LOG_LEVEL NX_LOG_INFO -#include - -#ifdef CONFIG_NX_DRIVER_PS2_MOUSE_IRQ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#define DRV_NAME "ps2 mouse irq driver" -#define DRV_VERSION "0.1" - -#define DEV_NAME "ps2mouse_irq" - -#define I8042_BUFFER 0x60 -#define I8042_STATUS 0x64 -#define I8042_ACK 0xFA -#define I8042_BUFFER_FULL 0x01 -#define I8042_WHICH_BUFFER 0x20 -#define I8042_MOUSE_BUFFER 0x20 -#define I8042_KEYBOARD_BUFFER 0x00 - -#define MOUSE_FIFO_MAX_SZ 128 - -typedef struct HalDeviceExtension -{ - char irq; /* irq号 */ - NX_Fifo * fifo; - NX_Semaphore fifoSem; - NX_Bool opened; /* irq driver opened */ -} HalDeviceExtension; - -NX_PRIVATE HalDeviceExtension halMouseExtension; - -NX_PRIVATE NX_Error MouseIrqOpen(struct NX_Device *device, NX_U32 flags) -{ - HalDeviceExtension * devext = (HalDeviceExtension *)device->extension; - - NX_LOG_D("MOUSE IRQ OPEN"); - NX_FifoReset(devext->fifo); - NX_SemaphoreInit(&devext->fifoSem, 0); - - devext->opened = NX_True; - - return NX_EOK; -} - -NX_PRIVATE NX_Error MouseIrqClose(struct NX_Device *device) -{ - HalDeviceExtension * devext = (HalDeviceExtension *)device->extension; - NX_LOG_D("MOUSE IRQ CLOSE"); - /* disable irq */ - devext->opened = NX_False; - NX_SemaphoreInit(&devext->fifoSem, 0); - NX_FifoReset(devext->fifo); - NX_IRQ_Mask(devext->irq); - - return NX_EOK; -} - -/* read irq data */ -NX_PRIVATE NX_Error MouseIrqRead(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - HalDeviceExtension * ext = device->extension; - - if (!len || len != 1) - { - return NX_EINVAL; - } - - if (ext->opened == NX_False) - { - NX_LOG_W("mouse irq not open\n"); - if (outLen) - { - *outLen = 0; - } - return NX_ENORES; - } - - NX_U8 scan_code = 0; - if (NX_SemaphoreWait(&ext->fifoSem) != NX_EOK) - { - NX_LOG_D("mouse irq wait intr\n"); - if (outLen) - { - *outLen = 0; - } - return NX_EINTR; - } - - if (!NX_FifoGet(ext->fifo, &scan_code, 1)) - { - NX_LOG_W("mouse irq fifo no data\n"); - if (outLen) - { - *outLen = 0; - } - return NX_ENORES; - } - - NX_MemCopy(buf, &scan_code, 1); - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_Error MouseIrqControl(struct NX_Device *device, NX_U32 cmd, void *arg) -{ - HalDeviceExtension * ext = device->extension; - - switch (cmd) - { - case NX_IRQ_CMD_MASK: - NX_IRQ_Mask(ext->irq); - break; - case NX_IRQ_CMD_UNMASK: - NX_IRQ_Unmask(ext->irq); - break; - - default: - break; - } - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps mouseIrqDriverOps = { - .read = MouseIrqRead, - .open = MouseIrqOpen, - .close = MouseIrqClose, - .control = MouseIrqControl, -}; - -NX_PRIVATE NX_Error MouseIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - HalDeviceExtension * devext = (HalDeviceExtension *)arg; - - while (1) - { - NX_U8 status = IO_In8(I8042_STATUS); - if (!(((status & I8042_WHICH_BUFFER) == I8042_MOUSE_BUFFER) && (status & I8042_BUFFER_FULL))) - { - break; - } - - NX_U8 data = IO_In8(I8042_BUFFER); - if (devext->opened) - { - NX_FifoPut(devext->fifo, &data, 1); - NX_SemaphoreSignal(&devext->fifoSem); - } - } - return NX_EOK; -} - -NX_PRIVATE void MouseIrqDriverInit(void) -{ - NX_Device *device; - HalDeviceExtension * devext; - - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_IRQ, 0, &mouseIrqDriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DEV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - devext = &halMouseExtension; - device->extension = devext; - - devext->irq = IRQ_MOUSE; - - devext->opened = NX_False; - devext->fifo = NX_FifoCreate(MOUSE_FIFO_MAX_SZ); - if (devext->fifo == NX_NULL) - { - NX_LOG_E("create %s fifo failed!", DEV_NAME); - - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } - NX_SemaphoreInit(&devext->fifoSem, 0); - - NX_ASSERT(NX_IRQ_Bind(devext->irq, MouseIrqHandler, devext, "ps2mouse", 0) == NX_EOK); - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - - NX_ASSERT(NX_IRQ_Unbind(devext->irq, NX_NULL) == NX_EOK); - - NX_FifoDestroy(devext->fifo); - - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } -} - -NX_PRIVATE void MouseIrqDriverExit(void) -{ - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(MouseIrqDriverInit); -NX_DRV_EXIT(MouseIrqDriverExit); - -#endif /* CONFIG_NX_DRIVER_PS2_MOUSE_IRQ */ diff --git a/src/platform/i386/drivers/rtc.c b/src/platform/i386/drivers/rtc.c deleted file mode 100644 index 6794e9b..0000000 --- a/src/platform/i386/drivers/rtc.c +++ /dev/null @@ -1,160 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: rtc driver - * - * Change Logs: - * Date Author Notes - * 2022-4-15 JasonHu Init - */ - -#include - -#define NX_LOG_NAME "rtc driver" -#include -#include -#include - -#include - -#define DRV_NAME "rtc device" -#define DEV_NAME "rtc" - -/* CMOS port */ -#define CMOS_INDEX 0x70 -#define CMOS_DATA 0x71 - -/* CMOS offset */ -#define CMOS_CUR_SEC 0x0 -#define CMOS_ALA_SEC 0x1 -#define CMOS_CUR_MIN 0x2 -#define CMOS_ALA_MIN 0x3 -#define CMOS_CUR_HOUR 0x4 -#define CMOS_ALA_HOUR 0x5 -#define CMOS_WEEK_DAY 0x6 -#define CMOS_MON_DAY 0x7 -#define CMOS_CUR_MON 0x8 -#define CMOS_CUR_YEAR 0x9 -#define CMOS_DEV_TYPE 0x12 -#define CMOS_CUR_CEN 0x32 - -#define BCD_HEX(n) ((n >> 4) * 10) + (n & 0xf) - -#define BCD_ASCII_FIRST(n) (((n << 4) >> 4) + 0x30) -#define BCD_ASCII_S(n) ((n << 4) + 0x30) - -NX_PRIVATE NX_U8 ReadCMOS(NX_U8 p) -{ - NX_U8 data; - IO_Out8(CMOS_INDEX, p); - data = IO_In8(CMOS_DATA); - IO_Out8(CMOS_INDEX, 0x80); - return data; -} - -NX_PRIVATE NX_U32 CMOS_GetHourHex(void) -{ - return BCD_HEX(ReadCMOS(CMOS_CUR_HOUR)); -} - -NX_PRIVATE NX_U32 CMOS_GetMinHex(void) -{ - return BCD_HEX(ReadCMOS(CMOS_CUR_MIN)); -} - -NX_PRIVATE NX_USED NX_U8 CMOS_GetMinHex8(void) -{ - return BCD_HEX(ReadCMOS(CMOS_CUR_MIN)); -} - -NX_PRIVATE NX_U32 CMOS_GetSecHex(void) -{ - return BCD_HEX(ReadCMOS(CMOS_CUR_SEC)); -} - -NX_PRIVATE NX_U32 CMOS_GetDayOfMonth(void) -{ - return BCD_HEX(ReadCMOS(CMOS_MON_DAY)); -} - -NX_PRIVATE NX_USED NX_U32 CMOS_GetDayOfWeek(void) -{ - return BCD_HEX(ReadCMOS(CMOS_WEEK_DAY)); -} - -NX_PRIVATE NX_U32 CMOS_GetMonHex(void) -{ - return BCD_HEX(ReadCMOS(CMOS_CUR_MON)); -} - -NX_PRIVATE NX_U32 CMOS_GetYear(void) -{ - return (BCD_HEX(ReadCMOS(CMOS_CUR_CEN))*100) + \ - BCD_HEX(ReadCMOS(CMOS_CUR_YEAR))+1980; -} - -NX_PRIVATE NX_Error RTC_Read(struct NX_Device *device, void *buf, NX_Offset off, NX_Size len, NX_Size *outLen) -{ - NX_Time time; - - if (len != sizeof(time)) - { - return NX_EINVAL; - } - - time.year = CMOS_GetYear(); - time.month = CMOS_GetMonHex(); - time.day = CMOS_GetDayOfMonth(); - time.hour = CMOS_GetHourHex(); - time.minute = CMOS_GetMinHex(); - time.second = CMOS_GetSecHex(); - - NX_MemCopy(buf, &time, sizeof(time)); - - if (outLen) - { - *outLen = len; - } - return NX_EOK; -} - -NX_PRIVATE NX_DriverOps RTC_DriverOps = { - .read = RTC_Read, -}; - -NX_PRIVATE void RTC_DriverInit(void) -{ - NX_Device *device; - NX_Driver *driver = NX_DriverCreate(DRV_NAME, NX_DEVICE_TYPE_VIRT, 0, &RTC_DriverOps); - if (driver == NX_NULL) - { - NX_LOG_E("create driver failed!"); - return; - } - - if (NX_DriverAttachDevice(driver, DEV_NAME, &device) != NX_EOK) - { - NX_LOG_E("attach device %s failed!", DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - if (NX_DriverRegister(driver) != NX_EOK) - { - NX_LOG_E("register driver %s failed!", DRV_NAME); - NX_DriverDetachDevice(driver, DEV_NAME); - NX_DriverDestroy(driver); - return; - } - - NX_LOG_I("init %s driver success!", DRV_NAME); -} - -NX_PRIVATE void RTC_DriverExit(void) -{ - NX_DriverCleanup(DRV_NAME); -} - -NX_DRV_INIT(RTC_DriverInit); -NX_DRV_EXIT(RTC_DriverExit); diff --git a/src/platform/i386/hal/Makefile b/src/platform/i386/hal/Makefile deleted file mode 100644 index b10ebae..0000000 --- a/src/platform/i386/hal/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -SRC += *.c -SRC += *.S diff --git a/src/platform/i386/hal/boot_setting.c b/src/platform/i386/hal/boot_setting.c deleted file mode 100644 index ca493d0..0000000 --- a/src/platform/i386/hal/boot_setting.c +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: PC32 boot setting - * - * Change Logs: - * Date Author Notes - * 2021-9-17 JasonHu Init - * 2022-06-03 JasonHu Add framebuffer support - * 2022-06-20 JasonHu change framebuffer to vbe - */ - -#include -#include -#include -#include - -#include - -NX_INLINE void BootModInit(struct multiboot_tag *tag); -NX_INLINE void BootMemModInit(struct multiboot_tag *tag); - -#ifdef CONFIG_NX_HARDWARE_VBE -NX_INLINE void BootVbeInit(struct multiboot_tag *tag); -NX_INLINE void BootFramebufferInit(struct multiboot_tag *tag); -#endif /* CONFIG_NX_HARDWARE_VBE */ - -int NX_HalBootSetting(unsigned long magic, unsigned long addr) -{ - // whether a multiboot - if (magic != MULTIBOOT2_BOOTLOADER_MAGIC || addr & 7) - { - return -1; - } - struct multiboot_tag *tag; - - BootModInfoInit(); - - for (tag = (struct multiboot_tag*)(addr + 8); - tag->type != MULTIBOOT_TAG_TYPE_END; - tag = (struct multiboot_tag*)((multiboot_uint8_t *)tag + ((tag->size + 7) & ~7))) - { - switch (tag->type) { - case MULTIBOOT_TAG_TYPE_MODULE: - BootModInit(tag); - break; - case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: - BootMemModInit(tag); - break; -#ifdef CONFIG_NX_HARDWARE_VBE - case MULTIBOOT_TAG_TYPE_VBE: - BootVbeInit(tag); - break; - case MULTIBOOT_TAG_TYPE_FRAMEBUFFER: - BootFramebufferInit(tag); - break; -#endif /* CONFIG_NX_HARDWARE_VBE */ - } - } - return 0; -} - -#define CmdlineIs(cmd) (!NX_StrCmp(((struct multiboot_tag_module *)tag)->cmdline, cmd)) - -NX_INLINE void BootModInit(struct multiboot_tag *tag) { - struct BootModInfo *modInfo = (struct BootModInfo *)BOOT_INFO_ADDR; - int index = modInfo->modNum; - - if (index >= MAX_BOOT_MODS_NUM - || modInfo->modSize + ((struct multiboot_tag_module *)tag)->size > MAX_BOOT_MODS_SIZE) - { - return; - } - - modInfo->modules[index].size = ((struct multiboot_tag_module *)tag)->size; - modInfo->modules[index].start = ((struct multiboot_tag_module *)tag)->mod_start; - modInfo->modules[index].end = ((struct multiboot_tag_module *)tag)->mod_end; - - if (CmdlineIs("initrd")) - { - modInfo->modules[index].type = BOOT_MOD_INITRD; - } - else - { - modInfo->modules[index].type = BOOT_MOD_UNKNOWN; - } - - modInfo->modSize += modInfo->modules[index].size; - ++modInfo->modNum; -} - -#undef CmdlineIs - -NX_INLINE void BootMemModInit(struct multiboot_tag *tag) -{ - unsigned long memUpper = ((struct multiboot_tag_basic_meminfo *)tag)->mem_upper; - unsigned long memLower = ((struct multiboot_tag_basic_meminfo *)tag)->mem_lower; - *((unsigned int *)0x000001000) = ((memUpper - memLower) << 10) + 0x100000; -} - -#ifdef CONFIG_NX_HARDWARE_VBE - -NX_INLINE void BootVbeInit(struct multiboot_tag *tag) -{ - struct multiboot_tag_vbe *vbeTag = (struct multiboot_tag_vbe *)tag; - - struct VbeInfoBlock *vbeInfo = (struct VbeInfoBlock *)VBE_BASE_INFO_ADDR; - struct VbeModeInfoBlock *modeInfo = (struct VbeModeInfoBlock *)VBE_BASE_MODE_ADDR; - - NX_MemCopy(vbeInfo, &(vbeTag->vbe_control_info), sizeof(struct VbeInfoBlock)); - NX_MemCopy(modeInfo, &(vbeTag->vbe_mode_info), sizeof(struct VbeModeInfoBlock)); -} - -NX_INLINE void BootFramebufferInit(struct multiboot_tag *tag) -{ - struct multiboot_tag_framebuffer *framebufferTag = (struct multiboot_tag_framebuffer *)tag; - - struct VbeModeInfoBlock *modeInfo = (struct VbeModeInfoBlock *)VBE_BASE_MODE_ADDR; - - struct VbeInfoBlock *vbeInfo = (struct VbeInfoBlock *)VBE_BASE_INFO_ADDR; - if (!vbeInfo->vbeVeision) - { - vbeInfo->vbeVeision = 0x0300; /* modify as v 0.3.0 */ - } - - modeInfo->xResolution = framebufferTag->common.framebuffer_width; - modeInfo->yResolution = framebufferTag->common.framebuffer_height; - modeInfo->bitsPerPixel = framebufferTag->common.framebuffer_bpp; - modeInfo->phyBasePtr = framebufferTag->common.framebuffer_addr; - - // TODO: get mode attributes value - // modeInfo->modeAttributes = ; - modeInfo->bytesPerScanLine = framebufferTag->common.framebuffer_pitch; -} - -#endif /* CONFIG_NX_HARDWARE_VBE */ diff --git a/src/platform/i386/hal/init.c b/src/platform/i386/hal/init.c deleted file mode 100644 index c0734f4..0000000 --- a/src/platform/i386/hal/init.c +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Init PC32 platfrom - * - * Change Logs: - * Date Author Notes - * 2021-9-17 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include - -#define NX_LOG_LEVEL NX_LOG_INFO -#define NX_LOG_NAME "INIT" -#include - -#include - -NX_INTERFACE NX_Error NX_HalPlatformInit(NX_UArch coreId) -{ - NX_HalClearBSS(); - - NX_HalDirectUartInit(); - - NX_Printf("hello, world!\na=%x b=%d c=%c e=%s\n", 0x1234abcd, 123456789, 'A', "hello"); - - NX_LOG_I("Hello, PC32!"); - - CPU_InitGate(); - CPU_InitSegment(); - CPU_InitTSS(); - CPU_InitInterrupt(); - - NX_HalPageZoneInit(); - - return NX_EOK; -} - -NX_INTERFACE NX_Error NX_HalPlatformStage2(void) -{ - NX_HalDirectUartStage2(); - - return NX_EOK; -} diff --git a/src/platform/i386/hal/main.c b/src/platform/i386/hal/main.c deleted file mode 100644 index ee1892e..0000000 --- a/src/platform/i386/hal/main.c +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom main - * - * Change Logs: - * Date Author Notes - * 2021-11-18 JasonHu Init - */ - -#include -#define NX_LOG_NAME "Hal Main" -#include - -#ifdef CONFIG_NX_ENABLE_PLATFORM_MAIN -NX_INTERFACE void NX_HalPlatformMain(void) -{ - NX_LOG_I("i386 platform main running...\n"); -} -#endif /* CONFIG_NX_ENABLE_PLATFORM_MAIN */ diff --git a/src/platform/i386/hal/multiboot2.S b/src/platform/i386/hal/multiboot2.S deleted file mode 100644 index a400afc..0000000 --- a/src/platform/i386/hal/multiboot2.S +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2018-2022, BookOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Multiboot2 start file - * - * Change Logs: - * Date Author Notes - * 2021-9-17 JasonHu Init - * 2022-06-03 JasonHu Add framebuffer support - */ - -#define __ASSEMBLY__ -#include -#include - -# the NX_USize of bootStack is 16KB -#define BOOT_STACK_SIZE 0x4000 - -.code32 - -.section .text.start -.globl Start, _start -.extern NX_Main -.extern NX_HalBootSetting - -Start: -_start: - jmp MultibootEntry - -.align 8 -MultibootHeader: - .long MULTIBOOT2_HEADER_MAGIC # magic number (multiboot 2) - .long MULTIBOOT_ARCHITECTURE_I386 # architecture 0 (protected mode i386) - .long MultibootHeaderEnd - MultibootHeader # header length - # checksum - .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (MultibootHeaderEnd - MultibootHeader)) - # insert optional multiboot tags here - -#ifdef CONFIG_NX_HARDWARE_VBE - .align 8 - TagFramebuffer: - .short MULTIBOOT_HEADER_TAG_FRAMEBUFFER - .short MULTIBOOT_HEADER_TAG_OPTIONAL - .long TagFramebufferEnd - TagFramebuffer - .long CONFIG_NX_HARDWARE_VBE_WIDTH # screen width - .long CONFIG_NX_HARDWARE_VBE_HEIGHT # screen height - .long CONFIG_NX_HARDWARE_VBE_BPP # bit per pixel - TagFramebufferEnd: -#endif /* CONFIG_NX_HARDWARE_VBE */ - - # required end tag - .align 8 - .short MULTIBOOT_HEADER_TAG_END # type - .short 0 # flags - .long 8 # NX_USize -MultibootHeaderEnd: -MultibootEntry: - # initialize the bootStack pointer - movl $(bootStack + BOOT_STACK_SIZE), %esp - - # reset EFLAGS - pushl $0 - popf - - # push the pointer to the Multiboot information structure - pushl %ebx - # push the magic value - pushl %eax - - call NX_HalBootSetting - cmpl $-1, %eax - je BootSetupFail - - add $8, %esp - - # call os main - call NX_Main - jmp MultibootHlt - -BootSetupFail: - # print "Error!" in protected mode - movl $0xcf72cf45, 0xb8000 - movl $0xcf6fcf72, 0xb8004 - movl $0xcf21cf72, 0xb8008 - -MultibootHlt: - hlt - jmp MultibootHlt - - .comm bootStack, BOOT_STACK_SIZE diff --git a/src/platform/i386/include/boot.h b/src/platform/i386/include/boot.h deleted file mode 100644 index 8c708c1..0000000 --- a/src/platform/i386/include/boot.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Boot info - * - * Change Logs: - * Date Author Notes - * 2021-10-19 JasonHu Init - */ - -#ifndef __PLATFORM_BOOT__ -#define __PLATFORM_BOOT__ - -#include - -#define BOOT_INFO_ADDR 0x3F1000 - -#define MAX_BOOT_MODS_NUM 1 -#define MAX_BOOT_MODS_SIZE (1 * NX_MB) - -enum BootModType -{ - // Unknown type - BOOT_MOD_UNKNOWN = 0, - // Initrd image type - BOOT_MOD_INITRD = 1, -}; - -struct BootModInfo -{ - unsigned int modNum; - unsigned int modSize; - struct - { - unsigned int type; - unsigned int size; - unsigned int start; - unsigned int end; - } modules[MAX_BOOT_MODS_NUM]; -} __attribute__ ((packed)); - -NX_INLINE void BootModInfoInit() -{ - struct BootModInfo *modInfo = (struct BootModInfo *)BOOT_INFO_ADDR; - modInfo->modNum = 0; - modInfo->modSize = 0; -} - -NX_INLINE void *BootModInfoFind(unsigned long addr, enum BootModType type) -{ - int i; - struct BootModInfo *modInfo; - modInfo = (struct BootModInfo *)(addr + BOOT_INFO_ADDR); - - for (i = 0; i < modInfo->modNum; ++i) - { - if (modInfo->modules[i].type == type) - { - return (void*)(addr + modInfo->modules[i].start); - } - } - - return (void*)0; -} - -#endif /* __PLATFORM_BOOT__ */ diff --git a/src/platform/i386/include/drivers/direct_uart.h b/src/platform/i386/include/drivers/direct_uart.h deleted file mode 100644 index dd62915..0000000 --- a/src/platform/i386/include/drivers/direct_uart.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart - * - * Change Logs: - * Date Author Notes - * 2021-10-3 JasonHu Init - */ - -#ifndef __DIRECT_UART_HEADER__ -#define __DIRECT_UART_HEADER__ - -#include - -/* direct means not use driver framework */ - -void NX_HalDirectUartInit(void); -void NX_HalDirectUartPutc(char ch); -void NX_HalDirectUartStage2(void); - -#endif /* __DIRECT_UART_HEADER__ */ diff --git a/src/platform/i386/include/drivers/vbe.h b/src/platform/i386/include/drivers/vbe.h deleted file mode 100644 index ceeaf24..0000000 --- a/src/platform/i386/include/drivers/vbe.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: vbe header - * - * Change Logs: - * Date Author Notes - * 2022-06-03 JasonHu Init - */ - -#ifndef __DRIVER_VBE_H__ -#define __DRIVER_VBE_H__ - -#include - -#define VBE_BASE_INFO_ADDR 0x00001100 -#define VBE_BASE_MODE_ADDR 0x00001300 - -struct VbeInfoBlock { - NX_U8 vbeSignature[4]; /* VEB Signature: 'VESA' */ - NX_U16 vbeVeision; /* VEB Version:0300h */ - NX_U32 oemStringPtr; /* VbeFarPtr to OEM string */ - NX_U8 capabilities[4]; /* Capabilities of graphics controller */ - NX_U32 videoModePtr; /* VbeFarPtr to VideoModeList */ - NX_U16 totalMemory; /* Number of 64kb memory blocks added for VEB2.0+ */ - NX_U16 oemSoftwareRev; /* VEB implementation Software revision */ - NX_U32 oemVendorNamePtr; /* VbeFarPtr to Vendor Name String */ - NX_U32 oemProductNamePtr; /* VbeFarPtr to Product Name String */ - NX_U32 oemProductRevPtr; /* VbeFarPtr to Product Revision String */ - NX_U8 reserved[222]; /* Reserved for VBE implementation scratch area */ - NX_U8 oemData[256]; /* Data Area for OEM String */ -} __attribute__ ((packed)); - -struct VbeModeInfoBlock { - /* Mandatory information for all VBE revisions */ - NX_U16 modeAttributes; /* mode attributes */ - NX_U8 winAAttributes; /* window A attributes */ - NX_U8 winBAttributes; /* window B attributes */ - NX_U16 winGranulaity; /* window granulaity */ - NX_U16 winSize; /* window size */ - NX_U16 winASegment; /* window A start segment */ - NX_U16 winBSegment; /* window B start segment */ - NX_U32 winFuncPtr; /* real mode pointer to window function */ - NX_U16 bytesPerScanLine; /* bytes per scan line */ - /* Mandatory information for VBE1.2 and above */ - NX_U16 xResolution; /* horizontal resolution in pixels or characters */ - NX_U16 yResolution; /* vertical resolution in pixels or characters */ - NX_U8 xCharSize; /* character cell width in pixels */ - NX_U8 yCharSize; /* character cell height in pixels */ - NX_U8 numberOfPlanes; /* number of banks */ - NX_U8 bitsPerPixel; /* bits per pixel */ - NX_U8 numberOfBanks; /* number of banks */ - NX_U8 memoryModel; /* memory model type */ - NX_U8 bankSize; /* bank size in KB */ - NX_U8 numberOfImagePages; /* number of images */ - NX_U8 reserved0; /* reserved for page function: 1 */ - NX_U8 redMaskSize; /* size of direct color red mask in bits */ - NX_U8 redFieldPosition; /* bit position of lsb of red mask */ - NX_U8 greenMaskSize; /* size of direct color green mask in bits */ - NX_U8 greenFieldPosition; /* bit position of lsb of green mask */ - NX_U8 blueMaskSize; /* size of direct color blue mask in bits */ - NX_U8 blueFieldPosition; /* bit position of lsb of blue mask */ - NX_U8 rsvdMaskSize; /* size of direct color reserved mask in bits */ - NX_U8 rsvdFieldPosition; /* bit position of lsb of reserved mask */ - NX_U8 directColorModeInfo; /* direct color mode attributes */ - - /* Mandatory information for VBE2.0 and above */ - NX_U32 phyBasePtr; /* physical address for flat memory frame buffer */ - NX_U32 reserved1; /* reserved-always set to 0 */ - NX_U16 reserved2; /* reserved-always set to 0 */ - /* Mandatory information for VBE3.0 and above */ - NX_U16 linebytesPerScanLine; /* bytes per scan line for linear modes */ - NX_U8 bnkNumberOfImagePages; /* number of images for banked modes */ - NX_U8 linNumberOfImagePages; /* number of images for linear modes */ - NX_U8 linRedMaskSize; /* size of direct color red mask(linear modes) */ - NX_U8 linRedFieldPosition; /* bit position of lsb of red mask(linear modes) */ - NX_U8 linGreenMaskSize; /* size of direct color green mask(linear modes) */ - NX_U8 linGreenFieldPosition; /* bit position of lsb of green mask(linear modes) */ - NX_U8 linBlueMaskSize; /* size of direct color blue mask(linear modes) */ - NX_U8 linBlueFieldPosition; /* bit position of lsb of blue mask(linear modes) */ - NX_U8 linRsvdMaskSize; /* size of direct color reserved mask(linear modes) */ - NX_U8 linRsvdFieldPosition; /* bit position of lsb of reserved mask(linear modes) */ - NX_U32 maxPixelClock; /* maximum pixel clock (in HZ) for graphics mode */ - NX_U8 reserved3[189]; /* remainder of ModeInfoBlock */ -} __attribute__ ((packed)); - -#endif /* __DRIVER_VBE_H__ */ diff --git a/src/platform/i386/include/multiboot2.h b/src/platform/i386/include/multiboot2.h deleted file mode 100644 index 3ba5b3c..0000000 --- a/src/platform/i386/include/multiboot2.h +++ /dev/null @@ -1,427 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Multiboot2 header file - * - * Change Logs: - * Date Author Notes - * 2021-9-17 JasonHu Init - */ - -/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY - * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR - * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __MULTIBOOT_HEADER__ -#define __MULTIBOOT_HEADER__ - -/* How many bytes from the start of the file we search for the header. */ -#define MULTIBOOT_SEARCH 32768 -#define MULTIBOOT_HEADER_ALIGN 8 - -/* The magic field should contain this. */ -#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6 - -/* This should be in %eax. */ -#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289 - -/* Alignment of multiboot modules. */ -#define MULTIBOOT_MOD_ALIGN 0x00001000 - -/* Alignment of the multiboot info structure. */ -#define MULTIBOOT_INFO_ALIGN 0x00000008 - -/* Flags set in the ’flags’ member of the multiboot header. */ - -#define MULTIBOOT_TAG_ALIGN 8 -#define MULTIBOOT_TAG_TYPE_END 0 -#define MULTIBOOT_TAG_TYPE_CMDLINE 1 -#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 -#define MULTIBOOT_TAG_TYPE_MODULE 3 -#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 -#define MULTIBOOT_TAG_TYPE_BOOTDEV 5 -#define MULTIBOOT_TAG_TYPE_MMAP 6 -#define MULTIBOOT_TAG_TYPE_VBE 7 -#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 -#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 -#define MULTIBOOT_TAG_TYPE_APM 10 -#define MULTIBOOT_TAG_TYPE_EFI32 11 -#define MULTIBOOT_TAG_TYPE_EFI64 12 -#define MULTIBOOT_TAG_TYPE_SMBIOS 13 -#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 -#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 -#define MULTIBOOT_TAG_TYPE_NETWORK 16 -#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 -#define MULTIBOOT_TAG_TYPE_EFI_BS 18 -#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 -#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 -#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 - -#define MULTIBOOT_HEADER_TAG_END 0 -#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1 -#define MULTIBOOT_HEADER_TAG_ADDRESS 2 -#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3 -#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4 -#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5 -#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6 -#define MULTIBOOT_HEADER_TAG_EFI_BS 7 -#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 8 -#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9 -#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10 - -#define MULTIBOOT_ARCHITECTURE_I386 0 -#define MULTIBOOT_ARCHITECTURE_MIPS32 4 -#define MULTIBOOT_HEADER_TAG_OPTIONAL 1 - -#define MULTIBOOT_LOAD_PREFERENCE_NONE 0 -#define MULTIBOOT_LOAD_PREFERENCE_LOW 1 -#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2 - -#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1 -#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 - -#ifndef __ASSEMBLY__ - -typedef unsigned char multiboot_uint8_t; -typedef unsigned short multiboot_uint16_t; -typedef unsigned int multiboot_uint32_t; -typedef unsigned long long multiboot_uint64_t; - -struct multiboot_header -{ - /* Must be MULTIBOOT_MAGIC - see above. */ - multiboot_uint32_t magic; - - /* ISA */ - multiboot_uint32_t architecture; - - /* Total header length. */ - multiboot_uint32_t header_length; - - /* The above fields plus this one must equal 0 mod 2^32. */ - multiboot_uint32_t checksum; -}; - -struct multiboot_header_tag -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; -}; - -struct multiboot_header_tag_information_request -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t requests[0]; -}; - -struct multiboot_header_tag_address -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t header_addr; - multiboot_uint32_t load_addr; - multiboot_uint32_t load_end_addr; - multiboot_uint32_t bss_end_addr; -}; - -struct multiboot_header_tag_entry_address -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t entry_addr; -}; - -struct multiboot_header_tag_console_flags -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t console_flags; -}; - -struct multiboot_header_tag_framebuffer -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t width; - multiboot_uint32_t height; - multiboot_uint32_t depth; -}; - -struct multiboot_header_tag_module_align -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; -}; - -struct multiboot_header_tag_relocatable -{ - multiboot_uint16_t type; - multiboot_uint16_t flags; - multiboot_uint32_t size; - multiboot_uint32_t min_addr; - multiboot_uint32_t max_addr; - multiboot_uint32_t align; - multiboot_uint32_t preference; -}; - -struct multiboot_color -{ - multiboot_uint8_t red; - multiboot_uint8_t green; - multiboot_uint8_t blue; -}; - -struct multiboot_mmap_entry -{ - multiboot_uint64_t addr; - multiboot_uint64_t len; -#define MULTIBOOT_MEMORY_AVAILABLE 1 -#define MULTIBOOT_MEMORY_RESERVED 2 -#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 -#define MULTIBOOT_MEMORY_NVS 4 -#define MULTIBOOT_MEMORY_BADRAM 5 - multiboot_uint32_t type; - multiboot_uint32_t zero; -}; -typedef struct multiboot_mmap_entry multiboot_memory_map_t; - -struct multiboot_tag -{ - multiboot_uint32_t type; - multiboot_uint32_t size; -}; - -struct multiboot_tag_string -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - char string[0]; -}; - -struct multiboot_tag_module -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t mod_start; - multiboot_uint32_t mod_end; - char cmdline[0]; -}; - -struct multiboot_tag_basic_meminfo -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t mem_lower; - multiboot_uint32_t mem_upper; -}; - -struct multiboot_tag_bootdev -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t biosdev; - multiboot_uint32_t slice; - multiboot_uint32_t part; -}; - -struct multiboot_tag_mmap -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t entry_Size; - multiboot_uint32_t entry_version; - struct multiboot_mmap_entry entries[0]; -}; - -struct multiboot_vbe_info_block -{ - multiboot_uint8_t external_specification[512]; -}; - -struct multiboot_vbe_mode_info_block -{ - multiboot_uint8_t external_specification[256]; -}; - -struct multiboot_tag_vbe -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - - multiboot_uint16_t vbe_mode; - multiboot_uint16_t vbe_interface_seg; - multiboot_uint16_t vbe_interface_off; - multiboot_uint16_t vbe_interface_len; - - struct multiboot_vbe_info_block vbe_control_info; - struct multiboot_vbe_mode_info_block vbe_mode_info; -}; - -struct multiboot_tag_framebuffer_common -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - - multiboot_uint64_t framebuffer_addr; - multiboot_uint32_t framebuffer_pitch; - multiboot_uint32_t framebuffer_width; - multiboot_uint32_t framebuffer_height; - multiboot_uint8_t framebuffer_bpp; -#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 -#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 -#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 - multiboot_uint8_t framebuffer_type; - multiboot_uint16_t reserved; -}; - -struct multiboot_tag_framebuffer -{ - struct multiboot_tag_framebuffer_common common; - - union - { - struct - { - multiboot_uint16_t framebuffer_palette_num_colors; - struct multiboot_color framebuffer_palette[0]; - }; - struct - { - multiboot_uint8_t framebuffer_red_field_position; - multiboot_uint8_t framebuffer_red_mask_Size; - multiboot_uint8_t framebuffer_green_field_position; - multiboot_uint8_t framebuffer_green_mask_Size; - multiboot_uint8_t framebuffer_blue_field_position; - multiboot_uint8_t framebuffer_blue_mask_Size; - }; - }; -}; - -struct multiboot_tag_elf_sections -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t num; - multiboot_uint32_t entSize; - multiboot_uint32_t shndx; - char sections[0]; -}; - -struct multiboot_tag_apm -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint16_t version; - multiboot_uint16_t cseg; - multiboot_uint32_t offset; - multiboot_uint16_t cseg_16; - multiboot_uint16_t dseg; - multiboot_uint16_t flags; - multiboot_uint16_t cseg_len; - multiboot_uint16_t cseg_16_len; - multiboot_uint16_t dseg_len; -}; - -struct multiboot_tag_efi32 -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t pointer; -}; - -struct multiboot_tag_efi64 -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint64_t pointer; -}; - -struct multiboot_tag_smbios -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t major; - multiboot_uint8_t minor; - multiboot_uint8_t reserved[6]; - multiboot_uint8_t tables[0]; -}; - -struct multiboot_tag_old_acpi -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t rsdp[0]; -}; - -struct multiboot_tag_new_acpi -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t rsdp[0]; -}; - -struct multiboot_tag_network -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint8_t dhcpack[0]; -}; - -struct multiboot_tag_efi_mmap -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t descr_Size; - multiboot_uint32_t descr_vers; - multiboot_uint8_t efi_mmap[0]; -}; - -struct multiboot_tag_efi32_ih -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t pointer; -}; - -struct multiboot_tag_efi64_ih -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint64_t pointer; -}; - -struct multiboot_tag_load_base_addr -{ - multiboot_uint32_t type; - multiboot_uint32_t size; - multiboot_uint32_t load_base_addr; -}; - -#endif /* ! __ASSEMBLY__ */ - -#endif /* ! __MULTIBOOT_HEADER__ */ \ No newline at end of file diff --git a/src/platform/i386/include/nx_configure.h b/src/platform/i386/include/nx_configure.h deleted file mode 100644 index 6ddf2ab..0000000 --- a/src/platform/i386/include/nx_configure.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __NX_CONFIG__ -#define __NX_CONFIG__ -#define CONFIG_NX_DEBUG 1 -#define CONFIG_NX_LOG_LEVEL 3 -#define CONFIG_NX_DEBUG_COLOR 1 -#define CONFIG_NX_DEBUG_TIMELINE 1 -#define CONFIG_NX_PLATFORM_NAME "x86-i386" -#define CONFIG_NX_MULTI_CORES_NR 1 -#define CONFIG_NX_ENABLE_PLATFORM_MAIN 1 -#define CONFIG_NX_IRQ_NAME_LEN 48 -#define CONFIG_NX_NR_IRQS 16 -#define CONFIG_NX_KVADDR_OFFSET 0x00000000 -#define CONFIG_NX_PAGE_SHIFT 12 -#define CONFIG_NX_MAX_THREAD_NR 256 -#define CONFIG_NX_THREAD_NAME_LEN 32 -#define CONFIG_NX_THREAD_STACK_SIZE 8192 -#define CONFIG_NX_ENABLE_SCHED 1 -#define CONFIG_NX_THREAD_MAX_PRIORITY_NR 16 -#define CONFIG_NX_PORCESS_ENV_ARGS 1024 -#define CONFIG_NX_TICKS_PER_SECOND 100 -#define CONFIG_NX_PLATFORM_I386_PC32 1 -#define CONFIG_NX_DRIVER_CONSOLE 1 -#define CONFIG_NX_PRINT_BUF_LEN 256 -#define CONFIG_NX_DRIVER_NULL 1 -#define CONFIG_NX_DRIVER_ZERO 1 -#define CONFIG_NX_DRIVER_MEMINFO 1 -#define CONFIG_NX_DRIVER_CPUINFO 1 -#define CONFIG_NX_DRIVER_PMEM 1 -#define CONFIG_NX_DRIVER_VMEM 1 -#define CONFIG_NX_VFS_MAX_PATH 512 -#define CONFIG_NX_VFS_MAX_NAME 256 -#define CONFIG_NX_VFS_MAX_FD 256 -#define CONFIG_NX_VFS_NODE_HASH_SIZE 256 -#endif diff --git a/src/platform/i386/include/platform.h b/src/platform/i386/include/platform.h deleted file mode 100644 index 236db07..0000000 --- a/src/platform/i386/include/platform.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom header - * - * Change Logs: - * Date Author Notes - * 2021-10-18 JasonHu Init - */ - -#ifndef __PLATFORM_I386__ -#define __PLATFORM_I386__ - -#include - -#define MEM_KERNEL_BASE 0x00000000 -#define MEM_KERNEL_SZ (8 * NX_MB) - -#define MEM_DMA_BASE (MEM_KERNEL_BASE + MEM_KERNEL_SZ) -#define MEM_DMA_SIZE (8 * NX_MB) - -#define MEM_NORMAL_BASE (MEM_DMA_BASE + MEM_DMA_SIZE) - -#define MEM_MIN_SIZE (510 * NX_MB) - -#define MEM_KERNEL_SPACE_SZ (512 * NX_MB) - -#define MEM_KERNEL_TOP (MEM_KERNEL_BASE + MEM_KERNEL_SPACE_SZ) - -/** - * Physical memory layout: - * - * +------------------------+ <- MAX PHY SIZE (TOP to 4GB) - * | L3 PAGES | - * +------------------------+ <- KERNEL PAGES (TOP to 512MB) - * | L3(K) & L1 & L2 PAGES | - * +------------------------+ <- 0x01000000 (16MB) - * | DMA | - * +------------------------+ <- 0x00800000 (8MB) - * | KERNEL | - * +------------------------+ <- 0x00000000 - */ - -/** - * Virtual memory layout: - * - * @: delay map - * - * +------------------------+ <- 0xFFFFFFFF (4GB) - * | @USER | - * +------------------------+ <- 0x20000000 (512MB) - * | @KMAP | - * +------------------------+ <- 0x10000000 (256MB) - * | KHEAP | - * +------------------------+ <- 0x01000000 (16MB) - * | DMA | - * +------------------------+ <- 0x00800000 (8MB) - * | KCODE & KDATA & KBSS | - * +------------------------+ <- 0x00000000 - */ - -void *NX_HalGetKernelPageTable(void); -void NX_HalClearBSS(void); - -#endif /* __PLATFORM_I386__ */ diff --git a/src/platform/i386/nxos.ld b/src/platform/i386/nxos.ld deleted file mode 100644 index 6763417..0000000 --- a/src/platform/i386/nxos.ld +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2018-2022, BookOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Link script for PC32 Platfrom - * - * Change Logs: - * Date Author Notes - * 2021-9-12 JasonHu Init - */ - -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") -OUTPUT_ARCH(i386) -ENTRY(Start) - -BASE_ADDRESS = 0x00100000; /* GRUB2 need kernel here */ - -SECTIONS { - /* Load the kernel at this address: "." means the current address */ - - . = BASE_ADDRESS; - - /* code segment */ - . = ALIGN(4); - __NX_TextStart = .; - .text : - { - *(.text.start) - *(.text) - *(.init.text) - *(.exit.text) - - . = ALIGN(4); - PROVIDE(__NX_InitCallStart = .); - KEEP(*(.initCall0.text)) - KEEP(*(.initCall1.text)) - KEEP(*(.initCall2.text)) - KEEP(*(.initCall3.text)) - KEEP(*(.initCall4.text)) - KEEP(*(.initCall5.text)) - KEEP(*(.initCall6.text)) - KEEP(*(.initCall7.text)) - KEEP(*(.initCall8.text)) - KEEP(*(.initCall9.text)) - PROVIDE(__NX_InitCallEnd = .); - - . = ALIGN(4); - PROVIDE(__NX_ExitCallStart = .); - KEEP(*(.exitcall0.text)) - KEEP(*(.exitcall1.text)) - KEEP(*(.exitcall2.text)) - KEEP(*(.exitcall3.text)) - KEEP(*(.exitcall4.text)) - KEEP(*(.exitcall5.text)) - KEEP(*(.exitcall6.text)) - KEEP(*(.exitcall7.text)) - KEEP(*(.exitcall8.text)) - KEEP(*(.exitcall9.text)) - PROVIDE(__NX_ExitCallEnd = .); - - /* section information for utest */ - . = ALIGN(4); - PROVIDE(__NX_UTestCaseTableStart = .); - KEEP(*(UTestCaseTable)) - PROVIDE(__NX_UTestCaseTableEnd = .); - - /* section information for integration */ - . = ALIGN(4); - PROVIDE(__NX_IntegrationTableStart = .); - KEEP(*(IntegrationTable)) - PROVIDE(__NX_IntegrationTableEnd = .); - } - __NX_TextEnd = .; - - - /* data segment */ - . = ALIGN(4); - __NX_DataStart = .; - - .data : - { - *(.data) - *(.data.*) - *(.rodata) - *(.rodata.*) - } - - .romdisk ALIGN(8) : - { - PROVIDE(__NX_RomdiskStart = .); - KEEP(*(.romdisk)) - PROVIDE(__NX_RomdiskEnd = .); - } - - . = ALIGN(8); - - __NX_DataEnd = .; - - /* bss segement */ - - . = ALIGN(4); - __NX_BssStart = .; - .bss : - { - *(.bss) - *(.bss.*) - *(COMMON) - } - . = ALIGN(4); - __NX_BssEnd = .; - -} diff --git a/src/platform/i386/nxos.mk b/src/platform/i386/nxos.mk deleted file mode 100644 index 65b8df1..0000000 --- a/src/platform/i386/nxos.mk +++ /dev/null @@ -1,21 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for PC32 Platform -# -# Change Logs: -# Date Author Notes -# 2021-9-20 JasonHu Init -## - -# -# Override default variables. -# -CFLAGS += -fno-builtin -fno-stack-protector -MCFLAGS += -march=i386 -LDFLAGS += -no-pie -nostartfile -n - -CC := $(CROSS_COMPILE)gcc -m32 -AS := $(CROSS_COMPILE)gcc -m32 -LD := $(CROSS_COMPILE)ld -m elf_i386 diff --git a/src/platform/k210/.gitignore b/src/platform/k210/.gitignore deleted file mode 100644 index 7404244..0000000 --- a/src/platform/k210/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tools/ -*.S diff --git a/src/platform/k210/Kconfig b/src/platform/k210/Kconfig deleted file mode 100644 index 274baee..0000000 --- a/src/platform/k210/Kconfig +++ /dev/null @@ -1,4 +0,0 @@ -config NX_PLATFORM_K210 - bool - default y - select NX_CPU_64BITS diff --git a/src/platform/k210/Makefile b/src/platform/k210/Makefile deleted file mode 100644 index e326730..0000000 --- a/src/platform/k210/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -SRC += drivers/ -SRC += hal/ \ No newline at end of file diff --git a/src/platform/k210/README.md b/src/platform/k210/README.md deleted file mode 100644 index 7a33e7d..0000000 --- a/src/platform/k210/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# 基于riscv架构的k210平台支持 - -* 双核 64-bit RISC-V RV64IMAFDC (RV64GC) CPU / 400MHz(可超频到600MHz) -* 双精度 FPU -* 8MiB 64bit 片上 SRAM(6MiB通用SRAM+2MiB的AI专用SRAM) -* 神经网络处理器(KPU) / 0.8TFLOPS -* 音频处理器(APU) -* 可编程 IO 阵列 (FPIOA) -* 双硬件512点16位复数FFT -* SPI, I2C, UART, I2S, RTC, PWM, 定时器支持 -* AES, SHA256 加速器 -* 直接内存存取控制器 (DMAC) diff --git a/src/platform/k210/cmd.mk b/src/platform/k210/cmd.mk deleted file mode 100644 index 65f9656..0000000 --- a/src/platform/k210/cmd.mk +++ /dev/null @@ -1,80 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for run k210 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -# -# Tools -# -TOOL_DIR := tools -RUSTSBI_DIR := $(TOOL_DIR)/SBI -SBI := $(TOOL_DIR)/SBI/rustsbi-k210 -RM := rm -MAKE := make -SU := sudo -PYTHON := python -CP := cp -DD := dd -DEBUGER := $(CROSS_COMPILE)gdb -DUMP := $(CROSS_COMPILE)objdump -OC := $(CROSS_COMPILE)objcopy - -K210_BIN := k210.bin -UART ?= /dev/ttyUSB0 -KFLASH := ./tools/kflash.py - -# -# Args for make -# -.PHONY: run clean - -# -# flush into k210 devboard -# -run: - $(OC) $(NXOS_NAME).elf --strip-all -O binary $(NXOS_NAME).bin - $(OC) $(SBI) --strip-all -O binary $(K210_BIN) - $(DD) if=$(NXOS_NAME).bin of=$(K210_BIN) bs=128k seek=1 - echo "K210 run..." -ifeq ($(HOSTOS),linux) - $(SU) chmod 777 $(UART) -endif - $(PYTHON) $(KFLASH) -p $(UART) -b 1500000 -t $(K210_BIN) - -# -# Clear target file -# -clean: - -$(RM) $(NXOS_NAME).elf - -$(RM) $(K210_BIN) - -$(RM) $(NXOS_NAME).dump.S - -$(RM) $(NXOS_NAME).bin - -# -# prepare tools -# -prepare: - -$(RM) -rf $(TOOL_DIR) - git clone https://gitee.com/BookOS/nxos-platform-k210-tools $(TOOL_DIR) - echo "parpare done." - -# -# gdb debug -# -gdb: - @echo gdb load file from $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DEBUGER) $(NXOS_NAME).elf -x connect.gdb - -# -# dump kernel -# -dump: - @echo dump kernel $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DUMP) -D -S $(NXOS_NAME).elf > $(NXOS_NAME).dump.S - \ No newline at end of file diff --git a/src/platform/k210/compile.mk b/src/platform/k210/compile.mk deleted file mode 100644 index 0470618..0000000 --- a/src/platform/k210/compile.mk +++ /dev/null @@ -1,17 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for QEMU Riscv64 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -# modify compiler here -ifeq ($(HOSTOS), windows) -CROSS_COMPILE := riscv-none-embed- -else -CROSS_COMPILE := riscv64-unknown-elf- -endif diff --git a/src/platform/k210/connect.gdb b/src/platform/k210/connect.gdb deleted file mode 100644 index 90f7c83..0000000 --- a/src/platform/k210/connect.gdb +++ /dev/null @@ -1 +0,0 @@ -target remote localhost:10001 \ No newline at end of file diff --git a/src/platform/k210/defconfig b/src/platform/k210/defconfig deleted file mode 100644 index 728c7e5..0000000 --- a/src/platform/k210/defconfig +++ /dev/null @@ -1,70 +0,0 @@ -CONFIG_NX_CPU_64BITS=y - -# -# OS Kernel -# - -# -# Debug -# -CONFIG_NX_DEBUG=y -CONFIG_NX_LOG_LEVEL=3 -CONFIG_NX_DEBUG_COLOR=y -CONFIG_NX_DEBUG_TIMELINE=y -# CONFIG_NX_DEBUG_LINENUMBER is not set -# end of Debug - -CONFIG_NX_PLATFORM_NAME="riscv64-k210" -CONFIG_NX_MULTI_CORES_NR=1 -CONFIG_NX_ENABLE_PLATFORM_MAIN=y -CONFIG_NX_IRQ_NAME_LEN=48 -CONFIG_NX_NR_IRQS=66 -CONFIG_NX_KVADDR_OFFSET=0x00000000 -CONFIG_NX_PAGE_SHIFT=12 -CONFIG_NX_MAX_THREAD_NR=256 -CONFIG_NX_THREAD_NAME_LEN=32 -CONFIG_NX_THREAD_STACK_SIZE=8192 -CONFIG_NX_ENABLE_SCHED=y -CONFIG_NX_THREAD_MAX_PRIORITY_NR=16 -CONFIG_NX_PORCESS_ENV_ARGS=1024 -CONFIG_NX_TICKS_PER_SECOND=100 -# end of OS Kernel - -# -# Platform -# -CONFIG_NX_PLATFORM_K210=y -# end of Platform - -# -# Device -# -CONFIG_NX_DRIVER_CONSOLE=y -CONFIG_NX_PRINT_BUF_LEN=256 -# CONFIG_NX_DRIVER_ROMDISK is not set -# CONFIG_NX_DRIVER_DUMMY is not set -CONFIG_NX_DRIVER_NULL=y -CONFIG_NX_DRIVER_ZERO=y -CONFIG_NX_DRIVER_MEMINFO=y -CONFIG_NX_DRIVER_CPUINFO=y -# end of Device - -# -# File System -# -# CONFIG_NX_FS_CPIO is not set -# CONFIG_NX_FS_DEVFS is not set -# CONFIG_NX_ENABLE_EXECUTE_USER is not set -# CONFIG_NX_ENABLE_MOUNT_TABLE is not set -CONFIG_NX_VFS_MAX_PATH=512 -CONFIG_NX_VFS_MAX_NAME=256 -CONFIG_NX_VFS_MAX_FD=256 -CONFIG_NX_VFS_NODE_HASH_SIZE=256 -# end of File System - -# -# Tests -# -# CONFIG_NX_ENABLE_TEST_UTEST is not set -# CONFIG_NX_ENABLE_TEST_INTEGRATION is not set -# end of Tests diff --git a/src/platform/k210/drivers/Makefile b/src/platform/k210/drivers/Makefile deleted file mode 100644 index 28afb05..0000000 --- a/src/platform/k210/drivers/Makefile +++ /dev/null @@ -1 +0,0 @@ -SRC += *.c \ No newline at end of file diff --git a/src/platform/k210/drivers/direct_uart.c b/src/platform/k210/drivers/direct_uart.c deleted file mode 100644 index 8ba0f39..0000000 --- a/src/platform/k210/drivers/direct_uart.c +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart driver from rustsbi - * - * Change Logs: - * Date Author Notes - * 2022-1-26 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -void NX_HalDirectUartPutc(char ch) -{ - sbi_console_putchar(ch); -} - -int NX_HalDirectUartGetc(void) -{ - return sbi_console_getchar(); -} - -NX_INTERFACE void NX_ConsoleSendData(char ch) -{ - NX_HalDirectUartPutc(ch); -} - -void NX_HalDirectUartInit(void) -{ - /* k210 do nothing */ -} - -/** - * default handler -*/ -NX_WEAK_SYM void NX_HalDirectUartGetcHandler(char data) -{ - NX_ConsoleReceveData(data); -} - -NX_PRIVATE NX_Error UartIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - int data = NX_HalDirectUartGetc(); - if (data != -1) - { - if (NX_HalDirectUartGetcHandler != NX_NULL) - { - NX_HalDirectUartGetcHandler(data); - } - } - return data != -1 ? NX_EOK : NX_EIO; -} - -void NX_HalDirectUartStage2(void) -{ - NX_ASSERT(NX_IRQ_Bind(UART0_IRQ, UartIrqHandler, NX_NULL, "Uart0", 0) == NX_EOK); - NX_ASSERT(NX_IRQ_Unmask(UART0_IRQ) == NX_EOK); -} diff --git a/src/platform/k210/hal/init.c b/src/platform/k210/hal/init.c deleted file mode 100644 index 4cbc940..0000000 --- a/src/platform/k210/hal/init.c +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Init Riscv64 Qemu platfrom - * - * Change Logs: - * Date Author Notes - * 2021-10-1 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NX_LOG_LEVEL NX_LOG_INFO -#define NX_LOG_NAME "INIT" -#include - -NX_INTERFACE NX_Error NX_HalPlatformInit(NX_UArch coreId) -{ - /* NOTE: init trap first before do anything */ - CPU_InitTrap(coreId); - - NX_HalDirectUartInit(); - - NX_LOG_I("Hello, world!"); - - PLIC_Init(NX_True); - - NX_HalPageZoneInit(); - - return NX_EOK; -} - -NX_INTERFACE NX_Error NX_HalPlatformStage2(void) -{ - NX_LOG_I("stage2!"); - - NX_HalDirectUartStage2(); - - return NX_EOK; -} diff --git a/src/platform/k210/hal/main.c b/src/platform/k210/hal/main.c deleted file mode 100644 index c20ceda..0000000 --- a/src/platform/k210/hal/main.c +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom main - * - * Change Logs: - * Date Author Notes - * 2021-12-04 JasonHu Init - */ - -#include -#define NX_LOG_NAME "Hal Main" -#include - -#ifdef CONFIG_NX_ENABLE_PLATFORM_MAIN -NX_INTERFACE void NX_HalPlatformMain(void) -{ - NX_LOG_I("k210 platform main running...\n"); -} -#endif /* CONFIG_NX_ENABLE_PLATFORM_MAIN */ diff --git a/src/platform/k210/include/drivers/direct_uart.h b/src/platform/k210/include/drivers/direct_uart.h deleted file mode 100644 index c0f200f..0000000 --- a/src/platform/k210/include/drivers/direct_uart.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart - * - * Change Logs: - * Date Author Notes - * 2021-12-4 JasonHu Init - */ - -#ifndef __DIRECT_UART_HEADER__ -#define __DIRECT_UART_HEADER__ - -#include - -#define UART0_PHY_ADDR 0x38000000L -#define UART0_IRQ 33 - -/* direct means not use driver framework */ - -void NX_HalDirectUartInit(void); -void NX_HalDirectUartStage2(void); - -void NX_HalDirectUartPutc(char ch); -int NX_HalDirectUartGetc(void); - -#endif /* __DIRECT_UART_HEADER__ */ diff --git a/src/platform/k210/include/nx_configure.h b/src/platform/k210/include/nx_configure.h deleted file mode 100644 index e8d5227..0000000 --- a/src/platform/k210/include/nx_configure.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __NX_CONFIG__ -#define __NX_CONFIG__ -#define CONFIG_NX_CPU_64BITS 1 -#define CONFIG_NX_DEBUG 1 -#define CONFIG_NX_LOG_LEVEL 3 -#define CONFIG_NX_DEBUG_COLOR 1 -#define CONFIG_NX_DEBUG_TIMELINE 1 -#define CONFIG_NX_PLATFORM_NAME "riscv64-k210" -#define CONFIG_NX_MULTI_CORES_NR 1 -#define CONFIG_NX_ENABLE_PLATFORM_MAIN 1 -#define CONFIG_NX_IRQ_NAME_LEN 48 -#define CONFIG_NX_NR_IRQS 66 -#define CONFIG_NX_KVADDR_OFFSET 0x00000000 -#define CONFIG_NX_PAGE_SHIFT 12 -#define CONFIG_NX_MAX_THREAD_NR 256 -#define CONFIG_NX_THREAD_NAME_LEN 32 -#define CONFIG_NX_THREAD_STACK_SIZE 8192 -#define CONFIG_NX_ENABLE_SCHED 1 -#define CONFIG_NX_THREAD_MAX_PRIORITY_NR 16 -#define CONFIG_NX_PORCESS_ENV_ARGS 1024 -#define CONFIG_NX_TICKS_PER_SECOND 100 -#define CONFIG_NX_PLATFORM_K210 1 -#define CONFIG_NX_DRIVER_CONSOLE 1 -#define CONFIG_NX_PRINT_BUF_LEN 256 -#define CONFIG_NX_DRIVER_NULL 1 -#define CONFIG_NX_DRIVER_ZERO 1 -#define CONFIG_NX_DRIVER_MEMINFO 1 -#define CONFIG_NX_DRIVER_CPUINFO 1 -#define CONFIG_NX_VFS_MAX_PATH 512 -#define CONFIG_NX_VFS_MAX_NAME 256 -#define CONFIG_NX_VFS_MAX_FD 256 -#define CONFIG_NX_VFS_NODE_HASH_SIZE 256 -#endif diff --git a/src/platform/k210/include/platform.h b/src/platform/k210/include/platform.h deleted file mode 100644 index 5fc000d..0000000 --- a/src/platform/k210/include/platform.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom header - * - * Change Logs: - * Date Author Notes - * 2021-10-18 JasonHu Init - */ - -#ifndef __PLATFORM_HEADER__ -#define __PLATFORM_HEADER__ - -#include - -#define DRAM_SIZE_DEFAULT (6 * NX_MB) - -#define MEM_SBI_BASE 0x80000000UL -#define MEM_SBI_SZ (128 * NX_KB) - -#define MEM_KERNEL_BASE (MEM_SBI_BASE + MEM_SBI_SZ) -#define MEM_KERNEL_SZ (512 * NX_KB) - -#define MEM_NORMAL_BASE (MEM_KERNEL_BASE + MEM_KERNEL_SZ) - -#define MEM_MIN_SIZE (4 * NX_MB) - -#define MEM_KERNEL_SPACE_SZ (6 * NX_MB) - -#define MEM_KERNEL_TOP (MEM_SBI_BASE + MEM_KERNEL_SPACE_SZ) - -/* max cpus for qemu */ -#define PLATFORM_MAX_NR_MULTI_CORES 2 - -/** - * Physical memory layout: - * - * +------------------------+ <- MAX PHY SIZE (TOP to 4GB) - * | L3 PAGES | - * +------------------------+ <- KERNEL PAGES (TOP to 2GB + 128MB) - * | L3(K) & L0/1/2 PAGES | - * +------------------------+ <- 0x82000000 (2GB + 32MB) - * | KERNEL | - * +------------------------+ <- 0x80200000 (2GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x80000000 (2GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -/** - * Virtual memory layout: - * - * @: delay map - * - * +------------------------+ <- 0x400000000 (16GB) - * | @USER | - * +------------------------+ <- 0xFFFFFFFF (4GB) - * | @RESERVED | - * +------------------------+ <- 0x88000000 (2GB + 128MB) - * | @KMAP | - * +------------------------+ <- 0x84000000 (2GB + 64MB) - * | KHEAP | - * +------------------------+ <- 0x82000000 (2GB + 32MB) - * | KCODE & KDATA & KBSS | - * +------------------------+ <- 0x80200000 (2GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x80000000 (2GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -NX_IMPORT void NX_HalClearBSS(void); -NX_IMPORT void MMU_EarlyMap(void); -void *NX_HalGetKernelPageTable(void); - -#endif /* __PLATFORM_HEADER__ */ diff --git a/src/platform/k210/nxos.ld b/src/platform/k210/nxos.ld deleted file mode 100644 index 703e25c..0000000 --- a/src/platform/k210/nxos.ld +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Link script for Riscv64 k210 Platform - * - * Change Logs: - * Date Author Notes - * 2022-1-25 JasonHu Init - * 2022-4-18 JasonHu update and add __global_pointer$ - */ - -OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") -OUTPUT_ARCH(riscv) -ENTRY(_Start) - -MEMORY -{ - /* rustsbi jump to 0x80020000 */ - SRAM : ORIGIN = 0x80020000, LENGTH = 0x5E0000 -} - -SECTIONS -{ - /* code segment */ - . = ALIGN(8); - .text : - { - __NX_TextStart = .; - *(.text.start) - *(.text) - *(.init.text) - *(.exit.text) - - *(.rodata) - *(.rodata.*) - - . = ALIGN(8); - PROVIDE(__NX_InitCallStart = .); - KEEP(*(.initCall0.text)) - KEEP(*(.initCall1.text)) - KEEP(*(.initCall2.text)) - KEEP(*(.initCall3.text)) - KEEP(*(.initCall4.text)) - KEEP(*(.initCall5.text)) - KEEP(*(.initCall6.text)) - KEEP(*(.initCall7.text)) - KEEP(*(.initCall8.text)) - KEEP(*(.initCall9.text)) - PROVIDE(__NX_InitCallEnd = .); - - . = ALIGN(8); - PROVIDE(__NX_ExitCallStart = .); - KEEP(*(.exitcall0.text)) - KEEP(*(.exitcall1.text)) - KEEP(*(.exitcall2.text)) - KEEP(*(.exitcall3.text)) - KEEP(*(.exitcall4.text)) - KEEP(*(.exitcall5.text)) - KEEP(*(.exitcall6.text)) - KEEP(*(.exitcall7.text)) - KEEP(*(.exitcall8.text)) - KEEP(*(.exitcall9.text)) - PROVIDE(__NX_ExitCallEnd = .); - - /* section information for utest */ - . = ALIGN(8); - PROVIDE(__NX_UTestCaseTableStart = .); - KEEP(*(UTestCaseTable)) - PROVIDE(__NX_UTestCaseTableEnd = .); - - /* section information for integration */ - . = ALIGN(8); - PROVIDE(__NX_IntegrationTableStart = .); - KEEP(*(IntegrationTable)) - PROVIDE(__NX_IntegrationTableEnd = .); - __NX_TextEnd = .; - } > SRAM - - /* data segment */ - . = ALIGN(8); - - .data : - { - __NX_DataStart = .; - *(.data) - *(.data.*) - - . = ALIGN(8); - PROVIDE( __global_pointer$ = . + 0x800 ); - - *(.sdata) - *(.sdata.*) - } > SRAM - - .romdisk ALIGN(8) : - { - PROVIDE(__NX_RomdiskStart = .); - KEEP(*(.romdisk)) - PROVIDE(__NX_RomdiskEnd = .); - __NX_DataEnd = .; - } > SRAM - - . = ALIGN(8); - - __NX_DataEnd = .; - - /* bss segement */ - - .sbss : - { - __NX_BssStart = .; - *(.sbss) - *(.sbss.*) - *(.dynsbss) - *(.scommon) - } > SRAM - - .bss : - { - *(.bss) - *(.bss.*) - *(.dynbss) - *(COMMON) - . = ALIGN(8); - __NX_BssEnd = .; - } > SRAM -} \ No newline at end of file diff --git a/src/platform/k210/nxos.mk b/src/platform/k210/nxos.mk deleted file mode 100644 index 003128d..0000000 --- a/src/platform/k210/nxos.mk +++ /dev/null @@ -1,18 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for QEMU Riscv64 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -# -# Override default variables. -# -CFLAGS += -fno-stack-protector -mno-relax -ASFLAGS += -ffunction-sections -fdata-sections -ffreestanding -MCFLAGS += -march=rv64imafdc -mabi=lp64d -mcmodel=medany -LDFLAGS += -no-pie -nostartfile -n diff --git a/src/platform/qemu_riscv64/.gitignore b/src/platform/qemu_riscv64/.gitignore deleted file mode 100644 index 7404244..0000000 --- a/src/platform/qemu_riscv64/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -tools/ -*.S diff --git a/src/platform/qemu_riscv64/Kconfig b/src/platform/qemu_riscv64/Kconfig deleted file mode 100644 index a985657..0000000 --- a/src/platform/qemu_riscv64/Kconfig +++ /dev/null @@ -1,8 +0,0 @@ -config NX_PLATFORM_RISCV64_QEMU - bool - default y - select NX_CPU_64BITS - -config NX_UART0_FROM_SBI - bool "Uart0 get/set from SBI" - default n diff --git a/src/platform/qemu_riscv64/Makefile b/src/platform/qemu_riscv64/Makefile deleted file mode 100644 index e326730..0000000 --- a/src/platform/qemu_riscv64/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -SRC += drivers/ -SRC += hal/ \ No newline at end of file diff --git a/src/platform/qemu_riscv64/README.md b/src/platform/qemu_riscv64/README.md deleted file mode 100644 index f001164..0000000 --- a/src/platform/qemu_riscv64/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# 基于riscv64处理器的QEMU平台支持 - -# TODO - -- [x] 添加异常处理 - - [x] 时钟中断导致异常,换成opensbi再试试。 -- [x] 添加内存管理 -- [x] 添加时钟中断 -- [x] 添加中断管理,中断控制器 -- [x] 添加串口接收中断 -- [x] 添加原子操作 -- [x] 添加上下文切换操作 -- [x] 完善多线程下上下文切换操作 -- [x] 添加quickstart.md -- [ ] 添加内核MMU映射 - -- [ ] 添加SMP支持 - - [x] 添加SMP启动 - - [ ] 添加SMP调度 - - [ ] 线程sleep有BUG。 - - [ ] SpinLockIRQ中添加level支持 - - - -# 内存布局 - -see https://nankai.gitbook.io/ucore-os-on-risc-v64/lab2/wu-li-nei-cun-tan-ce - diff --git a/src/platform/qemu_riscv64/cmd.mk b/src/platform/qemu_riscv64/cmd.mk deleted file mode 100644 index d7eaf36..0000000 --- a/src/platform/qemu_riscv64/cmd.mk +++ /dev/null @@ -1,97 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for run QEMU Riscv64 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -# -# Config graphic window ? (y/n) -# -QEMU_WINDOW ?= n - -# -# Tools -# -TOOL_DIR := tools -RUSTSBI_DIR := $(TOOL_DIR)/SBI -SBI := $(TOOL_DIR)/SBI/opensbi-qemu -RM := rm - -# -# Tools name -# -MAKE := make -QEMU := qemu-system-riscv64 -DEBUGER := $(CROSS_COMPILE)gdb -DUMP := $(CROSS_COMPILE)objdump - -# -# Qemu args configure -# -QEMU_ARGS := -m 256m \ - -name "NXOS - Plartform QEMU - Arch Riscv64" - -# cpus -ifndef CORES -CORES := 1 -endif # CORES - -QEMU_ARGS += -machine virt -QEMU_ARGS += -kernel $(NXOS_NAME).elf -QEMU_ARGS += -bios $(SBI) -QEMU_ARGS += -smp $(CORES) - -ifeq ($(QEMU_WINDOW),y) - QEMU_ARGS += -serial stdio -else - QEMU_ARGS += -nographic -endif - -ifeq ($(G),y) - QEMU_ARGS += -S -gdb tcp::10001,ipv4 -endif - -# -# Args for make -# -.PHONY: run clean - -# -# Run OS in QEMU -# -run: - $(QEMU) $(QEMU_ARGS) - -# -# Clear target file -# -clean: - -$(RM) $(NXOS_NAME).elf - -# -# prepare tools -# -prepare: - -$(RM) -rf $(TOOL_DIR) - git clone https://gitee.com/BookOS/nxos-platform-qemu-riscv64-tools $(TOOL_DIR) - echo "parpare done." - -# -# gdb debug -# -gdb: - @echo gdb load file from $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DEBUGER) $(NXOS_NAME).elf -x connect.gdb - -# -# dump kernel -# -dump: - @echo dump kernel $(ARCH)/$(PLATFORM)/$(NXOS_NAME).elf - $(DUMP) -D -S $(NXOS_NAME).elf > $(NXOS_NAME).dump.S - \ No newline at end of file diff --git a/src/platform/qemu_riscv64/compile.mk b/src/platform/qemu_riscv64/compile.mk deleted file mode 100644 index 0470618..0000000 --- a/src/platform/qemu_riscv64/compile.mk +++ /dev/null @@ -1,17 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for QEMU Riscv64 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -# modify compiler here -ifeq ($(HOSTOS), windows) -CROSS_COMPILE := riscv-none-embed- -else -CROSS_COMPILE := riscv64-unknown-elf- -endif diff --git a/src/platform/qemu_riscv64/connect.gdb b/src/platform/qemu_riscv64/connect.gdb deleted file mode 100644 index 90f7c83..0000000 --- a/src/platform/qemu_riscv64/connect.gdb +++ /dev/null @@ -1 +0,0 @@ -target remote localhost:10001 \ No newline at end of file diff --git a/src/platform/qemu_riscv64/defconfig b/src/platform/qemu_riscv64/defconfig deleted file mode 100644 index d5a9713..0000000 --- a/src/platform/qemu_riscv64/defconfig +++ /dev/null @@ -1,71 +0,0 @@ -CONFIG_NX_CPU_64BITS=y - -# -# OS Kernel -# - -# -# Debug -# -CONFIG_NX_DEBUG=y -CONFIG_NX_LOG_LEVEL=3 -CONFIG_NX_DEBUG_COLOR=y -CONFIG_NX_DEBUG_TIMELINE=y -# CONFIG_NX_DEBUG_LINENUMBER is not set -# end of Debug - -CONFIG_NX_PLATFORM_NAME="riscv64-qemu_riscv64" -CONFIG_NX_MULTI_CORES_NR=1 -CONFIG_NX_ENABLE_PLATFORM_MAIN=y -CONFIG_NX_IRQ_NAME_LEN=48 -CONFIG_NX_NR_IRQS=80 -CONFIG_NX_KVADDR_OFFSET=0x00000000 -CONFIG_NX_PAGE_SHIFT=12 -CONFIG_NX_MAX_THREAD_NR=256 -CONFIG_NX_THREAD_NAME_LEN=32 -CONFIG_NX_THREAD_STACK_SIZE=8192 -CONFIG_NX_ENABLE_SCHED=y -CONFIG_NX_THREAD_MAX_PRIORITY_NR=16 -CONFIG_NX_PORCESS_ENV_ARGS=1024 -CONFIG_NX_TICKS_PER_SECOND=100 -# end of OS Kernel - -# -# Platform -# -CONFIG_NX_PLATFORM_RISCV64_QEMU=y -CONFIG_NX_UART0_FROM_SBI=y -# end of Platform - -# -# Device -# -CONFIG_NX_DRIVER_CONSOLE=y -CONFIG_NX_PRINT_BUF_LEN=256 -# CONFIG_NX_DRIVER_ROMDISK is not set -# CONFIG_NX_DRIVER_DUMMY is not set -CONFIG_NX_DRIVER_NULL=y -CONFIG_NX_DRIVER_ZERO=y -CONFIG_NX_DRIVER_MEMINFO=y -CONFIG_NX_DRIVER_CPUINFO=y -# end of Device - -# -# File System -# -# CONFIG_NX_FS_CPIO is not set -# CONFIG_NX_FS_DEVFS is not set -# CONFIG_NX_ENABLE_EXECUTE_USER is not set -# CONFIG_NX_ENABLE_MOUNT_TABLE is not set -CONFIG_NX_VFS_MAX_PATH=512 -CONFIG_NX_VFS_MAX_NAME=256 -CONFIG_NX_VFS_MAX_FD=256 -CONFIG_NX_VFS_NODE_HASH_SIZE=256 -# end of File System - -# -# Tests -# -# CONFIG_NX_ENABLE_TEST_UTEST is not set -# CONFIG_NX_ENABLE_TEST_INTEGRATION is not set -# end of Tests diff --git a/src/platform/qemu_riscv64/drivers/Makefile b/src/platform/qemu_riscv64/drivers/Makefile deleted file mode 100644 index 28afb05..0000000 --- a/src/platform/qemu_riscv64/drivers/Makefile +++ /dev/null @@ -1 +0,0 @@ -SRC += *.c \ No newline at end of file diff --git a/src/platform/qemu_riscv64/drivers/direct_uart.c b/src/platform/qemu_riscv64/drivers/direct_uart.c deleted file mode 100644 index 4c015ff..0000000 --- a/src/platform/qemu_riscv64/drivers/direct_uart.c +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart driver - * low-level driver routines for 16550a UART. - * - * Change Logs: - * Date Author Notes - * 2021-10-1 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_NX_UART0_FROM_SBI -#include -#endif - -#include - -// the UART control registers. -// some have different meanings for -// read vs write. -// see http://byterunner.com/16550.html -#define RHR 0 // receive holding register (for input bytes) -#define THR 0 // transmit holding register (for output bytes) -#define IER 1 // interrupt enable register -#define IER_RX_ENABLE (1 << 0) // receiver ready interrupt. -#define IER_TX_ENABLE (1 << 1) // transmitter empty interrupt. -#define FCR 2 // FIFO control register -#define FCR_FIFO_ENABLE (1 << 0) -#define FCR_FIFO_CLEAR (3 << 1) // clear the content of the two FIFOs -#define ISR 2 // interrupt status register -#define LCR 3 // line control register -#define LCR_EIGHT_BITS (3 << 0) -#define LCR_BAUD_LATCH (1 << 7) // special mode to set baud rate -#define LSR 5 // line status register -#define LSR_RX_READY (1 << 0) // input is waiting to be read from RHR -#define LSR_TX_IDLE (1 << 5) // THR can accept another character to send - -void NX_HalDirectUartPutc(char ch) -{ -#ifdef CONFIG_NX_UART0_FROM_SBI - sbi_console_putchar(ch); -#else - if ((Read8(UART0_PHY_ADDR + LSR) & LSR_TX_IDLE) == 0) - { - // the UART transmit holding register is full, - return; - } - Write8(UART0_PHY_ADDR + THR, ch); -#endif -} - -int NX_HalDirectUartGetc(void) -{ -#ifdef CONFIG_NX_UART0_FROM_SBI - return sbi_console_getchar(); -#else - if (Read8(UART0_PHY_ADDR + LSR) & 0x01) - { - // input data is ready. - return Read8(UART0_PHY_ADDR + RHR); - } - else - { - return -1; - } -#endif -} - -NX_INTERFACE void NX_ConsoleSendData(char ch) -{ - NX_HalDirectUartPutc(ch); -} - -void NX_HalDirectUartInit(void) -{ - // disable interrupts. - Write8(UART0_PHY_ADDR + IER, 0x00); - // special mode to set baud rate. - Write8(UART0_PHY_ADDR + LCR, LCR_BAUD_LATCH); - // LSB for baud rate of 115.2K. - Write8(UART0_PHY_ADDR + 0, 0x01); - // MSB for baud rate of 115.2K. - Write8(UART0_PHY_ADDR + 1, 0x00); - // leave set-baud mode, - // and set word length to 8 bits, no parity. - Write8(UART0_PHY_ADDR + LCR, LCR_EIGHT_BITS); - // reset and enable FIFOs. - Write8(UART0_PHY_ADDR + FCR, FCR_FIFO_ENABLE | FCR_FIFO_CLEAR); -} - -/** - * default handler -*/ -NX_WEAK_SYM void NX_HalDirectUartGetcHandler(char data) -{ - NX_ConsoleReceveData(data); -} - -NX_PRIVATE NX_Error UartIrqHandler(NX_IRQ_Number irqno, void *arg) -{ - int data = NX_HalDirectUartGetc(); - if (data != -1) - { - if (NX_HalDirectUartGetcHandler != NX_NULL) - { - NX_HalDirectUartGetcHandler(data); - } - } - return data != -1 ? NX_EOK : NX_EIO; -} - -void NX_HalDirectUartStage2(void) -{ - /* enable receive interrupts. */ - Write8(UART0_PHY_ADDR + IER, IER_RX_ENABLE); - - NX_ASSERT(NX_IRQ_Bind(UART0_IRQ, UartIrqHandler, NX_NULL, "Uart", 0) == NX_EOK); - NX_ASSERT(NX_IRQ_Unmask(UART0_IRQ) == NX_EOK); -} diff --git a/src/platform/qemu_riscv64/hal/init.c b/src/platform/qemu_riscv64/hal/init.c deleted file mode 100644 index 86b857f..0000000 --- a/src/platform/qemu_riscv64/hal/init.c +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Init Riscv64 Qemu platfrom - * - * Change Logs: - * Date Author Notes - * 2021-10-1 JasonHu Init - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NX_LOG_LEVEL NX_LOG_INFO -#define NX_LOG_NAME "INIT" -#include - -NX_INTERFACE NX_Error NX_HalPlatformInit(NX_UArch coreId) -{ - /* NOTE: init trap first before do anything */ - CPU_InitTrap(coreId); - - NX_HalDirectUartInit(); - - sbi_init(); - sbi_print_version(); - - NX_LOG_I("Hello, QEMU Riscv64!"); - - PLIC_Init(NX_True); - - NX_HalPageZoneInit(); - - return NX_EOK; -} - -NX_INTERFACE NX_Error NX_HalPlatformStage2(void) -{ - NX_LOG_I("stage2!"); - - NX_HalDirectUartStage2(); - - return NX_EOK; -} diff --git a/src/platform/qemu_riscv64/hal/main.c b/src/platform/qemu_riscv64/hal/main.c deleted file mode 100644 index 2fae3cc..0000000 --- a/src/platform/qemu_riscv64/hal/main.c +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom main - * - * Change Logs: - * Date Author Notes - * 2021-12-04 JasonHu Init - */ - -#include -#define NX_LOG_NAME "Hal Main" -#include - -#ifdef CONFIG_NX_ENABLE_PLATFORM_MAIN -NX_INTERFACE void NX_HalPlatformMain(void) -{ - NX_LOG_I("QEMU platform main running...\n"); -} -#endif /* CONFIG_NX_ENABLE_PLATFORM_MAIN */ diff --git a/src/platform/qemu_riscv64/include/drivers/direct_uart.h b/src/platform/qemu_riscv64/include/drivers/direct_uart.h deleted file mode 100644 index 0bc9fd9..0000000 --- a/src/platform/qemu_riscv64/include/drivers/direct_uart.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Direct uart - * - * Change Logs: - * Date Author Notes - * 2021-12-4 JasonHu Init - */ - -#ifndef __DIRECT_UART_HEADER__ -#define __DIRECT_UART_HEADER__ - -#include - -#define UART0_PHY_ADDR 0x10000000L -#define UART0_IRQ 10 - -/* direct means not use driver framework */ - -void NX_HalDirectUartInit(void); -void NX_HalDirectUartStage2(void); - -void NX_HalDirectUartPutc(char ch); -int NX_HalDirectUartGetc(void); - -#endif /* __DIRECT_UART_HEADER__ */ diff --git a/src/platform/qemu_riscv64/include/nx_configure.h b/src/platform/qemu_riscv64/include/nx_configure.h deleted file mode 100644 index cd77689..0000000 --- a/src/platform/qemu_riscv64/include/nx_configure.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __NX_CONFIG__ -#define __NX_CONFIG__ -#define CONFIG_NX_CPU_64BITS 1 -#define CONFIG_NX_DEBUG 1 -#define CONFIG_NX_LOG_LEVEL 3 -#define CONFIG_NX_DEBUG_COLOR 1 -#define CONFIG_NX_DEBUG_TIMELINE 1 -#define CONFIG_NX_PLATFORM_NAME "riscv64-qemu_riscv64" -#define CONFIG_NX_MULTI_CORES_NR 1 -#define CONFIG_NX_ENABLE_PLATFORM_MAIN 1 -#define CONFIG_NX_IRQ_NAME_LEN 48 -#define CONFIG_NX_NR_IRQS 80 -#define CONFIG_NX_KVADDR_OFFSET 0x00000000 -#define CONFIG_NX_PAGE_SHIFT 12 -#define CONFIG_NX_MAX_THREAD_NR 256 -#define CONFIG_NX_THREAD_NAME_LEN 32 -#define CONFIG_NX_THREAD_STACK_SIZE 8192 -#define CONFIG_NX_ENABLE_SCHED 1 -#define CONFIG_NX_THREAD_MAX_PRIORITY_NR 16 -#define CONFIG_NX_PORCESS_ENV_ARGS 1024 -#define CONFIG_NX_TICKS_PER_SECOND 100 -#define CONFIG_NX_PLATFORM_RISCV64_QEMU 1 -#define CONFIG_NX_UART0_FROM_SBI 1 -#define CONFIG_NX_DRIVER_CONSOLE 1 -#define CONFIG_NX_PRINT_BUF_LEN 256 -#define CONFIG_NX_DRIVER_NULL 1 -#define CONFIG_NX_DRIVER_ZERO 1 -#define CONFIG_NX_DRIVER_MEMINFO 1 -#define CONFIG_NX_DRIVER_CPUINFO 1 -#define CONFIG_NX_VFS_MAX_PATH 512 -#define CONFIG_NX_VFS_MAX_NAME 256 -#define CONFIG_NX_VFS_MAX_FD 256 -#define CONFIG_NX_VFS_NODE_HASH_SIZE 256 -#endif diff --git a/src/platform/qemu_riscv64/include/platform.h b/src/platform/qemu_riscv64/include/platform.h deleted file mode 100644 index 39efbac..0000000 --- a/src/platform/qemu_riscv64/include/platform.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Platfrom header - * - * Change Logs: - * Date Author Notes - * 2021-10-18 JasonHu Init - */ - -#ifndef __PLATFORM_HEADER__ -#define __PLATFORM_HEADER__ - -#include - -#define DRAM_SIZE_DEFAULT (256 * NX_MB) - -#define MEM_SBI_BASE 0x80000000UL -#define MEM_SBI_SZ (2 * NX_MB) - -#define MEM_KERNEL_BASE (MEM_SBI_BASE + MEM_SBI_SZ) -#define MEM_KERNEL_SZ (30 * NX_MB) - -#define MEM_NORMAL_BASE (MEM_KERNEL_BASE + MEM_KERNEL_SZ) - -#define MEM_MIN_SIZE (128 * NX_MB) - -#define MEM_KERNEL_SPACE_SZ (128 * NX_MB) - -#define MEM_KERNEL_TOP (MEM_SBI_BASE + MEM_KERNEL_SPACE_SZ) - -/* max cpus for qemu */ -#define PLATFORM_MAX_NR_MULTI_CORES 8 - -/** - * Physical memory layout: - * - * +------------------------+ <- MAX PHY SIZE (TOP to 4GB) - * | L3 PAGES | - * +------------------------+ <- KERNEL PAGES (TOP to 2GB + 128MB) - * | L3(K) & L0/1/2 PAGES | - * +------------------------+ <- 0x82000000 (2GB + 32MB) - * | KERNEL | - * +------------------------+ <- 0x80200000 (2GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x80000000 (2GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -/** - * Virtual memory layout: - * - * @: delay map - * - * +------------------------+ <- 0x400000000 (16GB) - * | @USER | - * +------------------------+ <- 0xFFFFFFFF (4GB) - * | @RESERVED | - * +------------------------+ <- 0x88000000 (2GB + 128MB) - * | @KMAP | - * +------------------------+ <- 0x84000000 (2GB + 64MB) - * | KHEAP | - * +------------------------+ <- 0x82000000 (2GB + 32MB) - * | KCODE & KDATA & KBSS | - * +------------------------+ <- 0x80200000 (2GB + 2MB) - * | OPENSBI | - * +------------------------+ <- 0x80000000 (2GB) - * | MMIO/UNMAPPED | - * +------------------------+ <- 0x00000000 - */ - -NX_IMPORT void NX_HalClearBSS(void); -NX_IMPORT void MMU_EarlyMap(void); -void *NX_HalGetKernelPageTable(void); - -#endif /* __PLATFORM_HEADER__ */ diff --git a/src/platform/qemu_riscv64/nxos.ld b/src/platform/qemu_riscv64/nxos.ld deleted file mode 100644 index 7644115..0000000 --- a/src/platform/qemu_riscv64/nxos.ld +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) 2018-2022, NXOS Development Team - * SPDX-License-Identifier: Apache-2.0 - * - * Contains: Link script for QEMU Riscv64 Platform - * - * Change Logs: - * Date Author Notes - * 2021-10-1 JasonHu Init - * 2021-12-1 JasonHu Update symbol - * 2022-4-18 JasonHu update and add __global_pointer$ - */ - -OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") -OUTPUT_ARCH(riscv) -ENTRY(_Start) - -MEMORY -{ - /* opensbi jump to 0x80200000 */ - SRAM : ORIGIN = 0x80200000, LENGTH = 0x1E00000 -} - -SECTIONS -{ - /* code segment */ - . = ALIGN(8); - .text : - { - __NX_TextStart = .; - *(.text.start) - *(.text) - *(.init.text) - *(.exit.text) - - *(.rodata) - *(.rodata.*) - - . = ALIGN(8); - PROVIDE(__NX_InitCallStart = .); - KEEP(*(.initCall0.text)) - KEEP(*(.initCall1.text)) - KEEP(*(.initCall2.text)) - KEEP(*(.initCall3.text)) - KEEP(*(.initCall4.text)) - KEEP(*(.initCall5.text)) - KEEP(*(.initCall6.text)) - KEEP(*(.initCall7.text)) - KEEP(*(.initCall8.text)) - KEEP(*(.initCall9.text)) - PROVIDE(__NX_InitCallEnd = .); - - . = ALIGN(8); - PROVIDE(__NX_ExitCallStart = .); - KEEP(*(.exitcall0.text)) - KEEP(*(.exitcall1.text)) - KEEP(*(.exitcall2.text)) - KEEP(*(.exitcall3.text)) - KEEP(*(.exitcall4.text)) - KEEP(*(.exitcall5.text)) - KEEP(*(.exitcall6.text)) - KEEP(*(.exitcall7.text)) - KEEP(*(.exitcall8.text)) - KEEP(*(.exitcall9.text)) - PROVIDE(__NX_ExitCallEnd = .); - - /* section information for utest */ - . = ALIGN(8); - PROVIDE(__NX_UTestCaseTableStart = .); - KEEP(*(UTestCaseTable)) - PROVIDE(__NX_UTestCaseTableEnd = .); - - /* section information for integration */ - . = ALIGN(8); - PROVIDE(__NX_IntegrationTableStart = .); - KEEP(*(IntegrationTable)) - PROVIDE(__NX_IntegrationTableEnd = .); - __NX_TextEnd = .; - } > SRAM - - /* data segment */ - . = ALIGN(8); - - .data : - { - __NX_DataStart = .; - *(.data) - *(.data.*) - - . = ALIGN(8); - PROVIDE( __global_pointer$ = . + 0x800 ); - - *(.sdata) - *(.sdata.*) - } > SRAM - - .romdisk ALIGN(8) : - { - PROVIDE(__NX_RomdiskStart = .); - KEEP(*(.romdisk)) - PROVIDE(__NX_RomdiskEnd = .); - __NX_DataEnd = .; - } > SRAM - - . = ALIGN(8); - - __NX_DataEnd = .; - - /* bss segement */ - - .sbss : - { - __NX_BssStart = .; - *(.sbss) - *(.sbss.*) - *(.dynsbss) - *(.scommon) - } > SRAM - - .bss : - { - *(.bss) - *(.bss.*) - *(.dynbss) - *(COMMON) - . = ALIGN(8); - __NX_BssEnd = .; - } > SRAM -} \ No newline at end of file diff --git a/src/platform/qemu_riscv64/nxos.mk b/src/platform/qemu_riscv64/nxos.mk deleted file mode 100644 index 003128d..0000000 --- a/src/platform/qemu_riscv64/nxos.mk +++ /dev/null @@ -1,18 +0,0 @@ -## -# Copyright (c) 2018-2022, NXOS Development Team -# SPDX-License-Identifier: Apache-2.0 -# -# Contains: Makefile for QEMU Riscv64 Platform -# -# Change Logs: -# Date Author Notes -# 2021-10-1 JasonHu Init -## - -# -# Override default variables. -# -CFLAGS += -fno-stack-protector -mno-relax -ASFLAGS += -ffunction-sections -fdata-sections -ffreestanding -MCFLAGS += -march=rv64imafdc -mabi=lp64d -mcmodel=medany -LDFLAGS += -no-pie -nostartfile -n diff --git a/src/platform/qemu_riscv64/riscv64-virtio.dts b/src/platform/qemu_riscv64/riscv64-virtio.dts deleted file mode 100644 index 2a03039..0000000 --- a/src/platform/qemu_riscv64/riscv64-virtio.dts +++ /dev/null @@ -1,193 +0,0 @@ -/dts-v1/; - -/ { - #address-cells = <0x2>; - #size-cells = <0x2>; - compatible = "riscv-virtio"; - model = "riscv-virtio,qemu"; - - fw-cfg@10100000 { - dma-coherent; - reg = <0x0 0x10100000 0x0 0x18>; - compatible = "qemu,fw-cfg-mmio"; - }; - - chosen { - bootargs = [00]; - stdout-path = "/soc/uart@10000000"; - }; - - memory@80000000 { - device_type = "memory"; - reg = <0x0 0x80000000 0x0 0x8000000>; - }; - - cpus { - #address-cells = <0x1>; - #size-cells = <0x0>; - timebase-frequency = <0x989680>; - - cpu@0 { - phandle = <0x1>; - device_type = "cpu"; - reg = <0x0>; - status = "okay"; - compatible = "riscv"; - riscv,isa = "rv64imafdcsu"; - mmu-type = "riscv,sv48"; - - interrupt-controller { - #interrupt-cells = <0x1>; - interrupt-controller; - compatible = "riscv,cpu-intc"; - phandle = <0x2>; - }; - }; - - cpu-map { - - cluster0 { - - core0 { - cpu = <0x1>; - }; - }; - }; - }; - - soc { - #address-cells = <0x2>; - #size-cells = <0x2>; - compatible = "simple-bus"; - ranges; - - flash@20000000 { - bank-width = <0x4>; - reg = <0x0 0x20000000 0x0 0x2000000 0x0 0x22000000 0x0 0x2000000>; - compatible = "cfi-flash"; - }; - - rtc@101000 { - interrupts = <0xb>; - interrupt-parent = <0x3>; - reg = <0x0 0x101000 0x0 0x1000>; - compatible = "google,goldfish-rtc"; - }; - - uart@10000000 { - interrupts = <0xa>; - interrupt-parent = <0x3>; - clock-frequency = <0x384000>; - reg = <0x0 0x10000000 0x0 0x100>; - compatible = "ns16550a"; - }; - - poweroff { - value = <0x5555>; - offset = <0x0>; - regmap = <0x4>; - compatible = "syscon-poweroff"; - }; - - reboot { - value = <0x7777>; - offset = <0x0>; - regmap = <0x4>; - compatible = "syscon-reboot"; - }; - - test@100000 { - phandle = <0x4>; - reg = <0x0 0x100000 0x0 0x1000>; - compatible = "sifive,test1", "sifive,test0", "syscon"; - }; - - pci@30000000 { - interrupt-map-mask = <0x1800 0x0 0x0 0x7>; - interrupt-map = <0x0 0x0 0x0 0x1 0x3 0x20 0x0 0x0 0x0 0x2 0x3 0x21 0x0 0x0 0x0 0x3 0x3 0x22 0x0 0x0 0x0 0x4 0x3 0x23 0x800 0x0 0x0 0x1 0x3 0x21 0x800 0x0 0x0 0x2 0x3 0x22 0x800 0x0 0x0 0x3 0x3 0x23 0x800 0x0 0x0 0x4 0x3 0x20 0x1000 0x0 0x0 0x1 0x3 0x22 0x1000 0x0 0x0 0x2 0x3 0x23 0x1000 0x0 0x0 0x3 0x3 0x20 0x1000 0x0 0x0 0x4 0x3 0x21 0x1800 0x0 0x0 0x1 0x3 0x23 0x1800 0x0 0x0 0x2 0x3 0x20 0x1800 0x0 0x0 0x3 0x3 0x21 0x1800 0x0 0x0 0x4 0x3 0x22>; - ranges = <0x1000000 0x0 0x0 0x0 0x3000000 0x0 0x10000 0x2000000 0x0 0x40000000 0x0 0x40000000 0x0 0x40000000 0x3000000 0x4 0x0 0x4 0x0 0x4 0x0>; - reg = <0x0 0x30000000 0x0 0x10000000>; - dma-coherent; - bus-range = <0x0 0xff>; - linux,pci-domain = <0x0>; - device_type = "pci"; - compatible = "pci-host-ecam-generic"; - #size-cells = <0x2>; - #interrupt-cells = <0x1>; - #address-cells = <0x3>; - }; - - virtio_mmio@10008000 { - interrupts = <0x8>; - interrupt-parent = <0x3>; - reg = <0x0 0x10008000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10007000 { - interrupts = <0x7>; - interrupt-parent = <0x3>; - reg = <0x0 0x10007000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10006000 { - interrupts = <0x6>; - interrupt-parent = <0x3>; - reg = <0x0 0x10006000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10005000 { - interrupts = <0x5>; - interrupt-parent = <0x3>; - reg = <0x0 0x10005000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10004000 { - interrupts = <0x4>; - interrupt-parent = <0x3>; - reg = <0x0 0x10004000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10003000 { - interrupts = <0x3>; - interrupt-parent = <0x3>; - reg = <0x0 0x10003000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10002000 { - interrupts = <0x2>; - interrupt-parent = <0x3>; - reg = <0x0 0x10002000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - virtio_mmio@10001000 { - interrupts = <0x1>; - interrupt-parent = <0x3>; - reg = <0x0 0x10001000 0x0 0x1000>; - compatible = "virtio,mmio"; - }; - - plic@c000000 { - phandle = <0x3>; - riscv,ndev = <0x35>; - reg = <0x0 0xc000000 0x0 0x210000>; - interrupts-extended = <0x2 0xb 0x2 0x9>; - interrupt-controller; - compatible = "sifive,plic-1.0.0", "riscv,plic0"; - #interrupt-cells = <0x1>; - #address-cells = <0x0>; - }; - - clint@2000000 { - interrupts-extended = <0x2 0x3 0x2 0x7>; - reg = <0x0 0x2000000 0x0 0x10000>; - compatible = "sifive,clint0", "riscv,clint0"; - }; - }; -}; -- Gitee From 28f6be85b66c36e622c76ff869eac3c582d5b6c0 Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 28 Jun 2022 01:57:56 +0800 Subject: [PATCH 2/6] feat: update readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index df9e374..3c474ca 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,11 @@ | ARCH | PLATFORM |STATUS | | ------- | ---------- | ---------- | -| x86 | i386 | DONE | -| riscv64 | qemu | DONE | -| riscv64 | k210 | DONE | -| riscv64 | d1 | DONE | -| riscv64 | hifive unmached| DONE | +| x86 | [i386](https://gitee.com/BookOS/nxos-platform-i386) | DONE | +| riscv64 | [qemu](https://gitee.com/BookOS/nxos-platform-qemu_riscv64) | DONE | +| riscv64 | [k210](https://gitee.com/BookOS/nxos-platform-k210) | DONE | +| riscv64 | [d1](https://gitee.com/BookOS/nxos-platform-d1) | DONE | +| riscv64 | [hifive unmached](https://gitee.com/BookOS/nxos-platform-hifive_unmached)| DONE | | x86-64 | amd64 | TODO | | arm64 | qemu | TODO | | arm32 | qemu | TODO | @@ -41,7 +41,7 @@ 🏠 [文档中心](https://gitee.com/BookOS/nxos-documentation) ## 联系我们 -🌍 [官网](https://www.book-os.org) +🌍 [官网](https://www.book-os.cmd) 📫 [邮箱](mailto:book-os@163.com) ## 致谢 -- Gitee From b8e945f53b6e6b23c3003f4ceb1639ba34776ba3 Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 28 Jun 2022 02:02:46 +0800 Subject: [PATCH 3/6] refactor: update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c474ca..6cb9400 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ 🏠 [文档中心](https://gitee.com/BookOS/nxos-documentation) ## 联系我们 -🌍 [官网](https://www.book-os.cmd) +🌍 [官网](https://www.book-os.com) 📫 [邮箱](mailto:book-os@163.com) ## 致谢 -- Gitee From c5663ec27d7bf8751a888659ef2c01ab8313a776 Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 28 Jun 2022 02:09:00 +0800 Subject: [PATCH 4/6] feat: update gitkeep for platform --- src/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 85d1e6c..62d6c0d 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -64,5 +64,5 @@ fixdep init/rootfs.c build drivers/block/romdisk.S -!.gitkeep -platform \ No newline at end of file +platform +!platform/.gitkeep \ No newline at end of file -- Gitee From 8c5d223441f004fe13da9f46cb989fd33521e1f5 Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 28 Jun 2022 02:11:45 +0800 Subject: [PATCH 5/6] reafactor: update gitkeep --- .gitignore | 5 +++++ src/.gitignore | 4 +--- src/platform/.gitkeep | 0 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 src/platform/.gitkeep diff --git a/.gitignore b/.gitignore index 6843fcd..cae72b4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,11 @@ scripts/kconfiglib/__pycache__/*.pyc scripts/kconfiglib/kconfiglib.pyc src/platform/Kconfig +src/platform/d1 +src/platform/hifive_unmached +src/platform/i386 +src/platform/k210 +src/platform/qemu_riscv64 src/include/nx_configure.h platform.mk romdisk.cpio diff --git a/src/.gitignore b/src/.gitignore index 62d6c0d..985600c 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -63,6 +63,4 @@ dkms.conf fixdep init/rootfs.c build -drivers/block/romdisk.S -platform -!platform/.gitkeep \ No newline at end of file +drivers/block/romdisk.S \ No newline at end of file diff --git a/src/platform/.gitkeep b/src/platform/.gitkeep new file mode 100644 index 0000000..e69de29 -- Gitee From c475e23bdfe5f1455db40eae1e6fa7c191da6fa3 Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 28 Jun 2022 02:16:59 +0800 Subject: [PATCH 6/6] refactor: update readme website --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cb9400..34d5d17 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ 🏠 [文档中心](https://gitee.com/BookOS/nxos-documentation) ## 联系我们 -🌍 [官网](https://www.book-os.com) +🌍 [官网](http://www.book-os.com) 📫 [邮箱](mailto:book-os@163.com) ## 致谢 -- Gitee