summaryrefslogtreecommitdiff
path: root/410user/libsimics/simics_c.c
blob: c32a2983810e491701a7a3062c1ec9f3ad8740bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <simics.h>
#include <stdarg.h>
#include <stdio.h>
#include <syscall.h>    /* for readline() */

int sim_in_simics(void) {
    return sim_call(SIM_IN_SIMICS);
}

int sim_memsize(void) {
    return sim_call(SIM_MEMSIZE);
}

void sim_puts(const char *arg) {
    sim_call(SIM_PUTS, arg);
}

void sim_breakpoint(void) {
    sim_call(SIM_BREAKPOINT);
}

void sim_halt(void) {
    sim_call(SIM_HALT);
}

void sim_ck1(void) {
    sim_call(SIM_CK1);
}

void sim_fr_prog(int a) {
    sim_call(SIM_FR_PROG, a);
}

void sim_fr_here(void) {
    sim_call(SIM_FR_HERE);
}

void sim_vprintf(const char* fmt, va_list ap)
{
    char str[256];
    vsnprintf(str, sizeof(str) - 1, fmt, ap);
    sim_puts(str);
}

void sim_printf(const char* fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
    sim_vprintf(fmt, ap);
    va_end(ap);
}

void sim_update_scoreboard(char *testname, int success) {
    sim_call(SIM_TEST_REPORT, testname, success);
}

int magic_readline(int size, char *buf) {
    sim_call(SIM_FR_INKEYS);
    return readline(size, buf);
}