・sdmc-launcher-writerの追加

・nvramライブラリの追加
・gcdライブラリの完全削除 (元から使ってなかった)

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1043 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yutaka 2008-04-02 10:09:55 +00:00
parent e69ba86cea
commit 48045460db
26 changed files with 1814 additions and 4896 deletions

View File

@ -88,6 +88,7 @@ FIRM_LIBS_BASE ?= \
libfs_sp \
libaes_sp \
libpm_sp \
libnvram_sp \
endif

View File

@ -12,8 +12,8 @@
# in whole or in part, without the prior written consent of Nintendo.
#
# $Date:: $
# $Rev:$
# $Author:$
# $Rev$
# $Author$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
@ -25,6 +25,7 @@ SUBDIRS = \
gcdfirm-disp \
gcdfirm-print \
sdmc-launcher \
sdmc-launcher-writer \
#----------------------------------------------------------------------------

View File

@ -0,0 +1,55 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - tools - menu-launcher
# File: Makefile
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
# Company Ltd., and are protected by Federal copyright law. They may
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Date:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
TWL_PROC = ARM7
SUBDIRS =
LINCLUDES = ../include
#----------------------------------------------------------------------------
TARGET_BIN = sdmc_launcher_writer7.tef
SRCS = main.c
CRT0_O = crt0_firm.o
ADDRESS_STATIC = 0x037b8000
#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template
#SRCDIR = # using default
#LCFILE = # using default
LINCLUDES = $(ROOT)/build/libraries/fatfs/ARM7.TWL/include \
$(ROOT)/build/libraries/fatfs/ARM7.TWL/include/fatfs \
$(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000'
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,287 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - gcdfirm - sdmc-launcher-writer
File: main.c
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm.h>
#include <twl/mcu.h>
#include <symbols.h>
#include <twl/devices/sdmc/ARM7/sdmc.h>
#define PRINT_DEBUG
#ifndef PRINT_DEBUG
#undef OS_TPrintf
#undef OS_PutChar
#define OS_TPrintf(...) ((void)0)
#define OS_PutChar(...) ((void)0)
#endif // PRINT_DEBUG
/*
LEDをFINALROMとは別にOn/Offできます
*/
#define USE_DEBUG_LED
#ifdef USE_DEBUG_LED
static u8 step = 0x00;
#define InitDebugLED() I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x03, 0x00)
#define SetDebugLED(pattern) I2Ci_WriteRegister(I2C_SLAVE_DEBUG_LED, 0x01, (pattern));
#else
#define InitDebugLED() ((void)0)
#define SetDebugLED(pattern) ((void)0)
#endif
#define THREAD_PRIO_FATFS 8
#define DMA_FATFS_1 0
#define DMA_FATFS_2 1
#define DMA_CARD 2
static u8* const nor = (u8*)HW_TWL_MAIN_MEM;
static u8* const nand = (u8*)HW_TWL_MAIN_MEM + offsetof(NANDHeader,l);
static OSThread idleThread;
static u64 idleStack[32];
static void IdleThread(void* arg)
{
#pragma unused(arg)
OS_EnableInterrupts();
while (1)
{
OS_Halt();
}
}
static void CreateIdleThread(void)
{
OS_CreateThread(&idleThread, IdleThread, NULL, &idleStack[32], sizeof(idleStack), OS_THREAD_PRIORITY_MAX);
OS_WakeupThreadDirect(&idleThread);
}
// MCU旧バージョン対策
#if SDK_TS_VERSION <= 200
static u8 version = 0;
#define IS_OLD_MCU (version ? (version < 0x20) : ((version=MCUi_ReadRegister( MCU_REG_VER_INFO_ADDR )) < 0x20))
#else
#define IS_OLD_MCU FALSE
#define MCU_OLD_REG_TEMP_ADDR MCU_REG_TEMP_ADDR // avoid compiler error
#endif
/***************************************************************
PreInit
FromBootの対応
OS_Init前なので注意 (ARM9によるメインメモリ初期化で消されないように注意)
***************************************************************/
static void PreInit(void)
{
GCDHeader* const gh = &OSi_GetFromBromAddr()->header.gcd;
/*
*/
if ( !IS_OLD_MCU ) // MCU旧バージョン対策
{
if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 )
{
#ifndef SDK_FINALROM
OS_TPanic("Battery is empty.\n");
#else
PM_Shutdown();
#endif
}
}
MI_CpuCopyFast( gh, (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END - HW_ROM_HEADER_BUF );
// MI_CpuCopyFast( gh, (void*)HW_CARD_ROM_HEADER, HW_CARD_ROM_HEADER_SIZE );
// FromBrom全消去
MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) );
}
/***************************************************************
PostInit
***************************************************************/
static void PostInit(void)
{
#if SDK_TS_VERSION <= 200
// PMICの設定 for old version
PM_InitFIRM();
#endif
#if SDK_TS_VERSION <= 200
PMi_SetParams( REG_PMIC_BL_BRT_A_ADDR, PMIC_BACKLIGHT_BRIGHT_DEFAULT, PMIC_BL_BRT_A_MASK );
PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, PMIC_BACKLIGHT_BRIGHT_DEFAULT, PMIC_BL_BRT_B_MASK );
#else
MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK );
#endif
PM_BackLightOn( TRUE );
// アイドルスレッドの作成
CreateIdleThread();
// XYボタン通知
PAD_InitXYButton();
/*
*/
if ( !IS_OLD_MCU ) // MCU旧バージョン対策
{
if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 )
{
#ifndef SDK_FINALROM
OS_TPanic("Battery is empty.\n");
#else
PM_Shutdown();
#endif
}
}
}
/***************************************************************
EraseAll
DSモードにして終わるのがよいか
***************************************************************/
static void EraseAll(void)
{
GCDHeader* const gh = &OSi_GetFromBromAddr()->header.gcd;
AESi_ResetAesKeyA();
AESi_ResetAesKeyB();
AESi_ResetAesKeyC();
MI_CpuClearFast( nor, (gh->l.nandfirm_size + 512) * 2 );
}
extern SDMC_ERR_CODE FATFSi_sdmcGoIdle(u16 ports, void (*func1)(),void (*func2)());
void TwlSpMain( void )
{
GCDHeader* const gh = &OSi_GetFromBromAddr()->header.gcd;
u32 offset = gh->l.nandfirm_offset;
u32 size = gh->l.nandfirm_size;
u32 nsize = size - offsetof(NANDHeader,l); // size to write to nand
u32 sectors = (nsize + 511)/512;
u8* nor2 = nor + size; // buffer to verify
u8* nand2 = nand + size; // buffer to verify
s32 lock_id;
SdmcResultInfo sdResult;
InitDebugLED();
SetDebugLED(++step); // 0x01
PreInit();
SetDebugLED(++step); // 0x02
OS_InitFIRM();
OS_EnableIrq();
OS_EnableInterrupts();
SetDebugLED(++step); // 0x03
PostInit();
SetDebugLED(++step); // 0x04
// NAND初期化
if (SDMC_NORMAL != FATFSi_sdmcInit( (SDMC_DMA_NO)DMA_FATFS_1, (SDMC_DMA_NO)DMA_FATFS_2 ))
{
OS_TPrintf("Failed to call FATFSi_sdmcInit().\n");
goto err;
}
FATFSi_sdmcGoIdle( 2, NULL, NULL );
FATFSi_sdmcSelect( SDMC_PORT_NAND );
SetDebugLED(++step); // 0x05
// CARD初期化
CARD_Init();
CARD_Enable(TRUE);
lock_id = OS_GetLockID();
CARD_LockRom((u16)lock_id);
SetDebugLED(++step); // 0x06
PXI_SendStream(&size, sizeof(size));
if ( size < sizeof(NANDHeader) )
{
OS_TPrintf("No NAND firm is there.\n");
goto err;
}
SetDebugLED(++step); // 0x07
// read all
CARD_ReadRom( DMA_CARD, (void*)offset, nor, size );
SetDebugLED(++step); // 0x08
PXI_NotifyID( FIRM_PXI_ID_NULL );
// write NOR
NVRAMi_Write( 0, nor, sizeof(NORHeaderDS));
SetDebugLED(++step); // 0x09
{ // write boot_nandfirm flag
s32 tmp = -1;
NVRAMi_Write( 0x2ff, &tmp, 1 );
}
SetDebugLED(++step); // 0x0a
// write NAND
if ( FATFSi_sdmcWriteFifo( nand, sectors, 1, NULL, &sdResult ) )
{
OS_TPrintf("Failed to call FATFSi_sdmcWriteFifo() to write header.\n");
goto err;
}
SetDebugLED(++step); // 0x0b
PXI_NotifyID( FIRM_PXI_ID_NULL );
// verify NOR
NVRAMi_Read( 0, nor2, sizeof(NORHeaderDS) );
if ( MI_CpuComp8( nor, nor2, sizeof(NORHeaderDS) ) )
{
OS_TPrintf("Failed to verify firm data in NOR.\n");
goto err;
}
SetDebugLED(++step); // 0x0c
// verify NAND
if ( FATFSi_sdmcReadFifo( nand2, sectors, 1, NULL, &sdResult ) )
{
OS_TPrintf("Failed to call FATFSi_sdmcReadFifo() to write header.\n");
goto err;
}
SetDebugLED(++step); // 0x0d
if ( MI_CpuComp8( nand, nand2, nsize ) )
{
OS_TPrintf("Failed to verify firm data in NAND.\n");
goto err;
}
SetDebugLED(0); // 0x00
PXI_NotifyID( FIRM_PXI_ID_NULL );
if ( PXI_RecvID() != FIRM_PXI_ID_NULL )
{
goto err;
}
OS_TPrintf("Success all.\n");
MCUi_WriteRegister( MCU_REG_COMMAND_ADDR, MCU_REG_COMMAND_RESET_MASK );
OS_Terminate();
err:
SetDebugLED((u8)(step|0xF0));
EraseAll();
PXI_NotifyID( FIRM_PXI_ID_ERR );
PXI_NotifyID( FIRM_PXI_ID_ERR );
PXI_NotifyID( FIRM_PXI_ID_ERR );
PXI_NotifyID( FIRM_PXI_ID_ERR );
OS_Terminate();
}

View File

@ -1,6 +1,6 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# Project: TwlFirm - nandfirm - menu-launcher
# File: Makefile
#
# Copyright 2007 Nintendo. All rights reserved.
@ -16,42 +16,38 @@
# $Author$
#----------------------------------------------------------------------------
SUBDIRS =
SUBDIRS =
#LINCLUDES = ../include
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= True
TARGET_BIN = sdmc_launcher_writer9.srl
SRCS = main.c \
screen.c \
font.c
CRT0_O = crt0_firm.o
SRCDIR = . ../common
SRCS = \
gcd.c \
gcd_init.c \
blowfish.c \
ds_blowfish.c \
ds_blowfish_table.c \
ADDRESS_STATIC = 0x037c0000
TARGET_LIB = libgcd$(FIRM_LIBSUFFIX).a
INCDIR = ../include
MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher_writer7.tef
MAKEROM_ARM7_BASE = $(basename $(MAKEROM_ARM7))
#----------------------------------------------------------------------------
#LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(TWL_PROC)-$(TWL_PLATFORM)-PARTNER.lcf.template
#SRCDIR = # using default
#LCFILE = # using default
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
INSTALL_TARGETS = $(TARGETS)
INSTALL_DIR = $(FIRM_INSTALL_LIBDIR)
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
LDEPENDS_OBJ := $(MAKEFIRM_RSA_PUBKEY) \
gcd_acsign.c : $(LDEPENDS_OBJ)
touch gcd_acsign.c
#===== End of Makefile =====

View File

