add a save/restore procedure of BSC/CPG parameters at start

This commit is contained in:
Sylvain PILLOT 2023-01-04 20:47:52 +01:00
parent cdaaef6501
commit 1cff1b4fd7
6 changed files with 106 additions and 3 deletions

View File

@ -65,6 +65,8 @@ void cpg_compute_freq(void);
gint. These are always the settings from Ftune/Ptune, which are the most
widely tested and gint treats as the standard. */
enum {
/* Something went wrong during the overclocking process*/
CLOCK_ERROR = 99,
/* Combinations of hardware settings that are none of Ftune's levels */
CLOCK_SPEED_UNKNOWN = 0,
@ -111,6 +113,10 @@ enum {
correspond to any of Ftune's settings, CLOCK_SPEED_UNKNOWN is returned. */
int clock_get_speed(void);
void clock_save_state(void);
void clock_restore_state(void);
/* clock_set_speed(): Set the current clock speed
This function sets the clock speed to the desired level. This is "the

View File

@ -99,7 +99,7 @@ typedef volatile struct
} GPACKED(4) sh7305_scif_t;
#define SH7305_SCIF (*((sh7305_scif_t *)0x0xa4410000))
#define SH7305_SCIF (*((sh7305_scif_t *)0xa4410000))
typedef volatile struct
@ -200,7 +200,7 @@ typedef volatile struct
uint8_t SCFRDR; // Serial Receive Data FIFO (64 Bytes-long)
} GPACKED(4) sh7705_scif_t;
#define SH7705_SCIF (*((sh7705_scif_t *)0x0xa4410000))
#define SH7705_SCIF (*((sh7705_scif_t *)0xa4410000))
#ifdef __cplusplus

18
src/cpg/.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
src/cpg/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/home/sylvain/.local/share/giteapc/Slyvtt/gint/src/cpg",
"program": "/home/sylvain/.local/share/giteapc/Slyvtt/gint/src/cpg/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

36
src/cpg/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,36 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wconversion",
"-Wnull-dereference",
"-Wsign-conversion"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
]
}

View File

@ -59,6 +59,11 @@
#define SH3_DIV_4 3 //0b0011 // 1/4
static struct cpg_overclock_setting save_parameters_at_start = {0};
static bool is_initial_state_saved = false;
void cpg_get_overclock_setting(struct cpg_overclock_setting *s)
{
if(isSH3())
@ -139,6 +144,19 @@ void cpg_set_overclock_setting(struct cpg_overclock_setting const *s)
return;
}
void clock_save_state(void)
{
cpg_get_overclock_setting( &save_parameters_at_start );
is_initial_state_saved = true;
}
void clock_restore_state(void)
{
if(is_initial_state_saved==true)
cpg_set_overclock_setting( &save_parameters_at_start );
}
/*settings for the fxcg50 / G90+E*/
static struct cpg_overclock_setting settings_fxcg50[5] = {
/* CLOCK_SPEED_F1 */
@ -453,7 +471,7 @@ int clock_get_speed(void)
{
struct cpg_overclock_setting *settings = get_settings();
if(!settings)
return CLOCK_SPEED_UNKNOWN;
return CLOCK_ERROR;
if(isSH3())
{
@ -492,6 +510,7 @@ int clock_get_speed(void)
}
}
clock_save_state();
return CLOCK_SPEED_UNKNOWN;
}