Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: RowletQwQ/nemu
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ysyx2204
Choose a base ref
...
head repository: NJU-ProjectN/nemu
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ysyx2204
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Jun 4, 2021

  1. fix alloc

    ChyuWei committed Jun 4, 2021
    Copy the full SHA
    91f932c View commit details
  2. Copy the full SHA
    8489cd4 View commit details

Commits on Jul 21, 2022

  1. Copy the full SHA
    4aad1d6 View commit details

Commits on Aug 21, 2022

  1. fix format for uint64

    jaypiper committed Aug 21, 2022
    Copy the full SHA
    bf47a59 View commit details
  2. [fix]判断in_pmem时移项问题;采用PMEM64时出现MSIZE和MBASE的输出问题。

    应同时减去MBASE,上个提交中为MSIZE,减MBASE的好处为,若addr - CONFIG_MBASE为负数,将得到一个大于等于CONFIG_MSIZE的值,但若减去MSIZE,则在addr < CONFIG_MSIZE时会出现问题。
    另外,MBASE和MSIZE应该是paddr_t类型的,但是宏定义中并未限定类型,在commom.h中修改。
    HuJJ authored and jaypiper committed Aug 21, 2022
    Copy the full SHA
    404746d View commit details

Commits on Sep 2, 2022

  1. Copy the full SHA
    00bf810 View commit details
  2. Copy the full SHA
    014c787 View commit details
  3. Copy the full SHA
    4965f34 View commit details
  4. monitor,sdb: fix typo

    sashimi-yzh committed Sep 2, 2022
    Copy the full SHA
    c0ecbb4 View commit details
  5. Copy the full SHA
    ea9758d View commit details
  6. Copy the full SHA
    a1813e5 View commit details
  7. fix format introduced in commit bf47a59

    * We should use macros like PRIx64 for uint64_t. They may be defined as
      different formats in Linux and MacOS.
    sashimi-yzh committed Sep 2, 2022
    Copy the full SHA
    c52dfec View commit details

Commits on Sep 5, 2022

  1. Merge pull request NJU-ProjectN#41 from x402/decode

    修改了译码的表达方式,使INSTPAT更好写
    sashimi-yzh authored Sep 5, 2022
    Copy the full SHA
    71cfbf0 View commit details
  2. Copy the full SHA
    09bb925 View commit details

Commits on Dec 19, 2022

  1. cpu,decode: fix UB for invalid instructions

    * ((s)->isa.inst.val) >> 32 is UB, where ubsan reports "shift exponent
      32 is too large for 32-bit type 'unsigned int'"
    sashimi-yzh committed Dec 19, 2022
    Copy the full SHA
    8417a25 View commit details
  2. resource,debian: refine

    sashimi-yzh committed Dec 19, 2022
    Copy the full SHA
    f85b00d View commit details
  3. Copy the full SHA
    379f440 View commit details
  4. utils,filelist: sync

    sashimi-yzh committed Dec 19, 2022
    Copy the full SHA
    42b1f31 View commit details
  5. common.h: fix "invalid suffix on literal" warning for g++

    * "C++11 requires a space between literal and string macro"
    sashimi-yzh committed Dec 19, 2022
    Copy the full SHA
    947dc94 View commit details
  6. re-add mips32

    sashimi-yzh committed Dec 19, 2022
    Copy the full SHA
    76278e8 View commit details
  7. add loongarch32r

    sashimi-yzh committed Dec 19, 2022
    Copy the full SHA
    6fcaae0 View commit details

Commits on Jan 26, 2023

  1. fix: compile with llvm15 error

    If compile with llvm15, make will complain
    "invalid use of incomplete type ‘class llvm::MCSubtargetInfo’",
    which can be solved by include "llvm/MC/MCSubtargetInfo.h".
    Pcrab committed Jan 26, 2023
    Copy the full SHA
    ed2066c View commit details

Commits on Jan 28, 2023

  1. Merge pull request NJU-ProjectN#53 from Pcrab/master

    fix: compile with llvm15 error
    sashimi-yzh authored Jan 28, 2023
    Copy the full SHA
    1efb4b7 View commit details

Commits on Feb 4, 2023

  1. Copy the full SHA
    48b4860 View commit details
  2. Merge pull request NJU-ProjectN#54 from silver-ymz/fix-macos-macro-co…

    …nflict
    
    fix the macro conflict with sys/_types/_key_t.h on macos
    sashimi-yzh authored Feb 4, 2023
    Copy the full SHA
    e59f676 View commit details

