diff --git a/am/src/mycpu/include/mycpu.h b/am/src/mycpu/include/mycpu.h deleted file mode 100644 index a4c20b8..0000000 --- a/am/src/mycpu/include/mycpu.h +++ /dev/null @@ -1,5 +0,0 @@ -#include - -#define PMEM_SIZE (128 * 1024 * 1024) -#define PMEM_END ((uintptr_t)&_pmem_start + PMEM_SIZE) -extern char _pmem_start; diff --git a/am/src/mycpu/ioe/input.c b/am/src/mycpu/input.c similarity index 57% rename from am/src/mycpu/ioe/input.c rename to am/src/mycpu/input.c index 29a8662..0460fa4 100644 --- a/am/src/mycpu/ioe/input.c +++ b/am/src/mycpu/input.c @@ -1,6 +1,6 @@ #include void __am_input_keybrd(AM_INPUT_KEYBRD_T *kbd) { - - + kbd->keydown = 0; + kbd->keycode = AM_KEY_NONE; } diff --git a/am/src/mycpu/ioe/ioe.c b/am/src/mycpu/ioe.c similarity index 100% rename from am/src/mycpu/ioe/ioe.c rename to am/src/mycpu/ioe.c diff --git a/am/src/mycpu/scripts/section.ld b/am/src/mycpu/scripts/section.ld deleted file mode 100644 index a9f2688..0000000 --- a/am/src/mycpu/scripts/section.ld +++ /dev/null @@ -1,33 +0,0 @@ -_pmem_start = 0x80000000; - -ENTRY(_start) - -SECTIONS { - . = _pmem_start + 0x100000; - .text : { - *(entry) - *(.text*) - } - etext = .; - _etext = .; - .rodata : { - *(.rodata*) - } - .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); -} diff --git a/am/src/mycpu/boot/start.S b/am/src/mycpu/start.S similarity index 100% rename from am/src/mycpu/boot/start.S rename to am/src/mycpu/start.S diff --git a/am/src/mycpu/ioe/timer.c b/am/src/mycpu/timer.c similarity index 51% rename from am/src/mycpu/ioe/timer.c rename to am/src/mycpu/timer.c index f176d94..6ea0ffa 100644 --- a/am/src/mycpu/ioe/timer.c +++ b/am/src/mycpu/timer.c @@ -1,13 +1,17 @@ #include void __am_timer_init() { - } void __am_timer_uptime(AM_TIMER_UPTIME_T *uptime) { - + uptime->us = 0; } void __am_timer_rtc(AM_TIMER_RTC_T *rtc) { - + rtc->second = 0; + rtc->minute = 0; + rtc->hour = 0; + rtc->day = 0; + rtc->month = 0; + rtc->year = 1900; } diff --git a/am/src/mycpu/trm.c b/am/src/mycpu/trm.c index f9a9b84..0efe6e7 100644 --- a/am/src/mycpu/trm.c +++ b/am/src/mycpu/trm.c @@ -1,9 +1,13 @@ #include -#include +#include extern char _heap_start; int main(const char *args); +extern char _pmem_start; +#define PMEM_SIZE (128 * 1024 * 1024) +#define PMEM_END ((uintptr_t)&_pmem_start + PMEM_SIZE) + Area heap = RANGE(&_heap_start, PMEM_END); #ifndef MAINARGS #define MAINARGS "" @@ -11,7 +15,6 @@ Area heap = RANGE(&_heap_start, PMEM_END); static const char mainargs[] = MAINARGS; void putch(char ch) { - } void halt(int code) { diff --git a/scripts/riscv64-mycpu.mk b/scripts/riscv64-mycpu.mk index d20c8fc..8da161b 100644 --- a/scripts/riscv64-mycpu.mk +++ b/scripts/riscv64-mycpu.mk @@ -4,17 +4,17 @@ CFLAGS += $(COMMON_FLAGS) -static ASFLAGS += $(COMMON_FLAGS) -O0 LDFLAGS += -melf64lriscv -AM_SRCS := mycpu/boot/start.S \ +AM_SRCS := mycpu/start.S \ mycpu/trm.c \ - mycpu/ioe/timer.c \ - mycpu/ioe/ioe.c \ - mycpu/ioe/input.c + mycpu/ioe.c \ + mycpu/timer.c \ + mycpu/input.c CFLAGS += -fdata-sections -ffunction-sections -LDFLAGS += -T $(AM_HOME)/am/src/mycpu/scripts/section.ld +LDFLAGS += -T $(AM_HOME)/scripts/platform/nemu.ld --defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0 LDFLAGS += --gc-sections -e _start CFLAGS += -DMAINARGS=\"$(mainargs)\" -CFLAGS += -I$(AM_HOME)/am/src/mycpu/include +.PHONY: $(AM_HOME)/am/src/mycpu/trm.c image: $(IMAGE).elf @$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt