diff --git a/boards/x86_64/intel64/qemu-intel64/configs/knsh_romfs/defconfig b/boards/x86_64/intel64/qemu-intel64/configs/knsh_romfs/defconfig new file mode 100644 index 0000000000..9da96b7c65 --- /dev/null +++ b/boards/x86_64/intel64/qemu-intel64/configs/knsh_romfs/defconfig @@ -0,0 +1,91 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_X86_64_ACPI_DUMP is not set +# CONFIG_DEV_RANDOM is not set +# CONFIG_SIG_SIGKILL_ACTION is not set +# CONFIG_SIG_SIGSTOP_ACTION is not set +# CONFIG_TLS_ALIGNED is not set +CONFIG_16550_ADDRWIDTH=16 +CONFIG_16550_UART0=y +CONFIG_16550_UART0_BASE=0x3f8 +CONFIG_16550_UART0_CLOCK=1843200 +CONFIG_16550_UART0_IRQ=36 +CONFIG_16550_UART0_RXBUFSIZE=16 +CONFIG_16550_UART0_SERIAL_CONSOLE=y +CONFIG_16550_UART0_TXBUFSIZE=16 +CONFIG_16550_UART=y +CONFIG_ARCH="x86_64" +CONFIG_ARCH_ADDRENV=y +CONFIG_ARCH_BOARD="qemu-intel64" +CONFIG_ARCH_BOARD_INTEL64_QEMU=y +CONFIG_ARCH_CHIP="intel64" +CONFIG_ARCH_CHIP_INTEL64_QEMU=y +CONFIG_ARCH_DATA_VBASE=0x800080000 +CONFIG_ARCH_HEAP_VBASE=0x8000f0000 +CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ=2600000 +CONFIG_ARCH_KERNEL_STACKSIZE=8192 +CONFIG_ARCH_PGPOOL_MAPPING=y +CONFIG_ARCH_PGPOOL_PBASE=0x00c000000 +CONFIG_ARCH_PGPOOL_SIZE=67108864 +CONFIG_ARCH_PGPOOL_VBASE=0x10c000000 +CONFIG_ARCH_SIZET_LONG=y +CONFIG_ARCH_TEXT_VBASE=0x800000000 +CONFIG_ARCH_X86_64=y +CONFIG_BOARDCTL_APP_SYMTAB=y +CONFIG_BOARDCTL_ROMDISK=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=4687108 +CONFIG_BOOT_RUNFROMEXTSRAM=y +CONFIG_BUILD_KERNEL=y +CONFIG_CONSOLE_SYSLOG=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=16384 +CONFIG_ELF=y +CONFIG_ELF_STACKSIZE=163840 +CONFIG_EXAMPLES_HELLO=m +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_IDLETHREAD_STACKSIZE=16384 +CONFIG_INIT_FILEPATH="/system/bin/init" +CONFIG_INIT_MOUNT=y +CONFIG_INIT_MOUNT_FLAGS=0x1 +CONFIG_INIT_MOUNT_TARGET="/system/bin" +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LIBM=y +CONFIG_MM_KERNEL_HEAPSIZE=16384 +CONFIG_MM_PGALLOC=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_DISABLE_IFCONFIG=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILE_APPS=y +CONFIG_PREALLOC_CHILDSTATUS=16 +CONFIG_PTHREAD_MUTEX_TYPES=y +CONFIG_PTHREAD_STACK_MIN=16384 +CONFIG_RAM_SIZE=268435456 +CONFIG_RAM_VSTART=0x100000000 +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_TICKLESS=y +CONFIG_SCHED_TICKLESS_ALARM=y +CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP=y +CONFIG_SCHED_WAITPID=y +CONFIG_SIG_DEFAULT=y +CONFIG_START_DAY=3 +CONFIG_START_MONTH=3 +CONFIG_START_YEAR=2011 +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_PROGNAME="init" +CONFIG_SYSTEM_TIME64=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_FPUTESTDISABLE=y +CONFIG_TESTING_OSTEST_STACKSIZE=16384 +CONFIG_USEC_PER_TICK=1 diff --git a/boards/x86_64/intel64/qemu-intel64/configs/knsh_romfs_pci/defconfig b/boards/x86_64/intel64/qemu-intel64/configs/knsh_romfs_pci/defconfig new file mode 100644 index 0000000000..83599c33fc --- /dev/null +++ b/boards/x86_64/intel64/qemu-intel64/configs/knsh_romfs_pci/defconfig @@ -0,0 +1,95 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_PVHBOOT is not set +# CONFIG_ARCH_X86_64_ACPI_DUMP is not set +# CONFIG_DEV_RANDOM is not set +# CONFIG_SIG_SIGKILL_ACTION is not set +# CONFIG_SIG_SIGSTOP_ACTION is not set +# CONFIG_TLS_ALIGNED is not set +CONFIG_16550_ADDRWIDTH=16 +CONFIG_16550_PCI_UART0=y +CONFIG_16550_PCI_UART0_CLOCK=1843200 +CONFIG_16550_PCI_UART0_DEVICE=0x9100 +CONFIG_16550_PCI_UART0_SERIAL_CONSOLE=y +CONFIG_16550_PCI_UART0_VENDOR=0x125b +CONFIG_16550_PCI_UART=y +CONFIG_ARCH="x86_64" +CONFIG_ARCH_ADDRENV=y +CONFIG_ARCH_BOARD="qemu-intel64" +CONFIG_ARCH_BOARD_INTEL64_QEMU=y +CONFIG_ARCH_CHIP="intel64" +CONFIG_ARCH_CHIP_INTEL64_QEMU=y +CONFIG_ARCH_DATA_VBASE=0x800080000 +CONFIG_ARCH_HEAP_VBASE=0x8000f0000 +CONFIG_ARCH_INTEL64_CORE_FREQ_KHZ=0 +CONFIG_ARCH_KERNEL_STACKSIZE=8192 +CONFIG_ARCH_PGPOOL_MAPPING=y +CONFIG_ARCH_PGPOOL_PBASE=0x00c000000 +CONFIG_ARCH_PGPOOL_SIZE=67108864 +CONFIG_ARCH_PGPOOL_VBASE=0x10c000000 +CONFIG_ARCH_SIZET_LONG=y +CONFIG_ARCH_TEXT_VBASE=0x800000000 +CONFIG_ARCH_X86_64=y +CONFIG_BOARDCTL_APP_SYMTAB=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARDCTL_ROMDISK=y +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=999 +CONFIG_BOOT_RUNFROMEXTSRAM=y +CONFIG_BUILD_KERNEL=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=16384 +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_ELF=y +CONFIG_ELF_STACKSIZE=163840 +CONFIG_EXAMPLES_HELLO=m +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_IDLETHREAD_STACKSIZE=16384 +CONFIG_INIT_FILEPATH="/system/bin/init" +CONFIG_INIT_MOUNT=y +CONFIG_INIT_MOUNT_FLAGS=0x1 +CONFIG_INIT_MOUNT_TARGET="/system/bin" +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LIBM=y +CONFIG_MM_KERNEL_HEAPSIZE=16384 +CONFIG_MM_PGALLOC=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_DISABLE_IFCONFIG=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILE_APPS=y +CONFIG_PCI=y +CONFIG_PCI_MSIX=y +CONFIG_PREALLOC_CHILDSTATUS=16 +CONFIG_PTHREAD_MUTEX_TYPES=y +CONFIG_PTHREAD_STACK_MIN=16384 +CONFIG_RAM_SIZE=268435456 +CONFIG_RAM_VSTART=0x100000000 +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_TICKLESS=y +CONFIG_SCHED_TICKLESS_ALARM=y +CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEP=y +CONFIG_SCHED_WAITPID=y +CONFIG_SIG_DEFAULT=y +CONFIG_START_DAY=3 +CONFIG_START_MONTH=3 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_DEVPATH="/dev/S1" +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_PROGNAME="init" +CONFIG_SYSTEM_TIME64=y +CONFIG_TESTING_OSTEST=y +CONFIG_TESTING_OSTEST_FPUTESTDISABLE=y +CONFIG_TESTING_OSTEST_STACKSIZE=16384 diff --git a/boards/x86_64/intel64/qemu-intel64/src/Makefile b/boards/x86_64/intel64/qemu-intel64/src/Makefile index ca8ec7e0a9..4ff5d9fa99 100644 --- a/boards/x86_64/intel64/qemu-intel64/src/Makefile +++ b/boards/x86_64/intel64/qemu-intel64/src/Makefile @@ -23,6 +23,7 @@ include $(TOPDIR)/Make.defs CSRCS = qemu_boot.c qemu_bringup.c qemu_net.c +CSRCS += $(if $(wildcard romfs_boot.c), romfs_boot.c, romfs_stub.c) ifeq ($(CONFIG_BOARDCTL),y) CSRCS += qemu_appinit.c diff --git a/boards/x86_64/intel64/qemu-intel64/src/qemu_appinit.c b/boards/x86_64/intel64/qemu-intel64/src/qemu_appinit.c index 571ab8ee40..79bd770617 100644 --- a/boards/x86_64/intel64/qemu-intel64/src/qemu_appinit.c +++ b/boards/x86_64/intel64/qemu-intel64/src/qemu_appinit.c @@ -27,8 +27,28 @@ #include #include +#include + +#include + #include "x86_64_internal.h" #include "qemu_intel64.h" +#include "romfs.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Additional checks for kernel build */ + +#ifdef CONFIG_BUILD_KERNEL +# ifndef CONFIG_BOARD_LATE_INITIALIZE +# error KERNEL build require CONFIG_BOARD_LATE_INITIALIZE +# endif +#endif + +#define SECTORSIZE 512 +#define NSECTORS(b) (((b) + SECTORSIZE - 1) / SECTORSIZE) /**************************************************************************** * Public Functions @@ -71,3 +91,49 @@ int board_app_initialize(uintptr_t arg) return qemu_bringup(); #endif } + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will + * be called after up_initialize() and board_early_initialize() and just + * before the initial application is started. This additional + * initialization phase may be used, for example, to initialize board- + * specific device drivers for which board_early_initialize() is not + * suitable. + * + * Waiting for events, use of I2C, SPI, etc are permissible in the context + * of board_late_initialize(). That is because board_late_initialize() + * will run on a temporary, internal kernel thread. + * + ****************************************************************************/ + +void board_late_initialize(void) +{ + int ret = OK; + + UNUSED(ret); + + /* Perform board-specific initialization */ + + ret = qemu_bringup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: qemu_bringup() failed: %d\n", ret); + } + + /* Create ROM disk for mount in nx_start_application */ + + if (NSECTORS(romfs_img_len) > 1) + { + ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), + SECTORSIZE); + if (ret < 0) + { + ferr("ERROR: Failed to register romfs: %d\n", -ret); + } + } +} diff --git a/boards/x86_64/intel64/qemu-intel64/src/romfs.h b/boards/x86_64/intel64/qemu-intel64/src/romfs.h new file mode 100644 index 0000000000..c28c24d66e --- /dev/null +++ b/boards/x86_64/intel64/qemu-intel64/src/romfs.h @@ -0,0 +1,39 @@ +/**************************************************************************** + * boards/x86_64/intel64/qemu-intel64/src/romfs.h + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __BOARDS_X86_64_INTEL64_QEMU_INTEL64_SRC_ROMFS_H +#define __BOARDS_X86_64_INTEL64_QEMU_INTEL64_SRC_ROMFS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +extern const unsigned char romfs_img[]; +extern const unsigned int romfs_img_len; + +#endif /* __BOARDS_X86_64_INTEL64_QEMU_INTEL64_SRC_ROMFS_H */ diff --git a/boards/x86_64/intel64/qemu-intel64/src/romfs_stub.c b/boards/x86_64/intel64/qemu-intel64/src/romfs_stub.c new file mode 100644 index 0000000000..0cbe428a40 --- /dev/null +++ b/boards/x86_64/intel64/qemu-intel64/src/romfs_stub.c @@ -0,0 +1,39 @@ +/**************************************************************************** + * boards/x86_64/intel64/qemu-intel64/src/romfs_stub.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +weak_data const unsigned char aligned_data(4) romfs_img[] = +{ + 0x00 +}; +weak_data const unsigned int romfs_img_len = 1; + +/**************************************************************************** + * Public Functions + ****************************************************************************/