@ -0,0 +1,588 @@
/*---------------------------------------------------------------------------*
Project: NitroSDK - SPI - demos - pm-1
File: font.c
Copyright 2003-2005 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: font.c,v $
Revision 1.3 2005/02/28 05:26:11 yosizaki
do-indent.
Revision 1.2 2004/11/02 07:19:52 terui
Revision 1.1 2004/08/07 01:59:51 yada
modified much
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include "font.h"
/*---------------------------------------------------------------------------*
Character data
*---------------------------------------------------------------------------*/
const u32 d_CharData[8 * 256] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0000h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01010010, 0x01010010, 0x00000110, // 0001h
0x00011010, 0x01100010, 0x00000010, 0x00000010,
0x00000000, 0x01011010, 0x01010010, 0x00010010, // 0002h
0x00100010, 0x00100010, 0x00100001, 0x00100001,
0x00000000, 0x01010001, 0x01010001, 0x01111111, // 0003h
0x00000001, 0x00000001, 0x00000001, 0x01111110,
0x00000000, 0x01010000, 0x01111111, 0x00100000, // 0004h
0x00100000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x01010000, 0x01010100, 0x00001010, // 0005h
0x00010001, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01011000, 0x01011000, 0x01111111, // 0006h
0x00001000, 0x00101010, 0x01001010, 0x01001001,
0x00000000, 0x01010010, 0x01101111, 0x01010010, // 0007h
0x00010010, 0x00010010, 0x00010010, 0x00001001,
0x00000000, 0x01010010, 0x01011111, 0x00000100, // 0008h
0x00011111, 0x00001000, 0x00000001, 0x00011110,
0x00000000, 0x01010000, 0x01011000, 0x00000110, // 0009h
0x00000001, 0x00000110, 0x00011000, 0x00100000,
0x00000000, 0x01010000, 0x01111101, 0x00010001, // 000ah
0x00010001, 0x00010001, 0x00010001, 0x00001010,
0x00000000, 0x01010000, 0x01011110, 0x00100000, // 000bh
0x00000000, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x01010100, 0x01011111, 0x00001000, // 000ch
0x00010000, 0x00000001, 0x00000001, 0x00011110,
0x00000000, 0x01010001, 0x01010001, 0x00000001, // 000dh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01010000, 0x01111111, 0x00011000, // 000eh
0x00010100, 0x00010100, 0x00011000, 0x00001100,
0x00000000, 0x01010010, 0x01111111, 0x00010010, // 000fh
0x00010010, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x00001110, 0x01010100, 0x01010010, // 0010h
0x00111111, 0x00000100, 0x00000100, 0x00011000,
0x00000000, 0x01010100, 0x01011111, 0x00000100, // 0011h
0x01110100, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x01010100, 0x01011111, 0x00000010, // 0012h
0x00011110, 0x00100001, 0x00100000, 0x00011110,
0x00000000, 0x01010000, 0x01011100, 0x00100011, // 0013h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01010000, 0x01111111, 0x00010000, // 0014h
0x00001000, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x01010010, 0x01010010, 0x00001100, // 0015h
0x00000010, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x01010001, 0x01111101, 0x00010001, // 0016h
0x00010001, 0x00111001, 0x01010101, 0x00011001,
0x00000000, 0x01010100, 0x01010011, 0x01110010, // 0017h
0x00010001, 0x00010001, 0x00001010, 0x00000100,
0x00000000, 0x01011110, 0x01011000, 0x00000100, // 0018h
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x01010000, 0x01011100, 0x00010010, // 0019h
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01011101, 0x01010001, 0x00111101, // 001ah
0x00010001, 0x00011001, 0x00110101, 0x00001001,
0x00000000, 0x01110001, 0x01011101, 0x00110001, // 001bh
0x00010001, 0x00111001, 0x01010101, 0x00011001,
0x00000000, 0x01110100, 0x01010011, 0x00110010, // 001ch
0x00010001, 0x00010001, 0x00001010, 0x00000100,
0x00000000, 0x01101110, 0x01011000, 0x00100100, // 001dh
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x01110000, 0x01011100, 0x00110010, // 001eh
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01111101, 0x01010001, 0x00111101, // 001fh
0x00010001, 0x00011001, 0x00110101, 0x00001001,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 0020h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 0021h
0x00001000, 0x00001000, 0x00000000, 0x00001000,
0x00000000, 0x01101100, 0x01001000, 0x00100100, // 0022h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00100100, 0x01111111, 0x00100100, // 0023h
0x00100100, 0x01111111, 0x00010010, 0x00010010,
0x00000000, 0x00001000, 0x01111110, 0x00001001, // 0024h
0x00111110, 0x01001000, 0x00111111, 0x00001000,
0x00000000, 0x01000010, 0x00100101, 0x00010010, // 0025h
0x00001000, 0x00100100, 0x01010010, 0x00100001,
0x00000000, 0x00001110, 0x00010001, 0x00001001, // 0026h
0x01000110, 0x00101001, 0x00110001, 0x01001110,
0x00000000, 0x00011000, 0x00010000, 0x00001000, // 0027h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01110000, 0x00001000, 0x00000100, // 0028h
0x00000100, 0x00000100, 0x00001000, 0x01110000,
0x00000000, 0x00000111, 0x00001000, 0x00010000, // 0029h
0x00010000, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x00001000, 0x01001001, 0x00101010, // 002ah
0x00011100, 0x00101010, 0x01001001, 0x00001000,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 002bh
0x01111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002ch
0x00000000, 0x00001100, 0x00001000, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002dh
0x01111111, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 002eh
0x00000000, 0x00000000, 0x00000000, 0x00001100,
0x00000000, 0x01000000, 0x00100000, 0x00010000, // 002fh
0x00001000, 0x00000100, 0x00000010, 0x00000001,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0030h
0x01000001, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x00011100, 0x00010000, 0x00010000, // 0031h
0x00010000, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0032h
0x00111110, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x00111110, 0x01000001, 0x01000000, // 0033h
0x00111110, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x00100000, 0x00110000, 0x00101000, // 0034h
0x00100100, 0x00100010, 0x01111111, 0x00100000,
0x00000000, 0x01111111, 0x00000001, 0x00111111, // 0035h
0x01000000, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x00111110, 0x00000001, 0x00111111, // 0036h
0x01000001, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x01111111, 0x00100000, 0x00100000, // 0037h
0x00010000, 0x00010000, 0x00001000, 0x00001000,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0038h
0x00111110, 0x01000001, 0x01000001, 0x00111110,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 0039h
0x01000001, 0x01111110, 0x01000000, 0x00111110,
0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003ah
0x00000000, 0x00000000, 0x00001100, 0x00000000,
0x00000000, 0x00000000, 0x00001100, 0x00000000, // 003bh
0x00000000, 0x00001100, 0x00001000, 0x00000100,
0x00000000, 0x01100000, 0x00011000, 0x00000110, // 003ch
0x00000001, 0x00000110, 0x00011000, 0x01100000,
0x00000000, 0x00000000, 0x01111111, 0x00000000, // 003dh
0x00000000, 0x00000000, 0x01111111, 0x00000000,
0x00000000, 0x00000011, 0x00001100, 0x00110000, // 003eh
0x01000000, 0x00110000, 0x00001100, 0x00000011,
0x00000000, 0x00111110, 0x01000001, 0x01000001, // 003fh
0x00110000, 0x00001000, 0x00000000, 0x00001000,
0x00000000, 0x00011100, 0x00100010, 0x01001001, // 0040h
0x01010101, 0x01010101, 0x01010101, 0x00111010,
0x00000000, 0x00001000, 0x00010100, 0x00010100, // 0041h
0x00100010, 0x00111110, 0x01000001, 0x01000001,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0042h
0x00111111, 0x01000001, 0x01000001, 0x00111111,
0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0043h
0x00000001, 0x00000001, 0x01000010, 0x00111100,
0x00000000, 0x00011111, 0x00100001, 0x01000001, // 0044h
0x01000001, 0x01000001, 0x00100001, 0x00011111,
0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0045h
0x01111111, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x01111111, 0x00000001, 0x00000001, // 0046h
0x00111111, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00111100, 0x01000010, 0x00000001, // 0047h
0x01111001, 0x01000001, 0x01000010, 0x00111100,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0048h
0x01111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00111110, 0x00001000, 0x00001000, // 0049h
0x00001000, 0x00001000, 0x00001000, 0x00111110,
0x00000000, 0x01000000, 0x01000000, 0x01000000, // 004ah
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01100001, 0x00011001, 0x00000101, // 004bh
0x00000011, 0x00000101, 0x00011001, 0x01100001,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 004ch
0x00000001, 0x00000001, 0x00000001, 0x01111111,
0x00000000, 0x01000001, 0x01100011, 0x01010101, // 004dh
0x01001001, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x01000001, 0x01000011, 0x01000101, // 004eh
0x01001001, 0x01010001, 0x01100001, 0x01000001,
0x00000000, 0x00011100, 0x00100010, 0x01000001, // 004fh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0050h
0x00111111, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00011100, 0x00100010, 0x01000001, // 0051h
0x01000001, 0x01011001, 0x00100010, 0x01011100,
0x00000000, 0x00111111, 0x01000001, 0x01000001, // 0052h
0x00111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00111110, 0x01000001, 0x00000001, // 0053h
0x00111110, 0x01000000, 0x01000001, 0x00111110,
0x00000000, 0x01111111, 0x00001000, 0x00001000, // 0054h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0055h
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x01000001, 0x01000001, 0x00100010, // 0056h
0x00100010, 0x00010100, 0x00010100, 0x00001000,
0x00000000, 0x01000001, 0x01000001, 0x01000001, // 0057h
0x01001001, 0x01010101, 0x01100011, 0x01000001,
0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0058h
0x00001000, 0x00010100, 0x00100010, 0x01000001,
0x00000000, 0x01000001, 0x00100010, 0x00010100, // 0059h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01111111, 0x00100000, 0x00010000, // 005ah
0x00001000, 0x00000100, 0x00000010, 0x01111111,
0x00000000, 0x01111100, 0x00000100, 0x00000100, // 005bh
0x00000100, 0x00000100, 0x00000100, 0x01111100,
0x00000000, 0x00100010, 0x00010100, 0x00111110, // 005ch
0x00001000, 0x00111110, 0x00001000, 0x00001000,
0x00000000, 0x00011111, 0x00010000, 0x00010000, // 005dh
0x00010000, 0x00010000, 0x00010000, 0x00011111,
0x00000000, 0x00001000, 0x00010100, 0x00100010, // 005eh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 005fh
0x00000000, 0x00000000, 0x00000000, 0x01111111,
0x00000000, 0x00010000, 0x00001000, 0x00011000, // 0060h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00011110, 0x00100001, // 0061h
0x00111110, 0x00100001, 0x00100001, 0x01011110,
0x00000000, 0x00000001, 0x00000001, 0x00111111, // 0062h
0x01000001, 0x01000001, 0x01000001, 0x00111111,
0x00000000, 0x00000000, 0x00111100, 0x01000010, // 0063h
0x00000001, 0x00000001, 0x01000010, 0x00111100,
0x00000000, 0x01000000, 0x01000000, 0x01111110, // 0064h
0x01000001, 0x01000001, 0x01000001, 0x01111110,
0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0065h
0x01111111, 0x00000001, 0x01000001, 0x00111110,
0x00000000, 0x00110000, 0x00001000, 0x00001000, // 0066h
0x01111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x01111110, 0x01000001, // 0067h
0x01000001, 0x01111110, 0x01000000, 0x00111110,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0068h
0x00111111, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00001000, 0x00000000, 0x00001000, // 0069h
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00100000, 0x00000000, 0x00100000, // 006ah
0x00100000, 0x00100001, 0x00100001, 0x00011110,
0x00000000, 0x00000001, 0x00000001, 0x01100001, // 006bh
0x00011001, 0x00000111, 0x00011001, 0x01100001,
0x00000000, 0x00001000, 0x00001000, 0x00001000, // 006ch
0x00001000, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00110111, 0x01001001, // 006dh
0x01001001, 0x01001001, 0x01001001, 0x01001001,
0x00000000, 0x00000000, 0x00111111, 0x01000001, // 006eh
0x01000001, 0x01000001, 0x01000001, 0x01000001,
0x00000000, 0x00000000, 0x00011100, 0x00100010, // 006fh
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00000000, 0x00111101, 0x01000011, // 0070h
0x01000001, 0x01000011, 0x00111101, 0x00000001,
0x00000000, 0x00000000, 0x01011110, 0x01100001, // 0071h
0x01000001, 0x01100001, 0x01011110, 0x01000000,
0x00000000, 0x00000000, 0x00110001, 0x00001101, // 0072h
0x00000011, 0x00000001, 0x00000001, 0x00000001,
0x00000000, 0x00000000, 0x00111110, 0x01000001, // 0073h
0x00001110, 0x00110000, 0x01000001, 0x00111110,
0x00000000, 0x00000100, 0x00000100, 0x01111111, // 0074h
0x00000100, 0x00000100, 0x00000100, 0x01111000,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0075h
0x01000001, 0x01000001, 0x01000001, 0x01111110,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0076h
0x00100010, 0x00100010, 0x00010100, 0x00001000,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0077h
0x01001001, 0x00101010, 0x00101010, 0x00010100,
0x00000000, 0x00000000, 0x00100001, 0x00010010, // 0078h
0x00001100, 0x00001100, 0x00010010, 0x00100001,
0x00000000, 0x00000000, 0x01000001, 0x01000001, // 0079h
0x00100010, 0x00011100, 0x00001000, 0x00000110,
0x00000000, 0x00000000, 0x00111111, 0x00010000, // 007ah
0x00001000, 0x00000100, 0x00000010, 0x00111111,
0x00000000, 0x00001000, 0x00011110, 0x01100100, // 007bh
0x00011000, 0x00100100, 0x00000100, 0x01111000,
0x00000000, 0x00000000, 0x00011110, 0x00000100, // 007ch
0x00011110, 0x00110101, 0x00101101, 0x00010010,
0x00000000, 0x00000000, 0x00000000, 0x00010001, // 007dh
0x00100001, 0x00100001, 0x00000001, 0x00000010,
0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007eh
0x00011110, 0x00100000, 0x00100000, 0x00011100,
0x00000000, 0x00000000, 0x00011100, 0x00000000, // 007fh
0x00111110, 0x00010000, 0x00001100, 0x00110010,
0x00000000, 0x00000000, 0x00000100, 0x00101111, // 0080h
0x01000100, 0x00011110, 0x00100101, 0x00010110,
0x00000000, 0x00000000, 0x00001010, 0x00011110, // 0081h
0x00101011, 0x00100010, 0x00010100, 0x00000100,
0x00000000, 0x00000000, 0x00001000, 0x00011101, // 0082h
0x00101011, 0x00101001, 0x00011001, 0x00000100,
0x00000000, 0x00000000, 0x00001000, 0x00111000, // 0083h
0x00001000, 0x00011110, 0x00101001, 0x00000110,
0x00000000, 0x00000000, 0x00000000, 0x00011100, // 0084h
0x00100011, 0x00100000, 0x00100000, 0x00011100,
0x00000000, 0x00000110, 0x01001001, 0x00110000, // 0085h
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000100, 0x00111111, 0x00000100, // 0086h
0x00111110, 0x01010101, 0x01001101, 0x00100110,
0x00000000, 0x00000000, 0x00100001, 0x01000001, // 0087h
0x01000001, 0x01000001, 0x00000001, 0x00000010,
0x00000000, 0x00111100, 0x00000000, 0x00111110, // 0088h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x00011100, 0x00000000, 0x00111110, // 0089h
0x00010000, 0x00001000, 0x00010100, 0x01100010,
0x00000000, 0x00100100, 0x01011111, 0x00000100, // 008ah
0x00111110, 0x01000101, 0x01000101, 0x00100010,
0x00000000, 0x00100010, 0x01001111, 0x01010010, // 008bh
0x01010010, 0x00010010, 0x00010010, 0x00001001,
0x00000000, 0x00000100, 0x00111110, 0x00001000, // 008ch
0x00111110, 0x00010000, 0x00000010, 0x00111100,
0x00000000, 0x00100000, 0x00011000, 0x00000110, // 008dh
0x00000001, 0x00000110, 0x00011000, 0x00100000,
0x00000000, 0x00100000, 0x01111101, 0x00100001, // 008eh
0x00100001, 0x00100001, 0x00100001, 0x00010010,
0x00000000, 0x00011110, 0x00100000, 0x00000000, // 008fh
0x00000000, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x00001000, 0x01111111, 0x00010000, // 0090h
0x00100000, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x00000001, 0x00000001, 0x00000001, // 0091h
0x01000001, 0x01000001, 0x00100010, 0x00011100,
0x00000000, 0x00010000, 0x01111111, 0x00011000, // 0092h
0x00010100, 0x00010100, 0x00011000, 0x00001100,
0x00000000, 0x00100010, 0x01111111, 0x00100010, // 0093h
0x00100010, 0x00000010, 0x00000010, 0x01111100,
0x00000000, 0x00111100, 0x00010000, 0x00001100, // 0094h
0x01111111, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x00000100, 0x00011111, 0x00000100, // 0095h
0x01110100, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x00001000, 0x01111111, 0x00000100, // 0096h
0x00111100, 0x01000010, 0x01000000, 0x00111100,
0x00000000, 0x00000000, 0x00011100, 0x00100011, // 0097h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01111111, 0x00010000, 0x00001000, // 0098h
0x00001000, 0x00001000, 0x00001000, 0x00110000,
0x00000000, 0x00000010, 0x00110010, 0x00001100, // 0099h
0x00000010, 0x00000001, 0x00000001, 0x00111110,
0x00000000, 0x00100100, 0x01001111, 0x01000010, // 009ah
0x00010001, 0x00111100, 0x00010010, 0x00001100,
0x00000000, 0x00000010, 0x01111010, 0x01000010, // 009bh
0x00000010, 0x00000010, 0x00001010, 0x01110010,
0x00000000, 0x00100010, 0x00111110, 0x01010010, // 009ch
0x01001011, 0x01101101, 0x01010101, 0x00110010,
0x00000000, 0x00110010, 0x01001011, 0x01000110, // 009dh
0x01000110, 0x01110010, 0x01001011, 0x00110010,
0x00000000, 0x00011100, 0x00101010, 0x01001001, // 009eh
0x01001001, 0x01000101, 0x01000101, 0x00110010,
0x00000000, 0x00100001, 0x01111101, 0x00100001, // 009fh
0x00100001, 0x00111001, 0x01100101, 0x00011001,
0x00000000, 0x00000100, 0x00100011, 0x01100010, // 00a0h
0x00100001, 0x00100001, 0x00010010, 0x00001100,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a1h
0x00000000, 0x00000100, 0x00001010, 0x00000100,
0x00000000, 0x01110000, 0x00010000, 0x00010000, // 00a2h
0x00010000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a3h
0x00001000, 0x00001000, 0x00001000, 0x00001110,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00a4h
0x00000000, 0x00000010, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00011000, // 00a5h
0x00011000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01111111, 0x01000000, 0x01111111, // 00a6h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x00000000, 0x00111111, 0x00100000, // 00a7h
0x00010100, 0x00001100, 0x00000100, 0x00000010,
0x00000000, 0x00000000, 0x00100000, 0x00100000, // 00a8h
0x00010000, 0x00001111, 0x00001000, 0x00001000,
0x00000000, 0x00000000, 0x00000100, 0x00111111, // 00a9h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00aah
0x00001000, 0x00001000, 0x00001000, 0x01111111,
0x00000000, 0x00000000, 0x00010000, 0x00111111, // 00abh
0x00011000, 0x00010100, 0x00010010, 0x00011001,
0x00000000, 0x00000000, 0x00000010, 0x00111111, // 00ach
0x00100010, 0x00010010, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00000000, 0x00111110, // 00adh
0x00100000, 0x00100000, 0x00100000, 0x01111111,
0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00aeh
0x00111110, 0x00100000, 0x00100000, 0x00111110,
0x00000000, 0x00000000, 0x00100101, 0x00101010, // 00afh
0x00101010, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00b0h
0x01111111, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x01111111, 0x01000000, 0x00101000, // 00b1h
0x00011000, 0x00001000, 0x00001000, 0x00000100,
0x00000000, 0x01000000, 0x00100000, 0x00011000, // 00b2h
0x00010111, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x00001000, 0x01111111, 0x01000001, // 00b3h
0x01000001, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00000000, 0x00111110, 0x00001000, // 00b4h
0x00001000, 0x00001000, 0x00001000, 0x01111111,
0x00000000, 0x00100000, 0x01111111, 0x00110000, // 00b5h
0x00101000, 0x00100100, 0x00100010, 0x00110001,
0x00000000, 0x00000100, 0x01111111, 0x01000100, // 00b6h
0x01000100, 0x01000100, 0x01000010, 0x00100001,
0x00000000, 0x00000100, 0x00111111, 0x00001000, // 00b7h
0x01111111, 0x00010000, 0x00010000, 0x00010000,
0x00000000, 0x01111100, 0x01000100, 0x01000100, // 00b8h
0x01000010, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00000010, 0x01111110, 0x00100010, // 00b9h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00bah
0x01000000, 0x01000000, 0x01000000, 0x01111110,
0x00000000, 0x00100010, 0x01111111, 0x00100010, // 00bbh
0x00100010, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x00000011, 0x00000100, 0x01000011, // 00bch
0x01000100, 0x00100000, 0x00011000, 0x00000111,
0x00000000, 0x01111111, 0x01000000, 0x00100000, // 00bdh
0x00010000, 0x00011000, 0x00100100, 0x01000011,
0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00beh
0x00100010, 0x00000010, 0x00000010, 0x01111100,
0x00000000, 0x01000001, 0x01000010, 0x01000000, // 00bfh
0x00100000, 0x00100000, 0x00011000, 0x00000110,
0x00000000, 0x01111110, 0x01000010, 0x01001110, // 00c0h
0x01110001, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x01100000, 0x00011110, 0x00010000, // 00c1h
0x01111111, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x01000101, 0x01001010, 0x01001010, // 00c2h
0x01000000, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00c3h
0x00010000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x00000010, 0x00000010, 0x00000110, // 00c4h
0x00011010, 0x01100010, 0x00000010, 0x00000010,
0x00000000, 0x00010000, 0x00010000, 0x01111111, // 00c5h
0x00010000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x00000000, 0x00111110, 0x00000000, // 00c6h
0x00000000, 0x00000000, 0x00000000, 0x01111111,
0x00000000, 0x01111110, 0x01000000, 0x01000100, // 00c7h
0x00101000, 0x00010000, 0x00101000, 0x01000110,
0x00000000, 0x00001000, 0x01111111, 0x00100000, // 00c8h
0x00010000, 0x00011100, 0x01101011, 0x00001000,
0x00000000, 0x01000000, 0x01000000, 0x01000000, // 00c9h
0x00100000, 0x00100000, 0x00011000, 0x00000111,
0x00000000, 0x00010010, 0x00100010, 0x00100010, // 00cah
0x01000010, 0x01000010, 0x01000001, 0x01000001,
0x00000000, 0x00000001, 0x00000001, 0x01111111, // 00cbh
0x00000001, 0x00000001, 0x00000001, 0x01111110,
0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cch
0x01000000, 0x00100000, 0x00010000, 0x00001110,
0x00000000, 0x00000000, 0x00000100, 0x00001010, // 00cdh
0x00010001, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x00001000, 0x00001000, 0x01111111, // 00ceh
0x00001000, 0x00101010, 0x01001010, 0x01001001,
0x00000000, 0x01111111, 0x01000000, 0x01000000, // 00cfh
0x00100010, 0x00010100, 0x00001000, 0x00010000,
0x00000000, 0x00001110, 0x01110000, 0x00001110, // 00d0h
0x01110000, 0x00000110, 0x00011000, 0x01100000,
0x00000000, 0x00001000, 0x00001000, 0x00000100, // 00d1h
0x00000100, 0x00100010, 0x01000010, 0x01111111,
0x00000000, 0x01000000, 0x01000000, 0x00100100, // 00d2h
0x00101000, 0x00010000, 0x00101100, 0x01000011,
0x00000000, 0x01111111, 0x00000100, 0x01111111, // 00d3h
0x00000100, 0x00000100, 0x00000100, 0x01111000,
0x00000000, 0x00000010, 0x01111111, 0x01000010, // 00d4h
0x00100010, 0x00010100, 0x00000100, 0x00000100,
0x00000000, 0x00000000, 0x00111110, 0x00100000, // 00d5h
0x00100000, 0x00100000, 0x00100000, 0x01111111,
0x00000000, 0x01111110, 0x01000000, 0x01000000, // 00d6h
0x01111110, 0x01000000, 0x01000000, 0x01111110,
0x00000000, 0x00111110, 0x00000000, 0x01111111, // 00d7h
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00d8h
0x01000010, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00001010, 0x00001010, 0x00001010, // 00d9h
0x01001010, 0x01001010, 0x00101010, 0x00011001,
0x00000000, 0x00000010, 0x00000010, 0x01000010, // 00dah
0x01000010, 0x00100010, 0x00010010, 0x00001110,
0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dbh
0x01000001, 0x01000001, 0x01000001, 0x01111111,
0x00000000, 0x01111111, 0x01000001, 0x01000001, // 00dch
0x01000000, 0x01000000, 0x00100000, 0x00011100,
0x00000000, 0x01000011, 0x01000100, 0x01000000, // 00ddh
0x01000000, 0x00100000, 0x00010000, 0x00001111,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00deh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, // 00dfh
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00011110, 0x00001000, 0x00000100, // 00e0h
0x00101001, 0x01010001, 0x01010001, 0x00001100,
0x00000000, 0x00000000, 0x00001100, 0x00010010, // 00e1h
0x00010010, 0x00100001, 0x01000000, 0x00000000,
0x00000000, 0x01111101, 0x00100001, 0x01111101, // 00e2h
0x00100001, 0x00111001, 0x01100101, 0x00011001,
0x00000000, 0x00111100, 0x00010000, 0x00111100, // 00e3h
0x00010000, 0x00011100, 0x00110010, 0x00001100,
0x00000000, 0x00001110, 0x00101000, 0x00101000, // 00e4h
0x00111110, 0x01100101, 0x00100101, 0x00010010,
0x00000000, 0x00000100, 0x00101111, 0x01000100, // 00e5h
0x00000110, 0x01000101, 0x01000101, 0x00111110,
0x00000000, 0x00100010, 0x00100010, 0x00111110, // 00e6h
0x01010010, 0x01010101, 0x01001101, 0x00100110,
0x00000000, 0x00000100, 0x00011111, 0x00000010, // 00e7h
0x00011111, 0x01000010, 0x01000010, 0x00111100,
0x00000000, 0x00010010, 0x00111110, 0x01010011, // 00e8h
0x01000010, 0x00100100, 0x00000100, 0x00000100,
0x00000000, 0x00001000, 0x00111101, 0x01001011, // 00e9h
0x01001001, 0x01001001, 0x00111000, 0x00000100,
0x00000000, 0x00001000, 0x00111000, 0x00001000, // 00eah
0x00001000, 0x00011110, 0x00101001, 0x00000110,
0x00000000, 0x00011000, 0x00100000, 0x00000100, // 00ebh
0x00111010, 0x01000110, 0x01000000, 0x00111000,
0x00000000, 0x01000010, 0x01000010, 0x01000010, // 00ech
0x01000110, 0x01000000, 0x00100000, 0x00011000,
0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00edh
0x01000011, 0x01001100, 0x01010010, 0x00111100,
0x00000000, 0x00100010, 0x00110011, 0x00101010, // 00eeh
0x00100110, 0x00100010, 0x00100011, 0x01000010,
0x00000000, 0x00111110, 0x00010000, 0x00111100, // 00efh
0x01000011, 0x01000000, 0x01000010, 0x00111100,
0x00000000, 0x00000010, 0x00111011, 0x01000110, // 00f0h
0x01000010, 0x01000011, 0x01000010, 0x00110010,
0x00000000, 0x00000100, 0x00000100, 0x00000010, // 00f1h
0x01000110, 0x01000101, 0x01000101, 0x00111001,
0x00000000, 0x01010100, 0x01111111, 0x00100100, // 00f2h
0x00100100, 0x00100100, 0x00100010, 0x00010001,
0x00000000, 0x01010100, 0x01011111, 0x00000100, // 00f3h
0x00111111, 0x00001000, 0x00001000, 0x00001000,
0x00000000, 0x01011110, 0x01100010, 0x00100010, // 00f4h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010010, 0x01111110, 0x00100010, // 00f5h
0x00100001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010000, 0x01111111, 0x00100000, // 00f6h
0x00100000, 0x00100000, 0x00100000, 0x00111111,
0x00000000, 0x01010010, 0x01010010, 0x00111111, // 00f7h
0x00010010, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x01010011, 0x01010100, 0x00100011, // 00f8h
0x00100100, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x01010000, 0x01011111, 0x00010000, // 00f9h
0x00001000, 0x00001100, 0x00010010, 0x00100001,
0x00000000, 0x01010010, 0x01111111, 0x00100010, // 00fah
0x00010010, 0x00000010, 0x00000010, 0x00111100,
0x00000000, 0x01010001, 0x01010010, 0x00100000, // 00fbh
0x00100000, 0x00010000, 0x00001000, 0x00000110,
0x00000000, 0x01011110, 0x01010010, 0x00100110, // 00fch
0x00111001, 0x00100000, 0x00010000, 0x00001100,
0x00000000, 0x01010000, 0x01011110, 0x00010000, // 00fdh
0x01111111, 0x00010000, 0x00010000, 0x00001100,
0x00000000, 0x00100101, 0x01001010, 0x00101010, // 00feh
0x00100000, 0x00010000, 0x00001000, 0x00000111,
0x00000000, 0x01011110, 0x01010000, 0x00111111, // 00ffh
0x00001000, 0x00001000, 0x00001000, 0x00000110
};
/*---------------------------------------------------------------------------*
Palette data
*---------------------------------------------------------------------------*/
const u32 d_PaletteData[8 * 16] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, // black
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x001f0000, 0x00000000, 0x00000000, 0x00000000, // red
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x03e00000, 0x00000000, 0x00000000, 0x00000000, // green
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x7c000000, 0x00000000, 0x00000000, 0x00000000, // blue
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x03ff0000, 0x00000000, 0x00000000, 0x00000000, // yellow
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x7c1f0000, 0x00000000, 0x00000000, 0x00000000, // purple
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x7fe00000, 0x00000000, 0x00000000, 0x00000000, // light blue
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00180000, 0x00000000, 0x00000000, 0x00000000, // dark red
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x03000000, 0x00000000, 0x00000000, 0x00000000, // dark green
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x60000000, 0x00000000, 0x00000000, 0x00000000, // dark blue
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x03180000, 0x00000000, 0x00000000, 0x00000000, // dark yellow
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x60180000, 0x00000000, 0x00000000, 0x00000000, // dark purple
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x63000000, 0x00000000, 0x00000000, 0x00000000, // dark light blue
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x56b50000, 0x00000000, 0x00000000, 0x00000000, // gray
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x2d6b0000, 0x00000000, 0x00000000, 0x00000000, // dark gray
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x7fff0000, 0x00000000, 0x00000000, 0x00000000, // white
0x00000000, 0x00000000, 0x00000000, 0x00000000
};
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*
Project: NitroSDK - SPI - demos - pm-1
File: font.h
Copyright 2003-2005 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: font.h,v $
Revision 1.2 2005/02/28 05:26:12 yosizaki
do-indent.
Revision 1.1 2004/08/07 01:59:51 yada
modified much
$NoKeywords: $
*---------------------------------------------------------------------------*/
#ifndef FONT_H_
#define FONT_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro/types.h>
typedef enum
{
FONT_BLOCK = 0,
FONT_RED = 1,
FONT_GREEN = 2,
FONT_BLUE = 3,
FONT_YELLOW = 4,
FONT_PURPLE = 5,
FONT_CYAAN = 6,
FONT_WHITE = 15
}
MYFontColor;
extern const u32 d_CharData[8 * 256];
extern const u32 d_PaletteData[8 * 16];
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* FONT_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------*
Project: NitroSDK - SPI - demos - pm-1
File: screen.h
Copyright 2003-2006 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: screen.h,v $
Revision 1.3 2006/01/18 02:12:28 kitase_hirotake
do-indent
Revision 1.2 2005/02/28 05:26:12 yosizaki
do-indent.
Revision 1.1 2004/08/07 01:59:51 yada
modified much
$NoKeywords: $
*---------------------------------------------------------------------------*/
#ifndef SCREEN_H_
#define SCREEN_H_
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
#include <nitro/types.h>
extern u16 gScreen[32 * 32];
void ClearScreen(void);
void PrintString(s16 x, s16 y, u8 palette, char *text, ...);
void ColorString(s16 x, s16 y, s16 length, u8 palette);
/*===========================================================================*/
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SCREEN_H_ */
/*---------------------------------------------------------------------------*
End of file
*---------------------------------------------------------------------------*/

