TEMU  4.4
The Terma Emulator
Clock.h
Go to the documentation of this file.
1 //===------------------------------------------------------------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2016
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_CLOCK_H
10 #define TEMU_CLOCK_H
11 
12 #include "temu-c/Support/Objsys.h"
13 #include "temu-c/Support/Events.h"
14 
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /*
22  * THIS INTERFACE IS EXPERIMENTAL AND UNSTABLE
23  */
24 
25 /*!
26  * Clock stop reason, these are similar to CPU exit reason, but not
27  * identical.
28  */
29 typedef enum {
30  teCSR_Normal = 0, //!< Normal exit (cannot be passed to early exit)
31  teCSR_Halt, //!< Exited due to clock halting
32  teCSR_BreakWatch, //!< Exited due to breakpoint or watchpoint hit
33  teCSR_Early, //!< Other early stop reason
34  teCSR_Panic, //!< Clock had a serious internal error
35  teCSR_Sync, //!< Clock needs to synchronize
36 } temu_ClockStopReason;
37 
38 typedef struct {
39  temu_ClockStopReason (*step)(void *Obj, uint64_t Steps);
40  temu_ClockStopReason (*stepUntil)(void *Obj, uint64_t Steps, uint64_t Cycles);
41  temu_ClockStopReason (*advanceCycles)(void *Obj, uint64_t Cycles);
42  temu_ClockStopReason (*advanceToCycles)(void *Obj, uint64_t Cycles);
43 
44  uint64_t (*getSteps)(void *Obj);
45  uint64_t (*getCycles)(void *Obj);
46  uint64_t (*getNanos)(void *Obj);
47  double (*getSecs)(void *Obj);
48  /* Set time to arbitrary values without executing events */
49  void (*setSteps)(void *Obj, uint64_t Steps);
50  void (*setCycles)(void *Obj, uint64_t Ticks);
51  void (*setNanos)(void *Obj, uint64_t Nanos);
52  void (*setSecs)(void *Obj, double Secs);
53 
54  double (*getFreq)(void *Obj);
55  void (*setFreq)(void *Obj, double Freq);
56 
57 
58  temu_ClockStopReason (*synchronizingAdvanceCycles)(void *Obj, uint64_t Cycles);
59  temu_ClockStopReason (*synchronizingAdvanceToCycles)(void *Obj, uint64_t Cycles);
60  temu_ClockStopReason (*synchronizingStep)(void *Obj, uint64_t Steps);
61  temu_ClockStopReason (*synchronizingStepUntil)(void *Obj, uint64_t Steps, uint64_t Cycles);
62 
63 } temu_ClockIface;
64 
65 #define TEMU_CLOCK_IFACE_TYPE "ClockIface"
66 TEMU_IFACE_REFERENCE_TYPE(temu_Clock);
67 
68 
69 
70 typedef struct {
71  temu_ClockIface *Clock;
72 } temu_ClockVTable;
73 
74 
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* ! TEMU_CLOCK_H */
temu_ClockIface::getSecs
double(* getSecs)(void *Obj)
Definition: Clock.h:47
temu_ClockIface::setSteps
void(* setSteps)(void *Obj, uint64_t Steps)
Definition: Clock.h:49
teCSR_Panic
@ teCSR_Panic
Clock had a serious internal error.
Definition: Clock.h:34
temu_ClockIface::setNanos
void(* setNanos)(void *Obj, uint64_t Nanos)
Definition: Clock.h:51
teCSR_Sync
@ teCSR_Sync
Clock needs to synchronize.
Definition: Clock.h:35
teCSR_Early
@ teCSR_Early
Other early stop reason.
Definition: Clock.h:33
temu_ClockIface::setFreq
void(* setFreq)(void *Obj, double Freq)
Definition: Clock.h:55
temu_ClockIface::getFreq
double(* getFreq)(void *Obj)
Definition: Clock.h:54
teCSR_Halt
@ teCSR_Halt
Exited due to clock halting.
Definition: Clock.h:31
temu_ClockVTable::Clock
temu_ClockIface * Clock
Definition: Clock.h:71
temu_ClockIface::setCycles
void(* setCycles)(void *Obj, uint64_t Ticks)
Definition: Clock.h:50
teCSR_BreakWatch
@ teCSR_BreakWatch
Exited due to breakpoint or watchpoint hit.
Definition: Clock.h:32
temu_ClockIface::setSecs
void(* setSecs)(void *Obj, double Secs)
Definition: Clock.h:52
teCSR_Normal
@ teCSR_Normal
Normal exit (cannot be passed to early exit)
Definition: Clock.h:30