Commits on Mar 18, 2023

  1. Update difftest-def.h

    fix typo in the comments
    YJMSTR authored Mar 18, 2023
    Copy the full SHA
    cf50554 View commit details
  2. Merge pull request NJU-ProjectN#58 from YJMSTR/patch-1

    Update difftest-def.h
    sashimi-yzh authored Mar 18, 2023
    Copy the full SHA
    b79ec14 View commit details

Commits on Apr 7, 2023

  1. Copy the full SHA
    3d5b0b9 View commit details
  2. Copy the full SHA
    fe77a6b View commit details

Commits on Apr 12, 2023

  1. feat: add support for c++17

    myyerrol authored Apr 12, 2023
    Copy the full SHA
    5f66cb8 View commit details
  2. Merge pull request NJU-ProjectN#63 from myyerrol/ysyx2204

    feat: add support for c++17
    sashimi-yzh authored Apr 12, 2023
    Copy the full SHA
    773a409 View commit details

Commits on May 2, 2023

  1. Copy the full SHA
    c3baa4a View commit details

Commits on May 3, 2023

  1. Merge pull request NJU-ProjectN#64 from junyu33/master

    fix: compile error on ./nemu/tools/gen-expr/gen-expr.c
    sashimi-yzh authored May 3, 2023
    Copy the full SHA
    d45855a View commit details

Commits on May 5, 2023

  1. Copy the full SHA
    9bf4ff8 View commit details
  2. Merge pull request NJU-ProjectN#65 from unlsycn/feat-disasm

    小改进:反汇编时禁用aliases
    sashimi-yzh authored May 5, 2023
    Copy the full SHA
    e9c8a4e View commit details
Showing with 834 additions and 89 deletions.
  1. +3 −0 Kconfig
  2. +5 −0 configs/mips32-am_defconfig
  3. +1 −0 configs/riscv32-am_defconfig
  4. +1 −0 configs/riscv64-am_defconfig
  5. +3 −2 include/common.h
  6. +1 −1 include/cpu/decode.h
  7. +6 −3 include/difftest-def.h
  8. +4 −2 include/memory/paddr.h
  9. +15 −1 resource/debian/README.md
  10. +2 −2 scripts/build.mk
  11. +5 −1 src/cpu/cpu-exec.c
  12. +7 −5 src/cpu/difftest/ref.c
  13. +17 −0 src/device/io/mmio.c
  14. +5 −0 src/device/keyboard.c
  15. +25 −0 src/isa/loongarch32r/difftest/dut.c
  16. +35 −0 src/isa/loongarch32r/include/isa-def.h
  17. +43 −0 src/isa/loongarch32r/init.c
  18. +72 −0 src/isa/loongarch32r/inst.c
  19. +33 −0 src/isa/loongarch32r/local-include/reg.h
  20. +16 −0 src/isa/loongarch32r/logo.c
  21. +31 −0 src/isa/loongarch32r/reg.c
  22. +28 −0 src/isa/loongarch32r/system/intr.c
  23. +22 −0 src/isa/loongarch32r/system/mmu.c
  24. +25 −0 src/isa/mips32/difftest/dut.c
  25. +36 −0 src/isa/mips32/include/isa-def.h
  26. +42 −0 src/isa/mips32/init.c
  27. +74 −0 src/isa/mips32/inst.c
  28. +33 −0 src/isa/mips32/local-include/reg.h
  29. +78 −0 src/isa/mips32/logo.c
  30. +31 −0 src/isa/mips32/reg.c
  31. +28 −0 src/isa/mips32/system/intr.c
  32. +22 −0 src/isa/mips32/system/mmu.c
  33. +16 −21 src/isa/riscv32/inst.c
  34. +17 −22 src/isa/riscv64/inst.c
  35. +2 −3 src/memory/paddr.c
  36. +2 −0 src/monitor/monitor.c
  37. +1 −1 src/monitor/sdb/sdb.c
  38. +5 −0 src/utils/disasm.cc
  39. +1 −1 src/utils/filelist.mk
  40. +1 −1 tools/gen-expr/gen-expr.c
  41. +1 −1 tools/kconfig/Makefile
  42. +5 −5 tools/kvm-diff/src/kvm.c
  43. +5 −5 tools/qemu-diff/src/diff-test.c
  44. +2 −2 tools/spike-diff/Makefile
  45. +27 −10 tools/spike-diff/difftest.cc
3 changes: 3 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ config ISA_riscv32
bool "riscv32"
config ISA_riscv64
bool "riscv64"
config ISA_loongarch32r
bool "loongarch32r"
endchoice