View File

@ -0,0 +1,231 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - tools - ts_dev9
File: main.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm.h>
#include "font.h"
#include "screen.h"
//#define PRINT_DEBUG
#ifndef PRINT_DEBUG
#undef OS_TPrintf
#define OS_TPrintf(...) ((void)0)
#endif // PRINT_DEBUG
static void myInit(void);
static void myVBlankIntr(void);
/***************************************************************
PreInit
FromBootの対応OS_Init前に必要なメインメモリの初期化
***************************************************************/
static void PreInit(void)
{
/*
*/
// SHARED領域クリア
MI_CpuClearFast((void*)HW_WRAM_EX_LOCK_BUF, (HW_WRAM_EX_LOCK_BUF_END - HW_WRAM_EX_LOCK_BUF));
MI_CpuClearFast((void*)HW_BIOS_EXCP_STACK_MAIN, (HW_REAL_TIME_CLOCK_BUF - HW_BIOS_EXCP_STACK_MAIN));
MI_CpuClearFast((void*)HW_PXI_SIGNAL_PARAM_ARM9, (HW_MMEMCHECKER_MAIN - HW_PXI_SIGNAL_PARAM_ARM9));
MI_CpuClearFast((void*)HW_ROM_HEADER_BUF, (HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF));
// FromBrom全消去
MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) );
// ブートタイプの変更
( (OSBootInfo *)OS_GetBootInfo() )->boot_type = OS_BOOTTYPE_NAND;
}
/***************************************************************
PostInit
***************************************************************/
static void PostInit(void)
{
}
/***************************************************************
EraseAll
DSモードにして終わるのがよいか
***************************************************************/
static void EraseAll(void)
{
}
void TwlMain( void )
{
u32 len;
#define X_OFF 2
s16 y = 2;
PreInit();
myInit();
PostInit();
CARD_Init();
//---- clear screen buffer
ClearScreen();
PrintString( X_OFF, y, FONT_CYAAN, "NAND Firm Writer" );
PrintString( X_OFF+18, y++, FONT_YELLOW, "%s", __DATE__ );
PrintString( X_OFF+21, y++, FONT_YELLOW, "%s", __TIME__ );
OS_WaitVBlankIntr();
y++;
PXI_RecvStream(&len, sizeof(len));
PrintString( X_OFF, y++, FONT_WHITE, "Firm length: %d bytes", len );
OS_WaitVBlankIntr();
y++;
PrintString( X_OFF, y++, FONT_WHITE, "Load NAND Firm..." );
OS_WaitVBlankIntr();
if ( PXI_RecvID() != FIRM_PXI_ID_NULL )
{
goto err;
}
PrintString( X_OFF+20, y++, FONT_GREEN, "Done." );
PrintString( X_OFF, y++, FONT_WHITE, "Write NAND Firm..." );
OS_WaitVBlankIntr();
if ( PXI_RecvID() != FIRM_PXI_ID_NULL )
{
goto err;
}
PrintString( X_OFF+20, y++, FONT_GREEN, "Done." );
PrintString( X_OFF, y++, FONT_WHITE, "Verify NAND Firm..." );
OS_WaitVBlankIntr();
if ( PXI_RecvID() != FIRM_PXI_ID_NULL )
{
goto err;
}
PrintString( X_OFF+20, y++, FONT_GREEN, "Done." );
PrintString( X_OFF, 20, FONT_GREEN, "SUCCESS ALL!" );
do
{
OS_WaitVBlankIntr();
}
while ( PAD_DetectFold() && (PAD_Read() & PAD_ALL_MASK) == (PAD_BUTTON_START|PAD_BUTTON_SELECT|PAD_BUTTON_X));
PXI_NotifyID( FIRM_PXI_ID_NULL );
OS_Terminate();
err:
PrintString( X_OFF+20, y++, FONT_RED, "Failed." );
OS_WaitVBlankIntr();
PXI_NotifyID( FIRM_PXI_ID_ERR );
OS_Terminate();
}
//----------------------------------------------------------------
// myInit
//
void myInit(void)
{
//---- init
OS_InitFIRM();
OS_InitTick();
OS_InitAlarm();
FX_Init();
GX_Init();
GX_DispOff();
GXS_DispOff();
//---- init displaying
GX_SetBankForLCDC(GX_VRAM_LCDC_ALL);
MI_CpuClearFast((void *)HW_LCDC_VRAM, HW_LCDC_VRAM_SIZE);
(void)GX_DisableBankForLCDC();
MI_CpuFillFast((void *)HW_OAM, 192, HW_OAM_SIZE);
MI_CpuClearFast((void *)HW_PLTT, HW_PLTT_SIZE);
MI_CpuFillFast((void *)HW_DB_OAM, 192, HW_DB_OAM_SIZE);
MI_CpuClearFast((void *)HW_DB_PLTT, HW_DB_PLTT_SIZE);
//---- setting 2D for top screen
GX_SetBankForBG(GX_VRAM_BG_128_A);
G2_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256,
GX_BG_COLORMODE_16,
GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01);
G2_SetBG0Priority(0);
G2_BG0Mosaic(FALSE);
GX_SetGraphicsMode(GX_DISPMODE_GRAPHICS, GX_BGMODE_0, GX_BG0_AS_2D);
GX_SetVisiblePlane(GX_PLANEMASK_BG0);
GX_LoadBG0Char(d_CharData, 0, sizeof(d_CharData));
GX_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData));
//---- setting 2D for bottom screen
GX_SetBankForSubBG(GX_VRAM_SUB_BG_128_C);
G2S_SetBG0Control(GX_BG_SCRSIZE_TEXT_256x256,
GX_BG_COLORMODE_16,
GX_BG_SCRBASE_0xf800, GX_BG_CHARBASE_0x00000, GX_BG_EXTPLTT_01);
G2S_SetBG0Priority(0);
G2S_BG0Mosaic(FALSE);
GXS_SetGraphicsMode(GX_BGMODE_0);
GXS_SetVisiblePlane(GX_PLANEMASK_BG0);
GXS_LoadBG0Char(d_CharData, 0, sizeof(d_CharData));
GXS_LoadBGPltt(d_PaletteData, 0, sizeof(d_PaletteData));
//---- screen
MI_CpuFillFast((void *)gScreen, 0, sizeof(gScreen));
DC_FlushRange(gScreen, sizeof(gScreen));
/* DMA操作でIOレジスタへアクセスするのでキャッシュの Wait は不要 */
// DC_WaitWriteBufferEmpty();
GX_LoadBG0Scr(gScreen, 0, sizeof(gScreen));
GXS_LoadBG0Scr(gScreen, 0, sizeof(gScreen));
//---- init interrupt
OS_SetIrqFunction(OS_IE_V_BLANK, myVBlankIntr);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
//---- start displaying
GX_DispOn();
GXS_DispOn();
}
//----------------------------------------------------------------
// myVBlankIntr
// vblank interrupt handler
//
static void myVBlankIntr(void)
{
//---- upload pseudo screen to VRAM
DC_FlushRange(gScreen, sizeof(gScreen));
/* DMA操作でIOレジスタへアクセスするのでキャッシュの Wait は不要 */
// DC_WaitWriteBufferEmpty();
GX_LoadBG0Scr(gScreen, 0, sizeof(gScreen));
GXS_LoadBG0Scr(gScreen, 0, sizeof(gScreen));
OS_SetIrqCheckFlag(OS_IE_V_BLANK);
}

