NJU-ProjectN/abstract-machine ics2023 initialized
NJU-ProjectN/abstract-machine 3348db971fd860be5cb28e21c18f9d0e65d0c96a Merge pull request #8 from Jasonyanyusong/master
This commit is contained in:
parent
2824efad33
commit
8e4feb4010
129 changed files with 9017 additions and 0 deletions
4
abstract-machine/scripts/isa/loongarch32r.mk
Normal file
4
abstract-machine/scripts/isa/loongarch32r.mk
Normal file
|
@ -0,0 +1,4 @@
|
|||
CROSS_COMPILE := loongarch32r-linux-gnusf-
|
||||
COMMON_FLAGS := -fno-pic
|
||||
CFLAGS += $(COMMON_FLAGS) -static
|
||||
ASFLAGS += $(COMMON_FLAGS) -O0
|
5
abstract-machine/scripts/isa/mips32.mk
Normal file
5
abstract-machine/scripts/isa/mips32.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
CROSS_COMPILE := mips-linux-gnu-
|
||||
COMMON_FLAGS := -march=mips32 -fno-pic -fno-delayed-branch -mno-abicalls -mno-check-zero-division -EL
|
||||
CFLAGS += $(COMMON_FLAGS) -static -mno-llsc -mno-imadd -mno-mad
|
||||
ASFLAGS += $(COMMON_FLAGS) -O0
|
||||
LDFLAGS += -EL
|
8
abstract-machine/scripts/isa/riscv.mk
Normal file
8
abstract-machine/scripts/isa/riscv.mk
Normal file
|
@ -0,0 +1,8 @@
|
|||
CROSS_COMPILE := riscv64-linux-gnu-
|
||||
COMMON_CFLAGS := -fno-pic -march=rv64g -mcmodel=medany -mstrict-align
|
||||
CFLAGS += $(COMMON_CFLAGS) -static
|
||||
ASFLAGS += $(COMMON_CFLAGS) -O0
|
||||
LDFLAGS += -melf64lriscv
|
||||
|
||||
# overwrite ARCH_H defined in $(AM_HOME)/Makefile
|
||||
ARCH_H := arch/riscv.h
|
5
abstract-machine/scripts/isa/x86.mk
Normal file
5
abstract-machine/scripts/isa/x86.mk
Normal file
|
@ -0,0 +1,5 @@
|
|||
export CROSS_COMPILE := x86_64-linux-gnu-
|
||||
CFLAGS += -m32 -fno-pic -fno-omit-frame-pointer -march=i386
|
||||
CFLAGS += -fcf-protection=none # remove endbr32 in Ubuntu 20.04 with a CPU newer than Comet Lake
|
||||
ASFLAGS += -m32 -fno-pic
|
||||
LDFLAGS += -melf_i386
|
4
abstract-machine/scripts/isa/x86_64.mk
Normal file
4
abstract-machine/scripts/isa/x86_64.mk
Normal file
|
@ -0,0 +1,4 @@
|
|||
export CROSS_COMPILE := x86_64-linux-gnu-
|
||||
CFLAGS += -m64 -fPIC -mno-sse
|
||||
ASFLAGS += -m64 -fPIC
|
||||
LDFLAGS += -melf_x86_64
|
33
abstract-machine/scripts/linker.ld
Normal file
33
abstract-machine/scripts/linker.ld
Normal file
|
@ -0,0 +1,33 @@
|
|||
ENTRY(_start)
|
||||
PHDRS { text PT_LOAD; data PT_LOAD; }
|
||||
|
||||
SECTIONS {
|
||||
/* _pmem_start and _entry_offset are defined in LDFLAGS */
|
||||
. = _pmem_start + _entry_offset;
|
||||
.text : {
|
||||
*(entry)
|
||||
*(.text*)
|
||||
} : text
|
||||
etext = .;
|
||||
_etext = .;
|
||||
.rodata : {
|
||||
*(.rodata*)
|
||||
}
|
||||
.data : {
|
||||
*(.data)
|
||||
} : data
|
||||
edata = .;
|
||||
_data = .;
|
||||
.bss : {
|
||||
_bss_start = .;
|
||||
*(.bss*)
|
||||
*(.sbss*)
|
||||
*(.scommon)
|
||||
}
|
||||
_stack_top = ALIGN(0x1000);
|
||||
. = _stack_top + 0x8000;
|
||||
_stack_pointer = .;
|
||||
end = .;
|
||||
_end = .;
|
||||
_heap_start = ALIGN(0x1000);
|
||||
}
|
8
abstract-machine/scripts/loongarch32r-nemu.mk
Normal file
8
abstract-machine/scripts/loongarch32r-nemu.mk
Normal file
|
@ -0,0 +1,8 @@
|
|||
include $(AM_HOME)/scripts/isa/loongarch32r.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
CFLAGS += -DISA_H=\"loongarch/loongarch32r.h\"
|
||||
|
||||
AM_SRCS += loongarch/nemu/start.S \
|
||||
loongarch/nemu/cte.c \
|
||||
loongarch/nemu/trap.S \
|
||||
loongarch/nemu/vme.c
|
8
abstract-machine/scripts/mips32-nemu.mk
Normal file
8
abstract-machine/scripts/mips32-nemu.mk
Normal file
|
@ -0,0 +1,8 @@
|
|||
include $(AM_HOME)/scripts/isa/mips32.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
CFLAGS += -DISA_H=\"mips/mips32.h\"
|
||||
|
||||
AM_SRCS += mips/nemu/start.S \
|
||||
mips/nemu/cte.c \
|
||||
mips/nemu/trap.S \
|
||||
mips/nemu/vme.c
|
27
abstract-machine/scripts/native.mk
Normal file
27
abstract-machine/scripts/native.mk
Normal file
|
@ -0,0 +1,27 @@
|
|||
AM_SRCS := native/trm.c \
|
||||
native/ioe.c \
|
||||
native/cte.c \
|
||||
native/trap.S \
|
||||
native/vme.c \
|
||||
native/mpe.c \
|
||||
native/platform.c \
|
||||
native/ioe/input.c \
|
||||
native/ioe/timer.c \
|
||||
native/ioe/gpu.c \
|
||||
native/ioe/audio.c \
|
||||
native/ioe/disk.c \
|
||||
|
||||
CFLAGS += -fpie
|
||||
ASFLAGS += -fpie -pie
|
||||
comma = ,
|
||||
LDFLAGS_CXX = $(addprefix -Wl$(comma), $(LDFLAGS))
|
||||
|
||||
image:
|
||||
@echo + LD "->" $(IMAGE_REL)
|
||||
@g++ -pie -o $(IMAGE) -Wl,--whole-archive $(LINKAGE) -Wl,-no-whole-archive $(LDFLAGS_CXX) -lSDL2 -ldl
|
||||
|
||||
run: image
|
||||
$(IMAGE)
|
||||
|
||||
gdb: image
|
||||
gdb -ex "handle SIGUSR1 SIGUSR2 SIGSEGV noprint nostop" $(IMAGE)
|
29
abstract-machine/scripts/platform/nemu.mk
Normal file
29
abstract-machine/scripts/platform/nemu.mk
Normal file
|
@ -0,0 +1,29 @@
|
|||
AM_SRCS := platform/nemu/trm.c \
|
||||
platform/nemu/ioe/ioe.c \
|
||||
platform/nemu/ioe/timer.c \
|
||||
platform/nemu/ioe/input.c \
|
||||
platform/nemu/ioe/gpu.c \
|
||||
platform/nemu/ioe/audio.c \
|
||||
platform/nemu/ioe/disk.c \
|
||||
platform/nemu/mpe.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 += -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
|
||||
$(MAKE) -C $(NEMU_HOME) ISA=$(ISA) run ARGS="$(NEMUFLAGS)" IMG=$(IMAGE).bin
|
||||
|
||||
gdb: image
|
||||
$(MAKE) -C $(NEMU_HOME) ISA=$(ISA) gdb ARGS="$(NEMUFLAGS)" IMG=$(IMAGE).bin
|
21
abstract-machine/scripts/platform/npc.mk
Normal file
21
abstract-machine/scripts/platform/npc.mk
Normal file
|
@ -0,0 +1,21 @@
|
|||
AM_SRCS := riscv/npc/start.S \
|
||||
riscv/npc/trm.c \
|
||||
riscv/npc/ioe.c \
|
||||
riscv/npc/timer.c \
|
||||
riscv/npc/input.c \
|
||||
riscv/npc/cte.c \
|
||||
riscv/npc/trap.S \
|
||||
platform/dummy/vme.c \
|
||||
platform/dummy/mpe.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
|
||||
CFLAGS += -DMAINARGS=\"$(mainargs)\"
|
||||
.PHONY: $(AM_HOME)/am/src/riscv/npc/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
|
17
abstract-machine/scripts/platform/qemu.mk
Normal file
17
abstract-machine/scripts/platform/qemu.mk
Normal file
|
@ -0,0 +1,17 @@
|
|||
.PHONY: build-arg
|
||||
|
||||
LDFLAGS += -N -Ttext-segment=0x00100000
|
||||
QEMU_FLAGS += -serial mon:stdio \
|
||||
-machine accel=tcg \
|
||||
-smp "$(smp)" \
|
||||
-drive format=raw,file=$(IMAGE)
|
||||
|
||||
build-arg: image
|
||||
@( echo -n $(mainargs); ) | dd if=/dev/stdin of=$(IMAGE) bs=512 count=2 seek=1 conv=notrunc status=none
|
||||
|
||||
BOOT_HOME := $(AM_HOME)/am/src/x86/qemu/boot
|
||||
|
||||
image: $(IMAGE).elf
|
||||
@$(MAKE) -s -C $(BOOT_HOME)
|
||||
@echo + CREATE "->" $(IMAGE_REL)
|
||||
@( cat $(BOOT_HOME)/bootblock.o; head -c 1024 /dev/zero; cat $(IMAGE).elf ) > $(IMAGE)
|
10
abstract-machine/scripts/riscv32-nemu.mk
Normal file
10
abstract-machine/scripts/riscv32-nemu.mk
Normal file
|
@ -0,0 +1,10 @@
|
|||
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
CFLAGS += -DISA_H=\"riscv/riscv.h\"
|
||||
COMMON_CFLAGS += -march=rv32im_zicsr -mabi=ilp32 # overwrite
|
||||
LDFLAGS += -melf32lriscv # overwrite
|
||||
|
||||
AM_SRCS += riscv/nemu/start.S \
|
||||
riscv/nemu/cte.c \
|
||||
riscv/nemu/trap.S \
|
||||
riscv/nemu/vme.c
|
10
abstract-machine/scripts/riscv32e-nemu.mk
Normal file
10
abstract-machine/scripts/riscv32e-nemu.mk
Normal file
|
@ -0,0 +1,10 @@
|
|||
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
CFLAGS += -DISA_H=\"riscv/riscv.h\"
|
||||
COMMON_CFLAGS += -march=rv32em_zicsr -mabi=ilp32e # overwrite
|
||||
LDFLAGS += -melf32lriscv # overwrite
|
||||
|
||||
AM_SRCS += riscv/nemu/start.S \
|
||||
riscv/nemu/cte.c \
|
||||
riscv/nemu/trap.S \
|
||||
riscv/nemu/vme.c
|
10
abstract-machine/scripts/riscv32e-npc.mk
Normal file
10
abstract-machine/scripts/riscv32e-npc.mk
Normal file
|
@ -0,0 +1,10 @@
|
|||
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||
include $(AM_HOME)/scripts/platform/npc.mk
|
||||
COMMON_CFLAGS += -march=rv32e_zicsr -mabi=ilp32e # overwrite
|
||||
LDFLAGS += -melf32lriscv # overwrite
|
||||
|
||||
AM_SRCS += riscv/npc/libgcc/div.S \
|
||||
riscv/npc/libgcc/muldi3.S \
|
||||
riscv/npc/libgcc/multi3.c \
|
||||
riscv/npc/libgcc/ashldi3.c \
|
||||
riscv/npc/libgcc/unused.c
|
8
abstract-machine/scripts/riscv64-nemu.mk
Normal file
8
abstract-machine/scripts/riscv64-nemu.mk
Normal file
|
@ -0,0 +1,8 @@
|
|||
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
CFLAGS += -DISA_H=\"riscv/riscv.h\"
|
||||
|
||||
AM_SRCS += riscv/nemu/start.S \
|
||||
riscv/nemu/cte.c \
|
||||
riscv/nemu/trap.S \
|
||||
riscv/nemu/vme.c
|
19
abstract-machine/scripts/spike.mk
Normal file
19
abstract-machine/scripts/spike.mk
Normal file
|
@ -0,0 +1,19 @@
|
|||
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||
|
||||
AM_SRCS := riscv/spike/trm.c \
|
||||
riscv/spike/ioe.c \
|
||||
riscv/spike/timer.c \
|
||||
riscv/spike/start.S \
|
||||
riscv/spike/htif.S \
|
||||
platform/dummy/cte.c \
|
||||
platform/dummy/vme.c \
|
||||
platform/dummy/mpe.c \
|
||||
|
||||
CFLAGS += -fdata-sections -ffunction-sections
|
||||
LDFLAGS += -T $(AM_HOME)/am/src/riscv/spike/linker.ld
|
||||
LDFLAGS += --gc-sections -e _start
|
||||
|
||||
CFLAGS += -DMAINARGS=\"$(mainargs)\"
|
||||
.PHONY: $(AM_HOME)/am/src/riscv/spike/trm.c
|
||||
|
||||
image: $(IMAGE).elf
|
10
abstract-machine/scripts/x86-nemu.mk
Normal file
10
abstract-machine/scripts/x86-nemu.mk
Normal file
|
@ -0,0 +1,10 @@
|
|||
include $(AM_HOME)/scripts/isa/x86.mk
|
||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||
CFLAGS += -mstringop-strategy=loop -DISA_H=\"x86/x86.h\"
|
||||
# overwrite _pmem_start and _entry_offset defined in nemu.mk
|
||||
LDFLAGS += --defsym=_pmem_start=0x0 --defsym=_entry_offset=0x100000
|
||||
|
||||
AM_SRCS += x86/nemu/start.S \
|
||||
x86/nemu/cte.c \
|
||||
x86/nemu/trap.S \
|
||||
x86/nemu/vme.c
|
13
abstract-machine/scripts/x86-qemu.mk
Normal file
13
abstract-machine/scripts/x86-qemu.mk
Normal file
|
@ -0,0 +1,13 @@
|
|||
include $(AM_HOME)/scripts/isa/x86.mk
|
||||
include $(AM_HOME)/scripts/platform/qemu.mk
|
||||
|
||||
AM_SRCS := x86/qemu/start32.S \
|
||||
x86/qemu/trap32.S \
|
||||
x86/qemu/trm.c \
|
||||
x86/qemu/cte.c \
|
||||
x86/qemu/ioe.c \
|
||||
x86/qemu/vme.c \
|
||||
x86/qemu/mpe.c
|
||||
|
||||
run: build-arg
|
||||
@qemu-system-i386 $(QEMU_FLAGS)
|
13
abstract-machine/scripts/x86_64-qemu.mk
Normal file
13
abstract-machine/scripts/x86_64-qemu.mk
Normal file
|
@ -0,0 +1,13 @@
|
|||
include $(AM_HOME)/scripts/isa/x86_64.mk
|
||||
include $(AM_HOME)/scripts/platform/qemu.mk
|
||||
|
||||
AM_SRCS := x86/qemu/start64.S \
|
||||
x86/qemu/trap64.S \
|
||||
x86/qemu/trm.c \
|
||||
x86/qemu/cte.c \
|
||||
x86/qemu/ioe.c \
|
||||
x86/qemu/vme.c \
|
||||
x86/qemu/mpe.c
|
||||
|
||||
run: build-arg
|
||||
@qemu-system-x86_64 $(QEMU_FLAGS)
|
Loading…
Add table
Add a link
Reference in a new issue