add gcc demo
This commit is contained in:
193
board/QEMU_Spike/GCC/demo/Makefile
Normal file
193
board/QEMU_Spike/GCC/demo/Makefile
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
##########################################################################################################################
|
||||||
|
# File automatically-generated by tool: [projectgenerator] version: [3.3.0] date: [Mon Aug 05 10:29:11 CST 2019]
|
||||||
|
##########################################################################################################################
|
||||||
|
|
||||||
|
# ------------------------------------------------
|
||||||
|
# Generic Makefile (based on gcc)
|
||||||
|
#
|
||||||
|
# ChangeLog :
|
||||||
|
# 2017-02-10 - Several enhancements + project update mode
|
||||||
|
# 2015-07-22 - first version
|
||||||
|
# ------------------------------------------------
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# target
|
||||||
|
######################################
|
||||||
|
TARGET = demo
|
||||||
|
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# building variables
|
||||||
|
######################################
|
||||||
|
# debug build?
|
||||||
|
DEBUG = 1
|
||||||
|
# optimization
|
||||||
|
OPT = -O0
|
||||||
|
|
||||||
|
TOP_DIR = ../../../..
|
||||||
|
#######################################
|
||||||
|
# paths
|
||||||
|
#######################################
|
||||||
|
# Build path
|
||||||
|
BUILD_DIR = build
|
||||||
|
|
||||||
|
######################################
|
||||||
|
# source
|
||||||
|
######################################
|
||||||
|
# C sources
|
||||||
|
KERNEL_SRC = \
|
||||||
|
${wildcard $(TOP_DIR)/kernel/core/*.c}
|
||||||
|
C_SOURCES += $(KERNEL_SRC)
|
||||||
|
|
||||||
|
ARCH_SRC = \
|
||||||
|
${wildcard $(TOP_DIR)/arch/risc-v/rv32i/gcc/*.c} \
|
||||||
|
${wildcard $(TOP_DIR)/arch/risc-v/common/*.c}
|
||||||
|
C_SOURCES += $(ARCH_SRC)
|
||||||
|
|
||||||
|
HAL_DRIVER_SRC = \
|
||||||
|
$(TOP_DIR)/board/QEMU_Spike/Src/main.c
|
||||||
|
C_SOURCES += $(HAL_DRIVER_SRC)
|
||||||
|
|
||||||
|
# ASM sources
|
||||||
|
ASM_SOURCES =
|
||||||
|
|
||||||
|
ASM_SOURCES_S = \
|
||||||
|
$(TOP_DIR)/arch/risc-v/rv32i/gcc/port_s.S \
|
||||||
|
start.S
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# binaries
|
||||||
|
#######################################
|
||||||
|
PREFIX = riscv-none-embed-
|
||||||
|
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
|
||||||
|
# either it can be added to the PATH environment variable.
|
||||||
|
ifdef GCC_PATH
|
||||||
|
CC = $(GCC_PATH)/$(PREFIX)gcc
|
||||||
|
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
|
||||||
|
CP = $(GCC_PATH)/$(PREFIX)objcopy
|
||||||
|
SZ = $(GCC_PATH)/$(PREFIX)size
|
||||||
|
else
|
||||||
|
CC = $(PREFIX)gcc
|
||||||
|
AS = $(PREFIX)gcc -x assembler-with-cpp
|
||||||
|
CP = $(PREFIX)objcopy
|
||||||
|
SZ = $(PREFIX)size
|
||||||
|
endif
|
||||||
|
HEX = $(CP) -O ihex
|
||||||
|
BIN = $(CP) -O binary -S
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# CFLAGS
|
||||||
|
#######################################
|
||||||
|
# cpu
|
||||||
|
CPU = -march=rv32imac
|
||||||
|
|
||||||
|
# fpu
|
||||||
|
FPU =
|
||||||
|
|
||||||
|
# float-abi
|
||||||
|
FLOAT-ABI =
|
||||||
|
|
||||||
|
# mcu
|
||||||
|
MCU = $(CPU) $(FPU) $(FLOAT-ABI)
|
||||||
|
|
||||||
|
# macros for gcc
|
||||||
|
# AS defines
|
||||||
|
AS_DEFS =
|
||||||
|
|
||||||
|
# C defines
|
||||||
|
C_DEFS =
|
||||||
|
|
||||||
|
# AS includes
|
||||||
|
AS_INCLUDES =
|
||||||
|
|
||||||
|
# C includes
|
||||||
|
KERNEL_INC = \
|
||||||
|
-I $(TOP_DIR)/kernel/core/include \
|
||||||
|
-I $(TOP_DIR)/kernel/pm/include \
|
||||||
|
-I $(TOP_DIR)/kernel/hal/include \
|
||||||
|
-I $(TOP_DIR)/arch/risc-v/common/include \
|
||||||
|
-I $(TOP_DIR)/arch/risc-v/rv32i/gcc \
|
||||||
|
-I $(TOP_DIR)/board/QEMU_Spike/TOS-CONFIG
|
||||||
|
C_INCLUDES += $(KERNEL_INC)
|
||||||
|
CMSIS_INC =
|
||||||
|
|
||||||
|
HAL_DRIVER_INC = \
|
||||||
|
-I $(TOP_DIR)/board/QEMU_Spike/Inc \
|
||||||
|
C_INCLUDES += $(HAL_DRIVER_INC)
|
||||||
|
|
||||||
|
# compile gcc flags
|
||||||
|
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -mabi=ilp32 -msmall-data-limit=8 -mno-save-restore
|
||||||
|
|
||||||
|
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -mabi=ilp32 -msmall-data-limit=8 -mno-save-restore -std=gnu11 --specs=nosys.specs -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections
|
||||||
|
|
||||||
|
ifeq ($(DEBUG), 1)
|
||||||
|
CFLAGS += -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Generate dependency information
|
||||||
|
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# LDFLAGS
|
||||||
|
#######################################
|
||||||
|
# link script
|
||||||
|
LDSCRIPT = link.ld
|
||||||
|
|
||||||
|
# libraries
|
||||||
|
LIBS = -lc -lm -lnosys
|
||||||
|
LIBDIR =
|
||||||
|
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -nostartfiles
|
||||||
|
|
||||||
|
# default action: build all
|
||||||
|
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# build the application
|
||||||
|
#######################################
|
||||||
|
# list of objects
|
||||||
|
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
||||||
|
vpath %.c $(sort $(dir $(C_SOURCES)))
|
||||||
|
# list of ASM program objects
|
||||||
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
||||||
|
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
||||||
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES_S:.S=.o)))
|
||||||
|
vpath %.S $(sort $(dir $(ASM_SOURCES_S)))
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
||||||
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
||||||
|
$(AS) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.S Makefile | $(BUILD_DIR)
|
||||||
|
$(AS) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
||||||
|
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||||
|
$(SZ) $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||||
|
$(HEX) $< $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||||
|
$(BIN) $< $@
|
||||||
|
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir $@
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# clean up
|
||||||
|
#######################################
|
||||||
|
clean:
|
||||||
|
-rm -fR $(BUILD_DIR)
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# dependencies
|
||||||
|
#######################################
|
||||||
|
-include $(wildcard $(BUILD_DIR)/*.d)
|
||||||
|
|
||||||
|
# *** EOF ***
|
51
board/QEMU_Spike/GCC/demo/link.ld
Normal file
51
board/QEMU_Spike/GCC/demo/link.ld
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
OUTPUT_ARCH( "riscv" )
|
||||||
|
ENTRY( _start )
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
ROM (rxai!w) : ORIGIN = 0x80000000, LENGTH = 512K
|
||||||
|
RAM (wxa!ri) : ORIGIN = 0x84000000, LENGTH = 128K
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text : {
|
||||||
|
PROVIDE( _text = . );
|
||||||
|
*(.text.entry)
|
||||||
|
*(.text)
|
||||||
|
*(.rodata)
|
||||||
|
PROVIDE( _etext = . );
|
||||||
|
} >ROM AT>ROM
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
_load_data = LOADADDR(.data);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
.data : {
|
||||||
|
PROVIDE( _data = . );
|
||||||
|
*(.data)
|
||||||
|
. = ALIGN(4);
|
||||||
|
} >RAM AT>ROM
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE( _edata = . );
|
||||||
|
|
||||||
|
. = ALIGN(0x1000);
|
||||||
|
PROVIDE( _bss = . );
|
||||||
|
.bss : {
|
||||||
|
*(.bss)
|
||||||
|
} >RAM AT>RAM
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE( _ebss = . );
|
||||||
|
|
||||||
|
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE( end = . );
|
||||||
|
|
||||||
|
_stack_size = 128;
|
||||||
|
.stack ORIGIN(RAM) + LENGTH(RAM) - _stack_size :
|
||||||
|
{
|
||||||
|
. = _stack_size;
|
||||||
|
PROVIDE( _stack_top = . );
|
||||||
|
} >RAM AT>RAM
|
||||||
|
_end = .;
|
||||||
|
}
|
@@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1473950114" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.1473950114" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||||
|
|
||||||
<builder buildPath="${workspace_loc:/hello_world}/Debug" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1645829934" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
<builder buildPath="${workspace_loc:/demo}/Debug" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1645829934" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||||
|
|
||||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1747128168" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1747128168" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||||
|
|
||||||
@@ -107,9 +107,9 @@
|
|||||||
|
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.460479417" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.460479417" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/arch/risc-v/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TencentOS_tiny/arch/risc-v/common/include}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/arch/risc-v/rv32i/gcc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TencentOS_tiny/arch/risc-v/rv32i/gcc}""/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
@@ -125,17 +125,17 @@
|
|||||||
|
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.293419375" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.293419375" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/kernel/core/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TencentOS_tiny/kernel/core/include}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/kernel/pm/include}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TencentOS_tiny/kernel/pm/include}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/arch/risc-v/common}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TencentOS_tiny/arch/risc-v/common/include}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TencentOS_tiny/arch/risc-v/rv32i/gcc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TencentOS_tiny/arch/risc-v/rv32i/gcc}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/Inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/Inc}""/>
|
||||||
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/hello_world/TOS-CONFIG}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/demo/TOS-CONFIG}""/>
|
||||||
|
|
||||||
</option>
|
</option>
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
|
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.833637785" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.833637785" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||||
|
|
||||||
<builder buildPath="${workspace_loc:/hello_world}/Release" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1077218023" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
<builder buildPath="${workspace_loc:/demo}/Release" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.1077218023" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||||
|
|
||||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1163339278" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1163339278" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@
|
|||||||
|
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
|
||||||
<project id="hello_world.ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf.955814930" name="Executable" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
|
<project id="demo.ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf.955814930" name="Executable" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
|
||||||
|
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
|
||||||
@@ -417,13 +417,13 @@
|
|||||||
|
|
||||||
<configuration configurationName="Debug">
|
<configuration configurationName="Debug">
|
||||||
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/hello_world"/>
|
<resource resourceType="PROJECT" workspacePath="/demo"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
||||||
<configuration configurationName="Release">
|
<configuration configurationName="Release">
|
||||||
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/hello_world"/>
|
<resource resourceType="PROJECT" workspacePath="/demo"/>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>hello_world</name>
|
<name>demo</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1332077899269146722" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1359335743052093289" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
|
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
|
|
41
board/QEMU_Spike/eclipse/demo/start.S
Normal file
41
board/QEMU_Spike/eclipse/demo/start.S
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// See LICENSE for license details.
|
||||||
|
|
||||||
|
#include "riscv_encoding.h"
|
||||||
|
|
||||||
|
.section .text.entry
|
||||||
|
.globl _start
|
||||||
|
.type _start,@function
|
||||||
|
_start:
|
||||||
|
csrc mstatus, MSTATUS_MIE
|
||||||
|
csrw mie, 0
|
||||||
|
|
||||||
|
la t0, machine_trap_entry
|
||||||
|
csrw mtvec, t0
|
||||||
|
|
||||||
|
la sp, _stack_top
|
||||||
|
|
||||||
|
/* Load data section */
|
||||||
|
la a0, _load_data
|
||||||
|
la a1, _data
|
||||||
|
la a2, _edata
|
||||||
|
bgeu a1, a2, begin_clear_bss
|
||||||
|
clear_data:
|
||||||
|
lw t0, (a0)
|
||||||
|
sw t0, (a1)
|
||||||
|
addi a0, a0, 4
|
||||||
|
addi a1, a1, 4
|
||||||
|
bltu a1, a2, clear_data
|
||||||
|
|
||||||
|
begin_clear_bss:
|
||||||
|
// clear bss section
|
||||||
|
la a0, _bss
|
||||||
|
la a1, _ebss
|
||||||
|
bgeu a0, a1, init_finish
|
||||||
|
clear_bss:
|
||||||
|
sw zero, (a0)
|
||||||
|
addi a0, a0, 4
|
||||||
|
bltu a0, a1, clear_bss
|
||||||
|
init_finish:
|
||||||
|
call main
|
||||||
|
__die:
|
||||||
|
j __die
|
Reference in New Issue
Block a user