config ISA
@@ -19,6 +21,7 @@ config ISA
default "mips32" if ISA_mips32
default "riscv32" if ISA_riscv32
default "riscv64" if ISA_riscv64
default "loongarch32r" if ISA_loongarch32r
default "none"

config ISA64
5 changes: 5 additions & 0 deletions configs/mips32-am_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_ISA_mips32=y
CONFIG_TARGET_AM=y
# CONFIG_TRACE is not set
CONFIG_MSIZE=0x2000000
CONFIG_DEVICE=y
1 change: 1 addition & 0 deletions configs/riscv32-am_defconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CONFIG_TARGET_AM=y
# CONFIG_TRACE is not set
CONFIG_MSIZE=0x2000000
CONFIG_DEVICE=y
1 change: 1 addition & 0 deletions configs/riscv64-am_defconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG_ISA_riscv64=y
CONFIG_TARGET_AM=y
# CONFIG_TRACE is not set
CONFIG_MSIZE=0x2000000
CONFIG_DEVICE=y
5 changes: 3 additions & 2 deletions include/common.h
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
#define __COMMON_H__

#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>

@@ -36,11 +37,11 @@

typedef MUXDEF(CONFIG_ISA64, uint64_t, uint32_t) word_t;
typedef MUXDEF(CONFIG_ISA64, int64_t, int32_t) sword_t;
#define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016lx", "0x%08x")
#define FMT_WORD MUXDEF(CONFIG_ISA64, "0x%016" PRIx64, "0x%08" PRIx32)

typedef word_t vaddr_t;
typedef MUXDEF(PMEM64, uint64_t, uint32_t) paddr_t;
#define FMT_PADDR MUXDEF(PMEM64, "0x%016lx", "0x%08x")
#define FMT_PADDR MUXDEF(PMEM64, "0x%016" PRIx64, "0x%08" PRIx32)
typedef uint16_t ioaddr_t;

