*-nemu: refactor directories

This commit is contained in:
Zihao Yu 2020-03-05 17:25:06 +08:00
parent d4e99b5a03
commit 4371f037c1
31 changed files with 81 additions and 45 deletions

View File

@ -1,2 +1,10 @@
include $(AM_HOME)/am/arch/isa/mips32.mk
include $(AM_HOME)/am/arch/platform/nemu.mk
AM_SRCS += nemu/isa/mips/trm.c \
nemu/isa/mips/cte.c \
nemu/isa/mips/trap.S \
nemu/isa/mips/vme.c \
nemu/isa/mips/boot/start.S
LDFLAGS += -T $(AM_HOME)/am/src/nemu/isa/mips/boot/loader.ld

View File

@ -1,20 +1,16 @@
AM_SRCS := nemu-common/trm.c \
nemu-common/mainargs.S \
nemu-common/ioe.c \
nemu-common/nemu-input.c \
nemu-common/nemu-timer.c \
nemu-common/nemu-video.c \
$(ISA)/nemu/cte.c \
$(ISA)/nemu/trap.S \
$(ISA)/nemu/vme.c \
AM_SRCS += nemu/common/trm.c \
nemu/common/mainargs.S \
nemu/common/ioe.c \
nemu/common/input.c \
nemu/common/timer.c \
nemu/common/video.c \
dummy/mpe.c \
$(ISA)/nemu/boot/start.S
CFLAGS += -I$(AM_HOME)/am/src/nemu/include
ASFLAGS += -DMAINARGS=\"$(mainargs)\"
.PHONY: $(AM_HOME)/am/src/nemu-common/mainargs.S
.PHONY: $(AM_HOME)/am/src/nemu/common/mainargs.S
LDFLAGS += -L $(AM_HOME)/am/src/nemu-common
LDFLAGS += -T $(AM_HOME)/am/src/$(ISA)/nemu/boot/loader.ld
LDFLAGS += -L $(AM_HOME)/am/src/nemu/ldscript
NEMU_ARGS = --batch --log=$(shell dirname $(BINARY))/nemu-log.txt $(BINARY).bin

View File

@ -1,2 +1,10 @@
include $(AM_HOME)/am/arch/isa/riscv32.mk
include $(AM_HOME)/am/arch/platform/nemu.mk
AM_SRCS += nemu/isa/riscv/trm.c \
nemu/isa/riscv/cte.c \
nemu/isa/riscv/trap.S \
nemu/isa/riscv/vme.c \
nemu/isa/riscv/boot/start.S
LDFLAGS += -T $(AM_HOME)/am/src/nemu/isa/riscv/boot/loader.ld

View File

@ -1,3 +1,11 @@
include $(AM_HOME)/am/arch/isa/x86.mk
CFLAGS += -mstringop-strategy=loop
include $(AM_HOME)/am/arch/platform/nemu.mk
AM_SRCS += nemu/isa/x86/trm.c \
nemu/isa/x86/cte.c \
nemu/isa/x86/trap.S \
nemu/isa/x86/vme.c \
nemu/isa/x86/boot/start.S
CFLAGS += -mstringop-strategy=loop
LDFLAGS += -T $(AM_HOME)/am/src/nemu/isa/x86/boot/loader.ld

View File

@ -1,5 +1,7 @@
#include <am.h>
#include <nemu.h>
#include <klib-macros.h>
// common part of TMR
extern char _heap_start;
extern char _heap_end;
@ -7,19 +9,13 @@ int main(const char *args);
_Area _heap = RANGE(&_heap_start, &_heap_end);
void _putc(char ch) {
outb(SERIAL_PORT, ch);
}
void _halt(int code) {
nemu_trap(code);
// should not reach here
while (1);
}
void _trm_init() {
extern const char __am_mainargs;
int ret = main(&__am_mainargs);
_halt(ret);
}
// these APIs are defined under the isa-dependent directory
void _putc(char ch);
void _halt(int code);

View File

@ -5,18 +5,6 @@
#include ISA_H // "x86.h", "mips32.h", ...
#if defined(__ISA_X86__)
# define nemu_trap(code) asm volatile (".byte 0xd6" : :"a"(code))
#elif defined(__ISA_MIPS32__)
# define nemu_trap(code) asm volatile ("move $v0, %0; .word 0xf0000000" : :"r"(code))
#elif defined(__ISA_RISCV32__)
# define nemu_trap(code) asm volatile("mv a0, %0; .word 0x0000006b" : :"r"(code))
#elif defined(__ISA_RISCV64__)
# define nemu_trap(code) asm volatile("mv a0, %0; .word 0x0000006b" : :"r"(code))
#elif
# error unsupported ISA __ISA__
#endif
#ifdef __ARCH_X86_NEMU
# define SERIAL_PORT 0x3f8
# define KBD_ADDR 0x60

View File

@ -1,5 +1,4 @@
#include <am.h>
#include <mips32.h>
#include <nemu.h>
#include <klib.h>
static _Context* (*user_handler)(_Event, _Context*) = NULL;

View File

@ -0,0 +1,12 @@
#include <nemu.h>
void _putc(char ch) {
outb(0xa10003f8, ch);
}
void _halt(int code) {
asm volatile ("move $v0, %0; .word 0xf0000000" : :"r"(code));
// should not reach here
while (1);
}

View File

@ -1,6 +1,5 @@
#include <mips32.h>
#include <klib.h>
#include <nemu.h>
#include <klib.h>
#define USER_SPACE RANGE(0x40000000, 0x80000000)
#define PG_ALIGN __attribute((aligned(PGSIZE)))

View File

@ -0,0 +1,12 @@
#include <nemu.h>
void _putc(char ch) {
outb(0xa10003f8, ch);
}
void _halt(int code) {
asm volatile("mv a0, %0; .word 0x0000006b" : :"r"(code));
// should not reach here
while (1);
}

View File

@ -1,6 +1,5 @@
#include <am.h>
#include <x86.h>
#include "x86-nemu.h"
#include <nemu.h>
#include <klib.h>
#define NR_IRQ 256 // IDT size

12
am/src/nemu/isa/x86/trm.c Normal file
View File

@ -0,0 +1,12 @@
#include <nemu.h>
void _putc(char ch) {
outb(0x3f8, ch);
}
void _halt(int code) {
asm volatile (".byte 0xd6" : :"a"(code));
// should not reach here
while (1);
}

View File

@ -1,7 +1,6 @@
#include <am.h>
#include <nemu.h>
#include <klib.h>
#include "x86-nemu.h"
typedef uint32_t PTE;
typedef uint32_t PDE;