Skip to content

Commit

Permalink
vcs: add finish_device for simv_finish (#324)
Browse files Browse the repository at this point in the history
This change will clear device buffer, avoid potential affect between workloads.
  • Loading branch information
xiaokamikami authored Apr 3, 2024
1 parent 59b3e7a commit a4e01f7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/csrc/common/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ void send_key(uint8_t, bool);
void init_sdl(void);

void init_uart(void);
void finish_uart(void);
extern "C" void init_sd(void);
extern "C" void finish_sd(void);
extern "C" void init_flash(void);

void init_device(void) {
Expand All @@ -34,6 +36,14 @@ void init_device(void) {
init_sd();
}

void finish_device(void) {
#ifdef SHOW_SCREEN
finish_sdl();
#endif
finish_uart();
finish_sd();
}

void poll_event() {
#ifdef SHOW_SCREEN
SDL_Event event;
Expand Down
1 change: 1 addition & 0 deletions src/test/csrc/common/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "common.h"

void init_device();
void finish_device();
void poll_event();

#endif
6 changes: 6 additions & 0 deletions src/test/csrc/common/sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ void init_sd(void) {
check_sdcard();
#endif
}

void finish_sd(void) {
#ifdef SDCARD_IMAGE
fclose(fp);
#endif
}
}
6 changes: 6 additions & 0 deletions src/test/csrc/common/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ static void preset_input() {
void init_uart(void) {
preset_input();
}

void finish_uart(void) {
memset(queue, 0, sizeof(queue));
f = 0;
r = 0;
}
4 changes: 4 additions & 0 deletions src/test/csrc/common/vga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ void init_sdl() {
SDL_SetWindowTitle(window, "NOOP");
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, SCREEN_W, SCREEN_H);
}

void finish_sdl() {
memset(vmem, 0, sizeof(vmem));
}
#else
extern "C" void put_pixel(uint32_t pixel) {}
extern "C" void vmem_sync(void) {}
Expand Down
1 change: 1 addition & 0 deletions src/test/csrc/vcs/vcs_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ void simv_finish() {
goldenmem_finish();
difftest_finish();
}
finish_device();
delete simMemory;
simMemory = nullptr;
}
Expand Down

0 comments on commit a4e01f7

Please sign in to comment.