Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions include/rtl/pseudo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,16 @@ static inline def_rtl(mv, rtlreg_t* dest, const rtlreg_t *src1) {

static inline def_rtl(not, rtlreg_t *dest, const rtlreg_t* src1) {
// dest <- ~src1
#ifdef __ICS_EXPORT
TODO();
#else
rtl_xori(s, dest, src1, -1);
#endif
}

static inline def_rtl(neg, rtlreg_t *dest, const rtlreg_t* src1) {
// dest <- -src1
#ifdef __ICS_EXPORT
TODO();
#else
rtl_sub(s, dest, rz, src1);
#endif
}

static inline def_rtl(sext, rtlreg_t* dest, const rtlreg_t* src1, int width) {
// dest <- signext(src1[(width * 8 - 1) .. 0])
#ifdef __ICS_EXPORT
TODO();
#else
const int word_size = sizeof(word_t);
if (width == word_size) {
rtl_mv(s, dest, src1);
Expand All @@ -64,14 +53,10 @@ static inline def_rtl(sext, rtlreg_t* dest, const rtlreg_t* src1, int width) {
rtl_shli(s, dest, src1, (word_size - width) * 8);
rtl_sari(s, dest, dest, (word_size - width) * 8);
}
#endif
}

static inline def_rtl(zext, rtlreg_t* dest, const rtlreg_t* src1, int width) {
// dest <- zeroext(src1[(width * 8 - 1) .. 0])
#ifdef __ICS_EXPORT
TODO();
#else
const int word_size = sizeof(word_t);
if (width == word_size) {
rtl_mv(s, dest, src1);
Expand All @@ -82,19 +67,14 @@ static inline def_rtl(zext, rtlreg_t* dest, const rtlreg_t* src1, int width) {
rtl_shli(s, dest, src1, (word_size - width) * 8);
rtl_shri(s, dest, dest, (word_size - width) * 8);
}
#endif
}

static inline def_rtl(msb, rtlreg_t* dest, const rtlreg_t* src1, int width) {
// dest <- src1[width * 8 - 1]
#ifdef __ICS_EXPORT
TODO();
#else
rtl_shri(s, dest, src1, width * 8 - 1);
if (width != 4) {
rtl_andi(s, dest, dest, 0x1);
}
#endif
}

static inline def_rtl(trap, vaddr_t ret_pc, word_t NO) {
Expand All @@ -104,7 +84,6 @@ static inline def_rtl(trap, vaddr_t ret_pc, word_t NO) {
}
static inline def_rtl(mux, rtlreg_t* dest, const rtlreg_t* cond, const rtlreg_t* src1, const rtlreg_t* src2) {
// dest <- (cond ? src1 : src2)
// TODO();
rtl_setrelopi(s, RELOP_EQ, t0, cond, 0);
rtl_subi(s, t0, t0, 1);
// t0 = mask
Expand Down
10 changes: 0 additions & 10 deletions src/cpu/difftest/dut.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ static bool is_skip_ref = false;
static int skip_dut_nr_instr = 0;
void (*patch_fn)(void *arg) = NULL;
static void* patch_arg = NULL;
#ifndef __ICS_EXPORT
static bool is_detach = false;
#endif

// this is used to let ref skip instructions which
// can not produce consistent behavior with NEMU
void difftest_skip_ref() {
#ifndef __ICS_EXPORT
if (is_detach) return;
#endif
is_skip_ref = true;
// If such an instruction is one of the instruction packing in QEMU
// (see below), we end the process of catching up with QEMU's pc to
Expand All @@ -62,9 +58,7 @@ void difftest_skip_ref() {
// Let REF run `nr_ref` instructions first.
// We expect that DUT will catch up with REF within `nr_dut` instructions.
void difftest_skip_dut(int nr_ref, int nr_dut) {
#ifndef __ICS_EXPORT
if (is_detach) return;
#endif
skip_dut_nr_instr += nr_dut;
while (nr_ref -- > 0) {
ref_difftest_exec(1);
Expand Down Expand Up @@ -126,10 +120,8 @@ static void checkregs(CPU_state *ref, vaddr_t pc) {
void difftest_step(vaddr_t pc, vaddr_t npc) {
CPU_state ref_r;

#ifndef __ICS_EXPORT
if (is_detach) return;

#endif
if (skip_dut_nr_instr > 0) {
ref_difftest_regcpy(&ref_r, DIFFTEST_TO_DUT);
if (ref_r.pc == npc) {
Expand Down Expand Up @@ -162,7 +154,6 @@ void difftest_step(vaddr_t pc, vaddr_t npc) {
// Log("run ref %lx, %lx, %ld", pc, ref_r.pc, cpu.v);
checkregs(&ref_r, pc);
}
#ifndef __ICS_EXPORT
void difftest_detach() {
is_detach = true;
}
Expand All @@ -174,7 +165,6 @@ void difftest_attach() {

isa_difftest_attach();
}
#endif

#else
void init_difftest(char *ref_so_file, long img_size, int port) { }
Expand Down
8 changes: 0 additions & 8 deletions src/device/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ enum {

static uint8_t *sbuf = NULL;
static uint32_t *audio_base = NULL;
#ifndef __ICS_EXPORT
static int tail = 0;
#endif

static inline void audio_play(void *userdata, uint8_t *stream, int len) {
#ifndef __ICS_EXPORT
int nread = len;
int count = audio_base[reg_count];
if (count < len) nread = count;
Expand All @@ -50,11 +47,9 @@ static inline void audio_play(void *userdata, uint8_t *stream, int len) {
}
audio_base[reg_count] -= nread;
if (len > nread) memset(stream + nread, 0, len - nread);
#endif
}

static void audio_io_handler(uint32_t offset, int len, bool is_write) {
#ifndef __ICS_EXPORT
if (offset == reg_init * sizeof(uint32_t) && len == 4 && is_write) {
SDL_AudioSpec s = {};
s.freq = audio_base[reg_freq];
Expand All @@ -70,17 +65,14 @@ static void audio_io_handler(uint32_t offset, int len, bool is_write) {
SDL_OpenAudio(&s, NULL);
SDL_PauseAudio(0);
}
#endif
}

void init_audio() {
uint32_t space_size = sizeof(uint32_t) * nr_reg;
audio_base = (uint32_t *)new_space(space_size);
add_pio_map ("audio", CONFIG_AUDIO_CTL_PORT, audio_base, space_size, audio_io_handler);
add_mmio_map("audio", CONFIG_AUDIO_CTL_MMIO, audio_base, space_size, audio_io_handler);
#ifndef __ICS_EXPORT
audio_base[reg_sbuf_size] = CONFIG_SB_SIZE;
#endif

sbuf = (uint8_t *)new_space(CONFIG_SB_SIZE);
add_mmio_map("audio-sbuf", CONFIG_SB_ADDR, sbuf, CONFIG_SB_SIZE, NULL);
Expand Down
2 changes: 0 additions & 2 deletions src/device/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ static uint32_t *disk_base = NULL;
static FILE *fp = NULL;

static void disk_io_handler(uint32_t offset, int len, bool is_write) {
#ifndef __ICS_EXPORT
if (offset == CMD * sizeof(uint32_t) && len == 4 && is_write) {
assert(disk_base[CMD] == 0);
fseek(fp, disk_base[START] * 512, SEEK_SET);
Expand All @@ -46,7 +45,6 @@ static void disk_io_handler(uint32_t offset, int len, bool is_write) {
assert(ret == 1);
#endif
}
#endif
}

void init_disk() {
Expand Down
2 changes: 0 additions & 2 deletions src/device/intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@
#include <isa.h>

void dev_raise_intr() {
#ifndef __ICS_EXPORT
cpu.INTR = true;
#endif
}
5 changes: 1 addition & 4 deletions src/device/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ static inline void update_screen() {
#endif

void vga_update_screen() {
#ifdef __ICS_EXPORT
// TODO: call `update_screen()` when the sync register is non-zero,
// call `update_screen()` when the sync register is non-zero,
// then zero out the sync register
#else
if (vgactl_port_base[1]) {
IFDEF(CONFIG_VGA_SHOW_SCREEN, update_screen());
vgactl_port_base[1] = 0;
}
#endif
}

void init_vga() {
Expand Down
6 changes: 0 additions & 6 deletions src/memory/vaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <memory/host-tlb.h>
#include <cpu/decode.h>

#ifndef __ICS_EXPORT
#ifndef ENABLE_HOSTTLB

static paddr_t vaddr_trans_and_check_exception(vaddr_t vaddr, int len, int type, bool* exp) {
Expand Down Expand Up @@ -144,7 +143,6 @@ static void vaddr_mmu_write(struct Decode *s, vaddr_t addr, int len, word_t data
}
}
#endif
#endif

static inline word_t vaddr_read_internal(void *s, vaddr_t addr, int len, int type, int mmu_mode) {
void isa_misalign_data_addr_check(vaddr_t vaddr, int len, int type);
Expand All @@ -159,15 +157,13 @@ static inline word_t vaddr_read_internal(void *s, vaddr_t addr, int len, int typ
Logm("Paddr reading directly");
return paddr_read(addr, len, type, type, cpu.mode, addr);
}
#ifndef __ICS_EXPORT
#ifdef CONFIG_RVH
if(type != MEM_TYPE_IFETCH){
extern int rvh_hlvx_check(struct Decode *s, int type);
rvh_hlvx_check((Decode*)s, type);
}
#endif
return MUXDEF(ENABLE_HOSTTLB, hosttlb_read, vaddr_mmu_read) ((struct Decode *)s, addr, len, type);
#endif
return 0;
}

Expand Down Expand Up @@ -224,9 +220,7 @@ void vaddr_write(struct Decode *s, vaddr_t addr, int len, word_t data, int mmu_m
paddr_write(addr, len, data, cpu.mode, addr);
return;
}
#ifndef __ICS_EXPORT
MUXDEF(ENABLE_HOSTTLB, hosttlb_write, vaddr_mmu_write) (s, addr, len, data);
#endif
}

word_t vaddr_read_safe(vaddr_t addr, int len) {
Expand Down
7 changes: 0 additions & 7 deletions src/monitor/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
#include <isa.h>
#include <utils.h>
#include <cpu/cpu.h>
#ifndef __ICS_EXPORT
#include <memory/paddr.h>
#include <memory/vaddr.h>
#include <cpu/difftest.h>
#endif

#ifndef CONFIG_SHARE
#include <stdlib.h>
Expand Down Expand Up @@ -56,7 +54,6 @@ static int cmd_c(char *args) {
return 0;
}

#ifndef __ICS_EXPORT
static int cmd_si(char *args) {
/* extract the first argument */
char *arg = strtok(NULL, " ");
Expand Down Expand Up @@ -212,8 +209,6 @@ static int cmd_load(char *args) {
#else
#endif

#endif

static int cmd_q(char *args) {
return -1;
}
Expand All @@ -227,7 +222,6 @@ static struct {
} cmd_table [] = {
{ "help", "Display information about all supported commands", cmd_help },
{ "c", "Continue the execution of the program", cmd_c },
#ifndef __ICS_EXPORT
{ "si", "step", cmd_si },
{ "info", "info r - print register values; info w - show watch point state", cmd_info },
{ "x", "Examine memory", cmd_x },
Expand All @@ -239,7 +233,6 @@ static struct {
{ "attach", "attach diff test", cmd_attach },
{ "save", "save snapshot", cmd_save },
{ "load", "load snapshot", cmd_load },
#endif
#endif
{ "q", "Exit NEMU", cmd_q },

Expand Down
6 changes: 0 additions & 6 deletions src/monitor/watchpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
***************************************************************************************/

#include <common.h>
#ifndef __ICS_EXPORT
#include <stdlib.h>
#endif

#define NR_WP 32

Expand All @@ -26,10 +24,8 @@ typedef struct watchpoint {

/* TODO: Add more members if necessary */

#ifndef __ICS_EXPORT
char *expr;
word_t old_val;
#endif
} WP;

static WP wp_pool[NR_WP] = {};
Expand All @@ -49,7 +45,6 @@ void init_wp_pool() {

/* TODO: Implement the functionality of watchpoint */

#ifndef __ICS_EXPORT
static WP* new_WP() {
assert(free_ != NULL);
WP *p = free_;
Expand Down Expand Up @@ -120,4 +115,3 @@ void scan_watchpoint(vaddr_t pc) {
}
}
}
#endif
Loading