Skip to content

Commit c5249ab

Browse files
committed
Add icnt_factor and g_realtime keyboard shortcuts
Added controls to increment/decrement icnt_factor and toggle g_realtime for testing and debugging purposes. Left Alt = -> increment_icnt_factor(); Left Alt - -> decrement_icnt_factor(); Left Alt r -> toggle_g_realtime();
1 parent 8955be1 commit c5249ab

3 files changed

Lines changed: 70 additions & 1 deletion

File tree

core/hostevents_sdl.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,35 @@ void EventManager::poll_events() {
125125
}
126126
return;
127127
}
128+
// LAlt-+: speed up icnt_factor
129+
if (event.key.keysym.sym == SDLK_EQUALS && (event.key.keysym.mod & KMOD_ALL) == KMOD_LALT) {
130+
if (event.type == SDL_KEYUP) {
131+
int icnt_counter_val = increment_icnt_factor();
132+
LOG_F(INFO, "Incremented icnt_factor: %d", icnt_counter_val);
133+
}
134+
return;
135+
}
136+
// LAlt--: slow down icnt_factor
137+
if (event.key.keysym.sym == SDLK_MINUS && (event.key.keysym.mod & KMOD_ALL) == KMOD_LALT) {
138+
if (event.type == SDL_KEYUP) {
139+
int icnt_counter_val = decrement_icnt_factor();
140+
LOG_F(INFO, "Decremented icnt_factor: %d", icnt_counter_val);
141+
}
142+
return;
143+
}
144+
145+
// LALT-R: g_realtime toggle
146+
if (event.key.keysym.sym == SDLK_r && (event.key.keysym.mod & KMOD_ALL) == KMOD_LALT) {
147+
if (event.type == SDL_KEYUP) {
148+
bool g_realtime_status = toggle_g_realtime();
149+
if (g_realtime_status == true) {
150+
LOG_F(INFO, "g_realtime: enabled");
151+
} else if (g_realtime_status == false) {
152+
LOG_F(INFO, "g_realtime: disabled");
153+
}
154+
}
155+
}
156+
128157
// Control-L: log toggle
129158
if (event.key.keysym.sym == SDLK_l && (event.key.keysym.mod & KMOD_ALL) == KMOD_LCTRL) {
130159
if (event.type == SDL_KEYUP) {

cpu/ppc/ppcemu.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,4 +691,15 @@ extern void ppc_msr_did_change(uint32_t old_msr_val, uint32_t new_msr_val, bool
691691
uint64_t get_reg(std::string reg_name); /* get content of the register reg_name */
692692
void set_reg(std::string reg_name, uint64_t val); /* set reg_name to val */
693693

694+
/* icnt_factor control */
695+
extern int increment_icnt_factor();
696+
extern int decrement_icnt_factor();
697+
extern int get_icnt_factor();
698+
699+
/* toggle_g_realtime */
700+
extern bool toggle_g_realtime();
701+
702+
/* force_cycle_counter_reload */
703+
static void force_cycle_counter_reload();
704+
694705
#endif /* PPCEMU_H */

cpu/ppc/ppcexec.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool dec_exception_pending = false;
8181
uint32_t glob_bb_start_la;
8282

8383
/* variables related to virtual time */
84-
const bool g_realtime = false;
84+
bool g_realtime = false;
8585
uint64_t g_nanoseconds_base;
8686
uint64_t g_icycles;
8787
int icnt_factor;
@@ -290,6 +290,35 @@ static void force_cycle_counter_reload()
290290
exec_timer = true;
291291
}
292292

293+
int increment_icnt_factor()
294+
{
295+
icnt_factor += 1;
296+
force_cycle_counter_reload();
297+
return icnt_factor;
298+
}
299+
300+
int decrement_icnt_factor()
301+
{
302+
icnt_factor -= 1;
303+
force_cycle_counter_reload();
304+
return icnt_factor;
305+
}
306+
307+
int get_icnt_factor()
308+
{
309+
return icnt_factor;
310+
}
311+
312+
bool toggle_g_realtime()
313+
{
314+
if (g_realtime == false)
315+
g_realtime = true;
316+
else if (g_realtime == true)
317+
g_realtime = false;
318+
force_cycle_counter_reload();
319+
return g_realtime;
320+
}
321+
293322
typedef enum {
294323
main,
295324
until,

0 commit comments

Comments
 (0)