mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Add AUIPC test
This commit is contained in:
parent
f917ba38ff
commit
6a4118e420
3 changed files with 32 additions and 0 deletions
|
|
@ -1,5 +1,12 @@
|
|||
#include "uvm32_target.h"
|
||||
#include "shared.h"
|
||||
|
||||
void main(void) {
|
||||
switch(syscall(SYSCALL_PICKTEST, 0, 0)) {
|
||||
case TEST1:
|
||||
asm("auipc t0, 0"); // copy pc into t0
|
||||
asm("auipc t1, 0"); // copy pc into t1
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
6
test/invalid_opcodes/rom/shared.h
Normal file
6
test/invalid_opcodes/rom/shared.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#define SYSCALL_BASE 0x200
|
||||
#define SYSCALL_PICKTEST SYSCALL_BASE+0
|
||||
|
||||
enum {
|
||||
TEST1,
|
||||
};
|
||||
|
|
@ -4,11 +4,14 @@
|
|||
#include "../common/uvm32_common_custom.h"
|
||||
|
||||
#include "rom-header.h"
|
||||
#include "shared.h"
|
||||
|
||||
static uvm32_state_t vmst;
|
||||
static uvm32_evt_t evt;
|
||||
|
||||
void setUp(void) {
|
||||
uvm32_init(&vmst);
|
||||
uvm32_load(&vmst, rom_bin, rom_bin_len);
|
||||
}
|
||||
|
||||
void tearDown(void) {
|
||||
|
|
@ -41,3 +44,19 @@ void test_invalid_opcode_rd_extram(void) {
|
|||
}
|
||||
|
||||
|
||||
void test_auipc(void) {
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, TEST1);
|
||||
|
||||
// run vm to completion
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_END);
|
||||
|
||||
// The two PC values stored by auipc should be adjacent
|
||||
TEST_ASSERT_EQUAL(vmst._core.regs[6], vmst._core.regs[5] + 4);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue