Compare commits

..

No commits in common. "9e26dd655eae9ab12ddb79c8bfb328338a4fd788" and "ba0f154cba55096a2342375df3375f4626b15866" have entirely different histories.

11 changed files with 123 additions and 239 deletions

184
Makefile
View file

@ -1,5 +1,4 @@
# Makefile for AbstractMachine Kernels and Libraries # Makefile for AbstractMachine Kernels and Libraries
include scripts/helpers/rules.mk
### *Get a more readable version of this Makefile* by `make html` (requires python-markdown) ### *Get a more readable version of this Makefile* by `make html` (requires python-markdown)
html: html:
@ -9,15 +8,18 @@ html:
## 1. Basic Setup and Checks ## 1. Basic Setup and Checks
### Default to create all static libraries ### Default to create a bare-metal kernel image
ifeq ($(MAKECMDGOALS),) ifeq ($(MAKECMDGOALS),)
MAKECMDGOALS = libs MAKECMDGOALS = image
.DEFAULT_GOAL = libs .DEFAULT_GOAL = image
endif endif
### Override checks when `make clean/clean-all/html` ### Override checks when `make clean/clean-all/html`
ifeq ($(findstring $(MAKECMDGOALS),clean|clean-all|html),) ifeq ($(findstring $(MAKECMDGOALS),clean|clean-all|html),)
### Print build info message
$(info # Building $(NAME)-$(MAKECMDGOALS) [$(ARCH)])
### Check: environment variable `$AM_HOME` looks sane ### Check: environment variable `$AM_HOME` looks sane
ifeq ($(wildcard $(AM_HOME)/am/include/am.h),) ifeq ($(wildcard $(AM_HOME)/am/include/am.h),)
$(error $$AM_HOME must be an AbstractMachine repo) $(error $$AM_HOME must be an AbstractMachine repo)
@ -34,20 +36,35 @@ ARCH_SPLIT = $(subst -, ,$(ARCH))
ISA = $(word 1,$(ARCH_SPLIT)) ISA = $(word 1,$(ARCH_SPLIT))
PLATFORM = $(word 2,$(ARCH_SPLIT)) PLATFORM = $(word 2,$(ARCH_SPLIT))
### Check if there is something to build
ifeq ($(flavor SRCS), undefined)
$(error Nothing to build)
endif
### Checks end here ### Checks end here
endif endif
## 2. Setup variables pointing to build and install directory ## 2. General Compilation Targets
### Create the destination directory (`build/$ARCH`) ### Create the destination directory (`build/$ARCH`)
WORK_DIR ?= $(shell pwd) WORK_DIR = $(shell pwd)
DST_DIR ?= $(WORK_DIR)/build/$(ARCH) DST_DIR = $(WORK_DIR)/build/$(ARCH)
LIB_BUILDDIR ?= $(DST_DIR)/lib $(shell mkdir -p $(DST_DIR))
INSTALLDIR ?= $(WORK_DIR)/build/install/$(ARCH)
LIB_INSTALLDIR ?= $(INSTALLDIR)/lib
INC_INSTALLDIR ?= $(INSTALLDIR)/include
## 3. Toolchain setup ### Compilation targets (a binary image or archive)
IMAGE_REL = build/$(NAME)-$(ARCH)
IMAGE = $(abspath $(IMAGE_REL))
ARCHIVE = $(WORK_DIR)/build/$(NAME)-$(ARCH).a
### Collect the files to be linked: object files (`.o`) and libraries (`.a`)
OBJS = $(addprefix $(DST_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
LIBS := $(sort $(LIBS) am klib) # lazy evaluation ("=") causes infinite recursions
LINKAGE = $(OBJS) \
$(addsuffix -$(ARCH).a, $(join \
$(addsuffix /build/, $(addprefix $(AM_HOME)/, $(LIBS))), \
$(LIBS) ))
## 3. General Compilation Flags
### (Cross) compilers, e.g., mips-linux-gnu-g++ ### (Cross) compilers, e.g., mips-linux-gnu-g++
CC ?= $(CROSS_COMPILE)gcc CC ?= $(CROSS_COMPILE)gcc
@ -59,103 +76,80 @@ OBJDUMP ?= $(CROSS_COMPILE)objdump
OBJCOPY ?= $(CROSS_COMPILE)objcopy OBJCOPY ?= $(CROSS_COMPILE)objcopy
READELF ?= $(CROSS_COMPILE)readelf READELF ?= $(CROSS_COMPILE)readelf
### Compilation flags
INC_PATH += $(WORK_DIR)/include $(addsuffix /include/, $(addprefix $(AM_HOME)/, $(LIBS)))
INCFLAGS += $(addprefix -I, $(INC_PATH))
ARCH_H := arch/$(ARCH).h
CFLAGS += -lm -g -O3 -MMD -Wall $(INCFLAGS) \
-D__ISA__=\"$(ISA)\" -D__ISA_$(shell echo $(ISA) | tr a-z A-Z)__ \
-D__ARCH__=$(ARCH) -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
-D__PLATFORM__=$(PLATFORM) -D__PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z | tr - _) \
-DARCH_H=\"$(ARCH_H)\" \
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \
-Wno-main -U_FORTIFY_SOURCE -fvisibility=hidden
CXXFLAGS += $(CFLAGS) -ffreestanding -fno-rtti -fno-exceptions
ASFLAGS += $(INCFLAGS)
LDFLAGS += -z noexecstack
## 4. Arch-Specific Configurations ## 4. Arch-Specific Configurations
# TODO: Removed CROSS_COMPILE toolchain setup as it's too complicated ### Paste in arch-specific configurations (e.g., from `scripts/x86_64-qemu.mk`)
# for Makefile to do right. Force the user to provide a CROSS_COMPILE -include $(AM_HOME)/scripts/$(ARCH).mk
# prefix for now. They can also specify CFLAGS and LDFLAGS through
# environment variable. ### Fall back to native gcc/binutils if there is no cross compiler
include $(AM_HOME)/scripts/$(ARCH).mk ifeq ($(wildcard $(shell which $(CC))),)
$(info # $(CC) not found; fall back to default gcc and binutils)
CROSS_COMPILE := riscv64-unknown-linux-gnu-
endif
## 5. Compilation Rules ## 5. Compilation Rules
BUILDDIR := $(DST_DIR) ### Rule (compile): a single `.c` -> `.o` (gcc)
COMMON_CFLAGS := $(CFLAGS) -g -O3 -MMD -Wall \ $(DST_DIR)/%.o: %.c
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \ @mkdir -p $(dir $@) && echo + CC $<
-U_FORTIFY_SOURCE -fvisibility=hidden -fno-exceptions -std=gnu11 @$(CC) -std=gnu11 $(CFLAGS) -c -o $@ $(realpath $<)
INTERFACE_LDFLAGS += -z noexecstack
INTERFACE_CFLAGS += -fno-asynchronous-unwind-tables \
-fno-builtin -fno-stack-protector \
-U_FORTIFY_SOURCE -fvisibility=hidden -fno-exceptions
### Build libam
#### Include archetecture specific build flags
COMMON_CFLAGS += -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
-D__ISA_$(shell echo $(ISA) | tr a-z A-Z)__ \
-DARCH_H=\"$(ARCH_H)\"
INTERFACE_CFLAGS += -DARCH_H=\"$(ARCH_H)\"
#### Generating build rules with ADD_LIBRARY call. Target specific build flags can be tuned via changing prefixed variables (AM_ here) ### Rule (compile): a single `.cc` -> `.o` (g++)
AM_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/am/src $(AM_HOME)/klib/include $(DST_DIR)/%.o: %.cc
AM_CFLAGS += $(COMMON_CFLAGS) $(addprefix -I, $(AM_INCPATH)) @mkdir -p $(dir $@) && echo + CXX $<
AM_INTERFACE_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/klib/include @$(CXX) -std=c++17 $(CXXFLAGS) -c -o $@ $(realpath $<)
AM_INTERFACE_CFLAGS +=
AM_INTERFACE_LDFLAGS += -lam-$(ARCH) ### Rule (compile): a single `.cpp` -> `.o` (g++)
$(DST_DIR)/%.o: %.cpp
@mkdir -p $(dir $@) && echo + CXX $<
@$(CXX) -std=c++17 $(CXXFLAGS) -c -o $@ $(realpath $<)
$(eval $(call ADD_LIBRARY,$(LIB_BUILDDIR)/libam-$(ARCH).a,AM_)) ### Rule (compile): a single `.S` -> `.o` (gcc, which preprocesses and calls as)
$(DST_DIR)/%.o: %.S
@mkdir -p $(dir $@) && echo + AS $<
@$(AS) $(ASFLAGS) -c -o $@ $(realpath $<)
### Build klib ### Rule (recursive make): build a dependent library (am, klib, ...)
$(LIBS): %:
@$(MAKE) -s -C $(AM_HOME)/$* archive
KLIB_SRCS := $(shell find klib/src/ -name "*.c") ### Rule (link): objects (`*.o`) and libraries (`*.a`) -> `IMAGE.elf`, the final ELF binary to be packed into image (ld)
$(IMAGE).elf: $(OBJS) $(LIBS)
@echo + LD "->" $(IMAGE_REL).elf
@$(LD) $(LDFLAGS) -o $(IMAGE).elf --start-group $(LINKAGE) --end-group
KLIB_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/klib/include ### Rule (archive): objects (`*.o`) -> `ARCHIVE.a` (ar)
KLIB_CFLAGS += $(COMMON_CFLAGS) $(addprefix -I, $(KLIB_INCPATH)) $(ARCHIVE): $(OBJS)
KLIB_INTERFACE_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/klib/include @echo + AR "->" $(shell realpath $@ --relative-to .)
KLIB_INTERFACE_CFLAGS += @$(AR) rcs $(ARCHIVE) $(OBJS)
KLIB_INTERFACE_LDFLAGS += -lklib-$(ARCH)
$(eval $(call ADD_LIBRARY,$(LIB_BUILDDIR)/libklib-$(ARCH).a,KLIB_)) ### Rule (`#include` dependencies): paste in `.d` files generated by gcc on `-MMD`
-include $(addprefix $(DST_DIR)/, $(addsuffix .d, $(basename $(SRCS))))
LIBS := am klib ## 6. Miscellaneous
libs: $(addsuffix -$(ARCH).a, $(addprefix $(LIB_BUILDDIR)/lib, $(ALL)))
$(LIBS): %: $(addsuffix -$(ARCH).a, $(addprefix $(LIB_BUILDDIR)/lib, %))
## 6. Install rules ### Build order control
INTERFACE_INCPATH += $(sort $(KLIB_INTERFACE_INCPATH) $(AM_INTERFACE_INCPATH)) image: image-dep
# TODO: Use sort here will cause error on seperated flags, such as: -e _start archive: $(ARCHIVE)
# but without sort, duplicated flags will not be removed. image-dep: $(OBJS) $(LIBS)
INTERFACE_CFLAGS += $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR))) $(sort $(KLIB_INTERFACE_CFLAGS) $(AM_INTERFACE_CFLAGS)) @echo \# Creating image [$(ARCH)]
INTERFACE_CXXFLAGS += $(INTERFACE_CFLAGS) $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR))) .PHONY: image image-dep archive run $(LIBS)
INTERFACE_LDFLAGS += -L$(LIB_INSTALLDIR) $(sort $(KLIB_INTERFACE_LDFLAGS) $(AM_INTERFACE_LDFLAGS))
EXPORT_FLAGS_FILE := $(LIB_INSTALLDIR)/make/flags-$(ARCH).mk
EXPORT_FLAGS_TEMPLATE := $(file < $(AM_HOME)/scripts/templates/flags.tmpl)
HELPERS := $(wildcard find scripts/helpers/*.mk)
EXPORT_HELPERS := $(HELPERS:scripts/helpers/%=$(LIB_INSTALLDIR)/make/%)
EXPORTS := $(EXPORT_FLAGS_FILE) $(EXPORT_HELPERS)
$(EXPORT_HELPERS): $(LIB_INSTALLDIR)/make/%: scripts/helpers/%
@echo + INSTALL $(patsubst $(INSTALLDIR)/%,%,$@)
@install -dm755 $(dir $@)
@install -Dm644 $< $(dir $@)
export INTERFACE_CFLAGS INTERFACE_CXXFLAGS INTERFACE_ASFLAGS INTERFACE_INCPATH INTERFACE_LDFLAGS
$(EXPORT_FLAGS_FILE):
@echo + INSTALL $(patsubst $(INSTALLDIR)/%,%,$@)
@install -Dm644 <(printf $(EXPORT_FLAGS_TEMPLATE)) $(EXPORT_FLAGS_FILE)
LDSCRIPTS := $(patsubst $(AM_HOME)/scripts/%, $(LIB_INSTALLDIR)/ldscripts/%, $(shell find $(AM_HOME)/scripts -name "*.ld"))
$(LDSCRIPTS): $(LIB_INSTALLDIR)/ldscripts/%: $(AM_HOME)/scripts/%
@echo + INSTALL $(patsubst $(INSTALLDIR)/%,%,$@)
@mkdir -p $(LIB_INSTALLDIR)/ldscripts
@install -Dm644 $< $(dir $@)
install-libs: $(LIBS)
@echo + INSTALL LIBS: $(LIBS)
@install -dm755 $(LIB_INSTALLDIR)
@install -Dm644 $(addsuffix -$(ARCH).a, $(addprefix $(LIB_BUILDDIR)/lib, $(LIBS))) $(LIB_INSTALLDIR)
install-headers: HEADERS := $(shell find $(INTERFACE_INCPATH) -name '*.h')
install-headers: $(HEADERS) # Headers needs to be reinstalled if they are changed
@echo + INSTALL HEADERS: $(INTERFACE_INCPATH)
@install -dm755 $(INC_INSTALLDIR)
@cp -r $(addsuffix /*, $(INTERFACE_INCPATH)) $(INC_INSTALLDIR)
install: $(EXPORTS) install-libs install-headers $(LDSCRIPTS)
.PHONY: libs $(LIBS) install
### Clean a single project (remove `build/`) ### Clean a single project (remove `build/`)
clean: clean:

View file

@ -59,4 +59,3 @@ bool ioe_init() {
void ioe_read(int reg, void *buf) { ((handler_t)lut[reg])(buf); } void ioe_read(int reg, void *buf) { ((handler_t)lut[reg])(buf); }
void ioe_write(int reg, void *buf) { ((handler_t)lut[reg])(buf); } void ioe_write(int reg, void *buf) { ((handler_t)lut[reg])(buf); }

View file

@ -22,7 +22,6 @@ void halt(int code) {
while (1); while (1);
} }
void _trm_init() { void _trm_init() {
heap_alloc_ptr = heap.start; heap_alloc_ptr = heap.start;
int ret = main(mainargs); int ret = main(mainargs);

View file

@ -5,7 +5,4 @@
_start: _start:
mv s0, zero mv s0, zero
la sp, _stack_pointer la sp, _stack_pointer
jal _trm_init
lui t0, %hi(_trm_init) # Load upper 20 bits
addi t0, t0, %lo(_trm_init) # Add lower 12 bits
jalr ra, t0, 0 # Jump and link register

View file

@ -24,7 +24,6 @@ char *strcpy(char *dst, const char *src);
char *strncpy(char *dst, const char *src, size_t n); char *strncpy(char *dst, const char *src, size_t n);
int strcmp(const char *s1, const char *s2); int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n); int strncmp(const char *s1, const char *s2, size_t n);
void *memchr(const void *src, int c, size_t n);
//stdlib.h //stdlib.h

View file

@ -54,31 +54,4 @@ void *malloc(size_t size) {
void free(void *ptr) { void free(void *ptr) {
} }
#include <stdint.h>
#include <limits.h>
#define SS (sizeof(size_t))
#define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1))
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
void *memchr(const void *src, int c, size_t n)
{
const unsigned char *s = src;
c = (unsigned char)c;
#ifdef __GNUC__
for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
if (n && *s != c) {
typedef size_t __attribute__((__may_alias__)) word;
const word *w;
size_t k = ONES * c;
for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
s = (const void *)w;
}
#endif
for (; n && *s != c; s++, n--);
return n ? (void *)s : 0;
}
#endif #endif

View file

@ -1,64 +0,0 @@
# Usage:
# $(1): Target prefix
#
# Generate build rules for files in variable <PREFIX>_SRCS. Use <PREFIX>_CFLAGS,
# <PREFIX>_CXXFLAGS, <PREFIX>_ASFLAGS to control build flags.
# Object files will be put into $BUILDDIR
# E.g:
# $(eval $(call COMPILE_RULES,AM_))
define COMPILE_RULES
$(1)OBJS += $$(addprefix $$(BUILDDIR)/, $$(addsuffix .o, $$($(1)SRCS)))
### Rule (compile): a single `.c` -> `.c.o` (gcc)
$$(filter %.c.o, $$($(1)OBJS)): $$(BUILDDIR)/%.c.o: %.c
@mkdir -p $$(dir $$@) && echo + CC $$<
@$$(CC) $$($(1)CFLAGS) -c -o $$@ $$(realpath $$<)
### Rule (compile): a single `.cc` -> `.cc.o` (g++)
$$(filter %.cc.o, $$($(1)OBJS)): $$(BUILDDIR)/%.cc.o: %.cc
@mkdir -p $$(dir $$@) && echo + CXX $$<
@$$(CXX) $$($(1)CXXFLAGS) -c -o $$@ $$(realpath $$<)
### Rule (compile): a single `.cpp` -> `.cpp.o` (g++)
$$(filter %.cpp.o, $$($(1)OBJS)): $$(BUILDDIR)/%.cpp.o: %.cpp
@mkdir -p $$(dir $$@) && echo + CXX $$<
@$$(CXX) $$($(1)CXXFLAGS) -c -o $$@ $$(realpath $$<)
### Rule (compile): a single `.S` -> `.S.o` (gcc, which preprocesses and calls as)
$$(filter %.S.o, $$($(1)OBJS)): $$(BUILDDIR)/%.S.o: %.S
@mkdir -p $$(dir $$@) && echo + AS $$<
@$$(AS) $$($(1)ASFLAGS) -c -o $$@ $$(realpath $$<)
### Rule (`#include` dependencies): paste in `.d` files generated by gcc on `-MMD`
-include $$(addprefix $$(BUILDDIR)/, $$(addsuffix .d, $$(filter %.c %.cc, $$($(1)SRCS))))
endef
# Usage:
# $(1): Library build path
# $(2): Library variable prefix
# E.g:
# $(eval $(call ADD_LIBRARY,am-riscv,AM_))
define ADD_LIBRARY
$(eval $(call COMPILE_RULES,$(2)))
$(1): $$($(2)OBJS)
@mkdir -p $$(dir $$@)
@echo + AR "->" $$(patsubst $$(CURDIR)/%,%,$(1))
@$$(AR) rcs $$@ $$($(2)OBJS)
endef
# Usage:
# $(1): Image build path
# $(2): Image variable prefix
# E.g:
# $(eval $(call ADD_IMAGE,dummy,DUMMY_))
define ADD_IMAGE
$(eval $(call COMPILE_RULES,$(2)))
$(1).elf: $$($(2)OBJS)
@mkdir -p $$(dir $$@)
@echo + LD "->" $$(patsubst $$(CURDIR)/%,%,$(1).elf)
@$$(LD) -o $$@ $$(filter-out -l%,$$($(2)LDFLAGS)) --start-group $$($(2)OBJS) $$(filter -l%,$$($(2)LDFLAGS)) --end-group
$(1).bin: $(1).elf
@echo + OBJCOPY "->" $$(patsubst $$(CURDIR)/%,%,$(1).bin)
@$$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(1).elf $(1).bin
endef

View file

@ -1,9 +1,8 @@
AM_CFLAGS += -static -fno-pic -mstrict-align -ffreestanding CROSS_COMPILE := riscv64-linux-gnu-
AM_ASFLAGS += -static -fno-pic -O0 COMMON_CFLAGS := -fno-pic -march=rv64g -mcmodel=medany -mstrict-align
CFLAGS += $(COMMON_CFLAGS) -static
INTERFACE_CFLAGS += -static -mcmodel=medany -mstrict-align -ffreestanding ASFLAGS += $(COMMON_CFLAGS) -O0
INTERFACE_ASFLAGS += -static -mcmodel=medany LDFLAGS += -melf64lriscv -O2
INTERFACE_LDFLAGS +=
# overwrite ARCH_H defined in $(AM_HOME)/Makefile # overwrite ARCH_H defined in $(AM_HOME)/Makefile
ARCH_H := arch/riscv.h ARCH_H := arch/riscv.h

View file

@ -1,26 +1,28 @@
AM_SRCS := am/src/platform/nemu/trm.c \ AM_SRCS := platform/nemu/trm.c \
am/src/platform/nemu/ioe/ioe.c \ platform/nemu/ioe/ioe.c \
am/src/platform/nemu/ioe/timer.c \ platform/nemu/ioe/timer.c \
am/src/platform/nemu/ioe/input.c \ platform/nemu/ioe/input.c \
am/src/platform/nemu/ioe/gpu.c \ platform/nemu/ioe/gpu.c \
am/src/platform/nemu/ioe/audio.c \ platform/nemu/ioe/audio.c \
am/src/platform/nemu/ioe/disk.c \ platform/nemu/ioe/disk.c \
am/src/platform/nemu/mpe.c platform/nemu/mpe.c
AM_PUBLIC_CFLAGS := -fdata-sections -ffunction-sections
AM_PUBLIC_LDFLAGS := --defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0 \
--gc-sections --entry=_start
AM_CFLAGS += $(AM_PUBLIC_CFLAGS) -DMAINARGS=\"$(mainargs)\"
AM_LDFLAGS += -T$(AM_HOME)/scripts/linker.ld $(AM_PUBLIC_LDFLAGS)
AM_INCPATH += $(AM_HOME)/am/src/platform/nemu/include
AM_INTERFACE_CFLAGS += $(AM_PUBLIC_CFLAGS)
AM_INTERFACE_LDFLAGS += -T$(LIB_INSTALLDIR)/ldscripts/linker.ld $(AM_PUBLIC_LDFLAGS)
.PHONY: $(AM_HOME)/am/src/platform/nemu/trm.c
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += -T $(AM_HOME)/scripts/linker.ld \
--defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0
LDFLAGS += --gc-sections -e _start
NEMUFLAGS += -b NEMUFLAGS += -b
#-l $(shell dirname $(IMAGE).elf)/nemu-log.txt #-l $(shell dirname $(IMAGE).elf)/nemu-log.txt
CFLAGS += -DMAINARGS=\"$(mainargs)\"
CFLAGS += -I$(AM_HOME)/am/src/platform/nemu/include
.PHONY: $(AM_HOME)/am/src/platform/nemu/trm.c
image: $(IMAGE).elf
@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
@echo + OBJCOPY "->" $(IMAGE_REL).bin
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin
run: image run: image
$(MAKE) -C $(NEMU_HOME) ISA=$(ISA) run ARGS="$(NEMUFLAGS)" IMG=$(IMAGE).bin $(MAKE) -C $(NEMU_HOME) ISA=$(ISA) run ARGS="$(NEMUFLAGS)" IMG=$(IMAGE).bin

View file

@ -1,14 +1,10 @@
include $(AM_HOME)/scripts/isa/riscv.mk include $(AM_HOME)/scripts/isa/riscv.mk
include $(AM_HOME)/scripts/platform/nemu.mk include $(AM_HOME)/scripts/platform/nemu.mk
AM_CFLAGS += -DISA_H=\"riscv/riscv.h\" -march=rv32im_zicsr -mabi=ilp32 CFLAGS += -DISA_H=\"riscv/riscv.h\"
AM_ASFLAGS += -march=rv32im_zicsr -mabi=ilp32 COMMON_CFLAGS += -march=rv32im_zicsr -mabi=ilp32 # overwrite
KLIB_CFLAGS += -march=rv32im_zicsr -mabi=ilp32 LDFLAGS += -melf32lriscv # overwrite
AM_LDFLAGS += -melf32lriscv
INTERFACE_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
INTERFACE_CXXFLAGS += -march=rv32im_zicsr -mabi=ilp32
INTERFACE_ASFLAGS += -march=rv32im_zicsr -mabi=ilp32
AM_SRCS += am/src/riscv/nemu/start.S \ AM_SRCS += riscv/nemu/start.S \
am/src/riscv/nemu/cte.c \ riscv/nemu/cte.c \
am/src/riscv/nemu/trap.S \ riscv/nemu/trap.S \
am/src/riscv/nemu/vme.c riscv/nemu/vme.c

View file

@ -1,10 +0,0 @@
"AM_CFLAGS += %s \n\
AM_CXXFLAGS += %s \n\
AM_INCPATH += %s \n\
AM_LDFLAGS += %s \n\
AM_ASFLAGS += %s" \
"$INTERFACE_CFLAGS" \
"$INTERFACE_CXXFLAGS" \
"$INTERFACE_INCPATH" \
"$INTERFACE_LDFLAGS" \
"$INTERFACE_ASFLAGS"