View File

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*
Project: NitroSDK - SPI - demos - pm-1
File: screen.c
Copyright 2003-2006 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: screen.c,v $
Revision 1.3 2006/01/18 02:12:28 kitase_hirotake
do-indent
Revision 1.2 2005/02/28 05:26:12 yosizaki
do-indent.
Revision 1.1 2004/08/07 01:59:51 yada
modified much
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <nitro.h>
#include "screen.h"
u16 gScreen[32 * 32];
//u16 gScreen2[ 32 * 32 ];
// ** these code are refer to rtc sample. thanks.
/*---------------------------------------------------------------------------*
Name: ClearScreen
Description: clear screen buffer
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ClearScreen(void)
{
MI_CpuClearFast((void *)gScreen, sizeof(gScreen));
}
/*---------------------------------------------------------------------------*
Name: PrintString
Description: enter string into screen buffer
string must be within 32 chars
Arguments: x : x
y : y
palette : color (0-15)
text : string. end mark is NULL
Returns: None.
*---------------------------------------------------------------------------*/
void PrintString(s16 x, s16 y, u8 palette, char *text, ...)
{
va_list vlist;
char temp[32 + 2], *tempPtr;
s32 i;
u16 *p, *pLimit;
va_start(vlist, text);
(void)vsnprintf(temp, 33, text, vlist);
va_end(vlist);
*(u16 *)(&temp[32]) = 0;
p = &gScreen[((y * 32) + x) % (32 * 32)];
pLimit = &gScreen[32 * 32];
tempPtr = &temp[0];
for (i = 0; *tempPtr; i++, tempPtr++)
{
*p = (u16)((palette << 12) | *tempPtr);
if (++p >= pLimit)
{
p = &gScreen[0];
}
}
}
/*---------------------------------------------------------------------------*
Name: ColorString
Description: change string color which is put in screen buffer
Arguments: x : x
y : y
length : number of characters to change color
palette : color (0-15)
Returns: None.
*---------------------------------------------------------------------------*/
void ColorString(s16 x, s16 y, s16 length, u8 palette)
{
s32 i;
u16 *p, *pLimit;
if (length < 0)
return;
p = &gScreen[((y * 32) + x) % (32 * 32)];
pLimit = &gScreen[32 * 32];
for (i = 0; i < length; i++)
{
u16 temp = *p;
temp &= 0x0fff;
temp |= (palette << 12);
*p = temp;
if (++p >= pLimit)
{
p = &gScreen[0];
}
}
}

View File

@ -0,0 +1,57 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - gcdfirm - sdmc-launcher-writer
# File: Makefile
#
# Copyright 2008 Nintendo. All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
# Company Ltd., and are protected by Federal copyright law. They may
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Date:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
SUBDIRS = \
wram_regs \
ARM7 \
ARM9 \
ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),)
TARGET_FIRM_BIN = sdmc_launcher_writer-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd
NANDFIRM_BIN = ../../nandfirm/sdmc-launcher/sdmc_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).nand
BINDIR = .
MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/sdmc_launcher_writer9.tef
MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher_writer7.tef
MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der
LDEPENDS_BIN += wram_regs/wram_regs.rbin
MAKEFIRM_FLAGS += -p
FIRM_SPEC = gcdfirm.gcdsf
MAKEFIRM_DEFS += -DNANDFIRM_BIN=$(NANDFIRM_BIN)
LDIRT_CLEAN += $(wildcard *.gcd) \
rsa_public.sbin \
endif
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
do-build: $(TARGET_BIN)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,57 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - nandfirm - menu-launcher
# File: Makefile
#
# Copyright 2007 Nintendo. All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
# Company Ltd., and are protected by Federal copyright law. They may
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Date:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
override TARGET_PLATFORM := TWL
override TARGET_CODEGEN := ARM
override TWL_ARCHGEN := LIMITED
override TARGET_FINALROM := TRUE
override TARGET_RELEASE :=
override TARGET_DEBUG :=
SUBDIRS =
LINCLUDES = ../include
#----------------------------------------------------------------------------
TARGET_BIN = wram_regs.rbin
SRCS = \
wram_regs.c \
#SRCDIR = # using default
#LCFILE = # using default
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
INSTALL_DIR = .
INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN)
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - tools - nandfirm
File: wram_regs.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl/mi.h>
#include <firm/format/wram_regs.h>
MIHeader_WramRegs wram_regs_init =
{
// ARM9
{
REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM9 ),
REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM9 ),
REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM9 ),
REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM9 ),
},
{
REG_MI_MBK_B0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ),
REG_MI_MBK_B1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ),
REG_MI_MBK_B2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ),
REG_MI_MBK_B3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ),
REG_MI_MBK_B4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ),
REG_MI_MBK_B5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ),
REG_MI_MBK_B6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ),
REG_MI_MBK_B7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ),
},
{
REG_MI_MBK_C0_FIELD( 1, MI_WRAM_BC_OFFSET_0KB , MI_WRAM_ARM7 ),
REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM7 ),
REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM7 ),
REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM7 ),
REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM7 ),
REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM7 ),
REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM7 ),
REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM7 ),
},
REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF ),
MI_WRAM_IMAGE_256KB,
REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_A_SIZE )
),
REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ),
MI_WRAM_IMAGE_256KB,
REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA )
),
REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ),
MI_WRAM_IMAGE_256KB,
REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL )
),
// ARM7
REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ),
MI_WRAM_IMAGE_256KB,
REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL )
),
REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA + HW_WRAM_B_SIZE ),
MI_WRAM_IMAGE_256KB,
REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA )
),
REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE ),
MI_WRAM_IMAGE_256KB,
REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF - HW_WRAM_SIZE - HW_WRAM_C_SIZE )
),
// WRAM Lock
{
0,
0,
0,
},
// WRAM-0/1
3,
// VRAM-C
7,
// VRAM-D
7,
};

View File

@ -12,8 +12,8 @@
# in whole or in part, without the prior written consent of Nintendo.
#
# $Date:: $
# $Rev:$
# $Author:$
# $Rev$
# $Author$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
@ -30,7 +30,7 @@ SUBDIRS_P = \
fatfs \
aes \
pm \
gcd \
nvram \
#----------------------------------------------------------------------------

View File

@ -1,149 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - libraries - GCD
File: blowfish.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm/gcd/blowfish.h>
#define MAXKEYBYTES 56 /* 448 bits */
#define N 16
static u32 F(const BLOWFISH_CTX *ctx, u32 x);
void InitBlowfish(BLOWFISH_CTX *ctx, const unsigned char *key, int keyLen)
{
int i, j, k;
u32 data, datal, datar;
j = 0;
for (i = 0; i < N + 2; ++i) {
data = 0x00000000;
for (k = 0; k < 4; ++k) {
data = (data << 8) | key[j];
j = j + 1;
if (j >= keyLen)
j = 0;
}
ctx->P[i] = ctx->P[i] ^ data;
}
datal = 0x00000000;
datar = 0x00000000;
for (i = 0; i < N + 2; i += 2) {
EncryptByBlowfish(ctx, &datal, &datar);
ctx->P[i] = datal;
ctx->P[i + 1] = datar;
}
for (i = 0; i < 4; ++i) {
for (j = 0; j < 256; j += 2) {
EncryptByBlowfish(ctx, &datal, &datar);
ctx->S[i][j] = datal;
ctx->S[i][j + 1] = datar;
}
}
}
void EncryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr)
{
u32 Xl;
u32 Xr;
u32 temp;
int i;
Xl = *xl;
Xr = *xr;
for (i = 0; i < N; ++i) {
Xl = Xl ^ ctx->P[i];
Xr = F(ctx, Xl) ^ Xr;
temp = Xl;
Xl = Xr;
Xr = temp;
}
temp = Xl;
Xl = Xr;
Xr = temp;
Xr = Xr ^ ctx->P[N];
Xl = Xl ^ ctx->P[N + 1];
*xl = Xl;
*xr = Xr;
}
void DecryptByBlowfish(const BLOWFISH_CTX *ctx, u32 *xl, u32 *xr)
{
u32 Xl;
u32 Xr;
u32 temp;
int i;
Xl = *xl;
Xr = *xr;
for (i = N + 1; i > 1; --i) {
Xl = Xl ^ ctx->P[i];
Xr = F(ctx, Xl) ^ Xr;
/* Exchange Xl and Xr */
temp = Xl;
Xl = Xr;
Xr = temp;
}
/* Exchange Xl and Xr */
temp = Xl;
Xl = Xr;
Xr = temp;
Xr = Xr ^ ctx->P[1];
Xl = Xl ^ ctx->P[0];
*xl = Xl;
*xr = Xr;
}
static u32 F(const BLOWFISH_CTX *ctx, u32 x) {
u32 a, b, c, d;
u32 y;
d = x & 0x00FF;
x >>= 8;
c = x & 0x00FF;
x >>= 8;
b = x & 0x00FF;
x >>= 8;
a = x & 0x00FF;
y = ctx->S[0][a] + ctx->S[1][b];
y = y ^ ctx->S[2][c];
y = y + ctx->S[3][d];
return y;
}

View File

