diff --git a/ee/kernel/Makefile b/ee/kernel/Makefile index b0dc89de4c40..97299c6047f0 100644 --- a/ee/kernel/Makefile +++ b/ee/kernel/Makefile @@ -86,26 +86,26 @@ GLUE_OBJS += SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o SIO_OBJS = sio_init.o sio_putc.o sio_getc.o sio_write.o sio_read.o sio_puts.o \ sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o -ROM0_OBJS = _info_internals.o GetRomNameWithIODriver.o GetRomName.o IsDESRMachineWithIODriver.o IsDESRMachine.o IsT10KWithIODriver.o IsT10K.o +ROM0_OBJS = _info_internals.o SetupRomInfo.o GetRomName.o IsDESRMachine.o IsT10K.o ### Config objects CONFIG_OBJS = _config_internals.o converttobcd.o convertfrombcd.o __adjustTime.o IsEarlyJap.o \ - configGetLanguageWithIODriver.o configGetLanguage.o \ - configSetLanguageWithIODriver.o configSetLanguage.o \ - configGetTvScreenTypeWithIODriver.o configGetTvScreenType.o \ - configSetTvScreenTypeWithIODriver.o configSetTvScreenType.o \ - configGetDateFormatWithIODriver.o configGetDateFormat.o \ - configSetDateFormatWithIODriver.o configSetDateFormat.o \ - configGetTimeFormatWithIODriver.o configGetTimeFormat.o \ - configSetTimeFormatWithIODriver.o configSetTimeFormat.o \ - configGetTimezoneWithIODriver.o configGetTimezone.o \ - configSetTimezoneWithIODriver.o configSetTimezone.o \ - configIsSpdifEnabledWithIODriver.o configIsSpdifEnabled.o \ - configSetSpdifEnabledWithIODriver.o configSetSpdifEnabled.o \ - configIsDaylightSavingEnabledWithIODriver.o configIsDaylightSavingEnabled.o \ - configSetDaylightSavingEnabledWithIODriver.o configSetDaylightSavingEnabled.o \ - configConvertToGmtTime.o configConvertToLocalTimeWithIODriver.o configConvertToLocalTime.o + configGetLanguage.o \ + configSetLanguage.o \ + configGetTvScreenType.o \ + configSetTvScreenType.o \ + configGetDateFormat.o \ + configSetDateFormat.o \ + configGetTimeFormat.o \ + configSetTimeFormat.o \ + configGetTimezone.o \ + configSetTimezone.o \ + configIsSpdifEnabled.o \ + configSetSpdifEnabled.o \ + configIsDaylightSavingEnabled.o \ + configSetDaylightSavingEnabled.o \ + configConvertToGmtTime.o configConvertToLocalTime.o ### Patch objects diff --git a/ee/kernel/include/osd_config.h b/ee/kernel/include/osd_config.h index b7fcbd1c150c..4f8d2ce1bcc2 100644 --- a/ee/kernel/include/osd_config.h +++ b/ee/kernel/include/osd_config.h @@ -129,95 +129,99 @@ extern "C" { * @return Language value (See OSD_LANGUAGES above) */ extern int configGetLanguage(void); -extern int configGetLanguageWithIODriver(_io_driver *driver); +#define configGetLanguageWithIODriver(driver) configGetLanguage() /** sets the default language of the ps2 * @param language Language value (See OSD_LANGUAGES above) */ extern void configSetLanguage(int language); -extern void configSetLanguageWithIODriver(int language, _io_driver *driver); - +#define configSetLanguageWithIODriver(language, driver) configSetLanguage(language) /** get the tv screen type the ps2 is setup for * @return 0 = 4:3; 1 = fullscreen; 2 = 16:9 */ extern int configGetTvScreenType(void); -extern int configGetTvScreenTypeWithIODriver(_io_driver *driver); +#define configGetTvScreenTypeWithIODriver(driver) configGetTvScreenType() /** set the tv screen type * @param screenType 0 = 4:3; 1 = fullscreen; 2 = 16:9 */ extern void configSetTvScreenType(int screenType); -extern void configSetTvScreenTypeWithIODriver(int screenType, _io_driver *driver); +#define configSetTvScreenTypeWithIODriver(screenType, driver) configSetTvScreenType(screenType) /** gets the date display format * @return 0 = yyyy/mm/dd; 1 = mm/dd/yyyy; 2 = dd/mm/yyyy */ extern int configGetDateFormat(void); -extern int configGetDateFormatWithIODriver(_io_driver *driver); +#define configGetDateFormatWithIODriver(driver) configGetDateFormat() /** sets the date display format * @param dateFormat 0 = yyyy/mm/dd; 1 = mm/dd/yyyy; 2 = dd/mm/yyyy */ extern void configSetDateFormat(int dateFormat); -extern void configSetDateFormatWithIODriver(int dateFormat, _io_driver *driver); +#define configSetDateFormatWithIODriver(dateFormat, driver) configSetDateFormat(dateFormat) /** gets the time display format * (whether 24hour time or not) * @return 0 = 24hour; 1 = 12hour */ extern int configGetTimeFormat(void); -extern int configGetTimeFormatWithIODriver(_io_driver *driver); +#define configGetTimeFormatWithIODriver(driver) configGetTimeFormat() /** sets the time display format * (whether 24hour time or not) * @param timeFormat 0 = 24hour; 1 = 12hour */ extern void configSetTimeFormat(int timeFormat); -extern void configSetTimeFormatWithIODriver(int timeFormat, _io_driver *driver); +#define configSetTimeFormatWithIODriver(timeFormat, driver) configSetTimeFormat(timeFormat) /** get timezone * @return offset in minutes from GMT */ extern int configGetTimezone(void); -extern int configGetTimezoneWithIODriver(_io_driver *driver); +#define configGetTimezoneWithIODriver(driver) configGetTimezone() /** set timezone * @param offset offset in minutes from GMT */ extern void configSetTimezone(int offset); -extern void configSetTimezoneWithIODriver(int timezoneOffset, _io_driver *driver, void (*finishedCallback)(void)); +#define configSetTimezoneWithIODriver(offset, driver, finishedCallback) configSetTimezone(offset) /** checks whether the spdif is enabled or not * @return 1 = on; 0 = off */ extern int configIsSpdifEnabled(void); -extern int configIsSpdifEnabledWithIODriver(_io_driver *driver); +#define configIsSpdifEnabledWithIODriver(driver) configIsSpdifEnabled() /** sets whether the spdif is enabled or not * @param enabled 1 = on; 0 = off */ extern void configSetSpdifEnabled(int enabled); -extern void configSetSpdifEnabledWithIODriver(int enabled, _io_driver *driver); +#define configSetSpdifEnabledWithIODriver(enabled, driver) configSetSpdifEnabled(enabled) /** checks whether daylight saving is currently set * @return 1 = on; 0 = off */ extern int configIsDaylightSavingEnabled(void); -extern int configIsDaylightSavingEnabledWithIODriver(_io_driver *driver); +#define configIsDaylightSavingEnabledWithIODriver(driver) configIsDaylightSavingEnabled() /** sets daylight saving * @param enabled 1 = on; 0 = off */ extern void configSetDaylightSavingEnabled(int enabled); -extern void configSetDaylightSavingEnabledWithIODriver(int daylightSaving, _io_driver *driver, void (*finishedCallback)(void)); +#define configSetDaylightSavingEnabledWithIODriver(enabled, driver, finishedCallback) configSetDaylightSavingEnabled(enabled) #ifndef OSD_CONFIG_NO_LIBCDVD /** converts the time returned from the ps2's clock into GMT time * (ps2 clock is in JST time) */ extern void configConvertToGmtTime(sceCdCLOCK *time); -extern void configConvertToLocalTimeWithIODriver(sceCdCLOCK *time, _io_driver *driver); + +/** converts the time returned from the ps2's clock into local time + * (ps2 clock is in JST time) + */ +extern void configConvertToLocalTime(sceCdCLOCK *time); +#define configConvertToLocalTimeWithIODriver(time, driver) configConvertToLocalTime(time) #endif // Internal functions. diff --git a/ee/kernel/include/rom0_info.h b/ee/kernel/include/rom0_info.h index b02ccc6730ea..7078e9fe78d9 100644 --- a/ee/kernel/include/rom0_info.h +++ b/ee/kernel/include/rom0_info.h @@ -28,19 +28,21 @@ typedef struct { int openFlags; } _io_driver; +extern void SetupRomInfo(void); + /** check whether the PlayStation 2 is actually a DESR-XXXX machine * * @return 1 if DESR-XXXX machine; 0 if not */ extern int IsDESRMachine(void); -extern int IsDESRMachineWithIODriver(_io_driver *driver); +#define IsDESRMachineWithIODriver(driver) IsDESRMachine() /** check whether the PlayStation 2 is actually a TOOL DTL-T10000(H) * * @return 1 if DTL-T10000(H); 0 if not */ extern int IsT10K(void); -extern int IsT10KWithIODriver(_io_driver *driver); +#define IsT10KWithIODriver(driver) IsT10K() /** gets the romname from the current ps2 * 14 chars - doesnt set a null terminator @@ -49,7 +51,7 @@ extern int IsT10KWithIODriver(_io_driver *driver); * @return pointer to buffer containing romname */ extern char *GetRomName(char *romname); -extern char *GetRomNameWithIODriver(char *romname, _io_driver *driver); +#define GetRomNameWithIODriver(romname, driver) GetRomName(romname) #ifdef __cplusplus } diff --git a/ee/kernel/src/osd_config.c b/ee/kernel/src/osd_config.c index 8f56aa189f0c..bd9b9f8a976b 100644 --- a/ee/kernel/src/osd_config.c +++ b/ee/kernel/src/osd_config.c @@ -23,8 +23,6 @@ #include #include #include -#define NEWLIB_PORT_AWARE -#include /** config param data as stored on a DTL-T10000(H) TOOL */ typedef struct @@ -38,8 +36,6 @@ typedef struct u8 timeFormat; } ConfigParamT10K; -#define defaultIODriver { (void *)fioOpen, fioClose, fioRead, FIO_O_RDONLY } - extern ConfigParamT10K g_t10KConfig; #ifdef F__config_internals @@ -193,12 +189,12 @@ int IsEarlyJap(ConfigParam config) } #endif -#ifdef F_configGetLanguageWithIODriver -int configGetLanguageWithIODriver(_io_driver *driver) +#ifdef F_configGetLanguage +int configGetLanguage(void) { ConfigParam config; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) return g_t10KConfig.language; GetOsdConfigParam(&config); @@ -208,23 +204,15 @@ int configGetLanguageWithIODriver(_io_driver *driver) } #endif -#ifdef F_configGetLanguage -int configGetLanguage(void) -{ - _io_driver driver = defaultIODriver; - return configGetLanguageWithIODriver(&driver); -} -#endif - -#ifdef F_configSetLanguageWithIODriver -void configSetLanguageWithIODriver(int language, _io_driver *driver) +#ifdef F_configSetLanguage +void configSetLanguage(int language) { ConfigParam config; // make sure language is valid if (language < LANGUAGE_JAPANESE || language > LANGUAGE_PORTUGUESE) return; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.language = language; // set language @@ -237,20 +225,12 @@ void configSetLanguageWithIODriver(int language, _io_driver *driver) } #endif -#ifdef F_configSetLanguage -void configSetLanguage(int language) -{ - _io_driver driver = defaultIODriver; - configSetLanguageWithIODriver(language, &driver); -} -#endif - -#ifdef F_configGetTvScreenTypeWithIODriver -int configGetTvScreenTypeWithIODriver(_io_driver *driver) +#ifdef F_configGetTvScreenType +int configGetTvScreenType(void) { ConfigParam config; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) return g_t10KConfig.screenType; GetOsdConfigParam(&config); @@ -258,23 +238,15 @@ int configGetTvScreenTypeWithIODriver(_io_driver *driver) } #endif -#ifdef F_configGetTvScreenType -int configGetTvScreenType(void) -{ - _io_driver driver = defaultIODriver; - return configGetTvScreenTypeWithIODriver(&driver); -} -#endif - -#ifdef F_configSetTvScreenTypeWithIODriver -void configSetTvScreenTypeWithIODriver(int screenType, _io_driver *driver) +#ifdef F_configSetTvScreenType +void configSetTvScreenType(int screenType) { ConfigParam config; // make sure screen type is valid if (screenType < TV_SCREEN_43 || screenType > TV_SCREEN_169) return; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.screenType = screenType; // set screen type @@ -284,21 +256,13 @@ void configSetTvScreenTypeWithIODriver(int screenType, _io_driver *driver) } #endif -#ifdef F_configSetTvScreenType -void configSetTvScreenType(int screenType) -{ - _io_driver driver = defaultIODriver; - configSetTvScreenTypeWithIODriver(screenType, &driver); -} -#endif - -#ifdef F_configGetDateFormatWithIODriver -int configGetDateFormatWithIODriver(_io_driver *driver) +#ifdef F_configGetDateFormat +int configGetDateFormat(void) { ConfigParam config; Config2Param config2; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) return g_t10KConfig.dateFormat; GetOsdConfigParam(&config); @@ -309,16 +273,8 @@ int configGetDateFormatWithIODriver(_io_driver *driver) } #endif -#ifdef F_configGetDateFormat -int configGetDateFormat(void) -{ - _io_driver driver = defaultIODriver; - return configGetDateFormatWithIODriver(&driver); -} -#endif - -#ifdef F_configSetDateFormatWithIODriver -void configSetDateFormatWithIODriver(int dateFormat, _io_driver *driver) +#ifdef F_configSetDateFormat +void configSetDateFormat(int dateFormat) { ConfigParam config; Config2Param config2; @@ -326,7 +282,7 @@ void configSetDateFormatWithIODriver(int dateFormat, _io_driver *driver) // make sure date format is valid if (dateFormat < DATE_YYYYMMDD || dateFormat > DATE_DDMMYYYY) return; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.dateFormat = dateFormat; // set date format @@ -339,21 +295,13 @@ void configSetDateFormatWithIODriver(int dateFormat, _io_driver *driver) } #endif -#ifdef F_configSetDateFormat -void configSetDateFormat(int dateFormat) -{ - _io_driver driver = defaultIODriver; - configSetDateFormatWithIODriver(dateFormat, &driver); -} -#endif - -#ifdef F_configGetTimeFormatWithIODriver -int configGetTimeFormatWithIODriver(_io_driver *driver) +#ifdef F_configGetTimeFormat +int configGetTimeFormat(void) { ConfigParam config; Config2Param config2; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) return g_t10KConfig.timeFormat; GetOsdConfigParam(&config); @@ -364,16 +312,8 @@ int configGetTimeFormatWithIODriver(_io_driver *driver) } #endif -#ifdef F_configGetTimeFormat -int configGetTimeFormat(void) -{ - _io_driver driver = defaultIODriver; - return configGetTimeFormatWithIODriver(&driver); -} -#endif - -#ifdef F_configSetTimeFormatWithIODriver -void configSetTimeFormatWithIODriver(int timeFormat, _io_driver *driver) +#ifdef F_configSetTimeFormat +void configSetTimeFormat(int timeFormat) { ConfigParam config; Config2Param config2; @@ -381,7 +321,7 @@ void configSetTimeFormatWithIODriver(int timeFormat, _io_driver *driver) // make sure time format is valid if (timeFormat < TIME_24H || timeFormat > TIME_12H) return; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.timeFormat = timeFormat; // set time format @@ -394,21 +334,13 @@ void configSetTimeFormatWithIODriver(int timeFormat, _io_driver *driver) } #endif -#ifdef F_configSetTimeFormat -void configSetTimeFormat(int timeFormat) -{ - _io_driver driver = defaultIODriver; - configSetTimeFormatWithIODriver(timeFormat, &driver); -} -#endif - -#ifdef F_configGetTimezoneWithIODriver -int configGetTimezoneWithIODriver(_io_driver *driver) +#ifdef F_configGetTimezone +int configGetTimezone(void) { ConfigParam config; int timezoneOffset; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) { timezoneOffset = g_t10KConfig.timezoneOffset; } @@ -438,21 +370,13 @@ int configGetTimezoneWithIODriver(_io_driver *driver) } #endif -#ifdef F_configGetTimezone -int configGetTimezone(void) -{ - _io_driver driver = defaultIODriver; - return configGetTimezoneWithIODriver(&driver); -} -#endif - -#ifdef F_configSetTimezoneWithIODriver -void configSetTimezoneWithIODriver(int timezoneOffset, _io_driver *driver, void (*finishedCallback)(void)) +#ifdef F_configSetTimezone +void configSetTimezone(int timezoneOffset) { ConfigParam config; // set offset from GMT - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.timezoneOffset = timezoneOffset; GetOsdConfigParam(&config); @@ -481,25 +405,15 @@ void configSetTimezoneWithIODriver(int timezoneOffset, _io_driver *driver, void } SetOsdConfigParam(&config); - if (finishedCallback) - finishedCallback(); } #endif -#ifdef F_configSetTimezone -void configSetTimezone(int timezoneOffset) -{ - _io_driver driver = defaultIODriver; - configSetTimezoneWithIODriver(timezoneOffset, &driver, NULL); -} -#endif - -#ifdef F_configIsSpdifEnabledWithIODriver -int configIsSpdifEnabledWithIODriver(_io_driver *driver) +#ifdef F_configIsSpdifEnabled +int configIsSpdifEnabled(void) { ConfigParam config; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) return g_t10KConfig.spdifMode ^ 1; GetOsdConfigParam(&config); @@ -507,20 +421,12 @@ int configIsSpdifEnabledWithIODriver(_io_driver *driver) } #endif -#ifdef F_configIsSpdifEnabled -int configIsSpdifEnabled(void) -{ - _io_driver driver = defaultIODriver; - return configIsSpdifEnabledWithIODriver(&driver); -} -#endif - -#ifdef F_configSetSpdifEnabledWithIODriver -void configSetSpdifEnabledWithIODriver(int enabled, _io_driver *driver) +#ifdef F_configSetSpdifEnabled +void configSetSpdifEnabled(int enabled) { ConfigParam config; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.spdifMode = enabled ^ 1; GetOsdConfigParam(&config); @@ -529,21 +435,13 @@ void configSetSpdifEnabledWithIODriver(int enabled, _io_driver *driver) } #endif -#ifdef F_configSetSpdifEnabled -void configSetSpdifEnabled(int enabled) -{ - _io_driver driver = defaultIODriver; - configSetSpdifEnabledWithIODriver(enabled, &driver); -} -#endif - -#ifdef F_configIsDaylightSavingEnabledWithIODriver -int configIsDaylightSavingEnabledWithIODriver(_io_driver *driver) +#ifdef F_configIsDaylightSavingEnabled +int configIsDaylightSavingEnabled(void) { ConfigParam config; Config2Param config2; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) return g_t10KConfig.daylightSaving; GetOsdConfigParam(&config); @@ -555,21 +453,13 @@ int configIsDaylightSavingEnabledWithIODriver(_io_driver *driver) } #endif -#ifdef F_configIsDaylightSavingEnabled -int configIsDaylightSavingEnabled(void) -{ - _io_driver driver = defaultIODriver; - return configIsDaylightSavingEnabledWithIODriver(&driver); -} -#endif - -#ifdef F_configSetDaylightSavingEnabledWithIODriver -void configSetDaylightSavingEnabledWithIODriver(int daylightSaving, _io_driver *driver, void (*finishedCallback)(void)) +#ifdef F_configSetDaylightSavingEnabled +void configSetDaylightSavingEnabled(int daylightSaving) { ConfigParam config; Config2Param config2; - if (IsT10KWithIODriver(driver)) + if (IsT10K()) g_t10KConfig.daylightSaving = daylightSaving; GetOsdConfigParam(&config); @@ -578,16 +468,6 @@ void configSetDaylightSavingEnabledWithIODriver(int daylightSaving, _io_driver * GetOsdConfigParam2(&config2, sizeof(config2), 0); config2.daylightSaving = daylightSaving; SetOsdConfigParam2(&config2, sizeof(config2), 0); - if (finishedCallback) - finishedCallback(); -} -#endif - -#ifdef F_configSetDaylightSavingEnabled -void configSetDaylightSavingEnabled(int daylightSaving) -{ - _io_driver driver = defaultIODriver; - configSetDaylightSavingEnabledWithIODriver(daylightSaving, &driver, NULL); } #endif @@ -598,19 +478,11 @@ void configConvertToGmtTime(sceCdCLOCK *time) } #endif -#ifdef F_configConvertToLocalTimeWithIODriver -void configConvertToLocalTimeWithIODriver(sceCdCLOCK *time, _io_driver *driver) -{ - int timezone_offset = configGetTimezoneWithIODriver(driver); - int daylight_saving = configIsDaylightSavingEnabledWithIODriver(driver); - __adjustTime(time, timezone_offset - 540 + (daylight_saving * 60)); -} -#endif - #ifdef F_configConvertToLocalTime void configConvertToLocalTime(sceCdCLOCK *time) { - _io_driver driver = defaultIODriver; - configConvertToLocalTimeWithIODriver(time, &driver); + int timezone_offset = configGetTimezone(); + int daylight_saving = configIsDaylightSavingEnabled(); + __adjustTime(time, timezone_offset - 540 + (daylight_saving * 60)); } #endif diff --git a/ee/kernel/src/rom0_info.c b/ee/kernel/src/rom0_info.c index a7fe84d23459..fb50a20a7b35 100644 --- a/ee/kernel/src/rom0_info.c +++ b/ee/kernel/src/rom0_info.c @@ -16,76 +16,100 @@ #include -// We don't want kernel to depend newlib -#define NEWLIB_PORT_AWARE -#include "fileio.h" +#include +#include +#include +#include -#define defaultIODriver { (void *)fioOpen, fioClose, fioRead, FIO_O_RDONLY } +struct rom0_info_data +{ + /** stores romname of ps2 */ + char m_romver[17]; + /** Can be either PSX180 or PSX210 */ + char m_psxver[8]; +}; -extern char g_RomName[]; +extern struct rom0_info_data g_rom0_info_data; #ifdef F__info_internals -/** stores romname of ps2 */ -char g_RomName[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +struct rom0_info_data g_rom0_info_data; #endif -#ifdef F_GetRomNameWithIODriver -char *GetRomNameWithIODriver(char *romname, _io_driver *driver) +#ifdef F_SetupRomInfo +void SetupRomInfo(void) { - int fd; + void *iop_addr; + SifRpcReceiveData_t rdata; + u8 buf[64] __attribute__((__aligned__(64))); - fd = driver->open("rom0:ROMVER", driver->openFlags); - driver->read(fd, romname, 14); - driver->close(fd); - return romname; -} -#endif + /* ROMVER needs to be read from the IOP due to PPCIOP region patching. */ + /* only read in the romname the first time */ + if (g_rom0_info_data.m_romver[0]) + return; -#ifdef F_GetRomName -char *GetRomName(char *romname) -{ - _io_driver driver = defaultIODriver; - return GetRomNameWithIODriver(romname, &driver); -} -#endif + /* SYSMEM allocates in units of 256. */ + if (!(iop_addr = SifAllocIopHeap(256))) + { + memset(&g_rom0_info_data, 0, sizeof(g_rom0_info_data)); + return; + } -#ifdef F_IsDESRMachineWithIODriver -int IsDESRMachineWithIODriver(_io_driver *driver) -{ - int fd; + /* ROMVER is known to be 16 bytes. */ + if (SifLoadIopHeap("rom:ROMVER", iop_addr) >= 0) + { + SyncDCache(buf, buf + sizeof(buf)); + if (sceSifGetOtherData(&rdata, iop_addr, buf, sizeof(buf), 0) < 0) + { + SifFreeIopHeap(iop_addr); + memset(&g_rom0_info_data, 0, sizeof(g_rom0_info_data)); + return; + } - fd = driver->open("rom0:PSXVER", driver->openFlags); - if (fd > 0) { - driver->close(fd); - return 1; + memcpy(g_rom0_info_data.m_romver, UNCACHED_SEG(buf), sizeof(g_rom0_info_data.m_romver) - 1); + g_rom0_info_data.m_romver[sizeof(g_rom0_info_data.m_romver) - 1] = 0; } - return 0; + /* PSXVER is known to be 7 bytes. */ + if (SifLoadIopHeap("rom:PSXVER", iop_addr) >= 0) + { + SyncDCache(buf, buf + sizeof(buf)); + if (sceSifGetOtherData(&rdata, iop_addr, buf, sizeof(buf), 0) < 0) + { + SifFreeIopHeap(iop_addr); + memset(&g_rom0_info_data, 0, sizeof(g_rom0_info_data)); + return; + } + + memcpy(g_rom0_info_data.m_psxver, UNCACHED_SEG(buf), sizeof(g_rom0_info_data.m_psxver) - 1); + g_rom0_info_data.m_psxver[sizeof(g_rom0_info_data.m_psxver) - 1] = 0; + } + + SifFreeIopHeap(iop_addr); } #endif -#ifdef F_IsDESRMachine -int IsDESRMachine(void) +#ifdef F_GetRomName +char *GetRomName(char *romname) { - _io_driver driver = defaultIODriver; - return IsDESRMachineWithIODriver(&driver); + SetupRomInfo(); + /* Explicitly copy 14 bytes to the buffer */ + memcpy(romname, g_rom0_info_data.m_romver, 14); + return romname; } #endif -#ifdef F_IsT10KWithIODriver -int IsT10KWithIODriver(_io_driver *driver) +#ifdef F_IsDESRMachine +int IsDESRMachine(void) { - // only read in the romname the first time - if (g_RomName[0] == 0) - GetRomNameWithIODriver(g_RomName, driver); - return (g_RomName[4] == 'T' && g_RomName[5] != 'Z') ? 1 : 0; + SetupRomInfo(); + return (!memcmp(g_rom0_info_data.m_psxver, "PSX", 3)) ? 1 : 0; } #endif #ifdef F_IsT10K int IsT10K(void) { - _io_driver driver = defaultIODriver; - return IsT10KWithIODriver(&driver); + SetupRomInfo(); + return (g_rom0_info_data.m_romver[4] == 'T' && g_rom0_info_data.m_romver[5] != 'Z') ? 1 : 0; } #endif diff --git a/ee/libcglue/src/timezone.c b/ee/libcglue/src/timezone.c index 9cce3934ddc6..8fb82949d750 100644 --- a/ee/libcglue/src/timezone.c +++ b/ee/libcglue/src/timezone.c @@ -24,18 +24,15 @@ #define OSD_CONFIG_NO_LIBCDVD #include "osd_config.h" -#define posixIODriver { open, close, (int (*)(int fd, void *buf, int nbyte))read, O_RDONLY } - #ifdef F__libcglue_timezone_update_impl void _libcglue_timezone_update_impl() { /* Initialize timezone from PS2 OSD configuration */ - _io_driver driver = posixIODriver; - int tzOffset = configGetTimezoneWithIODriver(&driver); + int tzOffset = configGetTimezone(); int tzOffsetAbs = tzOffset < 0 ? -tzOffset : tzOffset; int hours = tzOffsetAbs / 60; int minutes = tzOffsetAbs - hours * 60; - int daylight = configIsDaylightSavingEnabledWithIODriver(&driver); + int daylight = configIsDaylightSavingEnabled(); static char tz[15]; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-overflow" @@ -61,14 +58,14 @@ void _libcglue_timezone_update() #ifdef F_ps2sdk_setTimezone void ps2sdk_setTimezone(int timezone) { - _io_driver driver = posixIODriver; - configSetTimezoneWithIODriver(timezone, &driver, _libcglue_timezone_update); + configSetTimezone(timezone); + _libcglue_timezone_update(); } #endif #ifdef F_ps2sdk_setDaylightSaving void ps2sdk_setDaylightSaving(int daylightSaving) { - _io_driver driver = posixIODriver; - configSetDaylightSavingEnabledWithIODriver(daylightSaving, &driver, _libcglue_timezone_update); + configSetDaylightSavingEnabled(daylightSaving); + _libcglue_timezone_update(); } #endif \ No newline at end of file