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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/** @file lib/simics.h
* @brief Simics interface (kernel side)
* @author matthewj S2008
*/
#ifndef LIB_SIMICS_H
#define LIB_SIMICS_H
#ifdef ASSEMBLER
#define lprintf sim_printf
#endif
#define SIM_IN_SIMICS 0x04100000
#define SIM_MEMSIZE 0x04100001
#define SIM_PUTS 0x04100002
#define SIM_BREAKPOINT 0x04100003
#define SIM_HALT 0x04100004
#define SIM_CK1 0x04108000
#define SIM_FR_INKEYS 0x04108004
#define SIM_FR_PROG 0x04108006
#define SIM_FR_HERE 0x04108007
#define SIM_TEST_REPORT 0x0410800B
#ifdef ASSEMBLER
/* Now *this* is a fun macro. It expands into a simics call to 'num' with
* arguments 'arg0' and 'arg1'. For use in assembly functions, to call simics
* without touching the stack. */
#define INLINE_SIMCALL(num, arg0, arg1) \
mov $num, %ebx; \
mov arg0, %ecx; \
mov arg1, %edx; \
xchg %ebx, %ebx;
#endif
#ifndef ASSEMBLER
#include <stdarg.h>
/** @brief Calls simics. Arguments are ebx, ecx, edx. */
extern int sim_call(int ebx, ...);
/** @brief Returns whether we are in simics */
extern int sim_in_simics(void);
/** @brief Returns machine memory size, from simics */
extern int sim_memsize(void);
/** @brief Prints a string to the simics console */
extern void sim_puts(const char *arg);
/** @brief Breakpoint */
extern void sim_breakpoint(void);
/** @brief Halt the simulation */
extern void sim_halt(void);
/** @brief Run the checkpoint 1 checker. */
extern void sim_ck1(void);
/** @brief Grading harness stuff */
extern void sim_fr_prog(int a);
extern void sim_fr_here(void);
/** @brief Convenience wrappers around sim_puts(). */
extern void sim_vprintf(const char* fmt, va_list ap);
extern void sim_printf(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
/** @brief readline(), but wrapped in "magic" */
int magic_readline(int size, char *buf);
void sim_update_scoreboard(char *testname, int success);
/* "Compatibility mode" for old code */
#define MAGIC_BREAK sim_breakpoint()
#define lprintf(...) sim_printf(__VA_ARGS__)
#endif /* !ASSEMBLER */
#endif /* !LIB_SIMICS_H */
|