@ -1,186 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - libraries - GCD
File: ds_blowfish.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm/gcd.h>
#include <firm/gcd/blowfish.h>
#ifdef PRINT_DEBUG
#define DBG_PRINTF vlink_dos_printf
#define DBG_CHAR vlink_dos_put_console
#else
#define DBG_PRINTF( ... ) ((void)0)
#define DBG_CHAR( c ) ((void)0)
#endif
static void my_memcopy(void *src, void *dst, int size);
// DS
static char *normal_mode_key ATTRIBUTE_ALIGN(4) = "NmMdOnly";
static char *png_off_key ATTRIBUTE_ALIGN(4) = "enPngOFF";
static char *encrypt_object_key ATTRIBUTE_ALIGN(4) = "encryObj";
extern GCDSharedWork GCDi_SharedWork[2];
extern GCDSecureWork GCDi_SecureWork[2];
static void GCDi_InitBlowfishKeyAndTableDS(BLOWFISH_CTX *ctx, u32 *keyBufp, s32 keyLen)
{
EncryptByBlowfish(ctx, &(keyBufp)[2], &(keyBufp)[1]);
EncryptByBlowfish(ctx, &(keyBufp)[1], &(keyBufp)[0]);
InitBlowfish(ctx, (u8 *)keyBufp, keyLen);
}
static void GCDi_MakeBlowfishTableDS(GCDSlot slot, BLOWFISH_CTX *tableBufp, const u32 *keyp, u32 *keyBufp, s32 keyLen)
{
const BLOWFISH_CTX *blowfishInitTablep = &GCDi_BlowfishInitTableDS;
GCDRomHeader *rh = GCDi_GetRomHeaderAddr( slot );
GCDSecureWork* sec = &GCDi_SecureWork[slot];
u32 *blowfishedKeyp;
MI_CpuCopy32((void *)blowfishInitTablep, (void *)tableBufp, sizeof(BLOWFISH_CTX));
keyBufp[0] = *keyp;
keyBufp[1] = (*keyp >> 1);
keyBufp[2] = (*keyp << 1);
GCDi_InitBlowfishKeyAndTableDS(tableBufp, keyBufp, keyLen);
*(u64 *)sec->cardNormalModeKey = *(u64 *)rh->l.romNormalModeKey;
blowfishedKeyp = sec->cardNormalModeKey;
DecryptByBlowfish(tableBufp, &(blowfishedKeyp)[1], &(blowfishedKeyp)[0]);
if (keyLen > 8) {
sec->isGenUnScrambleKey = 1;
}
GCDi_InitBlowfishKeyAndTableDS(tableBufp, keyBufp, keyLen);
}
void GCDi_InitCardOpBlowfishDS( GCDSlot slot )
{
GCDRomHeader *rh = GCDi_GetRomHeaderAddr( slot );
GCDSecureWork* sec = &GCDi_SecureWork[slot];
GCDi_MakeBlowfishTableDS(slot, &sec->blowfishCardTable, &rh->l.initialCode, sec->cardKeyBuf, 8);
}
static void GCDi_ChangeObjectTableDS(GCDSlot slot, s32 keyLen)
{
GCDSecureWork* sec = &GCDi_SecureWork[slot];
BLOWFISH_CTX *tableBufp = &sec->blowfishCardTable;
u32 *keyBufp = sec->cardKeyBuf;
keyBufp[1] = (keyBufp[1] << 1);
keyBufp[2] = (keyBufp[2] >> 1);
GCDi_InitBlowfishKeyAndTableDS(tableBufp, keyBufp, keyLen);
}
#define UNDEF_CODE 0xe7ffdeff
#define ENCRYPT_DEF_SIZE 0x800
/* あとで名前変える */
#define ENC_DESTINATION_BUF_SIZE 0x4000
static u32 encDestBuf[ENC_DESTINATION_BUF_SIZE/sizeof(u32)];
void GCDi_DecryptObjectFileDS( GCDSlot slot )
{
GCDRomHeader *rh = GCDi_GetRomHeaderAddr( slot );
GCDSecureWork* sec = &GCDi_SecureWork[slot];
GCDSharedWork* sh = &GCDi_SharedWork[slot];
BLOWFISH_CTX *tableBufp = &sec->blowfishCardTable;
u32 *encBufp = (u32 *)&sec->blowfishFlashTable;
u32 *encDestp = (u32 *)rh->l.arm9.ramAddr;
s32 size = sec->secureSize;
s32 restSize;
BOOL exist = TRUE;
int i;
sec->enableReadSecure = 1; // SECURE領域リード・イネーブル
encDestp = GCDi_SecureAreaBuf[slot];
encBufp = encDestBuf;
if (size > ENCRYPT_DEF_SIZE) {
size = ENCRYPT_DEF_SIZE;
}
restSize = size;
if (sec->enableReadSecure) {
MI_CpuCopy32(encDestp, encBufp, (u32)size);
DBG_PRINTF("%s %d\n",__FUNCTION__,__LINE__);
DecryptByBlowfish(tableBufp, &(encBufp)[1], &(encBufp)[0]);
}
GCDi_ChangeObjectTableDS( slot, 8 );
if (sec->enableReadSecure) {
DecryptByBlowfish(tableBufp, &(encBufp)[1], &(encBufp)[0]);
DBG_PRINTF("%s %d\n",__FUNCTION__,__LINE__);
#if 1
for ( i=0; i<8; i++ )
{
if ( encrypt_object_key[i] != ((char*)encBufp)[i] )
{
exist = FALSE;
break;
}
}
// 暗号化オブジェクト有効時
if ( exist )
{
#else
if ((encBufp[0] == encrypt_object_key[0]) // 暗号化オブジェクト有効時
&& (encBufp[1] == encrypt_object_key[1])) {
#endif
u32 *bufp = encBufp;
bufp[0] = UNDEF_CODE;
bufp[1] = UNDEF_CODE;
while ((restSize -= 8) > 0) {
bufp += 2; // 復号処理
DecryptByBlowfish(tableBufp, &(bufp)[1], &(bufp)[0]);
}
DBG_PRINTF("SUCCESS %s %d\n",__FUNCTION__,__LINE__);
}
else {
DBG_PRINTF("ERROR %s %d\n",__FUNCTION__,__LINE__);
// CpuClearFast32(UNDEF_CODE, encBufp, size); // 未定義コードでクリア
sh->disableEncryptedCardData = 1; // 暗号化オブジェクト無効 通知
}
MI_CpuCopy32(encBufp, encDestp, (u32)size);
DBG_PRINTF("%s %d\n",__FUNCTION__,__LINE__);
}
}
/***************************************************
utility functions
***************************************************/
static void my_memcopy(void *src, void *dst, int size)
{
u8 *s,*d;
int i;
s = (u8 *)src;
d = (u8 *)dst;
for( i = 0 ; i < size ; i++ ) {
*d++ = *s++;
}
}

View File

@ -1,286 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - libraries - GCD
File: ds_blowfish_table.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm/gcd/blowfish.h>
const BLOWFISH_CTX GCDi_BlowfishInitTableDS = {
0x5f20d599, 0xb9f54457, 0xd9a4196e, 0x945a6a9e,
0xebf1aed8, 0x3ae27541, 0x32d08293, 0xd531ee33,
0x9a6157cc, 0x1ba20637, 0xf5723979, 0xbef6ae55,
0xfb691b5f, 0xe9f19de5, 0xa1d92cce, 0xe605325e,
0xcffed3fe, 0x0d0462d4 ,
0xb7ecf58b, 0xbb79602b, 0x0d319512, 0x2bda3f6e,
0xf1f08488, 0x257e123d, 0xbbf12245, 0x061a0624,
0x28dfad11, 0x3481648b, 0x2933eb2b, 0xbdf2aa99,
0x9d95149c, 0x8cf5f79f, 0x29a19772, 0xcf5fd19d,
0x1a074d66, 0x4b4ad3de, 0xa3a7c985, 0x3a059517,
0xbf0a493d, 0xa28b890a, 0xdd49824a, 0x0bf19027,
0x6a1cebe9, 0x05457683, 0x617081ba, 0xde4b3f17,
0x39abcfae, 0x563af257, 0x8aad1148, 0x3f45e140,
0x54029bfa, 0xfb93a6ca, 0x6ffe4def, 0x9c87d8a3,
0x48d5ba08, 0xfd2d8d6a, 0x74f8156e, 0x8b52bebd,
0x9e8a2218, 0x073774fb, 0x4a6c361b, 0x6242ba19,
0x109179b9, 0x9665677b, 0xe82302fe, 0x778c99ee,
0x64865c3e, 0x86786d4d, 0xe2654fa5, 0x5adfb21e,
0x087ed00a, 0xac71b014, 0x1c83dbbd, 0x62a1d7b9,
0x7c63c6cd, 0xe6c36952, 0x12ce75bf, 0x04215d44,
0x3cd3fbfa, 0xd4631138, 0x49418595, 0x08f20946,
0x1fdc1143, 0x6d15c076, 0x70633c1f, 0x6c8087ea,
0x8b63bdc3, 0x372137c2, 0x2309eedc, 0x4d6a372e,
0x50f79073, 0x921cac30, 0x91231004, 0xaa07d24f,
0x9a4f3e68, 0x6a6064c9, 0xf32114c8, 0x124122d6,
0xe6cf2444, 0x0ddd568a, 0x85e14d53, 0x5a528c1e,
0xc284199c, 0x6ff15703, 0x58be00e3, 0xd5ed4cf6,
0x1f9c6421, 0x3c0355be, 0xaaffdc4a, 0x5de0dac9,
0xdee6bf5e, 0xf8b1d8f5, 0xb9b336ff, 0xdb956762,
0xed375f31, 0x9967704c, 0x3118b590, 0x99993d6c,
0xd3da42e4, 0xa0134225, 0x6c70d7ae, 0xc7cf55b1,
0x43d546d7, 0x443d1761, 0x8533e928, 0x93a2d0d5,
0x1f1225aa, 0x460bc5fb, 0x567697f5, 0x87bea645,
0xe86b94b1, 0x9933feb1, 0x6c3e1fae, 0x091d7139,
0xe4379000, 0x74753e10, 0x3b838cff, 0xf9b0f1b0,
0x42470501, 0xacd6f195, 0x9ee6387e, 0x3f267495,
0x185068b4, 0xb43043d0, 0x68e34b4c, 0xb64de5bf,
0xa00a8b95, 0x77322574, 0x2cf7a1cf, 0x5a1371d8,
0x51c9eaab, 0xefee0de8, 0x197e93e9, 0x38431ea7,
0xa12c1681, 0xcc73e348, 0xd36c2129, 0xd9a0ce5d,
0xa0437161, 0x64b51315, 0x192acf92, 0xa5b7addc,
0xf865869f, 0xfbe79f1a, 0x13b8fdf7, 0x6fdb276c,
0xf71c35df, 0x9b5b2c8d, 0x6438ab12, 0x31decc06,
0x11754ee8, 0xeafae364, 0xc25434eb, 0xeb343fad,
0x267d2c93, 0xf3569d36, 0xb3f6e15a, 0x9e4a6398,
0x9ae48332, 0x907d6084, 0xee0e132e, 0xa2364b93,
0x3816ec85, 0x020688e8, 0x3aa0f0bf, 0x9a6ad7ed,
0xcf57e173, 0xdcb844f8, 0xd159232e, 0x715295df,
0x4ba06199, 0x786e7fd5, 0x30c5a9ba, 0x328640d3,
0x9c0c329d, 0x2f02b737, 0xa99854ba, 0xc90413c4,
0xe7c8be8d, 0x2e50975d, 0x5922d693, 0x22bc270c,
0x20a7e092, 0x7f6f930f, 0xb5d39f4c, 0x740b2aa6,
0x107d4967, 0xc5d1cb26, 0x8ce77186, 0x5be99ca0,
0x01f61ab2, 0x5e9e8cee, 0xdb1af283, 0x84eae5e6,
0x7cd27659, 0x49a58df6, 0x16c24836, 0xa383bb52,
0x0c07b974, 0x2861ff3b, 0xe4e961e1, 0xaa156eef,
0x5de8ba4e, 0x32bb9605, 0x72fbb056, 0xc80e0f52,
0x76652542, 0xdef2af89, 0x01f02710, 0x97a7744b,
0x5426d507, 0x821f0954, 0x307d860a, 0x26b30e39,
0xbb570b9b, 0xaf310636, 0xd9fc79fd, 0x0c2b1030,
0xd79be1b3, 0xef5fdc7b, 0x4513f8d2, 0xbd75474d,
0x7e3c9646, 0xb53ef375, 0x3b9ac567, 0x6b295bb0,
0xc85b80de, 0x31b10515, 0xdd49ceb6, 0xaeb584ad,
0x3167dc60, 0x4efe3034, 0xa62f80bd, 0x213963bf,
0x7f35d986, 0x05226816, 0x2690e954, 0x516c078c,
0xd75531a4, 0x3ea80709, 0xc166532e, 0xc47bf2f8,
0xf1cf58f2, 0xe7a2c587, 0x87308f27, 0x6264a058,
0x88b91823, 0xc4cefa7c, 0x17adae98, 0xf35b4acc,
0x56d548e9, 0xc8f20dd3, 0xdb8c7392, 0xac562fd7,
0x6992f981, 0xf632c64d, 0x218dc0e6, 0x618076e2,
0x6cdcbc11, 0x6919af93, 0xb9bfd09b, 0x67029f31,
0x83ee51a3, 0x0c7b2206, 0x404249ab, 0x7d01d5b8,
0x55f75ece, 0x99c53953, 0x9f87d846, 0xb464f7ba,
0xa1fa9ae3, 0x1068906d, 0x548aca30, 0xc3609fa7,
0x0d6bf519, 0xe698517a, 0xb4514398, 0x4fe935d6,
0x7b0fdfc3, 0xbd5c2fd6, 0x1961153a, 0xaacb4bf1,
0xc9646ddc, 0x561ec6d3, 0x504c38ef, 0xcc758671,
0xe94e0d0d, 0x5d06f628, 0xd3aa1b70, 0x39a8cf45,
0x2ea695ac, 0xd422e4b4, 0x5f37a874, 0xcc047a48,
0xd8404ca5, 0x0828b428, 0x52721c0d, 0x477df041,
0x4e533a19, 0x6b628458, 0x818ab593, 0xdc0d4e21,
0xc6a23fb4, 0x402bc9fc, 0xe90438da, 0x6b865a5e,
0x8525220c, 0x7c8d1168, 0x55951d92, 0xbb8eab4d,
0xb7e6a6da, 0x5a32b651, 0x05dd4105, 0x50560a2a,
0xcc471791, 0xb57ee6c9, 0x73db4a61, 0x33c85167,
0x746edaf5, 0x37c3542e, 0x08af6d0d, 0x5f8a15e8,
0xcd2159e2, 0x060cdea8, 0x5f6b775a, 0x3e6518db,
0x78de50c8, 0xb382b8e0, 0x32724e5d, 0x34c14f07,
0xb796ba23, 0x28a44e67, 0xeb62341e, 0xe9706a2d,
0x70c4422f, 0x9c315a4e, 0x28475bf9, 0x6f71daaa,
0x78b31f38, 0x1c6b92c4, 0x9a35f69e, 0xbf0e4db7,
0x412918cc, 0x5d354803, 0xc62bd055, 0x605caf29,
0x5e8e6974, 0xbdd47c9b, 0x7d64447b, 0x695d923f,
0x4b001fb6, 0xcf3583d4, 0x174e647e, 0x2ed58dae,
0x4e12289a, 0x08492b2e, 0x46c6ae5c, 0x6141ae85,
0xd2826f1e, 0x1f163751, 0xa459f60b, 0xaf5aca9a,
0x8b33d40d, 0x84f16320, 0xcfcb5c80, 0xd3b9b408,
0x62bd0516, 0x569b3183, 0xba9f9851, 0xb2aa5bb2,
0xb52c6b22, 0x63fa48d4, 0xfa585f2b, 0x0964fa61,
0xb8e038bb, 0xa860929d, 0x0e6f670d, 0x010df537,
0xd477c29f, 0x73f1ecfe, 0x7de03930, 0xe49861f5,
0x0455282c, 0x2fdb5556, 0x58e5ec6b, 0x8064b606,
0x4e1a2a6a, 0xc4d80f5b, 0x19522e0a, 0x30f562d9,
0x7b8cbe48, 0xa29b384f, 0xd3c9afc3, 0x4162c1c7,
0x2161b986, 0x4f996f57, 0x7bcebac1, 0x5e4d3bb5,
0x57448b8a, 0x705f135f, 0x47295b6d, 0xece238dc,
0x12655504, 0x4317e82a, 0x2add8ee1, 0xf794e2b3,
0xe65c6e09, 0x6df88aeb, 0x48544989, 0xbfad2ff5,
0xca4b94ea, 0x828739fc, 0xf2018a5f, 0x71e6f275,
0xde42d8d6, 0x281d2df1, 0xa37e88a6, 0x301d47a0,
0xdf71a3d9, 0x01cb1c49, 0xf2b136f8, 0x5d5822f0,
0xa0bd6b45, 0x4288b2bb, 0xce288cc7, 0x6390e893,
0x897c9008, 0xb77df53c, 0x554f2d04, 0x7efd1651,
0xc1bee879, 0xf8d412f2, 0x230584b4, 0x2bd2cca0,
0xadabe1fd, 0x6c55d10d, 0x4d944123, 0x054f3777,
0x17bf0c28, 0x6c6712b3, 0xf75ac38c, 0x6d2a8441,
0x271294d0, 0x9cedb42c, 0x8247ec4d, 0xb967d597,
0x55c09d1b, 0x8ee57e07, 0x3ee7a8e2, 0x3a0ee412,
0x3455452a, 0x5a2df9a2, 0x7c52ab1b, 0x555f1083,
0x435af1d2, 0xa4a7c62b, 0xe8951589, 0xf89d4bb4,
0x609fe375, 0xe6d65b78, 0x21e6440d, 0x2247bd06,
0xad00a453, 0x8513438d, 0xfcaaf739, 0xed7baf38,
0x542be4fc, 0xfc4c9850, 0xdff78085, 0xe122803c,
0x24deda94, 0x397ab0c6, 0xa10fdc38, 0x6ff9f4a7,
0x8b571863, 0x2e2a4184, 0xd9f253d4, 0xddd00f00,
0xa6196e99, 0x5becd00a, 0xc0ab2458, 0xec6506cb,
0x9438131a, 0x2f03670a, 0x77e3f73f, 0xc6337744,
0xe3d03914, 0x7908a2c0, 0x579940bb, 0x90010b41,
0x48cce1cd, 0xafb3db67, 0x4cf37488, 0xb1728f82,
0xc42923b5, 0xfc196c12, 0x9ca4468e, 0x876525c4,
0x8abe6dd3, 0x38031193, 0xf32b83ed, 0xea93a446,
0x1d85533b, 0x08f1d4ce, 0xfced2783, 0xbc181a9b,
0xdcae8bf9, 0x3850ab24, 0x104b72e9, 0x467b1722,
0x6459ab5d, 0xf8ae40f3, 0xf9c8e5bb, 0x554e0326,
0xfeebeb7d, 0xe0e639f7, 0x2ebe110a, 0xed98ff28,
0x5642c9c0, 0x00fdc342, 0xa287aff6, 0x323f015b,
0x9a954792, 0x3d32a572, 0x9bd06bae, 0x9249d207,
0xfa4a78e3, 0xf27d06a1, 0x7477cf41, 0x0cb21404,
0x16648486, 0xa151bbd5, 0xd1f16fe5, 0x5ff7e2f2,
0xb84d2058, 0xddcfc757, 0x76bed8c5, 0x7e5ff63d,
0x888b2ae7, 0x3f381b24, 0x7723410e, 0xd44bf0f5,
0xa4fa1f0c, 0xcf5f800b, 0xdae0f645, 0x5359342f,
0x523c20fb, 0xb5355e62, 0x608bfe62, 0x5a86e363,
0xd16e1a15, 0x32bc4547, 0x3867ebb4, 0x336ee4ab,
0xa3edb53a, 0x4ee067ad, 0x62ee9541, 0x1d267162,
0x3062ef31, 0xac82d7af, 0x0405dcc2, 0xbf0797f5,
0x07235911, 0xe80264c0, 0xaf3ee597, 0xa659ac18,
0x90334a8b, 0x9c7c6e1c, 0x3c4c7e20, 0xbb64613e,
0x7e7c6bc5, 0x4cc59f3e, 0xf573ea9f, 0x4cc089d7,
0x2df4fbf4, 0x511b14ec, 0xc812c1d5, 0x4a0bdf10,
0x93bc9c8b, 0x3e3e6a45, 0xbaa9c17d, 0x07b4c1cd,
0x8668e1e4, 0x386db243, 0x5c0cfbf3, 0xde713766,
0xa06eef56, 0xa7654010, 0xbed0f798, 0x3637c80e,
0x7cca10ec, 0x1e84ab9c, 0x02761705, 0xaa524f1c,
0xa0c6c15f, 0x04d8b956, 0xa74d4484, 0x60ded859,
0x050e38e6, 0x3be1038f, 0x3304816d, 0xce0b306f,
0x33210569, 0x89bb26fb, 0x87aeb67d, 0xe007517e,
0x0a96f7ac, 0x5cc4f96b, 0x4744e41d, 0xe3fa5eb8,
0x42558478, 0xf75e484b, 0x8635477d, 0x05432b1d,
0xb88aec03, 0x763c061e, 0x431a480c, 0xed8ab7a7,
0x43c6131e, 0xdbef10ee, 0x833cfbec, 0xef4495b2,
0x4e5154d8, 0x1d44112d, 0x1e5936fb, 0xc3c1347a,
0x610057ca, 0x16a567ea, 0x55d0559b, 0x36d97fe1,
0xae7640d2, 0xb0ce01dc, 0xcbd5837a, 0x6bec9820,
0x349272c1, 0x375782f3, 0x36328a62, 0xae43900c,
0x789b5cae, 0x0265138e, 0xc17168fd, 0xa031b0fe,
0xc3b08224, 0xa76979b1, 0xd0ebd2f5, 0xdc32c082,
0x3c26c79e, 0xc1988d6d, 0xd0d422bb, 0x3eec330f,
0xdce1ccb9, 0x36774c6a, 0xbff91c14, 0x5f289f81,
0x29328571, 0xc4487590, 0xd8ce4ab3, 0x2f148f44,
0xef5740fd, 0xd97508aa, 0x6ed6d146, 0xc31f5532,
0x1f84fe18, 0xffd584fc, 0x481b5e71, 0x0e9586c3,
0xd3270828, 0x7b718338, 0x5463804c, 0xacb0569a,
0x31ca80cf, 0xf3feef09, 0x7e24afbe, 0x3f53fea6,
0x334a8dc2, 0xa622d168, 0xea7bad66, 0xb043b6de,
0x009525a1, 0x46753fa3, 0xec441114, 0x92bc95d7,
0x16a94ff0, 0x60976253, 0xf1410f2a, 0xeebe2471,
0xcd087f94, 0x85b39360, 0x3f00075b, 0x83280fd8,
0x9f69d19a, 0xc32edad1, 0xb9a20190, 0x662a4e6b,
0xa6aeda9d, 0x68d32aea, 0x9c0c0c2f, 0xed4a8cd2,
0x65579ee2, 0xa387099d, 0x5d32c4b4, 0x2b32d4c9,
0x1e71e0b1, 0x90e64d64, 0x401ee371, 0x84f37ded,
0x78c8ed0e, 0x71c0ae76, 0x05bb7227, 0xfb6402ea,
0xb56b48f3, 0xed3f9342, 0xd253139f, 0xec2afef7,
0xdb25471d, 0xc686913c, 0xfd11f08e, 0xf7367423,
0x7a9ef5a4, 0x4450537e, 0xd3ca47d4, 0xe66d38eb,
0x7f9471d9, 0x4b69c64a, 0xea52f411, 0xb08afe22,
0x598b6736, 0x2a80e6e8, 0x130465eb, 0x9edcecee,
0x05ecb15f, 0x9fe6596a, 0x896b595e, 0xca1af7bf,
0x6a5bf944, 0xe4038571, 0x70e06229, 0xcfc4416f,
0xe3ccb1b2, 0xa807a67e, 0x847fe787, 0x4b52db93,
0xdd7eec6c, 0x104824d4, 0x60049f69, 0x1848e674,
0xb92ce4f3, 0x7a502e4f, 0x6954d4df, 0xf3a78b2b,
0xf31fffce, 0x3901263e, 0x89849517, 0x4b4cf0b0,
0xc49f9182, 0xa59dac4b, 0x2517af74, 0xd332cac9,
0x848a89bc, 0xae0dcc89, 0x9cdba27c, 0xee91786a,
0x4e5d76ea, 0x69f56087, 0x02d46715, 0x3648afcf,
0x6fbfea07, 0x8f062d66, 0xf9fe9ac4, 0x758790f6,
0x0fadf7b8, 0x3d5a1076, 0xb32eb059, 0xcc2c35c7,
0xcb2b5670, 0xc59637e3, 0x8a1b462f, 0x88c74622,
0x983226a7, 0x2286df61, 0x2f1cf48a, 0xaa09a187,
0xd3aea9cc, 0x1c4500bd, 0x8687549a, 0xffef8752,
0x8fa18f1e, 0x355c89c1, 0x3a2dda1b, 0xc2b2162c,
0x78e256f1, 0x97636bc1, 0xc98f56c5, 0xaa2c7f32,
0xaca8a6af, 0x88229120, 0x8b60e4de, 0x25424bf9,
0x9c7fe31a, 0x3a89192c, 0x36d4057e, 0xc25869cc,
0x2f8b32c1, 0x7aeb8590, 0xa1a55039, 0x66c59227,
0x584f20b0, 0x4383557e, 0x9ce2452b, 0x9012d8e4,
0x5683162c, 0xb3037916, 0x18612dad, 0x371f131a,
0x739ce1e2, 0xfdd5807b, 0xfc87512d, 0x1fd7aa7b,
0xaf8e7a2c, 0xcdbb8df4, 0x727c1195, 0xe26fee0b,
0x37deafb9, 0x8d8cde83, 0xb7670562, 0x568dc696,
0x62d70db6, 0x3646d6ba, 0xe6c88ebd, 0x106c2aea,
0x5b6bff14, 0x463c82fa, 0x464330b1, 0x9b7d8a51,
0x79833e92, 0xb25d555b, 0x90ce5e6c, 0x98538e62,
0xe56d0dc9, 0xc5cd572d, 0xe1ba5781, 0x728fb8e8,
0xdc134fe5, 0x15719dea, 0x8811b210, 0x7fd409d5,
0x2c7f655b, 0x114c383b, 0xfb8d5068, 0xbf59b09e,
0x4a898094, 0x12181ac5, 0x4ad15389, 0x8ce82910,
0xeab6ec1c, 0x8b17c746, 0xa8311525, 0xb1436ba2,
0x0bdbe29d, 0x11b09b87, 0xd2710e04, 0x82897729,
0x7f41660a, 0xff480b1d, 0xfd24bb72, 0x9ba148c2,
0xce7f7bfe, 0xd986db88, 0xb01c3b85, 0x0733a8dc,
0xe32e51bf, 0x97009a0e, 0x97c0061e, 0xb6d89d43,
0x6786c445, 0x88f8005f, 0x9e52a49a, 0x838aaac7,
0x18c5ec75, 0x2fc3ceae, 0x18f92b1a, 0xf51aaeff,
0x33b50b53, 0xe8fda751, 0x64a2e1a8, 0x431722b6,
0xd80acc80, 0x40ba3bae, 0x4a92d9d7, 0x1004df89,
0x2b189bee, 0x8a69776a, 0xb9f9f468, 0x6e1521a2,
0x033b1ee6, 0x609b3062, 0x9b257e41, 0x52c58f9e,
0xc2f80810, 0x1121a169, 0x795e3788, 0x10ff6635,
0xed6e1842, 0x1c6bb697, 0x6de5364e, 0xbfe4b47d,
0x05e0b920, 0xb8d5693a, 0xe0dcd5e3, 0x3e53acb9,
0xad57a407, 0x1848ff77, 0x49ac2a76, 0x75478e2a,
0x63679f6d, 0x398c3530, 0x6fd53905, 0xad5b3a64,
0x82bb0bca, 0xb1459952, 0x99363693, 0x442013af,
0x4402d836, 0x85923909, 0x974a4aff, 0xd763a687,
0x24b5b5c7, 0x6fb40fed, 0x1452580c, 0xd37ba6d9,
0x5838bc79, 0x843bbda1, 0x061ad806, 0xeaa86bfd,
0x0428694b, 0x9982ad37, 0x851b0efb, 0x735da8bd,
0x7558dccd, 0x6c63be0a, 0xe44ce748, 0x60042b30,
0xdad815b9, 0x8f758186, 0x1c8dd496, 0x7c85705d,
0xd57b671c, 0xcea66708, 0x70660a4b, 0xd463e5b7,
0xea828a5b, 0xe2ca6710, 0x8517eff4, 0x8a5f2a2f,
0x6af88297, 0xea1034d6, 0x3c5cc9eb, 0x46f849e1,
0xf6bddeeb, 0xaaf192a9, 0xb018a0a6, 0x1f0fd33a,
0x31ff6ff3, 0xd3444345, 0x88f79a50, 0xcec19609,
0x2cf2cc76, 0x82adba2c, 0x84188f77, 0x9c07d2c0,
0x4e839036, 0x434fa50b, 0x78ab043e, 0x09fbd64f,
0xda902401, 0x613a3c6f, 0x4a697f0d, 0x02302beb,
0x84e0dbb4, 0x35d7eca9, 0x857d37bf, 0x4ea9ce58,
0xa8c780e4, 0x486730d3, 0x2faf29eb, 0xa7b46a74,
0x923f0f3f, 0xaccaf3af, 0x94d94baf, 0x81ca43c0,
0xa1482f0d, 0xd2d527b0, 0x85054bef, 0x934ddea3,
0xbbf03c30, 0x27308f4a, 0x3ee3eb4c, 0x2f9aed64,
0xf082f13b, 0x7fcff4ba, 0xe1b0cb40, 0x57aabc7f,
0xf274c9d3, 0x220d43fa, 0x4e77f4d0, 0x7085d793,
0xb6bf991f, 0x30f135de, 0xf0715ea7, 0x7b2d016b,
0x5333f064, 0xf388390a, 0x6ba63a6b, 0x432fd235,
0xb5fd02cd, 0xaa5bbce9, 0x7e19a4d8, 0x81945d0e,
0xad776f9e, 0x93740ed6, 0x18c4e796, 0x19f5ad5f
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# Project: TwlSDK - libraries - spi
# File: Makefile
#
# Copyright 2007 Nintendo. All rights reserved.
# Copyright 2003 Nintendo. All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
@ -27,14 +27,11 @@ TWL_PROC = ARM7
SRCDIR = . ../common
SRCS = \
gcd.c \
gcd_init.c \
blowfish.c \
ds_blowfish.c \
ds_blowfish_table.c \
nvram_misc.c \
TARGET_LIB = libgcd_sp$(FIRM_LIBSUFFIX).a
TARGET_LIB = libnvram_sp$(FIRM_LIBSUFFIX).a
INCDIR = ../include
LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include ../common/include
#----------------------------------------------------------------------------

View File

@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------*
Project: TwlBromSDK - libraries -
File: nvram_misc.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm/nvram.h>
#include "spi_sp.h"
#include "nvram_sp.h"
/*---------------------------------------------------------------------------*
Name: NvramCheckReadyToRead
Description: NVRAMを読み出し可能な状態かどうか確認する
Arguments: None.
Returns: BOOL - TRUEを返す
FALSEの場合は読み出し禁止の状態
*---------------------------------------------------------------------------*/
static BOOL NvramCheckReadyToRead(void)
{
u16 tempStatus;
// ステータスレジスタ読み出し
NVRAM_ReadStatusRegister((u8 *)(&tempStatus));
// 書き込みもしくは消去操作中かを確認
if (tempStatus & NVRAM_STATUS_REGISTER_WIP)
{
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: NvramCheckReadyToWrite
Description: NVRAMを書き込み可能な状態かどうか確認する
Arguments: None.
Returns: BOOL - TRUEを返す
FALSEの場合は書き込み禁止の状態
*---------------------------------------------------------------------------*/
static BOOL NvramCheckReadyToWrite(void)
{
u16 tempStatus;
// ステータスレジスタ読み出し
NVRAM_ReadStatusRegister((u8 *)(&tempStatus));
// 書き込みもしくは消去操作中かを確認
if (tempStatus & NVRAM_STATUS_REGISTER_WIP)
{
return FALSE;
}
// 書き込み許可されているかを確認
if (!(tempStatus & NVRAM_STATUS_REGISTER_WEL))
{
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: NVRAM_WaitOperation
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void NVRAM_WaitOperation(void)
{
while( NvramCheckReadyToRead() == FALSE ) {
}
}
/*---------------------------------------------------------------------------*
Name: NVRAM_WaitWriteEnable
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void NVRAM_WaitWriteEnable(void)
{
while( NvramCheckReadyToWrite() == FALSE ) {
}
}
/*---------------------------------------------------------------------------*
Name: NVRAMi_Read
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void NVRAMi_Read(u32 address, void *buf, u32 size)
{
NVRAM_WaitOperation();
NVRAM_ReadDataBytes(address, size, buf);
return;
}
/*---------------------------------------------------------------------------*
Name: NVRAMi_Write
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void NVRAMi_Write(u32 address, void *buf, u32 size)
{
u32 i;
u32 page_start;
u32 page_end;
u32 offset_start;
u32 offset_end;
u8 *src_ptr;
u8 temp_buffer[SPI_NVRAM_PAGE_SIZE];
src_ptr = (u8 *)buf;
page_start = (address / SPI_NVRAM_PAGE_SIZE) * SPI_NVRAM_PAGE_SIZE;
page_end = ((address+size-1) / SPI_NVRAM_PAGE_SIZE ) * SPI_NVRAM_PAGE_SIZE;
offset_start = address % SPI_NVRAM_PAGE_SIZE;
offset_end = (address+size-1) % SPI_NVRAM_PAGE_SIZE;
while( page_start <= page_end ) {
if( offset_start != 0 ) {
NVRAMi_Read(page_start, temp_buffer, offset_start);
}
if( page_start != page_end ) {
for( i = offset_start ; i < SPI_NVRAM_PAGE_SIZE ; i++ ) {
temp_buffer[i] = *src_ptr++;
}
}
else {
for( i = offset_start ; i <= offset_end ; i++ ) {
temp_buffer[i] = *src_ptr++;
}
if( offset_end != (SPI_NVRAM_PAGE_SIZE-1) ) {
NVRAMi_Read(page_start+offset_end+1, &(temp_buffer[offset_end+1]), SPI_NVRAM_PAGE_SIZE - (offset_end+1) );
}
}
NVRAM_WriteEnable();
NVRAM_WaitWriteEnable();
NVRAM_PageErase((u32)page_start);
NVRAM_WaitOperation();
NVRAM_WriteEnable();
NVRAM_PageWrite((u32)page_start, (u16)SPI_NVRAM_PAGE_SIZE, temp_buffer);
NVRAM_WaitOperation();
page_start += SPI_NVRAM_PAGE_SIZE;
offset_start = 0;
}
}

View File

@ -1,9 +1,9 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - gcd
# Project: TwlIPL - libraries - nvram
# File: Makefile
#
# Copyright 2007 Nintendo. All rights reserved.
# Copyright 2008 Nintendo. All rights reserved.
#
# These coded instructions, statements, and computer programs contain
# proprietary information of Nintendo of America Inc. and/or Nintendo
@ -11,8 +11,9 @@
# not be disclosed to third parties or copied or duplicated in any form,
# in whole or in part, without the prior written consent of Nintendo.
#
# $Log: $
# $NoKeywords: $
# $Date:: $
# $Rev$
# $Author$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
@ -20,11 +21,7 @@ include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = ARM9
#ifdef TWL_WITH_ARM7
SUBDIRS += ARM7
#endif
SUBDIRS = ARM7
#----------------------------------------------------------------------------

View File

@ -27,6 +27,7 @@
#include <firm/aes.h>
#include <firm/fatfs.h>
#include <firm/fs.h>
#include <firm/nvram.h>
/* FIRM_H_ */
#endif

View File

@ -1,26 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - GCD
File: gcd.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2007-09-06$
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef FIRM_GCD_H_
#define FIRM_GCD_H_
//#include <firm/card/rom.h>
#include <firm/gcd/gcd.h>
#include <firm/gcd/gcd_misc.h>
/* FIRM_GCD_H_ */
#endif

View File

@ -1,779 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - GCD - include
File: gcd.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2007-09-06$
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef FIRM_GCD_GCD_H_
#define FIRM_GCD_GCD_H_
#include <twl/misc.h>
#include <twl/types.h>
#include <firm/memorymap.h>
#include <firm/mi.h>
#include <firm/gcd/blowfish.h>
#include <firm/format/wram_regs.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
GCD_PRIMARY_SLOT = 0,
GCD_SECONDARY_SLOT = 1,
GCD_NO_SLOT = -1
}
GCDSlot;
/*****************/
/* ROMヘッダ・ブートパラメータ構造体 */
typedef struct {
u8 *romAddr; // ROMアドレス
u8 *entryAddr; // エントリアドレス
u8 *ramAddr; // RAMアドレス
s32 romSize; // ROMサイズ
} GCDBootUsrParam;
// カードアクセス・コントロールレジスタ構造体
typedef struct {
u16 latency1:13; // レイテンシ1のサイクル数
u16 dataScramble_on:1; // データスクランブル
u16 scrambleUnit_on:1; // スクランブル回路
u16 initScramblePN:1; // スクランブルPNデータ初期化
u16 latency2:6; // レイテンシ2のサイクル数
u16 cmdScramble_on:1; // コマンドスクランブル
u16 dataReady:1; // データ レディ
u16 pages:3; // ページ数
u16 clockType:1; // クロックタイプ(150ns/240ns)
u16 clockInLatency:1; // レイテンシ期間にクロック供給
u16 reset:1; // リセット信号
u16 accessMode:1; // アクセスモード
u16 start:1; // スタート
} GCDCardCnt;
// カードコントロール・パラメータ構造体
typedef struct {
// u32 dmaNo; // DMA番号
u32 cardCnt; // カードコントロール
u32 op[2]; // コマンド
} GCDCardCtrlParam;
/* ROMヘッダ構造体 */
typedef struct {
s8 titleName[12]; // ソフトタイトル名
u32 initialCode; // イニシャルコード
u16 makerCode; // メーカーコード
u8 machineCode; // 本体コード
u8 deviceType; // デバイスタイプ
u8 nonVerReserved[4]; // 予約4バイト
u8 verDepReserved[4]; // 予約バージョン依存、4バイト
u16 wirelessSerialNo;
u16 softVersion:8; // ソフトバージョン
u16 compArm9BootArea:1; // ARM9ブートエリア圧縮フラグ
u16 compArm7BootArea:1; // ARM7ブートエリア圧縮フラグ
u16 :0;
GCDBootUsrParam arm9; // ARM9ブート領域パラメータ
GCDBootUsrParam arm7; // ARM7ブート領域パラメータ
u32 fileSysReserved[8]; // ファイルシステム予約32バイト
GCDCardCnt romCtrl4Game; // ROMコントロール情報NORMAL & GAMEモード
GCDCardCnt romCtrl4Secure; // SECUREモード
u8 romCtrlReserved_l[4]; // 予約
u16 secureCRC16; // セキュア領域CRC16bit
u16 romTimerLatency; // タイマーレイテンシ((サイクル数/256) - 2、3Dメモリ用
u8 romReserved_h[8]; // 予約
u32 romNormalModeKey[2]; // NORMALモード判定キー
u8 reserved_80h[0x10]; // 予約領域16バイト
u16 normalAreaOffset; // NORMAL領域
u16 twlAreaOffset; // TWL専用領域
u8 reserved_94h[0x2c]; // 予約領域44バイト
u16 nintendoLogo[0x9c/2]; // NINTENDOロゴ156バイト
u16 ninLogoCRC16; // NINTENDOロゴCRC16
u16 headerCRC16; // ヘッダCRC16
u8 *dbgRomAddr; // デバッガモニタROMアドレス
s32 dbgRomSize; // デバッガモニタROMサイズ
u8 *dbgArm9RamAddr; // デバッガモニタARM9-RAMアドレス
u8 *dbgArm7RamAddr; // デバッガモニタARM7-RAMアドレス
u8 reserved_170h[0x10]; // 予約領域16バイト
}
GCDRomHeaderDS;
typedef struct {
// DS互換
GCDRomHeaderDS l;
// TWL拡張
MIHeader_WramRegs w;
u8 reserved_1b0h[0x10]; // 予約領域16バイト
GCDBootUsrParam arm9ex; // ARM9拡張ブート領域パラメータ
GCDBootUsrParam arm7ex; // ARM7拡張ブート領域パラメータ
u8 reserved_1e0h[0x1000 - 0x1e0 - 0x200]; // 予約領域
u8 acsign_contents[0x180]; // コンテンツ証明書
u8 acsign_header[0x80]; // ROMヘッダ電子署名
}
GCDRomHeader;
/* セキュアワーク構造体 */
typedef struct {
u8 recvRtcBuf[8]; // RTCデータ受信バッファ要4バイト境界
#if 0
u16 flashCrc16; // フラッシュメモリCRC16
u16 flashCount; // フラッシュメモリ 8バイトカウント
u32 flashBuf[2]; // フラッシュメモリ受信バッファ要4バイト境界
u32 flashKeyBuf[3]; // フラッシュメモリキー・テンポラリバッファ
#endif
u32 unScrambleKey[2]; // スクランブル解除キー8バイト、MakeBlowfishTable() で算出)
s16 isGenUnScrambleKey; // スクランブル解除キー生成完了MakeBlowfishTable() で設定)
u32 va; // 下位24bit24bit送信
u32 vb; // 中間20bit+未定義4bit、VBI: 32bit送信
u32 vc_dummy; // 下位16bit16bit送信
u32 vd; // 下位24bit24bit送信
GCDCardCnt cardCntBak4Secure; // SECUREコマンドパラメータ・バックアップ
s16 enableReadSecure; // SECURE領域リード・イネーブルLoadSecure4Card() で設定)
u32 cardNormalModeKey[2]; // NORMALモード判定キーMakeBlowfishTable() で算出)
u32 cardKeyBuf[3]; // カードキー・テンポラリバッファ
s32 secureSize; // SECURE領域サイズ
s16 sequenceNo4Secure; // シーケンス番号SECURE用
s16 segmentTblShift; // セグメント番号テーブルシフト値SECURE用
u8 *segmentTblp; // セグメントテーブルポインタSECURE用
s16 numSecureSegment; // SECUREセグメント数SECURE用
s16 segmentOffset; // セグメントオフセットSECURE用
s16 blockOffset; // ブロックオフセットSECURE用
// CardCtrlParam paramBak; // カードパラメータ 暗号化前バックアップSECURE用
BLOWFISH_CTX blowfishCardTable; // カード用Blowfishテーブル
BLOWFISH_CTX blowfishFlashTable;
u8 bufEnd[4]; // セキュアワーク最終データ
} GCDSecureWork;
/* 共有ワーク構造体 */
typedef struct {
u32 nCardID; // NORMALカードIDLoadCardHeader() で取得)
u32 sCardID; // SECUREカードIDCardTimerIntr4Secure() で取得)
u16 cardHeaderCrc16; // カードヘッダCRC16LoadCardHeader() で算出)
u16 cardSecureCrc16; // カードSECURE領域CRC16LoadSecure4Card() で算出)
s16 cardHeaderError; // カードヘッダエラーCheckCardHeader() で設定)
s16 disableEncryptedCardData;// カードSECURE領域暗号化データ無効DecryptObjectFile() で設定)
s16 cardSequenceNo; // カード読み込みシーケンス番号
s16 enableCardNormalOnly; // カードNORMALモードのみ有効LoadFlashDemo() で設定)
// s16 isOnDebugger; // デバッガ上で動作中か
// s16 rtcError; // RTCエラー
u32 recvRtc[2]; // RTCステータス1タイマーデータ要4バイト境界
} GCDSharedWork;
typedef union
{
u64 dw;
u8 b[8];
}
GCDCmd64;
typedef struct
{
u32 ctrl;
s32 cmdcount;
u32 latency;
u32 scramble;
u8 master;
u8 spi;
GCDSlot slot;
}
GCDCtrlRegs;
typedef struct
{
GCDCmd64 gcdOp;
u32 dmaNo;
u32 lastDmaNo;
BOOL ltckReq;
GCDCtrlRegs *gcdRegs;
GCDCtrlRegs nLoadTableRegs;
GCDCtrlRegs nSendOnlyOpRegs;
GCDCtrlRegs sSendOnlyOpRegs;
GCDCtrlRegs nIDRegs;
GCDCtrlRegs sIDRegs;
GCDCtrlRegs gIDRegs;
GCDCtrlRegs nReadShortHeaderRegs;
GCDCtrlRegs nReadRomRegs;
GCDCtrlRegs sReadRomRegs;
GCDCtrlRegs gReadRomRegs;
GCDCtrlRegs gWriteRomRegs;
}
GCDRomCtrls;
typedef void (* GCDRomFuncp)( u32 romp, void *ramp, s32 size );
typedef void (* GCDAsyncCoreFuncp)( GCDSlot slot, u32 romp, void *ramp, s32 size, GCDRomCtrls *ctrls );
typedef struct
{
u32 romp; // ROM offset
u8 *ramp; // RAM address
s32 restSize; // rest size
s32 oneShotSize; // one shot size
vs8 intrDone;
s8 isAsync;
volatile BOOL isPxiDone;
GCDRomCtrls ctrls;
GCDAsyncCoreFuncp funcp;
}
GCDWork;
#define GCD_DEFAULT_DMA_A_NO 7
#define GCD_DEFAULT_DMA_B_NO 6
#define GCD_CHATTERING_CYCLES 0x200U
#define GCD_ROM_PAGE_SIZE 0x200 // 512B
#define GCD_SECURE_SEGMENT_SIZE 0x1000 // 4KB
#define GCD_LOAD_TABLE_SIZE 0x2000 // 8KB
#define GCD_NML_AREA_ALIGN 0x80000 // 512KB
#define GCD_TWL_AREA_ALIGN 0x80000 // 512KB
#define GCD_SECURE2_AREA_SIZE 0x4000 // 16KB
#define GCD_SECURE2_AREA_OFFSET 0x3000 // 12KB
#define GCD_GAME2_AREA_OFFSET 0x7000 // 28KB
// ROM area
#define GCD_LOAD_TABLE_SIZE 0x2000 // 8KB
#define GCD_DS_ROM_HEADER_SIZE 0x200 // 512B
#define GCD_ROM_HEADER_SIZE 0x1000 // 4KB
#define GCD_SECURE_AREA_SIZE 0x4000 // 16KB
#define GCD_SECURE_AREA_OFFSET 0x4000
#define GCD_GAME_AREA_OFFSET 0x8000
// ROM command
#define GCDOP_BIT_NUM 64
// NORMAL mode
#define GCDOP_N_OP_MASK 0xff00000000000000ULL
#define GCDOP_N_OP_SIZE 8
#define GCDOP_N_OP_RD_ROM_ID 0x9000000000000000ULL
#define GCDOP_N_OP_RD_PAGE 0x0000000000000000ULL
#define GCDOP_N_OP_WR_PAGE 0x8000000000000000ULL
#define GCDOP_N_OP_LD_TABLE 0x9f00000000000000ULL
#define GCDOP_N_OP_CHG_MODE 0x3c00000000000000ULL
#define GCDOP_N_OP_CHG2_MODE 0x3d00000000000000ULL
#define GCDOP_N_RD_ROM_ID_PAD 0x00ffffffffffffffULL
#define GCDOP_N_RD_PAGE_PAD 0x00fffffeff00ffffULL
#define GCDOP_N_CHG_MODE_PAD 0x00000000f00000ffULL
#define GCDOP_N_CHG2_MODE_PAD GCDOP_N_CHG_MODE_PAD
#define GCDOP_N_RD_PAGE_ADDR_SHIFT 33
#define GCDOP_N_RD_PAGE_ADDR_SIZE 23
#define GCDOP_N_RD_PAGE_ADDR_MASK 0x00fffffe00000000ULL
#define GCDOP_N_VAE_SHIFT 32
#define GCDOP_N_VAE_SIZE 24
#define GCDOP_N_VAE_MASK 0x00ffffff00000000ULL
#define GCDOP_N_VBI_SHIFT 8
#define GCDOP_N_VBI_SIZE 20
#define GCDOP_N_VBI_MASK 0x000000000fffff00ULL
// SECURE mode
#define GCDOP_S_OP_MASK 0xf000000000000000ULL
#define GCDOP_S_OP_SIZE 4
#define GCDOP_S_OP_RD_ROM_ID 0x1000000000000000ULL
#define GCDOP_S_OP_RD_SEGMENT 0x2000000000000000ULL
#define GCDOP_S_OP_PNG_ON 0x4000000000000000ULL
#define GCDOP_S_OP_PNG_OFF 0x6000000000000000ULL
#define GCDOP_S_OP_CHG_MODE 0xa000000000000000ULL
#define GCDOP_S_VA_SHIFT GCDOP_S_VB_SIZE
#define GCDOP_S_VA_SIZE 24
#define GCDOP_S_VA_MASK 0x00000ffffff00000ULL
#define GCDOP_S_VB_SHIFT 0
#define GCDOP_S_VB_SIZE 20
#define GCDOP_S_VB_MASK 0x00000000000fffffULL
#define GCDOP_S_VC_SHIFT (GCDOP_S_VA_SIZE + GCDOP_S_VB_SIZE)
#define GCDOP_S_VC_SIZE 16
#define GCDOP_S_VC_MASK 0x0ffff00000000000ULL
#define GCDOP_S_VD_SHIFT GCDOP_S_VA_SHIFT
#define GCDOP_S_VD_SIZE GCDOP_S_VA_SIZE
#define GCDOP_S_VD_MASK GCDOP_S_VA_MASK
// GAME mode
#define GCDOP_G_OP_MASK 0xff00000000000000ULL
#define GCDOP_G_OP_SIZE 8
#define GCDOP_G_OP_RD_ROM_ID 0xb800000000000000ULL
#define GCDOP_G_OP_RD_ROM_UID 0xb900000000000000ULL
#define GCDOP_G_OP_RD_PAGE 0xb700000000000000ULL
#define GCDOP_G_OP_RD_CACHE_START 0x5800000000000000ULL
#define GCDOP_G_OP_RD_CACHE 0x6000000000000000ULL
#define GCDOP_G_OP_RD_CACHE_LAST 0x6800000000000000ULL
#define GCDOP_G_OP_WR_PAGE 0x8000000000000000ULL
#define GCDOP_G_RD_ROM_ID_PAD 0x00ffffffffffffffULL
#define GCDOP_G_RD_ROM_UID_PAD 0x00ffffffffffffffULL
#define GCDOP_G_RD_PAGE_PAD 0x00f0000000ffffffULL
#define GCDOP_G_RD_PAGE_ADDR_SHIFT 33
#define GCDOP_G_RD_PAGE_ADDR_SIZE 23
#define GCDOP_G_RD_PAGE_ADDR_MASK 0x000ffffe00000000ULL
// ROM ID
#define GCD_ROMID_1TROM_MASK 0x80000000UL
#define GCD_ROMID_TWLROM_MASK 0x40000000UL
#define GCD_ROMID_BADBLK_MASK 0x20000000UL
#define GCD_ROMID_SIZE_MASK 0x0000ff00UL
/*---------------------------------------------------------------------------*
Name: GCDi_ReadRomID
Description: read rom ID
sync version
Arguments: None
Returns: rom ID
*---------------------------------------------------------------------------*/
u32 GCDi_ReadRomID( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_ReadRom
Description: read rom data
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_ReadRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_ReadRomAsync
Description: read rom data
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_ReadRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_ReadNormalModeRom
Description: read rom data on normal mode
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_ReadNormalModeRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_ReadNormalModeRomAsync
Description: read rom data on normal mode
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ReadNormalModeRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_ReadGameModeRom
Description: read rom data on game mode
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_ReadGameModeRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_ReadGameModeRomAsync
Description: read rom data on game mode
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_ReadGameModeRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_WriteGameModeRom
Description: write rom data on game mode
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_WriteGameModeRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_WriteGameModeRomAsync
Description: write rom data on game mode
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_WriteGameModeRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_Enable
Description: Enable game card master control
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_Enable( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_Disable
Description: disable game card master control
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_Disable( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCD_SetPrimarySlot
Description: set primary game card slot
Arguments: primary slot
Returns: None
*---------------------------------------------------------------------------*/
void GCD_SetPrimarySlot( u8 slot );
/*---------------------------------------------------------------------------*
Name: GCD_GetPrimarySlot
Description: get primary game card slot
Arguments: None
Returns: primary slot
*---------------------------------------------------------------------------*/
u8 GCD_GetPrimarySlot(void );
/*---------------------------------------------------------------------------*
Name: GCD_Reset
Description: reset game card
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCD_Reset( GCDSlot slot, u32 chat_cycles );
/*---------------------------------------------------------------------------*
Name: GCD_Reset
Description: reset game card
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ResetAll( u32 chat_cycles );
/*---------------------------------------------------------------------------*
Name: GCDi_SelectRom
Description: select game card spi
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_SelectRom( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_SelectSpi
Description: select game card spi
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_SelectSpi( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_SetDmaNo
Description: set card dma number
Arguments: dmaNo : dma channel number
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_SetDmaNo( GCDSlot slot, u32 dmaNo );
/*---------------------------------------------------------------------------*
Name: GCDi_GetDmaNo
Description: get card dma number
Arguments: None
Returns: dmaNo : dma channel number
*---------------------------------------------------------------------------*/
u32 GCDi_GetDmaNo( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_InterruptHandler
Description: interrupt handler
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_InterruptHandlerPRIME( void );
void GCDi_InterruptHandlerSECOND( void );
void GCDi_InterruptHandlerCommon( GCDSlot slot );
//================================================================================
// WAIT/STOP
//================================================================================
/*---------------------------------------------------------------------------*
Name: GCDi_IsBusy
Description: check whether game card is busy or not
Arguments: None
Returns: TRUE if game card is busy, FALSE if not
*---------------------------------------------------------------------------*/
BOOL GCDi_IsBusy( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_IsDataReady
Description: check whether data is ready or not
Arguments: None
Returns: TRUE if game card is busy, FALSE if not
*---------------------------------------------------------------------------*/
BOOL GCDi_IsDataReady( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_Stop
Description: stop game card access
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_Stop( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_WaitCtrl
Description: wait while game card is busy
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_WaitCtrl( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_WaitData
Description: wait until data is ready
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_WaitData( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_WaitDma
Description: wait for stopping game card DMA
Arguments: dmaNo : DMA channel No.
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_WaitDma( GCDSlot slot, u32 dmaNo );
/*---------------------------------------------------------------------------*
Name: GCDi_WaitInterrupt
Description: wait for game card interrupt
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_WaitInterrupt( GCDSlot slot );
// internal
BOOL GCDi_IsSecureInitialized( GCDSlot slot );
BOOL GCDi_IsCtrApp( GCDSlot slot );
BOOL GCDi_IsDsApp( GCDSlot slot );
u32 GCDi_ReadNormalModeID( GCDSlot slot );
u32 GCDi_ReadSecureModeID( GCDSlot slot );
u32 GCDi_ReadGameModeID( GCDSlot slot );
u32 GCDi_ReadRomIDCore( GCDSlot slot, GCDRomCtrls *ctrls );
void GCDi_ReadRomCore( GCDSlot slot, void *ramp, s32 size, GCDRomCtrls *ctrls );
BOOL GCDi_ReadRomCommonPreCore( GCDSlot slot, u32 romp, void *ram, s32 size );
void GCDi_WriteRomCore( GCDSlot slot, void *ramp, s32 size, GCDRomCtrls *ctrls );
void GCDi_ReadNormalModeRomCore( GCDSlot slot, u32 romp, void *ramp, s32 size, GCDRomCtrls *ctrls );
void GCDi_InitSecureParam( GCDSlot slot, BOOL twl_ex );
void GCDi_InitPngIntf( GCDSlot slot );
void GCDi_SetInitCardOpBlowfish( void (*p)( void ) );
void GCDi_SetDecryptObjectFilep( void (*p)( void ) );
void GCDi_SetSetPngIntf( void (*p)( u32 pnA_l, u8 pnA_h, u32 pnB_l, u8 pnB_h ) );
void GCDi_SetReadSecureModeIDCorep( u32 (p)( GCDRomCtrls *ctrls ) );
void GCDi_SetReadSecureModeRomCorep( void (p)( u32 romp, void *ramp, s32 size, GCDRomCtrls *ctrls ) );
void GCDi_SetGetOneShotSizeFromCtrlp( s32 (p)( u32 ctrl ) );
void GCDi_SetSendOnlyCardOpCorep( void (*p)( GCDRomCtrls *ctrls ) );
void GCDi_ChangeIntoSecureMode( GCDSlot slot );
void GCDi_ChangeIntoSecure2Mode( GCDSlot slot );
void GCDi_SendPngON( GCDSlot slot );
void GCDi_SendPngOFF( GCDSlot slot );
void GCDi_ChangeIntoGameMode( GCDSlot slot );
void GCDi_ReadCardSegmentAsync4Secure( GCDSlot slot, BOOL twl_ex );
void GCDi_InitCardOpBlowfish( GCDSlot slot );
void GCDi_InitCardOpBlowfishDS( GCDSlot slot );
void GCDi_DecryptObjectFile( GCDSlot slot );
void GCDi_DecryptObjectFileDS( GCDSlot slot );
void GCD_SetInterrupt( GCDSlot slot, u32 romp, void *ramp, s32 size, GCDWork *wp );
void* GCDi_GetRomHeaderAddr( GCDSlot slot );
extern u32 GCDi_HeaderBuf[2][ GCD_ROM_HEADER_SIZE/sizeof(u32) ];
extern u32 GCDi_SecureAreaBuf[2][ GCD_SECURE_AREA_SIZE/sizeof(u32) ];
extern u32 GCDi_Secure2AreaBuf[2][ GCD_SECURE_AREA_SIZE/sizeof(u32) ];
extern GCDSharedWork GCDi_SharedWork[2];
extern GCDWork GCDi_Work[2];
// 初期化テーブル
extern const BLOWFISH_CTX GCDi_BlowfishInitTableDS;
extern const BLOWFISH_CTX GCDi_BlowfishInitTableGCDFIRM;
// ※SecondarySlotのカードロックが用意されていないので、とりあえずPrimarySlotと共用で。
s32 OS_LockExCard( u16 lockID );
s32 OS_UnlockExCard( u16 lockID );
#ifdef __cplusplus
} /* extern "C" */
#endif
/* FIRM_GCD_GCD_H_ */
#endif

View File

@ -1,516 +0,0 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - GCD - include
File: ngcd.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2007-09-06$
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef FIRM_GCD_GCD_MISC_H_
#define FIRM_GCD_GCD_MISC_H_
#include <firm/format/gcdfirm.h>
#include "./gcd.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PXI_FIFO_TAG_GCD PXI_FIFO_TAG_USER_1
#define reg_MI_MC_DET (*(REGType8v *) REG_MC_OFFSET)
#define reg_MI_MC_SWP (*(REGType8v *) ( REG_MC_OFFSET + 1 ) )
#define REG_MCCHAT_OFFSET 0x4012
#define REG_MCCHAT_ADDR (HW_REG_BASE + REG_MCCHAT_OFFSET)
#define reg_MI_MCCHAT (*( REGType16v *) REG_MCCHAT_ADDR)
/* MCSCRA_L */
#define REG_MCSCRA_L_OFFSET 0x1b0
#define REG_MCSCRA_L_ADDR (HW_REG_BASE + REG_MCSCRA_L_OFFSET)
#define reg_MI_MCSCRA_L (*( REGType32v *) REG_MCSCRA_L_ADDR)
/* MCSCRB_L */
#define REG_MCSCRB_L_OFFSET 0x1b4
#define REG_MCSCRB_L_ADDR (HW_REG_BASE + REG_MCSCRB_L_OFFSET)
#define reg_MI_MCSCRB_L (*( REGType32v *) REG_MCSCRB_L_ADDR)
/* MCSCRA_H */
#define REG_MCSCRA_H_OFFSET 0x1b8
#define REG_MCSCRA_H_ADDR (HW_REG_BASE + REG_MCSCRA_H_OFFSET)
#define reg_MI_MCSCRA_H (*( REGType8v *) REG_MCSCRA_H_ADDR)
/* MCSCRB_H */
#define REG_MCSCRB_H_OFFSET 0x1ba
#define REG_MCSCRB_H_ADDR (HW_REG_BASE + REG_MCSCRB_H_OFFSET)
#define reg_MI_MCSCRB_H (*( REGType8v *) REG_MCSCRB_H_ADDR)
#define REG_MI_MCCNT1_A_CSC_SHIFT 22
#define REG_MI_MCCNT1_A_CSC_SIZE 1
#define REG_MI_MCCNT1_A_CSC_MASK 0x00400000
#define REG_MI_MC_SWP_E_SHIFT 7
#define REG_MI_MC_SWP_E_SIZE 1
#define REG_MI_MC_SWP_E_MASK 0x80
typedef enum
{
GCD_PAGE_0 = 0x0UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_1 = 0x1UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_2 = 0x2UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_4 = 0x3UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_8 = 0x4UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_16 = 0x5UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_32 = 0x6UL << REG_MI_MCCNT1_A_PC_SHIFT,
GCD_PAGE_STAT = 0x7UL << REG_MI_MCCNT1_A_PC_SHIFT
}
GCDPageCount;
typedef enum
{
GCD_CKT_150NS = 0x0UL << REG_MI_MCCNT1_A_CT_SHIFT,
GCD_CKT_240NS = 0x1UL << REG_MI_MCCNT1_A_CT_SHIFT
}
GCDClockType;
typedef enum
{
GCD_RW_READ = 0x0UL << REG_MI_MCCNT1_WR_SHIFT,
GCD_RW_WRITE = 0x1UL << REG_MI_MCCNT1_WR_SHIFT
}
GCDRw;
typedef enum
{
GCD_RESET_LO = 0x0UL << REG_MI_MCCNT1_A_RESB_SHIFT,
GCD_RESET_HI = 0x1UL << REG_MI_MCCNT1_A_RESB_SHIFT
}
GCDReset;
typedef enum
{
#ifdef SDK_ARM9
GCD_LTCK_DISABLE = 0x0UL << REG_MI_MCCNT1_A_TRM_SHIFT,
GCD_LTCK_ENABLE = 0x1UL << REG_MI_MCCNT1_A_TRM_SHIFT
#else
GCD_LTCK_DISABLE = 0x0UL << REG_MI_MCCNT1_A_RTM_SHIFT,
GCD_LTCK_ENABLE = 0x1UL << REG_MI_MCCNT1_A_RTM_SHIFT
#endif
}
GCDLtClkEnable;
typedef struct
{
u32 ctrl;
u8 master;
u8 spi;
}
NGCDCtrlRegs;
// PXIでの通信プロトコル関連定義
#define GCD_PXI_COMMAND_MASK 0x0000003f // 開始ワードのコマンド部
#define GCD_PXI_COMMAND_SHIFT 0
#define GCD_PXI_COMMAND_SIZE 6
#define GCD_PXI_COMMAND_PARAM_MASK 0x03ffffc0 // 開始ワードのパラメータ部
#define GCD_PXI_COMMAND_PARAM_SHIFT 6
#define GCD_PXI_COMMAND_PARAM_SIZE 20
typedef union
{
struct
{
u32 cmd:GCD_PXI_COMMAND_SIZE;
u32 param:GCD_PXI_COMMAND_PARAM_SIZE-1;
u32 slot:1;
}
e;
u32 raw;
}
GCDPxiCmd;
// PXI経由で発行される命令
#define GCD_PXI_COMMAND_RESET 0x01
#define GCD_PXI_COMMAND_LOADED 0x02
/*---------------------------------------------------------------------------*
Name: GCD_Init
Description: initialize for game card access
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCD_Init( void );
/*---------------------------------------------------------------------------*
Name: GCDi_Init
Description: initialize for game card access
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_Init( BOOL reset );
/*---------------------------------------------------------------------------*
Name: GCD_ReadRomID
Description: read rom ID
sync version
Arguments: None
Returns: rom ID
*---------------------------------------------------------------------------*/
u32 GCD_ReadRomID( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCD_ReadRom
Description: read rom data
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ReadRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_ReadRomAsync
Description: read rom data
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ReadRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_ReadNormalModeRom
Description: read rom data on normal mode
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ReadNormalModeRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_ReadGameModeRom
Description: read rom data on game mode
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ReadGameModeRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_ReadRomPreCore
Description: read rom data
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
BOOL GCD_ReadRomPreCore( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_ReadGameModeRomAsync
Description: read rom data on game mode
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_ReadGameModeRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_WriteGameModeRom
Description: write rom data on game mode
sync version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_WriteGameModeRom( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCD_WriteGameModeRomAsync
Description: write rom data on game mode
async version
Arguments: romp : rom offset
ramp : ram destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
void GCD_WriteGameModeRomAsync( GCDSlot slot, u32 romp, void *ramp, s32 size );
/*---------------------------------------------------------------------------*
Name: GCDi_Enable
Description: Enable game card master control
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_Enable( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_Disable
Description: disable game card master control
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCDi_Disable( GCDSlot slot );
//================================================================================
// WAIT/STOP
//================================================================================
/*---------------------------------------------------------------------------*
Name: GCD_IsExisting
Description: get whether cartridge exists
Arguments: None
Returns: TRUE if game card is busy, FALSE if not
*---------------------------------------------------------------------------*/
static inline BOOL GCD_IsExisting( GCDSlot slot )
{
s32 ofs = (GCD_GetPrimarySlot() ^ slot) * 4;
s32 r = ~reg_MI_MC_DET & (REG_MI_MC_SL1_CDET_MASK << ofs);
return r >> (REG_MI_MC_SL1_CDET_SHIFT + ofs);
}
/*---------------------------------------------------------------------------*
Name: GCD_SetDetectMode
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static inline void GCD_SetDetectMode( GCDSlot slot, u32 mode )
{
s32 ofs = (GCD_GetPrimarySlot() ^ slot) * 4;
s32 others = reg_MI_MC_DET & ~(REG_MI_MC_SL1_MODE_MASK << ofs);
reg_MI_MC_DET = (u8)((mode << (REG_MI_MC_SL1_MODE_SHIFT + ofs)) | others);
}
/*---------------------------------------------------------------------------*
Name: GCD_GetDetectMode
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static inline u8 GCD_GetDetectMode( GCDSlot slot )
{
s32 ofs = (GCD_GetPrimarySlot() ^ slot) * 4;
return (u8)((reg_MI_MC_DET & (REG_MI_MC_SL1_MODE_MASK << ofs))
>> (REG_MI_MC_SL1_MODE_SHIFT + ofs));
}
/*---------------------------------------------------------------------------*
Name: GCD_SetChatCounter
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static inline void GCD_SetChatCounter( u16 value )
{
reg_MI_MCCHAT = value;
}
/*---------------------------------------------------------------------------*
Name: GCD_IsBusy
Description: check whether game card is busy or not
Arguments: None
Returns: TRUE if game card is busy, FALSE if not
*---------------------------------------------------------------------------*/
BOOL GCD_IsBusy( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCD_IsDataReady
Description: check whether data is ready or not
Arguments: None
Returns: TRUE if game card is busy, FALSE if not
*---------------------------------------------------------------------------*/
BOOL GCD_IsDataReady( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCD_Stop
Description: stop game card access
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCD_Stop( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCD_WaitRomAsync
Description: wait for game card async access
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void GCD_WaitRomAsync( GCDSlot slot );
/*---------------------------------------------------------------------------*
Name: GCDi_SelectRegAddr
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static inline void* GCDi_SelectRegAddr( GCDSlot slot, u32 base )
{
u32 addr = base;
if ( slot == GCD_SECONDARY_SLOT )
{
addr += REG_MCCNT0_B_ADDR - REG_MCCNT0_ADDR;
}
return (void*)addr;
}
/*---------------------------------------------------------------------------*
Name: GCDi_SelectIrqMask
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
static inline u32 GCDi_SelectIrqMask( GCDSlot slot, u32 base_mask )
{
u32 mask = base_mask;
if ( slot == GCD_SECONDARY_SLOT )
{
switch ( mask )
{
case OS_IE_CARD_DATA:
mask = OS_IE_CARD_B_DATA;
break;
case OS_IE_CARD_IREQ:
mask = OS_IE_CARD_B_IREQ;
break;
case OS_IE_CARD_A_DET:
mask = OS_IE_CARD_B_DET;
break;
}
}
return mask;
}
// internal
u32 GCD_ReadNormalModeID( GCDSlot slot );
u32 GCD_ReadSecureModeID( GCDSlot slot );
u32 GCD_ReadGameModeID( GCDSlot slot );
void GCDi_SetOp( GCDSlot slot, GCDCmd64* op );
void GCDi_SetCtrl( GCDSlot slot, GCDCtrlRegs* regs );
void GCDi_GenCtrl( GCDCtrlRegs* regs,
GCDRw rw,
GCDPageCount pcount,
GCDClockType ckt, u32 lt1, u32 lt2,
BOOL cpn, BOOL dpn, BOOL csc, BOOL dsc );
s32 GCDi_GetOneShotSizeFromCtrl( u32 ctrl );
void GCD_SendOnlyCardOpCore( GCDSlot slot, GCDRomCtrls *ctrls );
u32 GCDi_ReadRomIDCore( GCDSlot slot, GCDRomCtrls *ctrls );
void GCD_ReadRomCore( GCDSlot slot, u32 romp, void *ramp, s32 size, GCDRomCtrls *ctrls );
void GCD_WaitRomAsyncCore( GCDSlot slot );
void GCDi_WaitCtrl( GCDSlot slot );
void GCDi_WaitData( GCDSlot slot );
void GCDi_WaitDma( GCDSlot slot, u32 dmaNo );
void GCDi_WaitInterrupt( GCDSlot slot );
void GCDi_SendtoPxi(u32 data);
#ifdef __cplusplus
} /* extern "C" */
#endif
/* FIRM_GCD_GCD_MISC_H_ */
#endif