#include <debug.h>
2 changes: 1 addition & 1 deletion include/cpu/decode.h
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ static inline void pattern_decode_hex(const char *str, int len,
#define INSTPAT(pattern, ...) do { \
uint64_t key, mask, shift; \
pattern_decode(pattern, STRLEN(pattern), &key, &mask, &shift); \
if (((INSTPAT_INST(s) >> shift) & mask) == key) { \
if ((((uint64_t)INSTPAT_INST(s) >> shift) & mask) == key) { \
INSTPAT_MATCH(s, ##__VA_ARGS__); \
goto *(__instpat_end); \
} \
9 changes: 6 additions & 3 deletions include/difftest-def.h
Original file line number Diff line number Diff line change
@@ -19,16 +19,19 @@
#include <stdint.h>
#include <generated/autoconf.h>

#define __EXPORT __attribute__((visibility("default")))
enum { DIFFTEST_TO_DUT, DIFFTEST_TO_REF };

#if defined(CONFIG_ISA_x86)
# define DIFFTEST_REG_SIZE (sizeof(uint32_t) * 9) // GPRs + pc
#elif defined(CONFIG_ISA_mips32)
# define DIFFTEST_REG_SIZE (sizeof(uint32_t) * 38) // GRPs + status + lo + hi + badvaddr + cause + pc
# define DIFFTEST_REG_SIZE (sizeof(uint32_t) * 38) // GPRs + status + lo + hi + badvaddr + cause + pc
#elif defined(CONFIG_ISA_riscv32)
# define DIFFTEST_REG_SIZE (sizeof(uint32_t) * 33) // GRPs + pc
# define DIFFTEST_REG_SIZE (sizeof(uint32_t) * 33) // GPRs + pc
#elif defined(CONFIG_ISA_riscv64)
# define DIFFTEST_REG_SIZE (sizeof(uint64_t) * 33) // GRPs + pc
# define DIFFTEST_REG_SIZE (sizeof(uint64_t) * 33) // GPRs + pc
#elif defined(CONFIG_ISA_loongarch32r)
# define DIFFTEST_REG_SIZE (sizeof(uint32_t) * 33) // GPRs + pc
#else
# error Unsupport ISA
#endif
6 changes: 4 additions & 2 deletions include/memory/paddr.h
Original file line number Diff line number Diff line change
@@ -18,15 +18,17 @@

#include <common.h>

#define RESET_VECTOR (CONFIG_MBASE + CONFIG_PC_RESET_OFFSET)
#define PMEM_LEFT ((paddr_t)CONFIG_MBASE)
#define PMEM_RIGHT ((paddr_t)CONFIG_MBASE + CONFIG_MSIZE - 1)
#define RESET_VECTOR (PMEM_LEFT + CONFIG_PC_RESET_OFFSET)

/* convert the guest physical address in the guest program to host virtual address in NEMU */
uint8_t* guest_to_host(paddr_t paddr);
/* convert the host virtual address in NEMU to guest physical address in the guest program */
paddr_t host_to_guest(uint8_t *haddr);

static inline bool in_pmem(paddr_t addr) {
return (addr >= CONFIG_MBASE) && (addr - CONFIG_MSIZE < (paddr_t)CONFIG_MBASE);
return addr - CONFIG_MBASE < CONFIG_MSIZE;
}

word_t paddr_read(paddr_t addr, int len);
16 changes: 15 additions & 1 deletion resource/debian/README.md
Original file line number Diff line number Diff line change
@@ -42,12 +42,24 @@ sudo chroot /mnt /bin/bash
* 安装所需工具(根据实际情况选择)
```
apt-get update
apt-get install systemd
apt-get install gcc build-essential
apt-get install tmux libreadline-dev
apt-get install net-tools openssh-server
# fix long delay of openssh server
apt-get install haveged
agt-get install sbt
apt-get install sbt
```

* 修复`NO_PUBKEY E852514F5DF312F6`错误, 见[这里](https://www.reddit.com/r/RISCV/comments/sn0cph/sipeed_debian_the_following_signatures_couldnt_be/)
```
curl https://www.ports.debian.org/archive_2022.key | apt-key add -
```

* 同步时间
```
apt-get install ntpdate
ntpdate 0.asia.pool.ntp.org
```

*`/etc/fstab`中添加swap分区
@@ -156,3 +168,5 @@ sudo losetup -d /dev/loop0 # 删除loop设备
在i9-9900k上测试, 约90s后看到debian的登录提示符.

* 当以可写方式启动镜像时, NEMU遇到错误或通过Ctrl+C直接退出NEMU时, 可能会损坏镜像的崩溃一致性, 此时可以通过fsck命令修复分区.

* 更多命令可参考[这里](https://github.com/carlosedp/riscv-bringup/blob/master/Debian-Rootfs-Guide.md).
4 changes: 2 additions & 2 deletions scripts/build.mk
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
# Add necessary options if the target is a shared library
ifeq ($(SHARE),1)
SO = -so
CFLAGS += -fPIC
LDFLAGS += -rdynamic -shared -fPIC
CFLAGS += -fPIC -fvisibility=hidden
LDFLAGS += -shared -fPIC
endif

WORK_DIR = $(shell pwd)
6 changes: 5 additions & 1 deletion src/cpu/cpu-exec.c
Original file line number Diff line number Diff line change
@@ -61,9 +61,13 @@ static void exec_once(Decode *s, vaddr_t pc) {
memset(p, ' ', space_len);
p += space_len;

#ifndef CONFIG_ISA_loongarch32r
void disassemble(char *str, int size, uint64_t pc, uint8_t *code, int nbyte);
disassemble(p, s->logbuf + sizeof(s->logbuf) - p,
MUXDEF(CONFIG_ISA_x86, s->snpc, s->pc), (uint8_t *)&s->isa.inst.val, ilen);
#else
p[0] = '\0'; // the upstream llvm does not support loongarch32r
#endif
#endif
}

@@ -80,7 +84,7 @@ static void execute(uint64_t n) {

static void statistic() {
IFNDEF(CONFIG_TARGET_AM, setlocale(LC_NUMERIC, ""));
#define NUMBERIC_FMT MUXDEF(CONFIG_TARGET_AM, "%ld", "%'ld")
#define NUMBERIC_FMT MUXDEF(CONFIG_TARGET_AM, "%", "%'") PRIu64
Log("host time spent = " NUMBERIC_FMT " us", g_timer);
Log("total guest instructions = " NUMBERIC_FMT, g_nr_guest_inst);
if (g_timer > 0) Log("simulation frequency = " NUMBERIC_FMT " inst/s", g_nr_guest_inst * 1000000 / g_timer);
12 changes: 7 additions & 5 deletions src/cpu/difftest/ref.c
Original file line number Diff line number Diff line change
@@ -18,23 +18,25 @@
#include <difftest-def.h>
#include <memory/paddr.h>

void difftest_memcpy(paddr_t addr, void *buf, size_t n, bool direction) {
__EXPORT void difftest_memcpy(paddr_t addr, void *buf, size_t n, bool direction) {
assert(0);
}

void difftest_regcpy(void *dut, bool direction) {
__EXPORT void difftest_regcpy(void *dut, bool direction) {
assert(0);
}

void difftest_exec(uint64_t n) {
__EXPORT void difftest_exec(uint64_t n) {
assert(0);
}

void difftest_raise_intr(word_t NO) {
__EXPORT void difftest_raise_intr(word_t NO) {
assert(0);
}

void difftest_init(int port) {
__EXPORT void difftest_init(int port) {
void init_mem();
init_mem();
/* Perform ISA dependent initialization. */
init_isa();
}
17 changes: 17 additions & 0 deletions src/device/io/mmio.c
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
***************************************************************************************/

#include <device/map.h>
#include <memory/paddr.h>

#define NR_MAP 16

@@ -25,9 +26,25 @@ static IOMap* fetch_mmio_map(paddr_t addr) {
return (mapid == -1 ? NULL : &maps[mapid]);
}

static void report_mmio_overlap(const char *name1, paddr_t l1, paddr_t r1,
const char *name2, paddr_t l2, paddr_t r2) {
panic("MMIO region %s@[" FMT_PADDR ", " FMT_PADDR "] is overlapped "
"with %s@[" FMT_PADDR ", " FMT_PADDR "]", name1, l1, r1, name2, l2, r2);
}

/* device interface */
void add_mmio_map(const char *name, paddr_t addr, void *space, uint32_t len, io_callback_t callback) {
assert(nr_map < NR_MAP);
paddr_t left = addr, right = addr + len - 1;
if (in_pmem(left) || in_pmem(right)) {
report_mmio_overlap(name, left, right, "pmem", PMEM_LEFT, PMEM_RIGHT);
}
for (int i = 0; i < nr_map; i++) {
if (left <= maps[i].high && right >= maps[i].low) {
report_mmio_overlap(name, left, right, maps[i].name, maps[i].low, maps[i].high);
}
}

maps[nr_map] = (IOMap){ .name = name, .low = addr, .high = addr + len - 1,
.space = space, .callback = callback };
Log("Add mmio map '%s' at [" FMT_PADDR ", " FMT_PADDR "]",
5 changes: 5 additions & 0 deletions src/device/keyboard.c
Original file line number Diff line number Diff line change
@@ -33,6 +33,11 @@ f(UP) f(DOWN) f(LEFT) f(RIGHT) f(INSERT) f(DELETE) f(HOME) f(END) f(PAGEUP) f(PA

#define _KEY_NAME(k) _KEY_##k,

// It's conflicted on macos with sys/_types/_key_t.h
#ifdef __APPLE__
#undef _KEY_T
#endif

enum {
_KEY_NONE = 0,
MAP(_KEYS, _KEY_NAME)
25 changes: 25 additions & 0 deletions src/isa/loongarch32r/difftest/dut.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/***************************************************************************************
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
*
* NEMU is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

#include <isa.h>
#include <cpu/difftest.h>
#include "../local-include/reg.h"

bool isa_difftest_checkregs(CPU_state *ref_r, vaddr_t pc) {
return false;
}

void isa_difftest_attach() {
}
35 changes: 35 additions & 0 deletions src/isa/loongarch32r/include/isa-def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/***************************************************************************************
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
*
* NEMU is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

#ifndef __ISA_LOONGARCH32R_H__
#define __ISA_LOONGARCH32R_H__

#include <common.h>

typedef struct {
word_t gpr[32];
vaddr_t pc;
} loongarch32r_CPU_state;

// decode
typedef struct {
union {
uint32_t val;
} inst;
} loongarch32r_ISADecodeInfo;

#define isa_mmu_check(vaddr, len, type) (MMU_DIRECT)

#endif
43 changes: 43 additions & 0 deletions src/isa/loongarch32r/init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/***************************************************************************************
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
*
* NEMU is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

#include <isa.h>
#include <memory/paddr.h>

// this is not consistent with uint8_t
// but it is ok since we do not access the array directly
static const uint32_t img [] = {
0x1c00000c, // pcaddu12i $t0,0
0x29804180, // st.w $zero,$t0,16
0x28804184, // ld.w $a0,$t0,16
0x002a0000, // break 0 (used as nemu_trap)
0xdeadbeef, // some data
};

static void restart() {
/* Set the initial program counter. */
cpu.pc = RESET_VECTOR;

/* The zero register is always 0. */
cpu.gpr[0] = 0;
}

void init_isa() {
/* Load built-in image. */
memcpy(guest_to_host(RESET_VECTOR), img, sizeof(img));

/* Initialize this virtual computer system. */
restart();
}
Loading