111 lines
2.8 KiB
C
111 lines
2.8 KiB
C
/* V2MemTest - A CLI Tool to test & fix Voodoo² TMU System
|
|
* Copyright (C) 2026 ChaCha
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef _DEF_V2MEMTEST_H_
|
|
#define _DEF_V2MEMTEST_H_
|
|
|
|
#define V2MEMTEST__VERSION__MAJOR 0
|
|
#define V2MEMTEST__VERSION__MINOR 5
|
|
#define V2MEMTEST__VERSION__PATCH 0
|
|
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef enum _def_eTMURamLimit {
|
|
E_TMU_RAMSIZE__1MB = 1,
|
|
E_TMU_RAMSIZE__2MB = 2,
|
|
E_TMU_RAMSIZE__3MB = 3,
|
|
E_TMU_RAMSIZE__4MB = 4,
|
|
E_TMU_RAMSIZE__AUTO = -1,
|
|
}def_eTMURamLimit;
|
|
|
|
#define MAX_TMU 2
|
|
|
|
typedef enum _def_eLogLevel {
|
|
E_LOGLEVEL__ERROR = 0,
|
|
E_LOGLEVEL__WARNING = 1,
|
|
E_LOGLEVEL__INFO = 2,
|
|
E_LOGLEVEL__DEBUG = 3,
|
|
E_LOGLEVEL__TRACE = 4,
|
|
}def_eLogLevel;
|
|
|
|
#define DEF_BASE_ERRROR -1000
|
|
#define DEF_NO_ERROR_IDX 0
|
|
#define DEF_UNKNOWN_ERROR_IDX 1
|
|
#define DEF_GET_ERROR_IDX(CODE) -(DEF_BASE_ERRROR-CODE)
|
|
|
|
typedef enum _def_eErrorCode {
|
|
E_ERROR__NO_ERROR = 0,
|
|
E_ERROR__UNKNOWN_ERROR = -1,
|
|
E_ERROR__UNKNOWN_ARGUMENT = DEF_BASE_ERRROR,
|
|
E_ERROR__BAD_ARGUMENT_VALUE,
|
|
E_ERROR__SST1_INIT,
|
|
E_ERROR__SST1_GET_INFO,
|
|
E_ERROR__NOT_ENOUGH_FBI_RAM,
|
|
E_ERROR__TMU_NOT_FOUND,
|
|
E_ERROR__NO_TMU_SELECTED,
|
|
E_ERROR__WRONG_TMU_SELECTED,
|
|
E_INVALID_ERROR_CODE,
|
|
}def_eErrorCode;
|
|
|
|
extern const char* szErrorMsg[];
|
|
|
|
typedef struct _def_sOptions
|
|
{
|
|
def_eLogLevel eLogLevel;
|
|
int bSilent;
|
|
long lNumLoops;
|
|
int bTestTMU0;
|
|
def_eTMURamLimit eTMU0RamLimit;
|
|
int bTestTMU1;
|
|
def_eTMURamLimit eTMU1RamLimit;
|
|
int bTestTMUControl;
|
|
int bTestTMUAddress;
|
|
int bTestTMUData;
|
|
int bTestTMUDataHuge;
|
|
int bTestNoMem;
|
|
int bQuick;
|
|
int bForce;
|
|
int bContinue;
|
|
} def_sOptions;
|
|
|
|
extern def_sOptions sOptions;
|
|
|
|
|
|
#define logE(...) _log(E_LOGLEVEL__ERROR, __VA_ARGS__)
|
|
#define logW(...) _log(E_LOGLEVEL__WARNING, __VA_ARGS__)
|
|
#define logI(...) _log(E_LOGLEVEL__INFO, __VA_ARGS__)
|
|
#define logD(...) _log(E_LOGLEVEL__DEBUG, __VA_ARGS__)
|
|
#define logT(...) _log(E_LOGLEVEL__TRACE, __VA_ARGS__)
|
|
|
|
|
|
#define _log(_E_LOGLEVEL,...) \
|
|
do { \
|
|
if( (sOptions.eLogLevel >= _E_LOGLEVEL) \
|
|
&& !sOptions.bSilent) {\
|
|
if(_E_LOGLEVEL==E_LOGLEVEL__ERROR) \
|
|
fprintf(stderr,__VA_ARGS__); \
|
|
else \
|
|
printf(__VA_ARGS__); \
|
|
} \
|
|
} \
|
|
while(0)
|
|
|
|
|
|
|
|
#endif //_DEF_V2MEMTEST_H_
|