Skip to content

Commit

Permalink
Add SYS_GetConsoleType
Browse files Browse the repository at this point in the history
Guard InitializeUART behind development hardware
  • Loading branch information
Extrems committed Feb 15, 2025
1 parent 0c34f60 commit d494f02
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
33 changes: 33 additions & 0 deletions gc/ogc/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,38 @@ distribution.
*@}
*/

#define SYS_CONSOLE_MASK 0xf0000000
#define SYS_CONSOLE_RETAIL 0x00000000
#define SYS_CONSOLE_DEVELOPMENT 0x10000000
#define SYS_CONSOLE_TDEV 0x20000000

#if defined(HW_DOL)
#define SYS_CONSOLE_RETAIL_HW1 0x00000001
#define SYS_CONSOLE_RETAIL_HW2 0x00000002
#define SYS_CONSOLE_RETAIL_HW3 0x00000003
#define SYS_CONSOLE_DEVELOPMENT_HW1 0x10000004
#define SYS_CONSOLE_DEVELOPMENT_HW2 0x10000005
#define SYS_CONSOLE_DEVELOPMENT_HW3 0x10000006
#define SYS_CONSOLE_TDEV_HW1 0x20000004
#define SYS_CONSOLE_TDEV_HW2 0x20000005
#define SYS_CONSOLE_TDEV_HW3 0x20000006
#elif defined(HW_RVL)
#define SYS_CONSOLE_RETAIL_ES1_0 0x00000010
#define SYS_CONSOLE_RETAIL_ES1_1 0x00000011
#define SYS_CONSOLE_RETAIL_ES1_2 0x00000012
#define SYS_CONSOLE_RETAIL_ES2_0 0x00000020
#define SYS_CONSOLE_RETAIL_ES2_1 0x00000021
#define SYS_CONSOLE_RETAIL_ES3_0 0x00000030
#define SYS_CONSOLE_RETAIL_ES3_1 0x00000031
#define SYS_CONSOLE_NDEV_ES1_0 0x10000010
#define SYS_CONSOLE_NDEV_ES1_1 0x10000011
#define SYS_CONSOLE_NDEV_ES1_2 0x10000012
#define SYS_CONSOLE_NDEV_ES2_0 0x10000020
#define SYS_CONSOLE_NDEV_ES2_1 0x10000021
#define SYS_CONSOLE_NDEV_ES3_0 0x10000030
#define SYS_CONSOLE_NDEV_ES3_1 0x10000031
#endif

#define SYS_LANG_ENGLISH 0
#define SYS_LANG_GERMAN 1
#define SYS_LANG_FRENCH 2
Expand Down Expand Up @@ -350,6 +382,7 @@ void SYS_SetWirelessID(u32 chan,u16 id);
u16 SYS_GetGBSMode(void);
void SYS_SetGBSMode(u16 mode);

u32 SYS_GetConsoleType(void);
u32 SYS_GetFontEncoding(void);
u32 SYS_InitFont(sys_fontheader *font_data);
void SYS_GetFontTexture(s32 c,void **image,s32 *xpos,s32 *ypos,s32 *width);
Expand Down
6 changes: 5 additions & 1 deletion libogc/exi.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ distribution.
#include "asm.h"
#include "irq.h"
#include "processor.h"
#include "system.h"
#include "cache.h"
#include "exi.h"
#include "lwp.h"
Expand Down Expand Up @@ -1091,10 +1092,13 @@ void __SYS_EnableBarnacle(s32 chn,u32 dev)
s32 InitializeUART(void)
{
if(exi_uart_barnacle_enabled==0xa5ff005a) return 0;
if((SYS_GetConsoleType()&SYS_CONSOLE_MASK)!=SYS_CONSOLE_DEVELOPMENT) {
exi_uart_enabled = 0;
return 2;
}

exi_uart_chan = EXI_CHANNEL_0;
exi_uart_dev = EXI_DEVICE_1;

exi_uart_enabled = 0xa5ff005a;
return 0;
}
Expand Down
17 changes: 16 additions & 1 deletion libogc/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,22 @@ void SYS_SetGBSMode(u16 mode)
__SYS_UnlockSramEx(write);
}

#if defined(HW_RVL)
#if defined(HW_DOL)
u32 SYS_GetConsoleType(void)
{
u32 type;
type = *((u32*)0x8000002c);
return type;
}
#elif defined(HW_RVL)
u32 SYS_GetConsoleType(void)
{
u32 type;
type = SYS_CONSOLE_RETAIL_ES1_0;
type += *((u32*)0x80003138);
return type;
}

u32 SYS_GetHollywoodRevision(void)
{
u32 rev;
Expand Down

0 comments on commit d494f02

Please sign in to comment.