riscv/qemu-rv: revise PROTECTED mode

This revises PROTECTED build for qemu-rv mainly to avoid hard-coded
addresses in linker scripts. It also added rv32 support, cleaned up
config `pnsh64` and added config `pnsh`.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-08-03 11:25:20 +08:00 committed by Xiang Xiao
parent ba4769d412
commit 5848a8e77c
12 changed files with 213 additions and 90 deletions

View File

@ -90,7 +90,7 @@ If testing with S-mode build, remove the ``-bios none`` option. S-mode build
requires SBI to function properly. requires SBI to function properly.
For BUILD_PROTECTED the user-space binary must also be loaded, which can be For BUILD_PROTECTED the user-space binary must also be loaded, which can be
done by adding ``-device loader,file=./nuttx_user.elf`` to the command line done by adding ``-device loader,file=./nuttx_user`` to the command line
arguments. arguments.
citest citest

View File

@ -89,6 +89,27 @@ static void qemu_rv_clear_bss(void)
} }
} }
#ifdef CONFIG_BUILD_PROTECTED
static void qemu_rv_copy_data(void)
{
const uint32_t *src;
uint32_t *dest;
/* Move the initialized data from their temporary holding spot at FLASH
* into the correct place in SRAM. The correct place in SRAM is given
* by _sdata and _edata. The temporary location is in FLASH at the
* end of all of the other read-only data (.text, .rodata) at _eronly.
*/
for (src = (const uint32_t *)_eronly,
dest = (uint32_t *)_sdata; dest < (uint32_t *)_edata;
)
{
*dest++ = *src++;
}
}
#endif
#ifdef CONFIG_ARCH_USE_S_MODE #ifdef CONFIG_ARCH_USE_S_MODE
static void qemu_boot_secondary(int mhartid, uintptr_t dtb) static void qemu_boot_secondary(int mhartid, uintptr_t dtb)
{ {
@ -153,6 +174,10 @@ void qemu_rv_start(int mhartid, const char *dtb)
qemu_rv_clear_bss(); qemu_rv_clear_bss();
#ifdef CONFIG_BUILD_PROTECTED
qemu_rv_copy_data();
#endif
#ifdef CONFIG_RISCV_PERCPU_SCRATCH #ifdef CONFIG_RISCV_PERCPU_SCRATCH
riscv_percpu_add_hart(mhartid); riscv_percpu_add_hart(mhartid);
#endif #endif

View File

@ -18,8 +18,8 @@
* *
****************************************************************************/ ****************************************************************************/
#ifndef __ARCH_RISC_V_SRC_QEMURV_QEMURV_USERSPACE_H #ifndef __ARCH_RISCV_SRC_QEMU_RV_QEMU_RV_USERSPACE_H
#define __ARCH_RISC_V_SRC_QEMURV_QEMURV_USERSPACE_H #define __ARCH_RISCV_SRC_QEMU_RV_QEMU_RV_USERSPACE_H
/**************************************************************************** /****************************************************************************
* Included Files * Included Files
@ -46,4 +46,4 @@
void qemu_rv_userspace(void); void qemu_rv_userspace(void);
#endif #endif
#endif /* __ARCH_RISC_V_SRC_QEMURV_QEMURV_USERSPACE_H */ #endif /* __ARCH_RISCV_SRC_QEMU_RV_QEMU_RV_USERSPACE_H */

View File

@ -0,0 +1,2 @@
kernel/nuttx_user*
scripts/*.tmp

View File

@ -0,0 +1,75 @@
#
# 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_DISABLE_OS_API is not set
# CONFIG_NSH_DISABLE_LOSMART is not set
CONFIG_16550_ADDRWIDTH=0
CONFIG_16550_UART0=y
CONFIG_16550_UART0_BASE=0x10000000
CONFIG_16550_UART0_CLOCK=3686400
CONFIG_16550_UART0_IRQ=37
CONFIG_16550_UART0_SERIAL_CONSOLE=y
CONFIG_16550_UART=y
CONFIG_ARCH="risc-v"
CONFIG_ARCH_BOARD="rv-virt"
CONFIG_ARCH_BOARD_QEMU_RV_VIRT=y
CONFIG_ARCH_CHIP="qemu-rv"
CONFIG_ARCH_CHIP_QEMU_RV32=y
CONFIG_ARCH_CHIP_QEMU_RV=y
CONFIG_ARCH_CHIP_QEMU_RV_ISA_A=y
CONFIG_ARCH_CHIP_QEMU_RV_ISA_C=y
CONFIG_ARCH_CHIP_QEMU_RV_ISA_M=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_USE_MPU=y
CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BOARD_LOOPSPERMSEC=6366
CONFIG_BUILD_PROTECTED=y
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=4096
CONFIG_DEV_ZERO=y
CONFIG_ELF=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_FS_HOSTFS=y
CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=3072
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y
CONFIG_LIBC_STRERROR=y
CONFIG_LIBM=y
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NUTTX_USERSPACE=0x80040000
CONFIG_PASS1_BUILDIR="boards/risc-v/qemu-rv/rv-virt/kernel"
CONFIG_PATH_INITIAL="/system/bin"
CONFIG_RAM_SIZE=3145728
CONFIG_RAM_START=0x80000000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RISCV_PERCPU_SCRATCH=y
CONFIG_RISCV_SEMIHOSTING_HOSTFS=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_SERIAL_UART_ARCH_MMIO=y
CONFIG_STACK_COLORATION=y
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2021
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_USEC_PER_TICK=1000

View File

@ -26,14 +26,11 @@ CONFIG_ARCH_CHIP_QEMU_RV_ISA_M=y
CONFIG_ARCH_INTERRUPTSTACK=2048 CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_RISCV=y CONFIG_ARCH_RISCV=y
CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_USE_MMU=y
CONFIG_ARCH_USE_MPU=y CONFIG_ARCH_USE_MPU=y
CONFIG_BCH=y
CONFIG_BOARDCTL_POWEROFF=y CONFIG_BOARDCTL_POWEROFF=y
CONFIG_BOARD_LOOPSPERMSEC=6366 CONFIG_BOARD_LOOPSPERMSEC=6366
CONFIG_BUILD_PROTECTED=y CONFIG_BUILD_PROTECTED=y
CONFIG_BUILTIN=y CONFIG_BUILTIN=y
CONFIG_CANCELLATION_POINTS=y
CONFIG_DEBUG_ASSERTIONS=y CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_FULLOPT=y
@ -46,8 +43,6 @@ CONFIG_FS_HOSTFS=y
CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS=y
CONFIG_IDLETHREAD_STACKSIZE=2048 CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_INIT_ENTRYPOINT="nsh_main" CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=3072
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBC_ENVPATH=y CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y CONFIG_LIBC_EXECFUNCS=y
CONFIG_LIBC_PERROR_STDOUT=y CONFIG_LIBC_PERROR_STDOUT=y
@ -58,17 +53,14 @@ CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512 CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y CONFIG_NSH_READLINE=y
CONFIG_NUTTX_USERSPACE=0x80400000 CONFIG_NUTTX_USERSPACE=0x80040000
CONFIG_PASS1_BUILDIR="boards/risc-v/qemu-rv/rv-virt/kernel" CONFIG_PASS1_BUILDIR="boards/risc-v/qemu-rv/rv-virt/kernel"
CONFIG_PATH_INITIAL="/system/bin" CONFIG_PATH_INITIAL="/system/bin"
CONFIG_PRIORITY_INHERITANCE=y CONFIG_RAM_SIZE=3145728
CONFIG_RAM_SIZE=4194304
CONFIG_RAM_START=0x80000000 CONFIG_RAM_START=0x80000000
CONFIG_READLINE_CMD_HISTORY=y CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RISCV_MEMCPY=y CONFIG_RISCV_PERCPU_SCRATCH=y
CONFIG_RISCV_MEMSET=y
CONFIG_RISCV_SEMIHOSTING_HOSTFS=y CONFIG_RISCV_SEMIHOSTING_HOSTFS=y
CONFIG_RISCV_STRCMP=y
CONFIG_RR_INTERVAL=200 CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y CONFIG_SCHED_WAITPID=y
CONFIG_SERIAL_UART_ARCH_MMIO=y CONFIG_SERIAL_UART_ARCH_MMIO=y
@ -77,7 +69,6 @@ CONFIG_START_MONTH=12
CONFIG_START_YEAR=2021 CONFIG_START_YEAR=2021
CONFIG_SYMTAB_ORDEREDBYNAME=y CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NSH_STACKSIZE=3072
CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y CONFIG_TESTING_OSTEST=y
CONFIG_USEC_PER_TICK=1000 CONFIG_USEC_PER_TICK=1000

View File

@ -25,26 +25,25 @@ include $(TOPDIR)/Make.defs
CONFIG_INIT_ENTRYPOINT ?= user_start CONFIG_INIT_ENTRYPOINT ?= user_start
ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT)) ENTRYPT = $(patsubst "%",%,$(CONFIG_INIT_ENTRYPOINT))
# The memory layout
MEM_LAYOUT = memory.ld
# Get the paths to the libraries and the links script path in format that # Get the paths to the libraries and the links script path in format that
# is appropriate for the host OS # is appropriate for the host OS
USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS))))) USER_LIBPATHS = $(addprefix -L,$(call CONVERT_PATH,$(addprefix $(TOPDIR)$(DELIM),$(dir $(USERLIBS)))))
USER_LDSCRIPT = -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld) USER_LDSCRIPT = $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)ld-userland.script)
USER_LDSCRIPT += -T $(call CONVERT_PATH,$(BOARD_DIR)$(DELIM)scripts$(DELIM)user-space.ld)
USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex) USER_HEXFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.hex)
USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec) USER_SRECFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.srec)
USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin) USER_BINFILE += $(call CONVERT_PATH,$(TOPDIR)$(DELIM)nuttx_user.bin)
USER_LDFLAGS = -melf64lriscv --undefined=$(ENTRYPT) --entry=$(ENTRYPT) $(USER_LDSCRIPT) USER_LDFLAGS = --undefined=$(ENTRYPT) --entry=$(ENTRYPT) -T $(addsuffix .tmp,$(USER_LDSCRIPT))
USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS)))) USER_LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(USERLIBS))))
USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}" USER_LIBGCC = "${shell "$(CC)" $(ARCHCPUFLAGS) -print-libgcc-file-name}"
# Make a map, woo ifeq ($(CONFIG_ARCH_RV32),y)
USER_LDFLAGS += -Map=nuttx_user.map USER_LDFLAGS += --oformat elf32-littleriscv
else
USER_LDFLAGS += --oformat elf64-littleriscv
endif
# Source files # Source files
@ -54,49 +53,47 @@ OBJS = $(COBJS)
# Targets: # Targets:
all: $(TOPDIR)$(DELIM)nuttx_user.elf $(TOPDIR)$(DELIM)User.map $(TOPDIR)$(DELIM)nuttx_user.map all: $(TOPDIR)$(DELIM)nuttx_user $(TOPDIR)$(DELIM)User.map
.PHONY: nuttx_user.elf depend clean distclean .PHONY: nuttx_user depend clean distclean
$(COBJS): %$(OBJEXT): %.c $(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@) $(call COMPILE, $<, $@)
# Create the nuttx_user.elf file containing all of the user-mode code $(addsuffix .tmp,$(USER_LDSCRIPT)): $(USER_LDSCRIPT)
$(call PREPROCESS,$(patsubst %.tmp,%,$@),$@)
nuttx_user.elf: $(OBJS) # Create the nuttx_user file containing all of the user-mode code
nuttx_user: $(OBJS) $(addsuffix .tmp,$(USER_LDSCRIPT))
$(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC) $(Q) $(LD) -o $@ $(USER_LDFLAGS) $(USER_LIBPATHS) $(OBJS) --start-group $(USER_LDLIBS) --end-group $(USER_LIBGCC)
$(TOPDIR)$(DELIM)nuttx_user.elf: nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user: nuttx_user
@echo "LD: nuttx_user.elf" @echo "LD: nuttx_user"
$(Q) cp -a nuttx_user.elf $(TOPDIR)$(DELIM)nuttx_user.elf $(Q) cp -a $^ $(TOPDIR)$(DELIM)$^
ifeq ($(CONFIG_INTELHEX_BINARY),y) ifeq ($(CONFIG_INTELHEX_BINARY),y)
@echo "CP: nuttx_user.hex" @echo "CP: nuttx_user.hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex nuttx_user.elf $(USER_HEXFILE) $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $^ $(USER_HEXFILE)
endif endif
ifeq ($(CONFIG_MOTOROLA_SREC),y) ifeq ($(CONFIG_MOTOROLA_SREC),y)
@echo "CP: nuttx_user.srec" @echo "CP: nuttx_user.srec"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec nuttx_user.elf $(USER_SRECFILE) $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $^ $(USER_SRECFILE)
endif endif
ifeq ($(CONFIG_RAW_BINARY),y) ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: nuttx_user.bin" @echo "CP: nuttx_user.bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary nuttx_user.elf $(USER_BINFILE) $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $^ $(USER_BINFILE)
endif endif
$(TOPDIR)$(DELIM)User.map: nuttx_user.elf $(TOPDIR)$(DELIM)User.map: nuttx_user
@echo "MK: User.map" @echo "MK: User.map"
$(Q) $(NM) -n nuttx_user.elf >$(TOPDIR)$(DELIM)User.map $(Q) $(NM) -n $^ >$(TOPDIR)$(DELIM)User.map
$(Q) $(CROSSDEV)size nuttx_user.elf
$(TOPDIR)$(DELIM)nuttx_user.map: nuttx_user.elf
@echo "CP: nuttx_user.map"
$(Q) cp -a nuttx_user.map $(TOPDIR)$(DELIM)nuttx_user.map
.depend: .depend:
depend: .depend depend: .depend
clean: clean:
$(call DELFILE, nuttx_user.elf) $(call DELFILE, nuttx_user)
$(call DELFILE, nuttx_user.map) $(call DELFILE, $(addsuffix .tmp,$(USER_LDSCRIPT)))
$(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*") $(call DELFILE, "$(TOPDIR)$(DELIM)nuttx_user.*")
$(call DELFILE, "$(TOPDIR)$(DELIM)User.map") $(call DELFILE, "$(TOPDIR)$(DELIM)User.map")
$(call CLEAN) $(call CLEAN)

View File

@ -30,16 +30,10 @@ ifeq ($(CONFIG_BUILD_KERNEL),y)
LDSCRIPT = ld-nuttsbi.script LDSCRIPT = ld-nuttsbi.script
endif endif
else ifeq ($(CONFIG_BUILD_PROTECTED),y) else ifeq ($(CONFIG_BUILD_PROTECTED),y)
LDMEMORY = memory.ld LDSCRIPT = ld-protected.script
LDSCRIPT = kernel-space.ld
else
LDSCRIPT = ld.script
endif endif
endif endif
ifneq ($(LDMEMORY),)
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDMEMORY)
endif
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
ARCHPICFLAGS = -fpic -msingle-pic-base ARCHPICFLAGS = -fpic -msingle-pic-base

View File

@ -0,0 +1,66 @@
/****************************************************************************
* boards/risc-v/qemu-rv/rv-virt/scripts/ld-protected.mem
*
* 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.
*
****************************************************************************/
#include <nuttx/config.h>
/* Memory layout for ld-protected.script and ld-userland.script
*
* |-CONFIG_RAM_START
* | |-CONFIG_NUTTX_USERSPACE
* +--------+----------+--------+--------+
* | kflash | uflash | ksram | usram |
* +--------+----------+--------+--------+
* |>-- FLASH_SIZE ---<|>-- SRAM_SIZE --<|
*
*/
#define KFLASH_ADDR (CONFIG_RAM_START)
#define UFLASH_ADDR (CONFIG_NUTTX_USERSPACE)
#define KFLASH_SIZE (UFLASH_ADDR - KFLASH_ADDR)
#define UFLASH_SIZE (KFLASH_SIZE)
#define FLASH_SIZE (0x100000) /* needs be POT */
#define SRAM_SIZE (0x200000) /* needs be POT */
#if KFLASH_SIZE < 0
#error "Invalid KFLASH_SIZE!"
#endif
#if KFLASH_SIZE + UFLASH_SIZE > FLASH_SIZE
#error "Adjust FLASH_SIZE please!"
#endif
#if CONFIG_RAM_SIZE < FLASH_SIZE + SRAM_SIZE
#error "CONFIG_RAM_SIZE too small?"
#endif
#define KSRAM_SIZE (SRAM_SIZE / 2)
#define USRAM_SIZE (SRAM_SIZE - KSRAM_SIZE)
#define KSRAM_ADDR (KFLASH_ADDR + FLASH_SIZE)
#define USRAM_ADDR (KSRAM_ADDR + KSRAM_SIZE)
MEMORY
{
kflash (rx) : ORIGIN = KFLASH_ADDR, LENGTH = KFLASH_SIZE
uflash (rx) : ORIGIN = UFLASH_ADDR, LENGTH = UFLASH_SIZE
ksram (rwx) : ORIGIN = KSRAM_ADDR, LENGTH = KSRAM_SIZE
usram (rwx) : ORIGIN = USRAM_ADDR, LENGTH = USRAM_SIZE
}

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* boards/risc-v/qemu-rv/rv-virt/scripts/kernel-space.ld * boards/risc-v/qemu-rv/rv-virt/scripts/ld-protected.script
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -18,13 +18,11 @@
* *
****************************************************************************/ ****************************************************************************/
/* NOTE: This depends on the memory.ld script having been included prior to #include "ld-protected.mem"
* this script.
*/
OUTPUT_ARCH("riscv") OUTPUT_ARCH("riscv")
/* Provide these so there is no need for using config files for this */ /* Provide these to avoid using config files for them */
__uflash_start = ORIGIN(uflash); __uflash_start = ORIGIN(uflash);
__uflash_size = LENGTH(uflash); __uflash_size = LENGTH(uflash);
@ -77,7 +75,7 @@ SECTIONS
CONSTRUCTORS CONSTRUCTORS
. = ALIGN(4); . = ALIGN(4);
_edata = ABSOLUTE(.); _edata = ABSOLUTE(.);
} > kflash } > ksram AT > kflash
PROVIDE(__global_pointer$ = _sdata + ((_edata - _sdata) / 2)); PROVIDE(__global_pointer$ = _sdata + ((_edata - _sdata) / 2));
@ -88,7 +86,12 @@ SECTIONS
*(.gnu.linkonce.b.*) *(.gnu.linkonce.b.*)
*(.gnu.linkonce.sb.*) *(.gnu.linkonce.sb.*)
*(COMMON) *(COMMON)
. = ALIGN(4); } > ksram
/* Page tables here, align to 4K boundary */
.pgtables (NOLOAD) : ALIGN(0x1000) {
*(.pgtables)
. = ALIGN(32);
_ebss = ABSOLUTE(.); _ebss = ABSOLUTE(.);
} > ksram } > ksram

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* boards/risc-v/qemu-rv/rv-virt/scripts/user-space.ld * boards/risc-v/qemu-rv/rv-virt/scripts/ld-userland.script
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -18,9 +18,7 @@
* *
****************************************************************************/ ****************************************************************************/
/* NOTE: This depends on the memory.ld script having been included prior to #include "ld-protected.mem"
* this script.
*/
OUTPUT_ARCH("riscv") OUTPUT_ARCH("riscv")
@ -88,7 +86,7 @@ SECTIONS
_ebss = ABSOLUTE(.); _ebss = ABSOLUTE(.);
} > usram } > usram
/* Stabs debugging sections */ /* Stabs debugging sections. */
.stab 0 : { *(.stab) } .stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) } .stabstr 0 : { *(.stabstr) }

View File

@ -1,28 +0,0 @@
/****************************************************************************
* boards/risc-v/qemu-rv/rv-virt/scripts/memory.ld
*
* 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.
*
****************************************************************************/
MEMORY
{
kflash (rx) : ORIGIN = 0x80000000, LENGTH = 2M /* w/ cache */
ksram (rx) : ORIGIN = 0x80200000, LENGTH = 2M /* w/ cache */
uflash (rx) : ORIGIN = 0x80400000, LENGTH = 4M /* w/ cache */
usram (rwx) : ORIGIN = 0x80800000, LENGTH = 4M /* w/ cache */
}