made a copy

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/branches/20080509_fatfs_in_wram_test@1297 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yoshida_teruhisa 2008-05-09 04:26:06 +00:00
commit f19a0a9863
793 changed files with 116961 additions and 0 deletions

33
Makefile Normal file
View File

@ -0,0 +1,33 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - build
# 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$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
export TWL_ARCHGEN = ALL
SUBDIRS = \
build
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

38
Makefile.full Normal file
View File

@ -0,0 +1,38 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - build
# File: Makefile.full
#
# 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_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
export TWL_ARCHGEN = ALL
export NITRO_WITHOUT_DEMOS = TRUE
SUBDIRS = \
$(ROOT)/build/libraries/reboot \
$(ROOT)/build/demos/gx/UnitTours/DEMOLib \
$(NITROSYSTEM_ROOT) \
build
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

38
Makefile.sysmenu Normal file
View File

@ -0,0 +1,38 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - build
# File: Makefile.sysmenu
#
# 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$
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
export TWL_ARCHGEN = ALL
SUBDIRS = \
build/tools \
build/libraries_sysmenu \
build/components \
build/systemmenu_RED
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
<外字インストール方法>
PC内に外字ファイルがない場合は、\WINNT\SYSTEM32フォルダ内のeudcedit.exe
を実行して、適当な外字を追加することで\WINNT\Fonts\EUDC.TTEファイルを生成
します。
cpeudc.exeを実行して、「このマシンの外字ファイルを取得する」を実行。
取得したEUDC.TTEファイルを削除して、添付のNITROIPL_Gaiji.tteをEUDC.tte
にリネームする。
cpeudc.exeを実行して、「外字ファイルをこのマシンにインストールする」
を実行。
※既に他の外字ファイルがインストールされていた場合にこの方法でインストール
すると、その外字は消えてしまいますのでご注意下さい。

View File

@ -0,0 +1,12 @@
外字コピー屋さん Version 2.5
外字コピー屋さんは、Windows の外字環境を別のマシンのWindowsにインストールするツールです。
 詳しい使用方法は、ヘルプファイルcpeudc.chmを参照してください。
なお、インストーラは用意しておりません。実行ファイルをお好きなフォルダにコピーしてお使いください。
著作権は、East Valleyにあります。
バグや不具合などありましたら、下記まで連絡ください。
http://www.eastvalley.or.jp/cpeudc/
alioth@eastvalley.or.jp

Binary file not shown.

View File

@ -0,0 +1,25 @@
---------------
このパッチは暫定的ながら NitroSystem を
TWL-SDK 上でビルド/使用できるようにするものです。
添付の zip ファイルを展開し既存の NitroSystem に上書きしてください。
注意
・TWLSYSTEM_ROOT 環境変数に NITROSYSTEM_ROOT 環境変数と
 同じ値を設定する必要があります。
・NitroSystem はビルドしなおす必要があります。
・snd, mcs ライブラリは使用できません。
・demo はそのままではビルドできません。
 TWL-SDK では nef が tef へ変更されたため
 TARGET_NEF が設定されているものは削除する必要があります。
----
demoのビルドを通す方法
LLIBRARY_DIRS = $(G2D_DEMOLIB)/lib/$(NITRO_BUILDTYPE)
LLIBRARY_DIRS = $(G2D_DEMOLIB)/$(LIBDIR)
TARGET_NEF = main.nef を削除。

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,51 @@
ステップ1: 親機を動作させ、ビーコンを送信する
1. 2MフラッシュサブカードのついたDSフラッシュカードを準備します
2. バックアップデバイスにBACKUPDATA_FOR_RED.binを書き込んでください
3. DSフラッシュカードにbasestation.srlを書き込んでください
4. DSフラッシュカードを通常のDSに挿し、起動してください
(IS-NITRO-DEBUGGERを使うとトラブルシュートがしやすくなります)
5. 下画面に「サーバとインターネット経由で通信中」と表示されたら正常にイ
ンターネットと通信できています
6. しばらくたつと下画面に「DSの接続を待っています」と表示されます
7. この状態で親機はAP情報ビーコンを送信しています。
ステップ2: WDS組み込み済み店頭ブラウザ(DS版)でビーコン送信が正常であるこ
とを確認する
1. DSフラッシュカードを準備します
2. DSフラッシュカードにbrowser.srlを書き込んでください
3. DSフラッシュカードを通常のDSに挿し、起動してください
(IS-NITRO-DEBUGGERを使うとトラブルシュートがしやすくなります)
4. DSは自動的に店頭配信サーバに接続します。体験版等をダウンロードする画
面が表示されれば正常です。
ステップ3: TWL用WDSライブラリのサンプルを動作させる
1. WDS080221.zipを解凍してください
2. WDS/WDSTest/bin/ARM9-TS.HYB/Release/main.srlをTWLデバッガで動かします
3. デバッグ画面にビーコンの内容が出力され、動作の確認は終了です
以下WDSライブラリの簡単な説明です。
WDSライブラリはWMライブラリのラッパーとして動作します。そのため非常にシ
ンプルな構造となっております。
関数のリファレンスに関してはWDS/include/WDS.hにDoxygen準拠のコメントが付
いていますので、そちらをご覧いただければよいかと思います。
WDSライブラリを動作させる流れは、
1. WDS_Initialize関数でライブラリを初期化します
2. WDS_StartScan関数でビーコンスキャン開始、この処理は非同期処理で、完了
時にユーザーが与えたコールバック関数が呼び出されます
3. スキャンは非常に短い時間で終了します。1回のスキャンではビーコンが取れ
ないことが多いため、ユーザーは想定するスキャン時間が過ぎるまで、スキャン
完了コールバックを受けたら、再びWDS_StartScan関数を呼び出すことを繰り返
します
4. WDS_GetApInfoNum関数を使い、取得できたビーコンの数を得ることができま
す。これとWDS_GetApInfoAll関数を組み合わせて、受信したビーコンの情報を取
り出してください。
5. DSであれば、取得したビーコンをDWC_SetSpecifyAp2関数に与えて呼び出すこ
とでACの自動接続先としてビーコンに含まれている情報を設定できるのですが、
TWLではDWCが移植されていないため、ここはコメントアウトされています。
というようなものです。WDS/WDSTest/src/main.cに非常にシンプルなソースがあ
りますので、確認にご利用下さい。

42
build/Makefile Normal file
View File

@ -0,0 +1,42 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - build
# 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$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = \
tools \
libraries \
libraries_sysmenu\
nandfirm \
components \
systemmenu_RED \
gcdfirm \
ifdef TWL_IPL_WITH_TESTS
SUBDIRS += tests
endif
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,41 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - commondefs - common definitions for build system
# File: commondefs
#
# 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 TWL_IPL_COMMONDEFS_
TWL_IPL_COMMONDEFS_ = TRUE
FIRM_USE_TWLSDK_KEYS = TRUE
ifeq ($(TARGET_FIRM),SYSTEMMENU)
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs.sysmenu
else
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs.firm
endif
ifdef FIRM_USE_TWLSDK_KEYS
MACRO_FLAGS += -DFIRM_USE_TWLSDK_KEYS=$(FIRM_USE_TWLSDK_KEYS)
endif
ifeq ($(TWL_IPL_RED_PRIVATE_ROOT),)
TWL_KEYSDIR := $(TWL_IPL_RED_ROOT)/keys/dummy
else
TWL_KEYSDIR := $(TWL_IPL_RED_PRIVATE_ROOT)/keys
endif
#----------------------------------------------------------------------------
endif # TWL_IPL_COMMONDEFS_
#----- End of commondefs -----

View File

@ -0,0 +1,140 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - commondefs - common definitions for build system
# File: commondefs
#
# 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 TWLFIRM_COMMONDEFS_
TWLFIRM_COMMONDEFS_ = TRUE
EMPTY ?=
SPACE ?= $(EMPTY) $(EMPTY)
TARGET_BIN ?= $(TARGET_FIRM_BIN)
#
# change default variables for product
#
override TARGET_PLATFORM := TWL
override TWL_ARCHGEN := LIMITED
override TWL_MEMSIZE := 16M
#----------------------------------------------------------------------------
### TWL-commondefs
#
include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot
#----------------------------------------------------------------------------
# TWL-FIRM path settings
#
FIRM_ROOT := $(call eupath,$(TWL_IPL_RED_ROOT))
FIRM_BUILDTOOLSDIR := $(FIRM_ROOT)/build/buildtools
FIRM_BUILDSETUPDIR := $(FIRM_ROOT)/build/buildsetup
FIRM_INCDIR := $(FIRM_ROOT)/include
FIRM_TOOLSDIR := $(FIRM_ROOT)/tools
FIRM_COMPONENTSDIR := $(FIRM_ROOT)/components
FIRM_ADDINS ?= $(FIRM_ROOT)/add-ins
FIRM_LIBDIR = $(FIRM_ROOT)/lib/$(TWL_LIBTYPE)
FIRM_LIBSUFFIX = .firm$(ARCHGEN_TYPE)$(CODEGEN_ARCH)
FIRM_SPECDIR := $(FIRM_INCDIR)/firm/specfiles
FIRM_LSFARCH = $(TWL_LIBARCH)-FIRM
FIRM_LCFARCH = $(FIRM_LSFARCH)
DEFAULT_FIRM_LCFILE = $(FIRM_SPECDIR)/$(FIRM_LCFARCH).lcf
DEFAULT_FIRM_LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(FIRM_LCFARCH).lcf.template
DEFAULT_FIRM_LCFILE_SPEC = $(FIRM_SPECDIR)/$(FIRM_LSFARCH).lsf
DEFAULT_FIRM_ROM_SPEC = $(FIRM_SPECDIR)/ROM-$(TWL_PLATFORM)-FIRM.rsf
### Compiler & Linker settings
# replace NitroSDK
DEFAULT_LCFILE_TEMPLATE = $(DEFAULT_FIRM_LCFILE_TEMPLATE)
DEFAULT_LCFILE_SPEC = $(DEFAULT_FIRM_LCFILE_SPEC)
DEFAULT_ROM_SPEC = $(DEFAULT_FIRM_ROM_SPEC)
LDEPENDS_LCF += $(FIRM_BUILDTOOLSDIR)/commondefs
LDEPENDS_RES += $(FIRM_BUILDTOOLSDIR)/commondefs
### SDK Library settings
ifeq ($(CODEGEN_PROC),ARM9)
FIRM_LIBS_BASE ?= \
libos \
libpxi \
libfs \
libfatfs \
libmi \
else # ($(CODEGEN_PROC),ARM7)
FIRM_LIBS_BASE ?= \
libos_sp \
libpxi_sp \
libfs_sp \
libaes_sp \
libpm_sp \
libnvram_sp \
endif
FIRM_LIBS ?= $(addsuffix $(FIRM_LIBSUFFIX).a,$(FIRM_LIBS_BASE))
#----------------------------------------------------------------------------
# MY BUILD TOOLS
#
MAKENORFIRM := $(FIRM_TOOLSDIR)/bin/makenorfirm.exe
MAKENANDFIRM := $(FIRM_TOOLSDIR)/bin/makenandfirm.exe
MAKEGCDFIRM := $(FIRM_TOOLSDIR)/bin/makegcdfirm.exe
OPENSSL := $(FIRM_TOOLSDIR)/openssl/openssl.exe
NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe
MAKEBANNER := $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe
MAKEFIRM_RSA_PRVKEY ?= $(FIRM_TOOLSDIR)/openssl/rsa_private.der
MAKEFIRM_RSA_PUBKEY ?= $(FIRM_TOOLSDIR)/openssl/rsa_public.der
MAKEFIRM_FLAGS ?=
#----------------------------------------------------------------------------
### Global Library resettings
GINCLUDES := $(FIRM_INCDIR) $(GINCLUDES)
GLIBRARY_DIRS := $(FIRM_LIBDIR) $(GLIBRARY_DIRS)
GLIBRARIES := $(FIRM_LIBS) $(GLIBRARIES)
#----------------------------------------------------------------------------
# TWLFIRM_INSTALL_ROOT
#
ifdef TWLFIRM_INSTALL_ROOT
TWLFIRM_INSTALL_ROOT_ := $(TWLFIRM_INSTALL_ROOT)
else
TWLFIRM_INSTALL_ROOT_ := $(TWL_IPL_RED_ROOT)
endif
FIRM_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWLFIRM_INSTALL_ROOT_)))
FIRM_INSTALL_INCDIR := $(FIRM_INSTALL_ROOT)/include
FIRM_INSTALL_TOOLSDIR := $(FIRM_INSTALL_ROOT)/tools
FIRM_INSTALL_LIBDIR = $(FIRM_INSTALL_ROOT)/lib/$(TWL_LIBTYPE)
FIRM_INSTALL_PROMDIR := $(FIRM_INSTALL_TOOLSDIR)/prom
FIRM_INSTALL_COMPONENTSDIR := $(FIRM_INSTALL_ROOT)/components
FIRM_INSTALL_ADDINS := $(FIRM_INSTALL_ROOT)/add-ins
#----------------------------------------------------------------------------
endif # TWLFIRM_COMMONDEFS_
#----- End of commondefs -----

View File

@ -0,0 +1,142 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - commondefs - common definitions for build system
# File: commondefs
#
# 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 TWL_SYSMENU_COMMONDEFS_
TWL_SYSMENU_COMMONDEFS_ = TRUE
#SYSMENU_DISABLE_TWL_BOOT = TRUE
#SYSMENU_DISABLE_RETAIL_BOOT = TRUE
NITRO_NO_STD_PCHDR = TRUE # プリコンパイルヘッダ抑止
EMPTY ?=
SPACE ?= $(EMPTY) $(EMPTY)
TWL_KEYSDIR ?= $(SYSMENU_ROOT)/keys/dummy
#----------------------------------------------------------------------------
### TWL-commondefs
#
#include $(TWLSDK_ROOT)/build/buildtools/commondefs
include $(NITROSYSTEM_ROOT)/build/buildtools/commondefs
# TwlSDK の TWLSYSTEM_* -> NITROSYSTEM_* 変更暫定対策
# NitroSystemパッチが更新されれば不要のはず
NITROSYSTEM_INCDIR ?= $(TWLSYSTEM_INCDIR)
NITROSYSTEM_LIBDIR ?= $(TWLSYSTEM_LIBDIR)
NITROSYSTEM_LIBS ?= $(TWLSYSTEM_LIBS)
#----------------------------------------------------------------------------
# TWL-SYSTEM-MENU path settings
#
#SYSMENU_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWL_IPL_RED_ROOT)))
SYSMENU_ROOT := $(call eupath,$(TWL_IPL_RED_ROOT))
SYSMENU_BUILDTOOLSDIR := $(SYSMENU_ROOT)/build/buildtools
SYSMENU_INCDIR := $(SYSMENU_ROOT)/include \
$(ROOT)/build/libraries/spi/ARM9/include \
$(ROOT)/build/libraries/os/common/include \
$(ROOT)/build/libraries/mb/common/include
SYSMENU_TOOLSDIR := $(SYSMENU_ROOT)/tools
SYSMENU_COMPONENTSDIR := $(SYSMENU_ROOT)/components
LDEPENDS_LCF += $(SYSMENU_BUILDTOOLSDIR)/commondefs.sysmenu
LDEPENDS_RES += $(SYSMENU_BUILDTOOLSDIR)/commondefs.sysmenu
ifneq ($(TARGET_TAD),)
TARGETS += $(TARGET_TAD)
endif
#----------------------------------------------------------------------------
### SYSTEM_MENU Library settings
SYSMENU_LIBDIR := $(SYSMENU_ROOT)/lib/$(TWL_LIBTYPE)
ifeq ($(CODEGEN_PROC),ARM9)
SYSMENU_LIBS ?= \
liblcfg$(TWL_LIBSUFFIX).a \
libsysmenu$(TWL_LIBSUFFIX).a \
libsysmmcu$(TWL_LIBSUFFIX).a \
libmbloader$(TWL_LIBSUFFIX).a \
libboot$(TWL_LIBSUFFIX).a \
libds$(TWL_LIBSUFFIX).a \
libhotsw$(TWL_LIBSUFFIX).a \
libdht$(TWL_LIBSUFFIX).a \
else # ($(CODEGEN_PROC),ARM7)
SYSMENU_LIBS ?= \
libsysmenu_sp$(TWL_LIBSUFFIX).a \
libsysmmcu_sp$(TWL_LIBSUFFIX).a \
libmbloader_sp$(TWL_LIBSUFFIX).a \
libboot_sp$(TWL_LIBSUFFIX).a \
libds_sp$(TWL_LIBSUFFIX).a \
libhotsw_sp$(TWL_LIBSUFFIX).a \
libdht_sp$(TWL_LIBSUFFIX).a \
endif
#----------------------------------------------------------------------------
# MY BUILD TOOLS
#
OPENSSL := $(SYSMENU_TOOLSDIR)/openssl/openssl.exe
NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe
MAKEBANNER := $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe
MAKESYSMENU_RSA_PRVKEY ?= $(SYSMENU_TOOLSDIR)/openssl/rsa_private.der
MAKESYSMENU_RSA_PUBKEY ?= $(SYSMENU_TOOLSDIR)/openssl/rsa_public.der
MAKETAD ?= $(ROOT)/tools/bin/makeTad.pl
#----------------------------------------------------------------------------
### Global Library resettings
GINCLUDES := $(SYSMENU_INCDIR) $(GINCLUDES)
ifneq ($(ES_ROOT),)
GINCLUDES += $(ES_ROOT)/twl/include
endif
GLIBRARY_DIRS := $(SYSMENU_LIBDIR) $(GLIBRARY_DIRS)
GLIBRARIES := $(SYSMENU_LIBS) $(GLIBRARIES)
#----------------------------------------------------------------------------
# TWLSYSMENU_INSTALL_ROOT
#
SYSMENU_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWL_IPL_RED_ROOT)))
SYSMENU_INSTALL_INCDIR := $(SYSMENU_INSTALL_ROOT)/include
SYSMENU_INSTALL_TOOLSDIR := $(SYSMENU_INSTALL_ROOT)/tools
SYSMENU_INSTALL_LIBDIR := $(SYSMENU_INSTALL_ROOT)/lib/$(TWL_LIBTYPE)
SYSMENU_INSTALL_COMPONENTSDIR := $(SYSMENU_INSTALL_ROOT)/components
SDK_NMENU_DATADIR = $(ROOT)/build/tools/TwlNMenu/data
#----------------------------------------------------------------------------
ifdef SYSMENU_DISABLE_TWL_BOOT
MACRO_FLAGS += -DSYSMENU_DISABLE_TWL_BOOT=$(SYSMENU_DISABLE_TWL_BOOT)
endif
ifdef SYSMENU_DISABLE_RETAIL_BOOT
MACRO_FLAGS += -DSYSMENU_DISABLE_RETAIL_BOOT=$(SYSMENU_DISABLE_RETAIL_BOOT)
endif
#----------------------------------------------------------------------------
endif # TWL_SYSMENU_COMMONDEFS_
#----- End of commondefs -----

View File

@ -0,0 +1,34 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - modulerules - common rules for build system
# File: modulerules
#
# 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 TWL_IPL_MODULERULES_
#----------------------------------------------------------------------------
### TWL-modulerules
#
ifeq ($(TARGET_FIRM),SYSTEMMENU)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules.sysmenu
else
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules.firm
endif
#----------------------------------------------------------------------------
TWL_IPL_MODULERULES_ = TRUE
endif # TWL_IPL_MODULERULES_
#----- End of modulerules -----

View File

@ -0,0 +1,88 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - modulerules - common rules for build system
# File: modulerules
#
# 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 TWLFIRM_MODULERULES_
#----------------------------------------------------------------------------
### TWL-modulerules
#
include $(TWLSDK_ROOT)/build/buildtools/modulerules
#----------------------------------------------------------------------------
#
# MAKEROM for IS-TWL-DEBUGGER
#
ifeq ($(filter $(MAKEROM_FLAGS),-F),)
MAKEROM_FLAGS += -F
endif
#
# MAKENORFIRM / MAKENANDFIRM / MAKEGCDFIRM
#
MAKEFIRM_ARM7 ?= ARM7/bin/$(TWL_BUILDTYPE_ARM7)/main.tef
MAKEFIRM_ARM9 ?= ARM9/bin/$(TWL_BUILDTYPE_ARM9)/main.tef
MAKEFIRM_RSA_PRVKEY ?= $(TWL_KEYSDIR)/rsa/pubkey_nor.der
MAKEFIRM_ARM7_M := $(call empath,$(MAKEFIRM_ARM7))
MAKEFIRM_ARM9_M := $(call empath,$(MAKEFIRM_ARM9))
MAKEFIRM_RSA_PRVKEY_M := $(call empath,$(MAKEFIRM_RSA_PRVKEY))
MAKEFIRM_DEFS += -DFIRM_ROOT='$(FIRM_ROOT)' \
-DMAKEFIRM_ARM9='$(basename $(MAKEFIRM_ARM9_M))' \
-DMAKEFIRM_ARM7='$(basename $(MAKEFIRM_ARM7_M))' \
-DMAKEFIRM_RSA_PRVKEY='$(MAKEFIRM_RSA_PRVKEY_M)' \
ifdef TWL_KEYSDIR
MAKEGCDFIRM_FLAGS += -t'$(TWL_KEYSDIR)/blowfish/gcdfirm_header_twlj.template.sbin'
else
MAKEGCDFIRM_FLAGS += -t'$(FIRM_ROOT)/build/tools/makegcdfirm/gcdfirm_header_twlj.template.sbin'
endif
FIRM_SDEPENDS_BIN := $(call eupath,$(MAKEFIRM_RSA_PRVKEY)) \
$(call eupath,$(MAKEFIRM_ARM9)) \
$(call eupath,$(MAKEFIRM_ARM7))
.PHONY: firmtop firmlib
firmtop:
@$(MAKE) -C $(TWL_IPL_RED_ROOT)/build
firmlib:
@$(MAKE) -C $(TWL_IPL_RED_ROOT)/build/libraries
# .nor
$(BINDIR)/%.nor: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE)
$(MAKENORFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@
# .nand
$(BINDIR)/%.nand: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE)
$(MAKENANDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@
# .gcd
$(BINDIR)/%.gcd: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE)
$(MAKEGCDFIRM) $(MAKEFIRM_FLAGS) $(MAKEGCDFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@
# .rbin
$(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS)
objcopy -I elf32-little -O binary $< $@
#----------------------------------------------------------------------------
TWLFIRM_MODULERULES_ = TRUE
endif # TWLFIRM_MODULERULES_
#----- End of modulerules -----

View File

@ -0,0 +1,37 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - modulerules - common rules for build system
# File: modulerules
#
# 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 TWL_SYSMENU_MODULERULES_
#----------------------------------------------------------------------------
### TWL-modulerules
#
#include $(TWLSDK_ROOT)/build/buildtools/modulerules
include $(NITROSYSTEM_ROOT)/build/buildtools/modulerules
%.tad: $(BINDIR)/$(TARGET_BIN)
$(MAKETAD) $< $(MAKETAD_FLAGS) -o $@
# .rbin
$(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS)
objcopy -I elf32-little -O binary $< $@
#----------------------------------------------------------------------------
TWL_SYSMENU_MODULERULES_ = TRUE
endif # TWL_SYSMENU_MODULERULES_
#----- End of modulerules -----

32
build/components/Makefile Normal file
View File

@ -0,0 +1,32 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - build
# 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$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = \
hyena.TWL
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,106 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL
# 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$
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
override TARGET_PLATFORM = TWL
override TWL_PROC = ARM7
override TWL_ARCHGEN = LIMITED
TWL_NO_STD_PCHDR = True
TWL_CODEGEN ?= ARM
#----------------------------------------------------------------------------
SUBDIRS = $(SYSMENU_ROOT)/build/libraries/aes \
wram_regs
SRCS = main.c \
initScfg.c \
$(ROOT)/build/libraries/init/ARM7.TWL/src/crt0.SCR.c
TARGET_NAME = hyena
TARGET_NEF = $(TARGET_NAME).tef
LCFILE_SPEC = $(TARGET_NAME).lsf
LCFILE_TEMPLATE = $(TARGET_NAME).lcf.template
LDRES_TEMPLATE = $(ROOT)/build/components/racoon.TWL/racoon.response.template
# crt0.oは、ランチャー向けに特殊ビルドしたものを使用
CRT0_O = $(OBJDIR)/crt0.SCR.o
# スタック不足防止の為、インライン展開せずにコンパイルする
CCFLAGS_OPT = -O4 -inline off
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot
GLIBRARIES := $(filter-out $(CRT0_O),$(GLIBRARIES))
ifdef TWLSDK_NOCRYPTO
CCFLAGS += -DSDK_NOCRYPTO
endif
ifndef TWLSDK_NOCRYPTO
MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libsea_sp$(TWL_LIBSUFFIX).a libcrypto_sp$(TWL_LIBSUFFIX).a'
MACRO_FLAGS += -DSDK_SEA
endif
MACRO_FLAGS += -DSDK_SYSMENU_BUILD
#MACRO_FLAGS += -DSDK_ARM7COMP_LTD
MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x03798000' \
-DADDRESS_FLXMAIN='0x02280200' \
-DADDRESS_BOOTCORE='0x0380f000' \
-DCRT0_O='$(CRT0_O)'
MAKELCF_FLAGS += -DISDBG_LIBS_TWL='$(if $(ISDBG_LIBS_TWL),$(ISDBG_LIBS_TWL),libstubsistd_sp$(TWL_LIBSUFFIX).a)' \
-DISDBG_LIBS_NITRO='libstubsisd_sp$(TWL_LIBSUFFIX).a'
ifeq ($(LAUNCHER_DEBUG_MODE),TRUE)
MACRO_FLAGS += -DLAUNCHER_DEBUG_MODE
endif
#--------------------------------
# install target
#--------------------------------
INSTALL_TARGETS = $(BINDIR)/$(TARGET_NAME).tef \
$(BINDIR)/$(TARGET_NAME).TWL.FLX.sbin \
$(BINDIR)/$(TARGET_NAME)_defs.TWL.FLX.sbin \
$(BINDIR)/$(TARGET_NAME).TWL.LTD.sbin \
$(BINDIR)/$(TARGET_NAME)_defs.TWL.LTD.sbin
INSTALL_DIR = $(TWL_INSTALL_COMPONENTSDIR)/$(TARGET_NAME)/$(TWL_BUILDTYPE)
LINCLUDES = $(ROOT)/build/libraries/spi/ARM7/include \
$(ROOT)/build/libraries/spi/ARM7/pm/include \
$(ROOT)/build/libraries/init/common/include \
$(SYSMENU_ROOT)/build/libraries_sysmenu/sysmenu/common/include
LLIBRARY_DIRS += ./
LLIBRARIES += libwl_sp.TWL.LTD.a \
libaes_sp.firm.LTD.a \
libsea_sp.TWL.LTD.a
LDEPENDS_NEF = $(TWL_LIBS) $(LLIBRARIES)
do-build: $(TARGETS)
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,388 @@
#---------------------------------------------------------------------------
# Project: TwlSDK - components - armadillo.TWL
# File: armadillo.lcf.template
#
# 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$
#---------------------------------------------------------------------------
MEMORY
{
<STATIC.NAME> (RWX) : ORIGIN = <STATIC.ADDRESS>, LENGTH = 0x0 > <STATIC.NAME><PROPERTY.FLXSUFFIX>
binary.STATIC_FOOTER (RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.FLXSUFFIX>
<PROPERTY.OVERLAYDEFS>F (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.OVERLAYDEFS><PROPERTY.FLXSUFFIX>
binary.LTDAUTOLOAD_TOP (RW) : ORIGIN = 0, LENGTH = 0x0 > <STATIC.NAME><PROPERTY.LTDSUFFIX>
<FOREACH.LTDAUTOLOADS>
<LTDAUTOLOAD.NAME> (RWX) : ORIGIN = <LTDAUTOLOAD.ADDRESS>, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.LTDSUFFIX>
<END.LTDAUTOLOADS>
binary.LTDAUTOLOAD_INFO (RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.LTDSUFFIX>
<PROPERTY.LTDOVERLAYDEFS>L (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.LTDOVERLAYDEFS><PROPERTY.LTDSUFFIX>
check.WORKRAM (RWX) : ORIGIN = 0x03740000, LENGTH = 0xd0000 > workram.check
}
KEEP_SECTION
{
.sinit
}
SECTIONS
{
############################ STATIC #################################
.<STATIC.NAME>:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.STATIC.SEARCHSYMBOLS>
SEARCH_SYMBOL <STATIC.SEARCHSYMBOL>;
<END.STATIC.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_STATIC_START =.;
OBJECT(_start,*)
<FOREACH.STATIC.OBJECTS=.text>
<STATIC.OBJECT=.text:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.text>
<STATIC.LIBRARY=.text:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.rodata>
<STATIC.OBJECT=.rodata:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.rodata>
<STATIC.LIBRARY=.rodata:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.init>
<STATIC.OBJECT=.init:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.init>
<STATIC.LIBRARY=.init:t>
<END.STATIC.LIBRARIES>
. = ALIGN(4);
SDK_STATIC_SINIT_START =.;
<FOREACH.STATIC.OBJECTS=.ctor>
<STATIC.OBJECT=.ctor:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.ctor>
<STATIC.LIBRARY=.ctor:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.sinit>
<STATIC.OBJECT=.sinit:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.sinit>
<STATIC.LIBRARY=.sinit:t>
<END.STATIC.LIBRARIES>
WRITEW 0;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
<FOREACH.STATIC.OBJECTS=.sdata>
<STATIC.OBJECT=.sdata:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.sdata>
<STATIC.LIBRARY=.sdata:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.data>
<STATIC.OBJECT=.data:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.data>
<STATIC.LIBRARY=.data:t>
<END.STATIC.LIBRARIES>
. = ALIGN(4);
SDK_STATIC_END =.;
SDK_STATIC_SIZE = SDK_STATIC_END - SDK_STATIC_START;
__sinit__ = SDK_STATIC_SINIT_START; # for static initializer
} > <STATIC.NAME>
.<STATIC.NAME>.bss:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.STATIC.SEARCHSYMBOLS>
SEARCH_SYMBOL <STATIC.SEARCHSYMBOL>;
<END.STATIC.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_STATIC_BSS_START =.;
<FOREACH.STATIC.OBJECTS=.sbss>
<STATIC.OBJECT=.sbss:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.sbss>
<STATIC.LIBRARY=.sbss:t>
<END.STATIC.LIBRARIES>
<FOREACH.STATIC.OBJECTS=.bss>
<STATIC.OBJECT=.bss:t>
<END.STATIC.OBJECTS>
<FOREACH.STATIC.LIBRARIES=.bss>
<STATIC.LIBRARY=.bss:t>
<END.STATIC.LIBRARIES>
. = ALIGN(4);
SDK_STATIC_BSS_END = .;
SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START;
} >> <STATIC.NAME>
SDK_SUBPRIV_ARENA_LO = SDK_STATIC_BSS_END;
############################ STATIC_FOOTER ##########################
.binary.STATIC_FOOTER:
{
WRITEW 0xdec00621; # LE(0x2106C0DE) = NITRO CODE
WRITEW _start_ModuleParams - ADDR(.<STATIC.NAME>);
WRITEW 0; # NO DIGEST
WRITEW _start_LtdModuleParams - ADDR(.<STATIC.NAME>);
} > binary.STATIC_FOOTER
############################ OVERLAYDEFS ############################
.<PROPERTY.OVERLAYDEFS>F:
{
### <STATIC.NAME> module information
WRITEW ADDR(.<STATIC.NAME>); # load address
WRITEW _start; # entry address
WRITEW SDK_STATIC_SIZE; # size of module
WRITEW _start_AutoloadDoneCallback; # callback autoload done
} > <PROPERTY.OVERLAYDEFS>F
########################### LTDAUTOLOADS ############################
SDK_LTDAUTOLOAD_TOP_START = 0x02f00000;
SDK_LTDAUTOLOAD_TOP_SIZE = 4; # STATIC 領域が無い代わりに 4 bytes のダミーがバイナリファイルの先頭に入る #
SDK_LTDAUTOLOAD_START = SDK_LTDAUTOLOAD_TOP_START + SDK_LTDAUTOLOAD_TOP_SIZE;
SDK_LTDAUTOLOAD_SIZE = 0;
SDK_LTDAUTOLOAD_BSS_END = 0x03740000;
.binary.LTDAUTOLOAD_TOP:
{
WRITEW 0;
} > binary.LTDAUTOLOAD_TOP
<FOREACH.LTDAUTOLOADS>
.<LTDAUTOLOAD.NAME>:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDAUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDAUTOLOAD.SEARCHSYMBOL>;
<END.LTDAUTOLOAD.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.START =.;
<FOREACH.LTDAUTOLOAD.OBJECTS=.text>
<LTDAUTOLOAD.OBJECT=.text:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.text>
<LTDAUTOLOAD.LIBRARY=.text:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.etable>
<LTDAUTOLOAD.OBJECT=.exception:t>
. = ALIGN(4);
SDK_STATIC_ETABLE_START =.;
__exception_table_start__ =.;
EXCEPTION
__exception_table_end__ =.;
SDK_STATIC_ETABLE_END =.;
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.OBJECTS=.rodata>
<LTDAUTOLOAD.OBJECT=.rodata:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.rodata>
<LTDAUTOLOAD.LIBRARY=.rodata:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.init>
<LTDAUTOLOAD.OBJECT=.init:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.init>
<LTDAUTOLOAD.LIBRARY=.init:t>
<END.LTDAUTOLOAD.LIBRARIES>
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SINIT_START =.;
<FOREACH.LTDAUTOLOAD.OBJECTS=.ctor>
<LTDAUTOLOAD.OBJECT=.ctor:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ctor>
<LTDAUTOLOAD.LIBRARY=.ctor:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.sinit>
<LTDAUTOLOAD.OBJECT=.sinit:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.sinit>
<LTDAUTOLOAD.LIBRARY=.sinit:t>
<END.LTDAUTOLOAD.LIBRARIES>
WRITEW 0;
#
# DATA BLOCK: READ WRITE BLOCK
#
. = ALIGN(4);
<FOREACH.LTDAUTOLOAD.OBJECTS=.sdata>
<LTDAUTOLOAD.OBJECT=.sdata:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.sdata>
<LTDAUTOLOAD.LIBRARY=.sdata:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.data>
<LTDAUTOLOAD.OBJECT=.data:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.data>
<LTDAUTOLOAD.LIBRARY=.data:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.wram>
<LTDAUTOLOAD.OBJECT=.wram:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.wram>
<LTDAUTOLOAD.LIBRARY=.wram:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.ltdwram>
<LTDAUTOLOAD.OBJECT=.ltdwram:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdwram>
<LTDAUTOLOAD.LIBRARY=.ltdwram:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.ltdmain>
<LTDAUTOLOAD.OBJECT=.ltdmain:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdmain>
<LTDAUTOLOAD.LIBRARY=.ltdmain:t>
<END.LTDAUTOLOAD.LIBRARIES>
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.END =.;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.START;
SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SIZE;
} > <LTDAUTOLOAD.NAME>
.<LTDAUTOLOAD.NAME>.bss:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDAUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDAUTOLOAD.SEARCHSYMBOL>;
<END.LTDAUTOLOAD.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_START =.;
<FOREACH.LTDAUTOLOAD.OBJECTS=.sbss>
<LTDAUTOLOAD.OBJECT=.sbss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.sbss>
<LTDAUTOLOAD.LIBRARY=.sbss:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.bss>
<LTDAUTOLOAD.OBJECT=.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.bss>
<LTDAUTOLOAD.LIBRARY=.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.wram>
<LTDAUTOLOAD.OBJECT=.wram.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.wram>
<LTDAUTOLOAD.LIBRARY=.wram.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.ltdwram>
<LTDAUTOLOAD.OBJECT=.ltdwram.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdwram>
<LTDAUTOLOAD.LIBRARY=.ltdwram.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
<FOREACH.LTDAUTOLOAD.OBJECTS=.ltdmain>
<LTDAUTOLOAD.OBJECT=.ltdmain.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdmain>
<LTDAUTOLOAD.LIBRARY=.ltdmain.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_END =.;
SDK_LTDAUTOLOAD_BSS_END =.;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_START;
} >> <LTDAUTOLOAD.NAME>
<END.LTDAUTOLOADS>
SDK_MOUNT_INFO_TABLE = SDK_LTDAUTOLOAD_BSS_END;
SDK_LTDAUTOLOAD_BSS_END = SDK_MOUNT_INFO_TABLE + 0x400;
######################### LTDAUTOLOAD_INFO ##########################
.binary.LTDAUTOLOAD_INFO:
{
<FOREACH.LTDAUTOLOADS>
WRITEW ADDR(.<LTDAUTOLOAD.NAME>);
WRITEW SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SIZE;
WRITEW SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SINIT_START;
WRITEW SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.BSS_SIZE;
<END.LTDAUTOLOADS>
} > binary.LTDAUTOLOAD_INFO
SDK_LTDAUTOLOAD_LIST = SDK_LTDAUTOLOAD_START + SDK_LTDAUTOLOAD_SIZE;
SDK_LTDAUTOLOAD_LIST_END = SDK_LTDAUTOLOAD_LIST + SIZEOF(.binary.LTDAUTOLOAD_INFO);
SDK_LTDAUTOLOAD_SIZE = SDK_LTDAUTOLOAD_SIZE + SIZEOF(.binary.LTDAUTOLOAD_INFO);
########################## LTDOVERLAYDEFS ###########################
.<PROPERTY.LTDOVERLAYDEFS>L:
{
### TWL limited extended static module information
WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address
WRITEW SDK_MOUNT_INFO_TABLE; # address of the FS mount information table
WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module
WRITEW 0; # padding
} > <PROPERTY.LTDOVERLAYDEFS>L
############################ OTHERS #################################
SDK_SUBPRIV_ARENA_LO = 0x02ffc000; # メインメモリアリーナはサイズ 0
SDK_SEA_KEY_STORE = SDK_LTDAUTOLOAD_BSS_END;
SDK_WRAM_ARENA_LO = SDK_LTDAUTOLOAD_BSS_END + 0x40;
SDK_IRQ_STACKSIZE = <STATIC.IRQSTACKSIZE>; # allocated in WRAM
SDK_SYS_STACKSIZE = <STATIC.STACKSIZE>; # allocated in WRAM
SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1;
.check.WORKRAM:
{
. = SDK_WRAM_ARENA_LO + 0x80 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
} > check.WORKRAM
}

View File

@ -0,0 +1,94 @@
#----------------------------------------------------------------------------
# Project: TwlSDK - components - armadillo.TWL
# File: armadillo.lsf
#
# Copyright 2008 Nintendo. All rights reserved.
#
# These coded insructions, 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$
#----------------------------------------------------------------------------
#
# Nitro LCF SPEC FILE
#
#--------
Static $(TARGET_NAME)
{
Address 0x02280000
StackSize 1024 1024
Library $(CRT0_O)
}
#--------
Ltdautoload SCRWRAM
{
Address 0x03740000
Library libsubpsyscall.a
Library libsyscall_sp.twl.a
Library $(CW_LIBS)
Library $(ISDBG_LIBS_TWL)
Library $(ISDBG_LIBS_NITRO)
Object * (.etable)
Object $(OBJDIR)/main.o
Library libsea_sp$(LIBSUFFIX).a
Library libcrypto_sp$(LIBSUFFIX).a
Library libos_sp$(LIBSUFFIX).a
Library libmi_sp$(LIBSUFFIX).a
Library libstd_sp$(LIBSUFFIX).a
Library libmath_sp$(LIBSUFFIX).a
Library libpxi_sp$(LIBSUFFIX).a
Library libexi_sp$(LIBSUFFIX).a
Library libi2c_sp$(LIBSUFFIX).a
Library libsdio_sp$(LIBSUFFIX).a
Library libpad_sp$(LIBSUFFIX).a
Library libscfg_sp$(LIBSUFFIX).a
Library libmcu_sp$(LIBSUFFIX).a
Library libcdc_sp$(LIBSUFFIX).a
Library libsnd_sp$(LIBSUFFIX).a
Library libsndex_sp$(LIBSUFFIX).a
Library libspi_sp$(LIBSUFFIX).a
Library libpm_sp$(LIBSUFFIX).a
Library libtp_sp$(LIBSUFFIX).a
Library libtpex_sp$(LIBSUFFIX).a
Library libmic_sp$(LIBSUFFIX).a
Library libmicex_sp$(LIBSUFFIX).a
Library libnvram_sp$(LIBSUFFIX).a
Library librtc_sp$(LIBSUFFIX).a
Library libfatfs_sp$(LIBSUFFIX).a
Library libwm_sp$(LIBSUFFIX).a
Library libnwm_sp$(LIBSUFFIX).a
Library libwvr_sp$(LIBSUFFIX).a
Library libwl_sp$(LIBSUFFIX).a
Library libwpa_sp$(LIBSUFFIX).a
Library libathdrv_sp$(LIBSUFFIX).a
Library libfs_sp$(LIBSUFFIX).a
Library libcard_sp$(LIBSUFFIX).a
Library libcamera_sp$(LIBSUFFIX).a
Library libboot_sp$(LIBSUFFIX).a \
libreboot_sp$(LIBSUFFIX).a \
libhotsw_sp$(LIBSUFFIX).a \
libreloc_info_sp$(LIBSUFFIX).a \
libsysmenu_sp$(LIBSUFFIX).a \
libsysmmcu_sp$(LIBSUFFIX).a \
libaes_sp.firm.LTD.a \
libsea_sp$(LIBSUFFIX).a \
libcrypto_sp$(LIBSUFFIX).a
Object * (.wram)
Object * (.ltdwram)
Object * (.rsvwram)
Object * (.main)
Object * (.ltdmain)
}

View File

@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - components - mongoose.TWL
File: initScfg.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.
$Date:: 2008-03-03#$
$Rev: 4466 $
$Author: terui $
*---------------------------------------------------------------------------*/
#include <twl/memorymap_sp.h>
#include <twl/hw/common/mmap_wramEnv.h>
extern void INIT_InitializeScfg(void);
#include <twl/code32.h>
/*---------------------------------------------------------------------------*
Name: INIT_InitializeScfg
Description: SCFG
crt0
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
asm void
INIT_InitializeScfg(void)
{
// SCFG enable?
ldr r2, =REG_EXT_ADDR
ldr r0, [r2]
tst r0, #REG_SCFG_EXT_CFG_MASK
beq @end
/* NITRO 互換無線の送受信機能を動作 */
ldr r1, =REG_WL_ADDR
ldrh r0, [r1]
orr r0, r0, #REG_SCFG_WL_OFFB_MASK
strh r0, [r1]
/* 新規サウンドブロックへのクロック供給 */
ldr r1, =REG_CLK_ADDR
ldrh r0, [r1]
orr r0, r0, #REG_SCFG_CLK_SNDMCLK_MASK
strh r0, [r1]
/* ARM7 側の DMA には新 DMA 回路を採用 */
ldr r1, =REG_EXT_ADDR
ldr r0, [r1]
orr r0, r0, #REG_SCFG_EXT_DMAC_MASK
str r0, [r1]
ldr r2, =HW_PRV_WRAM_SYSRV
//EXT(extentions)
ldr r3, =REG_EXT_ADDR
ldr r0, [r3]
str r0, [r2, #HWi_WSYS04_WRAMOFFSET]
//OPT(bonding option)
ldr r3, =REG_OP_ADDR
ldrb r0, [r3]
//A9ROM(ARM9 ROM)
ldr r3, =REG_A9ROM_ADDR
ldrb r1, [r3]
and r12,r1, #(REG_SCFG_A9ROM_RSEL_MASK | REG_SCFG_A9ROM_SEC_MASK)
orr r0, r0, r12, LSL #(HWi_WSYS08_ROM_ARM9RSEL_SHIFT - REG_SCFG_A9ROM_RSEL_SHIFT)
//A7ROM(ARM7 ROM)
ldr r3, =REG_A7ROM_ADDR
ldrb r1, [r3]
and r12,r1, #(REG_SCFG_A7ROM_RSEL_MASK | REG_SCFG_A7ROM_FUSE_MASK)
orr r0, r0, r12, LSL #(HWi_WSYS08_ROM_ARM7RSEL_SHIFT - REG_SCFG_A7ROM_RSEL_SHIFT)
//DS-WL(DS wireless)
ldr r3, =REG_WL_ADDR
ldrb r1, [r3]
and r12,r1, #REG_SCFG_WL_OFFB_MASK
orr r0, r0, r12, LSL #(HWi_WSYS08_WL_OFFB_SHIFT - REG_SCFG_WL_OFFB_SHIFT)
strb r0, [r2, #HWi_WSYS08_WRAMOFFSET]
//OPT(JTAG info)
ldr r3, =REG_JTAG_ADDR
ldrh r0, [r3]
and r12,r0, #REG_SCFG_JTAG_DSPJE_MASK
orr r0, r0, r12, LSR #(REG_SCFG_JTAG_DSPJE_SHIFT - HWi_WSYS09_JTAG_DSPJE_SHIFT)
//CLK(only wram clock)
ldr r3, =REG_CLK_ADDR
ldrh r1, [r3]
and r12,r1, #(REG_SCFG_CLK_AESHCLK_MASK | REG_SCFG_CLK_SD2HCLK_MASK | REG_SCFG_CLK_SD1HCLK_MASK)
orr r0, r0, r12, LSL #(HWi_WSYS09_CLK_SD1HCLK_SHIFT - REG_SCFG_CLK_SD1HCLK_SHIFT)
and r12,r1, #(REG_SCFG_CLK_SNDMCLK_MASK | REG_SCFG_CLK_WRAMHCLK_MASK)
orr r0, r0, r12, LSR #(REG_SCFG_CLK_WRAMHCLK_SHIFT - HWi_WSYS09_CLK_WRAMHCLK_SHIFT)
strb r0, [r2, #HWi_WSYS09_WRAMOFFSET]
#if 0
/* A7-SCFG ブロックへのアクセスを無効化 */
ldr r1, =REG_EXT_ADDR
ldr r0, [r1]
bic r0, r0, #REG_SCFG_EXT_CFG_MASK
str r0, [r1]
#endif
@end:
bx lr
}
#include <twl/codereset.h>

View File

@ -0,0 +1,845 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - components - hyena.TWL
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.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <nitro/types.h>
#include <twl/init/crt0.h>
#include <twl/memorymap_sp.h>
#include <twl/os.h>
#include <twl/spi.h>
#include <twl/fatfs.h>
#include <nitro/pad.h>
#include <nitro/std.h>
#include <nitro/snd.h>
#include <nitro/wvr.h>
#include <twl/nwm.h>
#include <twl/camera.h>
#include <twl/rtc.h>
#include <nitro/hw/common/lcd.h>
#include <nitro/gx.h>
#include <twl/os/common/codecmode.h>
#include <twl/cdc.h>
#include <twl/snd/ARM7/sndex_api.h>
#include <twl/aes.h>
#include <twl/mcu.h>
#include <twl/hw/common/mmap_wramEnv.h>
#include <sysmenu.h>
#include <sysmenu/mcu.h>
#include <firm/memorymap.h>
#include "pm_pmic.h"
#include "internal_api.h"
#include "nvram_sp.h"
#include "twl/sea.h"
// 未実装(現状ではデバッガ接続しないなら選択してもよい)
//#define HYENA_ROMEMU_INFO_FROM_LNCR_PARAM
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/* [TODO] Work around. Should be defined in wm_sp.h */
#define WM_WL_HEAP_SIZE 0x2100
#define ATH_DRV_HEAP_SIZE 0x5800 /* TBD */
#define WPA_HEAP_SIZE 0x0000 /* TBD */
#define MEM_TYPE_WRAM 0
#define MEM_TYPE_MAIN 1
/* Priorities of each threads */
#define THREAD_PRIO_SPI 2
#define THREAD_PRIO_MCU 4 // 暫定
#define THREAD_PRIO_SYSMMCU 6
#define THREAD_PRIO_SND 6
#define THREAD_PRIO_FATFS 8
#define THREAD_PRIO_HOTSW 11
#define THREAD_PRIO_RTC 12
#define THREAD_PRIO_SNDEX 14
#define THREAD_PRIO_FS 15
/* OS_THREAD_LAUNCHER_PRIORITY 16 */
/* [TODO] 以下は New WM 側に移行するほうが好ましい? */
#define NWM_DMANO 3
#define THREAD_PRIO_NWM_COMMMAND 9
#define THREAD_PRIO_NWM_EVENT 7
#define THREAD_PRIO_NWM_SDIO 8
#define THREAD_PRIO_NWM_WPA 10
// ROM 内登録エリアの拡張言語コード
#define ROMHEADER_FOR_CHINA_BIT 0x80
#define ROMHEADER_FOR_KOREA_BIT 0x40
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
static void ResetRTC( void );
static void ReadLauncherParameter( void );
static void PrintDebugInfo(void);
static OSHeapHandle InitializeAllocateSystem(u8 memType);
static OSHeapHandle InitializeAllocateSystemCore(u8 memType);
#ifdef SDK_TWLHYB
static OSHeapHandle InitializeAllocateSystemCoreEx(u8 memType);
#endif
static void DummyThread(void* arg);
static void ReadUserInfo(void);
static void VBlankIntr(void);
static void InitializeFatfs(void);
static void InitializeNwm(OSHeapHandle drvHeapHandle, OSHeapHandle wpaHeapHandle);
static void InitializeCdc(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#ifdef SDK_TWLHYB
extern void SDK_LTDAUTOLOAD_LTDWRAM_BSS_END(void);
extern void SDK_LTDAUTOLOAD_LTDMAIN_BSS_END(void);
#endif
extern void SDK_SEA_KEY_STORE(void);
extern void SDK_STATIC_BSS_END(void);
/*---------------------------------------------------------------------------*
Name: TwlSpMain
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void
TwlSpMain(void)
{
OSHeapHandle wramHeapHandle, mainHeapHandle;
// SYSMワークのクリア
MI_CpuClear32( SYSMi_GetWork(), sizeof(SYSM_work) );
// バックライトON
while ( (reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK) == FALSE )
{
}
PMi_SetControl( PMIC_CTL_BKLT1 | PMIC_CTL_BKLT2 );
// OS 初期化
OS_Init();
PrintDebugInfo();
// ランチャーバージョンを格納(今のところ、最低でもマウント情報登録前には格納する必要あり)
*(u8 *)HW_TWL_RED_LAUNCHER_VER = (u8)SYSM_LAUNCHER_VER;
// ランチャーのマウント情報登録
SYSMi_SetLauncherMountInfo();
// ランチャーパラメター取得Cold/Hotスタート判定含む
ReadLauncherParameter();
// RTCリセット
ResetRTC(); // 330usくらい
// NVRAM からユーザー情報読み出し
ReadUserInfo();
// [TODO:] カード電源ONして、ROMヘッダのみリードチェックくらいはやっておきたい
SYSMi_GetWork()->flags.common.isARM9Start = TRUE; // [TODO:] HW_RED_RESERVEDはNANDファームでクリアしておいて欲しい
// ヒープ領域設定
OS_SetSubPrivArenaHi( (void*)SYSM_OWN_ARM7_MMEM_ADDR_END ); // メモリ配置をいじっているので、アリーナHiも変更しないとダメ
OS_SetSubPrivArenaLo( (void*)SDK_STATIC_BSS_END ); // メモリ配置をいじっているので、アリーナHiも変更しないとダメ
OS_SetWramSubPrivArenaHi( (void*)(SYSM_OWN_ARM7_WRAM_ADDR_END - HW_FIRM_FROM_FIRM_BUF_SIZE) ); // この時点では鍵をつぶさないように
OS_TPrintf( "MMEM SUBPRV ARENA HI : %08x -> %08x\n", OS_GetSubPrivArenaHi(), OS_GetSubPrivArenaHi() );
OS_TPrintf( "WRAM SUBPRV ARENA HI : %08x -> %08x\n", OS_GetWramSubPrivArenaHi(), OS_GetWramSubPrivArenaHi() );
OS_TPrintf( "MMEM SUBPRV ARENA LO : %08x -> %08x\n", OS_GetSubPrivArenaLo(), OS_GetSubPrivArenaLo() );
OS_TPrintf( "WRAM SUBPRV ARENA LO : %08x -> %08x\n", OS_GetWramSubPrivArenaLo(), OS_GetWramSubPrivArenaLo() );
wramHeapHandle = InitializeAllocateSystem(MEM_TYPE_WRAM);
mainHeapHandle = InitializeAllocateSystem(MEM_TYPE_MAIN);
// ボタン入力サーチ初期化
(void)PAD_InitXYButton();
// 割り込み許可
(void)OS_SetIrqFunction(OS_IE_V_BLANK, VBlankIntr);
(void)OS_EnableIrqMask(OS_IE_V_BLANK);
(void)GX_VBlankIntr(TRUE);
(void)OS_EnableIrq();
(void)OS_EnableInterrupts();
// PXIコールバックの設定
SYSM_InitPXI(THREAD_PRIO_SYSMMCU);
// ファイルシステム初期化
FS_Init(FS_DMA_NOT_USE);
FS_CreateReadServerThread(THREAD_PRIO_FS);
if (OS_IsRunOnTwl() == TRUE)
{
InitializeFatfs(); // FATFS 初期化
InitializeNwm(mainHeapHandle, mainHeapHandle); // NWM 初期化
#ifndef SDK_NOCRYPTO
AES_Init(); // AES 初期化
// NANDファームがHW_LAUNCHER_DELIVER_PARAM_BUFへのAES_SEEDセットを行ってくれるので、ISデバッガ接続に関係なくSDK_SEA_KEY_STOREへのコピーを行えばよい
MI_CpuCopyFast( (void *)HW_LAUNCHER_DELIVER_PARAM_BUF, (void *)SDK_SEA_KEY_STORE, HW_LAUNCHER_DELIVER_PARAM_BUF_SIZE );
#ifdef SDK_SEA
SEA_Init();
#endif // ifdef SDK_SEA
#endif
MCU_InitIrq(THREAD_PRIO_MCU); // MCU 初期化
}
if (OSi_IsCodecTwlMode() == TRUE)
{
// CODEC 初期化
InitializeCdc();
// カメラ初期化
CAMERA_Init();
/* CODEC が TWL モードでないとシャッター音を強制的に鳴らす
使CODEC TWL
使 */
}
// サウンド初期化
SND_Init(THREAD_PRIO_SND);
if (OS_IsRunOnTwl() == TRUE)
{
SNDEX_Init(THREAD_PRIO_SNDEX);
}
// RTC 初期化
RTC_Init(THREAD_PRIO_RTC);
// 旧無線初期化
WVR_Begin(wramHeapHandle);
// SPI 初期化
SPI_Init(THREAD_PRIO_SPI);
BOOT_Init();
// 活栓挿抜機能初期化
if( ( SYSM_GetLauncherParamBody()->v1.flags.isValid ) &&
( SYSM_GetLauncherParamBody()->v1.flags.bootType != LAUNCHER_BOOTTYPE_ROM ) &&
( SYSM_GetLauncherParamBody()->v1.bootTitleID )
)
#ifdef HYENA_ROMEMU_INFO_FROM_LNCR_PARAM
{
// ランチャーパラメータでダイレクトカードブート以外の指定がある時は、活線挿抜をOFFにする。
SYSMi_GetWork()->flags.hotsw.isEnableHotSW = 0;
}else {
// それ以外の時は活線挿抜ON
SYSMi_GetWork()->flags.hotsw.isEnableHotSW = 1;
}
#else
{
// ランチャーパラメータでダイレクトカードブート以外の指定がある時は、ROMエミュレーション情報のみ必要。
SYSMi_GetWork()->flags.hotsw.isLoadRomEmuOnly = 1;
}else {
// それ以外の時は普通にロード
SYSMi_GetWork()->flags.hotsw.isLoadRomEmuOnly = 0;
}
SYSMi_GetWork()->flags.hotsw.isEnableHotSW = 1;
#endif
// [TODO]アプリジャンプ有効で、カードブートでない時は、最初からHOTSW_Initを呼ばないようにしたい。
HOTSW_Init(THREAD_PRIO_HOTSW);
// 外部デポップ回路を無効にします。
CDC_DisableExternalDepop();
while (TRUE)
{
OS_Halt();
//---- check reset
if (OS_IsResetOccurred())
{
OS_ResetSystem();
}
BOOT_WaitStart();
}
}
void SDK_LTDAUTOLOAD_LTDMAIN_START( void )
{
}
// RTCのリセットチェック
static void ResetRTC( void )
{
SYSM_work* sw = SYSMi_GetWork();
// ランチャーでリセットを検出するためにこの処理をしているが、RTC_Init内でも同じことをしているので、ちょっと無駄。
RTCRawStatus1 stat1;
RTCRawStatus2 stat2;
RTC_ReadStatus1( &stat1 );
RTC_ReadStatus2( &stat2 );
// リセット、電源投入、電源電圧低下、ICテストの各フラグを確認
if ( stat1.reset || stat1.poc || stat1.bld || stat2.test )
{
// リセット実行
stat1.reset = 1;
RTC_WriteStatus1( &stat1 );
{
RTCRawFout fout;
fout.fout = RTC_FOUT_DUTY_32KHZ;
RTC_WriteFout(&fout);
}
sw->flags.common.isResetRTC = TRUE;
}
// RTC初回データ読み込み
RTC_ReadDateTime(&sw->Rtc1stData);
}
// ランチャーパラメータのリードおよびHot/Coldスタート判定
void ReadLauncherParameter( void )
{
BOOL hot;
SYSMi_GetWork()->flags.common.isValidLauncherParam = OS_ReadLauncherParameter( (LauncherParam *)&(SYSMi_GetWork()->launcherParam), &hot );
SYSMi_GetWork()->flags.common.isHotStart = hot;
// メインメモリのランチャーパラメータをクリアしておく
MI_CpuClearFast( (void*)HW_PARAM_LAUNCH_PARAM, HW_PARAM_LAUNCH_PARAM_SIZE );
// Coldスタート時はアプリパラメータもクリア
if ( ! hot )
{
MI_CpuClearFast( (void*)HW_PARAM_DELIVER_ARG, HW_PARAM_DELIVER_ARG_SIZE );
}
}
/*---------------------------------------------------------------------------*
Name: PrintDebugInfo
Description: ARM7
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
PrintDebugInfo(void)
{
if(OS_IsRunOnTwl())
{
OS_TPrintf("ARM7: This component is running on TWL.\n");
}
else
{
OS_TPrintf("ARM7: This component is running on NITRO.\n");
}
OS_TPrintf("ARM7: This component is \"hyena.TWL\"\n");
}
#include <twl/ltdwram_begin.h>
/*---------------------------------------------------------------------------*
Name: InitializeFatfs
Description: FATFSライブラリを初期化するFATFS初期化関数内でスレッド休止
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
InitializeFatfs(void)
{
OSThread thread;
u32 stack[18];
// ダミースレッド作成
OS_CreateThread(&thread, DummyThread, NULL,
(void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX);
OS_WakeupThreadDirect(&thread);
// FATFSライブラリの初期化
#ifndef SDK_NOCRYPTO
if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_5, THREAD_PRIO_FATFS))
#else
if (FATFS_Init(FATFS_DMA_NOT_USE, FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS))
#endif
{
// do nothing
}
// ダミースレッド破棄
OS_KillThread(&thread, NULL);
}
#include <twl/ltdwram_end.h>
#include <twl/ltdwram_begin.h>
/*---------------------------------------------------------------------------*
Name: InitializeNwm
Description: NWMライブラリを初期化する
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
InitializeNwm(OSHeapHandle drvHeapHandle, OSHeapHandle wpaHeapHandle)
{
NwmspInit nwmInit;
nwmInit.dmaNo = NWM_DMANO;
nwmInit.cmdPrio = THREAD_PRIO_NWM_COMMMAND;
nwmInit.evtPrio = THREAD_PRIO_NWM_EVENT;
nwmInit.sdioPrio = THREAD_PRIO_NWM_SDIO;
nwmInit.drvHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */
nwmInit.drvHeap.handle = drvHeapHandle;
#ifdef WPA_BUILT_IN /* WPA が組み込まれる場合、以下のメンバが追加される */
nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA;
nwmInit.wpaHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */
nwmInit.wpaHeap.handle = wpaHeapHandle;
#endif
NWMSP_Init(&nwmInit);
}
#include <twl/ltdwram_end.h>
#include <twl/ltdwram_begin.h>
/*---------------------------------------------------------------------------*
Name: InitializeCdc
Description: CDCライブラリを初期化するCDC初期化関数内でスレッド休止する
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void
InitializeCdc(void)
{
OSThread thread;
u32 stack[18];
// ※ランチャーでは必要なし
#if 0
// ランチャー経由で起動した場合はCODECは既に初期化されているため
// コンポーネントがCODECを初期化する必要はありません。
// 将来的にはバッサリと切る必要がありますが、
// 暫定的にI2Sが有効かどうかでCODECが初期化済みかどうかを判定します。
if (reg_SND_SMX_CNT & REG_SND_SMX_CNT_E_MASK)
{
CDC_InitLib();
return;
}
#endif
// ダミースレッド作成
OS_CreateThread(&thread, DummyThread, NULL,
(void*)((u32)stack + (sizeof(u32) * 18)), sizeof(u32) * 18, OS_THREAD_PRIORITY_MAX);
OS_WakeupThreadDirect(&thread);
#if 1
// CODEC 初期化
CDC_InitForFirstBoot(); // ※ランチャー特殊処理。
CDC_InitMic();
// CDCi_DumpRegisters();
#else
/* [Debug] CODEC を DS モードで初期化 */
*((u8*)(HW_TWL_ROM_HEADER_BUF + 0x01bf)) &= ~(0x01);
CDC_Init();
CDC_GoDsMode();
OS_TPrintf("Codec mode changed to DS mode for debug.\n");
#endif
// ダミースレッド破棄
OS_KillThread(&thread, NULL);
}
/*---------------------------------------------------------------------------*
Name: DummyThread
Description: FATFSライブラリCDCライブラリを初期化する際に立てるダミーの
Arguments: arg - 使
Returns: None.
*---------------------------------------------------------------------------*/
static void
DummyThread(void* arg)
{
#pragma unused(arg)
while (TRUE)
{
}
}
#include <twl/ltdwram_end.h>
/*---------------------------------------------------------------------------*
Name: InitializeAllocateSystem
Description:
Arguments: None.
Returns: OSHeapHandle - WRAM
*---------------------------------------------------------------------------*/
static OSHeapHandle InitializeAllocateSystem(u8 memType)
{
OSHeapHandle hh;
#ifdef SDK_TWLHYB
if( OS_IsRunOnTwl() == TRUE)
{
hh = InitializeAllocateSystemCoreEx(memType); /* Hybrid を TWL で動作させる */
}
else
#endif
{
hh = InitializeAllocateSystemCore(memType); /* Hybrid を DS で動作させる or Limited */
}
return hh;
}
/*---------------------------------------------------------------------------*
Name: InitializeAllocateSystemCore
Description:
Hybrid DS Limited TWL
Arguments: None.
Returns: OSHeapHandle - WRAM
*---------------------------------------------------------------------------*/
static OSHeapHandle InitializeAllocateSystemCore(u8 memType)
{
OSHeapHandle hh;
/* MAIN */
if(memType == MEM_TYPE_MAIN)
{
{
void* lo = (void*)OS_GetSubPrivArenaLo();
void* hi = (void*)OS_GetSubPrivArenaHi();
// アリーナを 0 クリア
MI_CpuClear8(lo, (u32)hi - (u32)lo);
// メモリ割り当て初期化
lo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, lo, hi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, lo);
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, lo, hi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to MAIN create heap.\n");
}
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh);
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh);
if( heapSize <= 0) /* ヒープ領域の確保に失敗 */
{
OS_Panic("ARM7: Failed to MAIN create heap.\n");
}
#ifdef SDK_TWLLTD
{
if ((ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE) > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE);
}
}
#endif
OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize);
}
}
/* WRAM */
if( memType == MEM_TYPE_WRAM)
{
{
void* lo = (void*)OS_GetWramSubPrivArenaLo();
void* hi = (void*)OS_GetWramSubPrivArenaHi();
// アリーナを 0 クリア
MI_CpuClear8(lo, (u32)hi - (u32)lo);
// メモリ割り当て初期化
lo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, lo, hi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, lo);
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, lo, hi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to WRAM create heap.\n");
}
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh);
if( heapSize <= 0) /* ヒープ領域の確保に失敗 */
{
OS_Panic("ARM7: Failed to MAIN create heap.\n");
}
if (WM_WL_HEAP_SIZE > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE);
}
OS_TPrintf("ARM7: WRAM heap size is %d\n", heapSize);
}
}
return hh;
}
#ifdef SDK_TWLHYB
#include <twl/ltdwram_begin.h>
/*---------------------------------------------------------------------------*
Name: InitializeAllocateSystemCoreEx
Description:
Hybrid TWL
Arguments: None.
Returns: OSHeapHandle - WRAM
*---------------------------------------------------------------------------*/
static OSHeapHandle InitializeAllocateSystemCoreEx(u8 memType)
{
OSHeapHandle hh;
if(memType == MEM_TYPE_MAIN)
{
{
void* basicLo = (void*)OS_GetSubPrivArenaLo();
void* basicHi = (void*)OS_GetSubPrivArenaHi();
void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDMAIN_BSS_END, 32);
void* extraHi = (void*)MATH_ROUNDDOWN(HW_MAIN_MEM_SUB, 32);
#if SDK_DEBUG
// debug information
OS_TPrintf("ARM7: MAIN arena basicLo = %p\n", basicLo);
OS_TPrintf("ARM7: MAIN arena basicHi = %p\n", basicHi);
OS_TPrintf("ARM7: MAIN arena extraLo = %p\n", extraLo);
OS_TPrintf("ARM7: MAIN arena extraHi = %p\n", extraHi);
#endif
// アリーナを 0 クリア
MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo);
MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo);
// メモリ割り当て初期化
if ((u32)basicLo < (u32)extraLo)
{
basicLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, basicLo, extraHi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_MAIN_SUBPRIV, basicLo);
}
else
{
extraLo = OS_InitAlloc(OS_ARENA_MAIN_SUBPRIV, extraLo, basicHi, 1);
}
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, basicLo, basicHi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to create MAIN heap.\n");
}
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh);
if( heapSize <= 0) /* ヒープ領域の確保に失敗 */
{
OS_Panic("ARM7: Failed to MAIN create heap.\n");
}
OS_TPrintf("ARM7: MAIN heap size is %d (before AddToHead)\n", heapSize);
}
// ヒープに拡張ブロックを追加
OS_AddToHeap(OS_ARENA_MAIN_SUBPRIV, hh, extraLo, extraHi);
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_MAIN_SUBPRIV, hh);
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_MAIN_SUBPRIV, hh);
if( heapSize <= 0) /* ヒープ領域の確保に失敗 */
{
OS_Panic("ARM7: Failed to MAIN create heap.\n");
}
if ((ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE) > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, ATH_DRV_HEAP_SIZE + WPA_HEAP_SIZE);
}
OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize);
}
}
if(memType == MEM_TYPE_WRAM)
{
{
void* basicLo = (void*)OS_GetWramSubPrivArenaLo();
void* basicHi = (void*)OS_GetWramSubPrivArenaHi();
void* extraLo = (void*)MATH_ROUNDUP((u32)SDK_LTDAUTOLOAD_LTDWRAM_BSS_END, 32);
void* extraHi = (void*)MATH_ROUNDDOWN(HW_WRAM_A_HYB_END, 32);
#if SDK_DEBUG
// debug information
OS_TPrintf("ARM7: WRAM arena basicLo = %p\n", basicLo);
OS_TPrintf("ARM7: WRAM arena basicHi = %p\n", basicHi);
OS_TPrintf("ARM7: WRAM arena extraLo = %p\n", extraLo);
OS_TPrintf("ARM7: WRAM arena extraHi = %p\n", extraHi);
#endif
// アリーナを 0 クリア
MI_CpuClear8(basicLo, (u32)basicHi - (u32)basicLo);
MI_CpuClear8(extraLo, (u32)extraHi - (u32)extraLo);
// メモリ割り当て初期化
if ((u32)basicLo < (u32)extraLo)
{
basicLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, basicLo, extraHi, 1);
// アリーナ下位アドレスを設定
OS_SetArenaLo(OS_ARENA_WRAM_SUBPRIV, basicLo);
}
else
{
extraLo = OS_InitAlloc(OS_ARENA_WRAM_SUBPRIV, extraLo, basicHi, 1);
}
// ヒープ作成
hh = OS_CreateHeap(OS_ARENA_WRAM_SUBPRIV, basicLo, basicHi);
if (hh < 0)
{
OS_Panic("ARM7: Failed to WRAM create heap.\n");
}
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh);
if( heapSize <= 0) /* ヒープ領域の確保に失敗 */
{
OS_Panic("ARM7: Failed to WRAM create heap.\n");
}
if (WM_WL_HEAP_SIZE > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE);
}
OS_TPrintf("ARM7: WRAM heap size is %d (before AddToHeap)\n", heapSize);
}
// ヒープに拡張ブロックを追加
OS_AddToHeap(OS_ARENA_WRAM_SUBPRIV, hh, extraLo, extraHi);
}
// カレントヒープに設定
(void)OS_SetCurrentHeap(OS_ARENA_WRAM_SUBPRIV, hh);
// ヒープサイズの確認
{
u32 heapSize;
heapSize = (u32)OS_CheckHeap(OS_ARENA_WRAM_SUBPRIV, hh);
if( heapSize <= 0) /* ヒープ領域の確保に失敗 */
{
OS_Panic("ARM7: Failed to WRAM create heap.\n");
}
if (WM_WL_HEAP_SIZE > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, WM_WL_HEAP_SIZE);
}
OS_TPrintf("ARM7: WRAM heap size is %d\n", heapSize);
}
}
return hh;
}
#include <twl/ltdwram_end.h>
#endif
#ifdef WM_PRECALC_ALLOWEDCHANNEL
extern u16 WMSP_GetAllowedChannel(u16 bitField);
#endif
/*---------------------------------------------------------------------------*
Name: ReadUserInfo
Description: NVRAMからユーザー情報を読み出し
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static void ReadUserInfo(void)
{
u8 *p = OS_GetSystemWork()->nvramUserInfo;
// 無線MACアドレスをユーザー情報の後ろに展開
{
u8 wMac[6];
// NVRAMからMACアドレスを読み出し
NVRAM_ReadDataBytes(NVRAM_CONFIG_MACADDRESS_ADDRESS, 6, wMac);
// 展開先アドレスを計算
p = (u8 *)((u32)p + ((sizeof(NVRAMConfig) + 3) & ~0x00000003));
// 共有領域に展開
MI_CpuCopy8(wMac, p, 6);
}
#ifdef WM_PRECALC_ALLOWEDCHANNEL
// 使用可能チャンネルから使用許可チャンネルを計算
{
u16 enableChannel;
u16 allowedChannel;
// 使用可能チャンネルを読み出し
NVRAM_ReadDataBytes(NVRAM_CONFIG_ENABLECHANNEL_ADDRESS, 2, (u8 *)(&enableChannel));
// 使用許可チャンネルを計算
allowedChannel = WMSP_GetAllowedChannel((u16)(enableChannel >> 1));
// 展開先アドレスを計算(MACアドレスの後ろの2バイト)
p = (u8 *)((u32)p + 6);
// 共有領域に展開
*((u16 *)p) = allowedChannel;
}
#endif
}
/*---------------------------------------------------------------------------*
Name: VBlankIntr
Description: V
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
extern BOOL PMi_Initialized;
void PM_SelfBlinkProc(void);
static void
VBlankIntr(void)
{
if (PMi_Initialized)
{
PM_SelfBlinkProc();
}
}

View File

@ -0,0 +1,49 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - tools - nandfirm-ds-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.
#
# $Log: $
# $NoKeywords: $
#----------------------------------------------------------------------------
TWL_PROC = ARM7
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,121 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - wram_regs
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:: 2007-12-11#$
$Rev: 2990 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#include <twl/mi.h>
#define HW_HYENA_WRAM_A_OFS (HW_WRAM_A_LTD - HW_WRAM_BASE)
#define HW_HYENA_WRAM_A_OFS_END (HW_HYENA_WRAM_A_OFS + HW_WRAM_A_SIZE)
#define HW_HYENA_WRAM_B_OFS (HW_WRAM_B - HW_WRAM_BASE)
#define HW_HYENA_WRAM_B_OFS_END (HW_HYENA_WRAM_B_OFS + HW_WRAM_B_SIZE * 2)
#define HW_HYENA_WRAM_C_OFS (HW_WRAM_C - HW_WRAM_BASE)
#define HW_HYENA_WRAM_C_OFS_END (HW_HYENA_WRAM_C_OFS + HW_WRAM_C_SIZE)
// MAP_TS_LTD for hyena
// WRAM-A Lock:ON, Master:ARM7, Enable:Slot0-3(256Kbytes), Address(7):0x037c0000-0x037fffff, Address(9):None
// WRAM-B Lock:ON, Master:ARM7, Enable:Slot5-7(96Kbytes), Address(7):0x037a8000-0x037bffff, Address(9):None
// WRAM-B Lock:OFF, Master:ARM9, Enable:Slot0-4(160Kbytes), Address(7):0x03740000-0x037bffff, Address(9):0x03740000-0x037bffff
// WRAM-C Lock:OFF, Msster:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03700000-0x0373ffff, Address(9):0x03700000-0x0373ffff
// WRAM-0 Master:ARM9, (16Kbytes), Address(7):0x03040000-0x03043fff, Address(9):0x03040000-0x03043fff
// WRAM-1 Master:ARM9, (16Kbytes), Address(7):0x03044000-0x03047fff, Address(9):0x03044000-0x03047fff
// MAP_TS_LTD original
// WRAM-A Lock:ON, Master:ARM7, Enable:Slot0-3(256Kbytes), Address(7):0x037c0000-0x037fffff, Address(9):None
// WRAM-B Lock:OFF, Master:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03740000-0x037bffff, Address(9):0x03740000-0x037bffff
// WRAM-C Lock:OFF, Msster:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03700000-0x0373ffff, Address(9):0x03700000-0x0373ffff
// WRAM-0 Master:ARM9, (16Kbytes), Address(7):0x03040000-0x03043fff, Address(9):0x03040000-0x03043fff
// WRAM-1 Master:ARM9, (16Kbytes), Address(7):0x03044000-0x03047fff, Address(9):0x03044000-0x03047fff
u32 HYENA_WramReg[0x30/sizeof(u32)] =
{
// ARM9
// WRAM-A
REG_MI_MBK1_FIELD(
TRUE, MI_WRAM_OFFSET_192KB/2, MI_WRAM_ARM7,
TRUE, MI_WRAM_OFFSET_128KB/2, MI_WRAM_ARM7,
TRUE, MI_WRAM_OFFSET_64KB/2, MI_WRAM_ARM7,
TRUE, MI_WRAM_OFFSET_0KB/2, MI_WRAM_ARM7
),
// WRAM-B
REG_MI_MBK2_FIELD(
TRUE, MI_WRAM_OFFSET_96KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_64KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_32KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_0KB, MI_WRAM_ARM9
),
REG_MI_MBK3_FIELD(
TRUE, MI_WRAM_OFFSET_224KB, MI_WRAM_ARM7,
TRUE, MI_WRAM_OFFSET_192KB, MI_WRAM_ARM7,
TRUE, MI_WRAM_OFFSET_160KB, MI_WRAM_ARM7,
TRUE, MI_WRAM_OFFSET_128KB, MI_WRAM_ARM9
),
// WRAM-C
REG_MI_MBK4_FIELD(
TRUE, MI_WRAM_OFFSET_96KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_64KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_32KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_0KB, MI_WRAM_ARM9
),
REG_MI_MBK5_FIELD(
TRUE, MI_WRAM_OFFSET_224KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_192KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_160KB, MI_WRAM_ARM9,
TRUE, MI_WRAM_OFFSET_128KB, MI_WRAM_ARM9
),
REG_MI_MBK6_FIELD( NULL >> 16,
MI_WRAM_IMAGE_256KB,
NULL >> 16
),
REG_MI_MBK7_FIELD( HW_HYENA_WRAM_B_OFS_END >> 15,
MI_WRAM_IMAGE_256KB,
HW_HYENA_WRAM_B_OFS >> 15
),
REG_MI_MBK8_FIELD( HW_HYENA_WRAM_C_OFS_END >> 15,
MI_WRAM_IMAGE_256KB,
HW_HYENA_WRAM_C_OFS >> 15
),
// ARM7
REG_MI_MBK6_FIELD( HW_HYENA_WRAM_A_OFS_END >> 16,
MI_WRAM_IMAGE_256KB,
HW_HYENA_WRAM_A_OFS >> 16
),
REG_MI_MBK7_FIELD( HW_HYENA_WRAM_B_OFS_END >> 15,
MI_WRAM_IMAGE_256KB,
HW_HYENA_WRAM_B_OFS >> 15
),
REG_MI_MBK8_FIELD( HW_HYENA_WRAM_C_OFS_END >> 15,
MI_WRAM_IMAGE_256KB,
HW_HYENA_WRAM_C_OFS >> 15
),
// WRAM Lock
(u32)(
(0x0F << 0) |
(0xE0 << 8) |
(0x00 << 16) |
// WRAM-0/1
(0 << 24) |
// VRAM-C
(7 << 26) |
// VRAM-D
(7 << 29)
),
};

35
build/gcdfirm/Makefile Normal file
View File

@ -0,0 +1,35 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - firmware
# 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$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = \
gcdfirm-disp \
gcdfirm-print \
sdmc-launcher \
sdmc-launcher-writer \
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,51 @@
#! 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 = gcdfirm_disp7.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
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,70 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - tools - firm_writer_gcd
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 <twl/mcu.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
void TwlSpMain( void )
{
#ifdef PRINT_DEBUG
reg_SCFG_JTAG = REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK;
#endif // PRINT_DEBUG
MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) );
OS_InitFIRM();
OS_TPrintf( "\nARM7 starts.\n" );
OS_EnableInterrupts();
OS_EnableIrq();
PM_InitFIRM();
#if SDK_TS_VERSION < 300
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 );
// ボタンが押されるまで待つ
OS_TPrintf( "\nPress A button.\n");
while ( !(PAD_Read() & PAD_BUTTON_A) )
{
}
OS_TPrintf( "\nARM7 ends.\n" );
(void)OS_DisableIrq();
// OSi_Finalize();
#ifdef PRINT_DEBUG
reg_SCFG_JTAG = REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK;
#endif // PRINT_DEBUG
while (1)
{
}
// OS_Terminate();
}

View File

@ -0,0 +1,54 @@
#! 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:$
#----------------------------------------------------------------------------
SUBDIRS =
#LINCLUDES = ../include
#----------------------------------------------------------------------------
TARGET_BIN = gcdfirm_disp9.srl
SRCS = main.c \
screen.c \
font.c \
CRT0_O = crt0_firm.o
ADDRESS_STATIC = 0x037c0000
MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/gcdfirm_disp7.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
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== 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,150 @@
/*---------------------------------------------------------------------------*
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"
//#include <string.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);
void TwlMain( void )
{
s16 x = 2, y = 2;
OS_TPrintf( "\nGCD Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick()));
MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) );
myInit();
OS_TPrintf( "\nARM9 starts.\n" );
//---- clear screen buffer
ClearScreen();
PrintString( x, y, FONT_CYAAN, "Gcdfirm-Disp" );
PrintString( (s16)(x+17), y++, FONT_WHITE, "%s", __DATE__ );
PrintString( (s16)(x+20), y++, FONT_WHITE, "%s", __TIME__ );
y++;
PrintString( x, y++, FONT_YELLOW, "Hello!");
OS_TPrintf( "\nARM9 ends.\n" );
OS_WaitVBlankIntr();
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,48 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - gcdfirm - gcdfirm-disp
# 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$
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
SUBDIRS = \
wram_regs \
ARM7 \
ARM9 \
TARGET_FIRM_BIN = gcdfirm_disp-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd
BINDIR = .
MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/gcdfirm_disp9.tef
MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/gcdfirm_disp7.tef
MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der
LDEPENDS_BIN += wram_regs/wram_regs.rbin
MAKEFIRM_FLAGS += -p
FIRM_SPEC = gcdfirm.gcdsf
LDIRT_CLEAN += $(wildcard *.gcd) \
rsa_public.sbin \
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,21 @@
#GCDSF --- Gcdfirm Spec File
VERSION : 0x0 # GENERATE
RSA_KEY : $(MAKEFIRM_RSA_PRVKEY)
OUT_KEY : rsa_public.sbin
WRAM_RBIN : ./wram_regs/wram_regs.rbin
ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN
ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin
ARM9_ELF : $(MAKEFIRM_ARM9).tef
ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN
ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin
ARM7_ELF : $(MAKEFIRM_ARM7).tef
ARM9_X2 : TRUE # TRUE or FALSE
#NORFIRM : $(NORFIRM_BIN)
#NANDFIRM : $(NANDFIRM_BIN)

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:: 2007-11-12#$
$Rev: 149 $
$Author: yutaka $
*---------------------------------------------------------------------------*/
#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

@ -0,0 +1,46 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - gcdfirm - gcdfirm-print
# 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$
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
SUBDIRS = ../../norfirm/norfirm-print
TARGET_FIRM_BIN = gcdfirm_print-$(TWL_BUILD_TYPE).gcd
BINDIR = .
MAKEFIRM_ARM9 = ../../norfirm/norfirm-print/ARM9/bin/$(TWL_BUILDTYPE_ARM9)/twl_norfirm9_print.tef
MAKEFIRM_ARM7 = ../../norfirm/norfirm-print/ARM7/bin/$(TWL_BUILDTYPE_ARM7)/twl_norfirm7_print.tef
MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der
LDEPENDS_BIN += ../../norfirm/norfirm-print/wram_regs/wram_regs.rbin
MAKEFIRM_FLAGS += -p
FIRM_SPEC = gcdfirm.gcdsf
LDIRT_CLEAN += $(wildcard *.gcd) \
rsa_public.sbin \
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,22 @@
#GCDSF --- Gcdfirm Spec File
VERSION : GENERATE
RSA_KEY : $(MAKEFIRM_RSA_PRVKEY)
OUT_KEY : rsa_public.sbin
WRAM_RBIN: ../../norfirm/norfirm-print/wram_regs/wram_regs.rbin
DECOMP_PROC : ARM9 # ARM9 or ARM7
ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN
ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin
ARM9_ELF : $(MAKEFIRM_ARM9).tef
ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN
ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin
ARM7_ELF : $(MAKEFIRM_ARM7).tef
ARM9_X2 : TRUE # TRUE or FALSE
NCD_ROMOFS : 0x07fe00

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,253 @@
/*---------------------------------------------------------------------------*
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);
}
/***************************************************************
PreInit
FromBootの対応
OS_Init前なので注意 (ARM9によるメインメモリ初期化で消されないように注意)
***************************************************************/
static void PreInit(void)
{
// GCDヘッダコピー
MI_CpuCopyFast( OSi_GetFromBromAddr(), (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END - HW_ROM_HEADER_BUF );
// FromBrom全消去
MIi_CpuClearFast( 0, (void*)OSi_GetFromBromAddr(), sizeof(OSFromBromBuf) );
}
/***************************************************************
PostInit
***************************************************************/
static void PostInit(void)
{
MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK );
PM_BackLightOn( TRUE );
// アイドルスレッドの作成
CreateIdleThread();
// XYボタン通知
PAD_InitXYButton();
/*
*/
MCUi_WriteRegister( MCU_REG_MODE_ADDR, MCU_SYSTEMMODE_FIRMWARE ); // change battery level only
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 = (GCDHeader*)HW_ROM_HEADER_BUF;
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

@ -0,0 +1,53 @@
#! 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$
#----------------------------------------------------------------------------
SUBDIRS =
#LINCLUDES = ../include
#----------------------------------------------------------------------------
TARGET_BIN = sdmc_launcher_writer9.srl
SRCS = main.c \
screen.c \
font.c
CRT0_O = crt0_firm.o
ADDRESS_STATIC = 0x037c0000
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
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== 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,62 @@
#! 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 \
LDEPENDS_BIN += $(NANDFIRM_BIN)
endif
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
do-build: $(TARGET_BIN)
$(NANDFIRM_BIN):
$(REMAKE) -C $(dir $(NANDFIRM_BIN))
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,21 @@
#GCDSF --- Gcdfirm Spec File
VERSION : 0x0 # GENERATE
RSA_KEY : $(MAKEFIRM_RSA_PRVKEY)
OUT_KEY : rsa_public.sbin
WRAM_RBIN : ./wram_regs/wram_regs.rbin
ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN
ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin
ARM9_ELF : $(MAKEFIRM_ARM9).tef
ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN
ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin
ARM7_ELF : $(MAKEFIRM_ARM7).tef
ARM9_X2 : TRUE # TRUE or FALSE
#NORFIRM : $(NORFIRM_BIN)
NANDFIRM : $(NANDFIRM_BIN)

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

@ -0,0 +1,49 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - nandfirm - sdmc-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 =
#----------------------------------------------------------------------------
TARGET_BIN = sdmc_launcher7.tef
SRCS = main.c
CRT0_O = crt0_firm.o
#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
MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037c0000'
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,339 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - gcdfirm - sdmc-launcher
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.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <firm.h>
#include <twl/mcu.h>
/*
PROFILE_ENABLE
main.cかどこかにu32 profile[256]; u32 pf_cnt = 0;
*/
#define PROFILE_ENABLE
/*
LEDをFINALROMとは別にOn/Offできます
*/
#define USE_DEBUG_LED
/*
PRINT_MEMORY_ADDR SPrintfを行います()
FINALROM版でもコードが残るので注意してください
*/
//#define PRINT_MEMORY_ADDR 0x02FFC800
#ifdef PROFILE_ENABLE
#define PROFILE_MAX 16
u32 profile[PROFILE_MAX];
u32 pf_cnt = 0;
#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()))
#else
#define PUSH_PROFILE() ((void)0)
#endif
#ifdef USE_DEBUG_LED
static u8 step = 0x80;
#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
#ifdef PRINT_MEMORY_ADDR
static char* debugPtr = (char*)PRINT_MEMORY_ADDR;
#undef OS_TPrintf
//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf))
#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__))
#endif
#define THREAD_PRIO_FATFS 8
#define DMA_FATFS_1 0
#define DMA_FATFS_2 1
static ROM_Header* const rh= (ROM_Header*)HW_TWL_ROM_HEADER_BUF;
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)
{
/*
*/
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
}
}
/*
FromBrom関連
*/
if ( !OSi_FromBromToMenu() )
{
OS_Terminate();
}
/*
(1)(1)
*/
#define HOTSTART_FLAG_ENABLE 0x80
if ( IS_OLD_MCU ) // MCU旧バージョン対策
{
*(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCUi_ReadRegister( (u16)(MCU_OLD_REG_TEMP_ADDR + OS_MCU_RESET_VALUE_OFS) ) | HOTSTART_FLAG_ENABLE);
}
else
{
*(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCUi_ReadRegister( (u16)(MCU_REG_TEMP_ADDR + OS_MCU_RESET_VALUE_OFS) ) | HOTSTART_FLAG_ENABLE);
}
}
/***************************************************************
PostInit
***************************************************************/
static void PostInit(void)
{
#if SDK_TS_VERSION <= 200
// PMICの設定 for old version
PM_InitFIRM();
#endif
// AESの初期化
AES_Init(); // for encrypted NAND
// マウント情報の初期化
FS_InitMountInfo(FALSE, TRUE);
// アイドルスレッドの作成
CreateIdleThread();
/*
*/
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)
{
AESi_ResetAesKeyA();
AESi_ResetAesKeyB();
AESi_ResetAesKeyC();
MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) );
#ifdef SDK_FINALROM
MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE );
OS_BootFromFIRM();
#endif
}
void TwlSpMain( void )
{
int fd; // menu file descriptor
#ifdef PROFILE_ENABLE
// 0: bootrom
profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick());
#endif
InitDebugLED();
SetDebugLED(++step); // 0x81
PreInit();
#ifdef PROFILE_ENABLE
// 1: after PreInit
profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick());
#endif
SetDebugLED(++step); // 0x82
OS_InitFIRM();
OS_EnableIrq();
OS_EnableInterrupts();
// 2: after OS_InitFIRM
PUSH_PROFILE();
SetDebugLED(++step); // 0x83
PostInit();
// 3: after PostInit
PUSH_PROFILE();
SetDebugLED(++step); // 0x84
if ( !FATFS_Init( DMA_FATFS_1, DMA_FATFS_2, THREAD_PRIO_FATFS ) )
{
OS_TPrintf("Failed to call FATFS_Init().\n");
goto end;
}
// 4: after FATFS_Init
PUSH_PROFILE();
SetDebugLED(++step); // 0x85
if ( PXI_RecvID() != FIRM_PXI_ID_SET_PATH )
{
OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_SET_PATH).\n");
goto end;
}
// 5: after PXI
PUSH_PROFILE();
SetDebugLED(++step); // 0x86
if ( (fd = FS_OpenSrl()) < 0 )
{
OS_TPrintf("Failed to call FS_OpenSrl().\n");
goto end;
}
// 6: after FS_OpenSrl
PUSH_PROFILE();
SetDebugLED(++step); // 0x87
if ( !FS_LoadHeader( fd ) )
{
OS_TPrintf("Failed to call FS_LoadHeader().\n");
goto end;
}
// 7: after FS_LoadHeader
PUSH_PROFILE();
SetDebugLED(++step); // 0x88
if ( PXI_RecvID() != FIRM_PXI_ID_DONE_HEADER )
{
OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_HEADER).\n");
goto end;
}
// 8: after PXI
PUSH_PROFILE();
SetDebugLED(++step); // 0x89
AESi_InitKeysFIRM();
AESi_InitSeed();
// 9: after AESi_InitSeed
PUSH_PROFILE();
SetDebugLED(++step); // 0x8a
if ( !FS_LoadStatic( fd ) )
{
OS_TPrintf("Failed to call FS_LoadStatic().\n");
goto end;
}
// 10: after FS_LoadStatic
PUSH_PROFILE();
SetDebugLED(++step); // 0x8b
if ( PXI_RecvID() != FIRM_PXI_ID_DONE_STATIC )
{
OS_TPrintf("PXI_RecvID() was received invalid value (!=FIRM_PXI_ID_DONE_STATIC).\n");
goto end;
}
// 11: after PXI
PUSH_PROFILE();
#ifdef PROFILE_ENABLE
{
int i;
PXI_RecvID();
OS_TPrintf("\n[ARM7] Begin\n");
for (i = 0; i < PROFILE_MAX; i++)
{
// OS_TPrintf("0x%08X\n", profile[i]);
if ( !profile[i] ) break;
OS_TPrintf("%2d: %7d usec", i, profile[i]);
if (i)
{
OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]);
}
else
{
OS_TPrintf("\n");
}
}
OS_TPrintf("\n[ARM7] End\n");
}
#endif
SetDebugLED( 0 );
#if SDK_TS_VERSION < 300
PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, 22, PMIC_BL_BRT_B_MASK );
#else
MCUi_WriteRegister( MCU_REG_BL_ADDR, MCU_REG_BL_BRIGHTNESS_MASK );
#endif
PM_BackLightOn( TRUE );
AESi_ResetAesKeyA();
AESi_ResetAesKeyB();
AESi_ResetAesKeyC();
MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) );
FS_SetMountInfoForSrl();
OS_BootFromFIRM();
end:
SetDebugLED( (u8)(0xF0 | step));
EraseAll();
// failed
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

@ -0,0 +1,51 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - nandfirm - sdmc-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$
#----------------------------------------------------------------------------
SUBDIRS =
LINCLUDES =
#----------------------------------------------------------------------------
TARGET_BIN = sdmc_launcher9.srl
SRCS = main.c
CRT0_O = crt0_firm.o
MAKEROM_ARM7 = ../ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.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
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,331 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - gcdfirm - sdmc-launcher
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.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <firm.h>
#ifndef FIRM_USE_TWLSDK_KEYS
static const u8* rsa_key_user = NULL; // not acceptable
static const u8* rsa_key_sys = NULL; // not acceptable
static const u8 rsa_key_secure[128] =
{
0xC7, 0x94, 0x50, 0x00, 0x3A, 0xE1, 0x0E, 0x6C, 0xA8, 0xD1, 0xC0, 0x2D, 0x77, 0xB7, 0x6D, 0xBC,
0x31, 0xDB, 0x12, 0x08, 0x09, 0x0D, 0x2A, 0xE8, 0xC9, 0x1A, 0x2B, 0x6E, 0x6C, 0x85, 0x78, 0xD7,
0x46, 0x50, 0x05, 0xB5, 0xCC, 0x3B, 0xEC, 0xBA, 0xF4, 0xDE, 0xC2, 0x13, 0x13, 0xBE, 0x67, 0xEE,
0x85, 0x19, 0xEB, 0x62, 0xB3, 0x5C, 0x09, 0xA8, 0x54, 0x44, 0x26, 0x85, 0x25, 0xEA, 0xE5, 0x85,
0xD1, 0xB5, 0xCE, 0xA0, 0xFF, 0x6B, 0x61, 0xCA, 0x94, 0xC1, 0x67, 0xBE, 0xC0, 0x7E, 0x3B, 0xFF,
0x12, 0x9B, 0x79, 0xDB, 0xAC, 0xD3, 0x5A, 0x3F, 0x14, 0x37, 0x49, 0xA8, 0x7C, 0x2F, 0x07, 0xF4,
0x8B, 0xA9, 0x8B, 0x8D, 0xB2, 0x60, 0xA5, 0xD5, 0x64, 0xEE, 0xCF, 0x3F, 0x32, 0xEE, 0x77, 0xAC,
0x27, 0x75, 0x2B, 0x04, 0xD7, 0x26, 0xA8, 0x8A, 0x55, 0x2A, 0x76, 0xE5, 0x68, 0x80, 0x57, 0x85
};
#else
static const u8 rsa_key_user[128] =
{
0xAC, 0x93, 0xBB,
0x3C, 0x15, 0x5C, 0x5F, 0x25, 0xB0, 0x4C, 0x37, 0xA4, 0x2D, 0x85, 0x29, 0x1D, 0x7A, 0x9D, 0x2D,
0xD5, 0x79, 0xB5, 0x5D, 0xB1, 0x08, 0x20, 0x9C, 0xF0, 0x4C, 0x56, 0x27, 0x97, 0xF8, 0x7E, 0x3E,
0xCB, 0x94, 0x06, 0x05, 0x94, 0x00, 0x92, 0x9B, 0xB0, 0x5B, 0x06, 0xF6, 0xAF, 0xAA, 0x9C, 0xA5,
0xF0, 0x11, 0xA7, 0x8A, 0xCB, 0x0C, 0x11, 0xD6, 0x0C, 0x3D, 0x30, 0xAC, 0x51, 0x79, 0x5A, 0xB5,
0x7F, 0x11, 0x92, 0x74, 0x48, 0x82, 0x81, 0xBF, 0x3B, 0xFA, 0x93, 0xBF, 0x6B, 0x5B, 0x3F, 0x86,
0x96, 0x4F, 0xCC, 0x90, 0x12, 0xB2, 0x39, 0x8D, 0x68, 0x16, 0x7B, 0xC6, 0x87, 0xF1, 0xF5, 0x60,
0x62, 0x39, 0xFB, 0x10, 0x7E, 0x48, 0x7F, 0xDD, 0x82, 0x38, 0x38, 0x76, 0xB5, 0xCE, 0x21, 0x4B,
0xC9, 0x6F, 0x31, 0x8D, 0x23, 0x57, 0x3D, 0xB6, 0x6C, 0xEE, 0xC2, 0x0D, 0x11
};
static const u8 rsa_key_sys[128] =
{
0xe9, 0x9e, 0xa7, 0x9f, 0x59, 0x4d, 0xf4, 0xa7, 0x60, 0x04, 0xbd, 0x47, 0xf2, 0xb3, 0x64, 0xcd,
0x16, 0x79, 0xc1, 0x47, 0x39, 0xf6, 0xa9, 0xf8, 0xee, 0x1a, 0xd0, 0x72, 0xcf, 0x43, 0x97, 0x0c,
0x93, 0xa1, 0x38, 0x4e, 0x13, 0x40, 0x6c, 0x10, 0x59, 0x43, 0xe2, 0x71, 0x29, 0x54, 0x14, 0x2c,
0xc5, 0xda, 0x59, 0x4d, 0xb4, 0x6a, 0xef, 0x85, 0x61, 0x6f, 0x7f, 0x1c, 0x59, 0x34, 0x2c, 0xc6,
0x24, 0xf3, 0x7b, 0xc3, 0xb7, 0x40, 0xd1, 0x46, 0xf8, 0x90, 0xb7, 0xc2, 0x98, 0x50, 0xaf, 0x95,
0x52, 0x42, 0xdb, 0xac, 0xd6, 0x7e, 0xa9, 0xc3, 0x3d, 0x1b, 0x51, 0x56, 0x07, 0x06, 0xd0, 0x0b,
0x01, 0xbb, 0x58, 0x93, 0xea, 0xa0, 0x2c, 0xc7, 0x7d, 0x6a, 0x31, 0x7e, 0xc9, 0xe2, 0xda, 0xfe,
0x1f, 0x2e, 0x9d, 0xa7, 0x54, 0x84, 0xdc, 0x28, 0xb9, 0x18, 0xea, 0x16, 0xf2, 0x95, 0x55, 0x6d,
};
static const u8 rsa_key_secure[128] =
{
0xa7, 0x9f, 0x54, 0xa0, 0xc7, 0x45, 0xae, 0xf6, 0x63, 0xa7, 0x53, 0xb7, 0x0a, 0xcc, 0x0b, 0xcb,
0x65, 0xe1, 0x11, 0xc6, 0x05, 0x15, 0xb5, 0x6e, 0xbd, 0xac, 0x0c, 0xca, 0xf4, 0x7c, 0x68, 0x7a,
0xf9, 0x0e, 0x5d, 0x98, 0x5b, 0xc8, 0x4d, 0x22, 0x3b, 0xa3, 0xbe, 0x8b, 0x5b, 0x7f, 0x26, 0x44,
0x9f, 0xc4, 0x48, 0x44, 0xb1, 0x32, 0xb7, 0xbe, 0x63, 0xba, 0xd6, 0xc1, 0x10, 0xce, 0xf6, 0xed,
0x47, 0x8f, 0xe1, 0xff, 0x7f, 0x5a, 0xd5, 0x5d, 0x94, 0x38, 0x2f, 0xa1, 0xd4, 0xef, 0x82, 0xb1,
0x0d, 0xc4, 0x43, 0xec, 0xbe, 0x77, 0xb6, 0x82, 0x9c, 0xfa, 0x17, 0x87, 0x84, 0x82, 0x25, 0x46,
0xfb, 0xd6, 0x05, 0xc8, 0x9a, 0x7e, 0xad, 0x44, 0x40, 0x0d, 0x35, 0x9c, 0x45, 0x44, 0x64, 0x36,
0x61, 0x4b, 0xf7, 0xe6, 0x31, 0x5c, 0x7d, 0x96, 0x73, 0xe8, 0xac, 0xb4, 0xe3, 0x5e, 0xd1, 0x9d,
};
#endif
#define RSA_HEAP_SIZE (4*1024) // RSA用ヒープサイズ (サイズ調整必要)
static u8 acHeap[RSA_HEAP_SIZE] __attribute__ ((aligned (32)));
static SVCSignHeapContext acPool;
#define MENU_FILE "sdmc:/menu.srl"
/*
PROFILE_ENABLE
main.cかどこかにu32 profile[256]; u32 pf_cnt = 0;
*/
#define PROFILE_ENABLE
/*
PRINT_MEMORY_ADDR SPrintfを行います()
FINALROM版でもコードが残るので注意してください
*/
//#define PRINT_MEMORY_ADDR 0x02FFC000
//#ifdef SDK_FINALROM // FINALROMで無効化
//#undef PROFILE_ENABLE
//#endif
#ifdef PROFILE_ENABLE
#define PROFILE_MAX 16
u32 profile[PROFILE_MAX];
u32 pf_cnt = 0;
#define PUSH_PROFILE() (profile[pf_cnt++] = (u32)OS_TicksToMicroSeconds(OS_GetTick()))
#else
#define PUSH_PROFILE() ((void)0)
#endif
#ifdef PRINT_MEMORY_ADDR
static char* debugPtr = (char*)PRINT_MEMORY_ADDR;
#undef OS_TPrintf
//#define OS_TPrintf(...) (debugPtr = (char*)((u32)(debugPtr + STD_TSPrintf(debugPtr, __VA_ARGS__) + 0xf) & ~0xf))
#define OS_TPrintf(...) (debugPtr += STD_TSPrintf(debugPtr, __VA_ARGS__))
#endif
/***************************************************************
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関連
*/
if ( !OSi_FromBromToMenu() )
{
OS_Terminate();
}
// ブートタイプの変更
( (OSBootInfo *)OS_GetBootInfo() )->boot_type = OS_BOOTTYPE_NAND;
}
/***************************************************************
PostInit
***************************************************************/
static void PostInit(void)
{
// RSA用ヒープ設定
SVC_InitSignHeap( &acPool, acHeap, sizeof(acHeap) );
// FS/FATFS初期化
FS_InitFIRM();
}
/***************************************************************
CheckHeader
***************************************************************/
static BOOL CheckHeader(void)
{
ROM_Header_Short* const rhs = (ROM_Header_Short*)HW_TWL_ROM_HEADER_BUF;
// イニシャルコードなど
OS_TPrintf("Initial Code : %08X (%.4s)\n", *(u32*)rhs->game_code, rhs->game_code);
OS_TPrintf("Platform Code : %02X\n", rhs->platform_code);
OS_TPrintf("Codec Mode : %s\n", rhs->codec_mode ? "TWL" : "NITRO");
OS_TPrintf("Sigunature : %s\n", rhs->enable_signature ? "AVAILABLE" : "NOT AVAILABLE");
OS_TPrintf("AES Encryption : %s\n", rhs->enable_aes ? "AVAILABLE" : "NOT AVAILABLE");
if ( rhs->enable_aes )
{
OS_TPrintf("AES Key Type : %s\n", rhs->developer_encrypt ? "FOR DEVELOPMENT" : "FOR PRODUCT");
}
// エントリポイント
OS_TPrintf("ARM9 Entry point : %08X\n", rhs->main_entry_address);
OS_TPrintf("ARM7 Entry point : %08X\n", rhs->sub_entry_address);
// ロード範囲
OS_TPrintf("ARM9 ROM address : %08X\n", rhs->main_rom_offset);
OS_TPrintf("ARM9 RAM address : %08X\n", rhs->main_ram_address);
OS_TPrintf("ARM9 size : %08X\n", rhs->main_size);
OS_TPrintf("ARM7 ROM address : %08X\n", rhs->sub_rom_offset);
OS_TPrintf("ARM7 RAM address : %08X\n", rhs->sub_ram_address);
OS_TPrintf("ARM7 size : %08X\n", rhs->sub_size);
OS_TPrintf("ARM9 LTD ROM address: %08X\n", rhs->main_ltd_rom_offset);
OS_TPrintf("ARM9 LTD RAM address: %08X\n", rhs->main_ltd_ram_address);
OS_TPrintf("ARM9 LTD size : %08X\n", rhs->main_ltd_size);
OS_TPrintf("ARM7 LTD ROM address: %08X\n", rhs->sub_ltd_rom_offset);
OS_TPrintf("ARM7 LTD RAM address: %08X\n", rhs->sub_ltd_ram_address);
OS_TPrintf("ARM7 LTD size : %08X\n", rhs->sub_ltd_size);
#ifndef NO_SECURITY_CHECK
// 順序ほぼ最適化済み
#ifndef FIRM_USE_TWLSDK_KEYS
if ( rhs->platform_code != PLATFORM_CODE_TWL_LIMITED || // TWL Limited only
!rhs->enable_signature || // Should be use ROM header signature
#else
if ( // no check
#endif
!rhs->codec_mode || // TWL mode only
// should be in main memory
HW_TWL_MAIN_MEM > (u32)rhs->main_ram_address ||
HW_TWL_MAIN_MEM > (u32)rhs->sub_ram_address ||
HW_TWL_MAIN_MEM > (u32)rhs->main_ltd_ram_address ||
HW_TWL_MAIN_MEM > (u32)rhs->sub_ltd_ram_address ||
// should be in static area without Limited region
(u32)rhs->main_ram_address > (u32)rhs->main_entry_address ||
(u32)rhs->sub_ram_address > (u32)rhs->sub_entry_address ||
// should be in main memory (end address)
HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ram_address + rhs->main_size ||
HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ram_address + rhs->sub_size ||
HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->main_ltd_ram_address + rhs->main_ltd_size ||
HW_FIRM_FATFS_COMMAND_BUFFER <= (u32)rhs->sub_ltd_ram_address + rhs->sub_ltd_size ||
// should be in static area without Limited region (end address)
(u32)rhs->main_ram_address + rhs->main_size <= (u32)rhs->main_entry_address ||
(u32)rhs->sub_ram_address + rhs->sub_size <= (u32)rhs->sub_entry_address ||
0 )
{
OS_TPrintf("Invalid ROM header for SDMC Launcher!\n");
return FALSE;
}
#endif
return TRUE;
}
/***************************************************************
EraseAll
DSモードにして終わるのがよいか
***************************************************************/
static void EraseAll(void)
{
MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) );
#ifdef SDK_FINALROM
MI_CpuClearFast( (void*)HW_TWL_ROM_HEADER_BUF, HW_TWL_ROM_HEADER_BUF_SIZE );
MI_CpuClearFast( (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF );
OS_BootFromFIRM();
#endif
}
void TwlMain( void )
{
#ifdef PROFILE_ENABLE
// 0: bootrom
profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick());
#endif
PreInit();
#ifdef PROFILE_ENABLE
// 1: before OS_InitFIRM
profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick());
#endif
OS_InitFIRM();
OS_EnableIrq();
OS_EnableInterrupts();
#ifdef PROFILE_ENABLE
// 2: before OS_InitTick
profile[pf_cnt++] = OS_TicksToMicroSecondsBROM32(OS_GetTick());
OS_InitTick();
#endif
PostInit();
// 3: after PostInit
PUSH_PROFILE();
STD_CopyString((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, MENU_FILE);
// 4: after STD_CopyString
PUSH_PROFILE();
PXI_NotifyID( FIRM_PXI_ID_SET_PATH );
// 5: after PXI
PUSH_PROFILE();
if ( !FS_LoadHeader( &acPool, rsa_key_user, rsa_key_sys, rsa_key_secure ) || !CheckHeader() )
{
OS_TPrintf("Failed to call FS_LoadHeader() and/or CheckHeader().\n");
goto end;
}
// 6: after FS_LoadHeader
PUSH_PROFILE();
PXI_NotifyID( FIRM_PXI_ID_DONE_HEADER );
// 7: after PXI
PUSH_PROFILE();
if ( !FS_LoadStatic( NULL ) )
{
OS_TPrintf("Failed to call FS_LoadStatic().\n");
goto end;
}
// 8: after FS_LoadStatic
PUSH_PROFILE();
PXI_NotifyID( FIRM_PXI_ID_DONE_STATIC );
// 9: after PXI
PUSH_PROFILE();
#ifdef PROFILE_ENABLE
{
int i;
OS_TPrintf("\n[ARM9] Begin\n");
for (i = 0; i < PROFILE_MAX; i++)
{
// OS_TPrintf("0x%08X\n", profile[i]);
if ( !profile[i] ) break;
OS_TPrintf("%2d: %7d usec", i, profile[i]);
if (i)
{
OS_TPrintf(" ( %7d usec )\n", profile[i]-profile[i-1]);
}
else
{
OS_TPrintf("\n");
}
}
OS_TPrintf("\n[ARM9] End\n");
PXI_NotifyID( FIRM_PXI_ID_NULL );
}
#endif
MI_CpuClearFast( OSi_GetFromFirmAddr(), sizeof(OSFromFirmBuf) );
OS_BootFromFIRM();
end:
EraseAll();
// failed
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

@ -0,0 +1,48 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - gcdfirm - sdmc-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$
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
SUBDIRS = \
wram_regs \
ARM7 \
ARM9 \
TARGET_FIRM_BIN = sdmc_launcher-$(TWL_BUILD_TYPE)$(CODEGEN_ARCH).gcd
BINDIR = .
MAKEFIRM_ARM9 = ARM9/bin/$(TWL_BUILDTYPE_ARM9)/sdmc_launcher9.tef
MAKEFIRM_ARM7 = ARM7/bin/$(TWL_BUILDTYPE_ARM7)/sdmc_launcher7.tef
MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_gcd.der
LDEPENDS_BIN += wram_regs/wram_regs.rbin
MAKEFIRM_FLAGS += -p
FIRM_SPEC = gcdfirm.gcdsf
LDIRT_CLEAN += $(wildcard *.gcd) \
rsa_public.sbin \
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,21 @@
#GCDSF --- Gcdfirm Spec File
VERSION : 0x0 # GENERATE
RSA_KEY : $(MAKEFIRM_RSA_PRVKEY)
OUT_KEY : rsa_public.sbin
WRAM_RBIN : ./wram_regs/wram_regs.rbin
ARM9_COMP : FALSE # TRUE or FALSE, should be before ARM9_SBIN
ARM9_SBIN : $(MAKEFIRM_ARM9).TWL.FLX.sbin
ARM9_ELF : $(MAKEFIRM_ARM9).tef
ARM7_COMP : FALSE # TRUE or FALSE, should be before ARM7_SBIN
ARM7_SBIN : $(MAKEFIRM_ARM7).TWL.FLX.sbin
ARM7_ELF : $(MAKEFIRM_ARM7).tef
ARM9_X2 : TRUE # TRUE or FALSE
#NORFIRM : $(NORFIRM_BIN)
#NANDFIRM : $(NANDFIRM_BIN)

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 =
#----------------------------------------------------------------------------
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,
};

40
build/libraries/Makefile Normal file
View File

@ -0,0 +1,40 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries
# 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$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS_P = \
init \
os \
pxi \
fs \
mi \
fatfs \
aes \
pm \
nvram \
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,52 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - aes
# 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:$
#----------------------------------------------------------------------------
SUBDIRS =
SUBMAKES =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= TRUE
# Codegen for sub processer
TWL_PROC = ARM7
SRCDIR = .
SRCS = \
aes_init.c \
TARGET_LIB = libaes_sp$(FIRM_LIBSUFFIX).a
#----------------------------------------------------------------------------
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
#===== End of Makefile =====

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - aes
File: aes_init.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 <firm/os.h>
#include <firm/aes.h>
#include <firm/pxi.h>
// •Ï<E280A2>X‰Â
#define AES_IDS_ID0_C(c) (((unsigned long)c[0] << 0) | ((unsigned long)c[1] << 8) | ((unsigned long)c[2] << 16) | ((unsigned long)c[3] << 24))
#define AES_IDS_ID0_D(c) (((unsigned long)c[3] << 0) | ((unsigned long)c[2] << 8) | ((unsigned long)c[1] << 16) | ((unsigned long)c[0] << 24))
/*---------------------------------------------------------------------------*
Name: AESi_PreInitKeys
Description: reset IDs preset by bootrom.
you SHOULD NOT touch any ID registers after this call.
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void AESi_PreInitKeys( void )
{
AES_WaitKey();
reg_AES_AES_ID_B2 = reg_OS_CHIP_ID1 ^ *(const u32*)&OSi_GetFromFirmAddr()->aes_key[2][0];
reg_AES_AES_ID_D1 = reg_OS_CHIP_ID0 ^ *(const u32*)&OSi_GetFromFirmAddr()->aes_key[2][8];
reg_AES_AES_ID_D2 = reg_OS_CHIP_ID1 ^ *(const u32*)&OSi_GetFromFirmAddr()->aes_key[2][4];
}
/*---------------------------------------------------------------------------*
Name: AESi_InitKeysForApp
Description: set IDs depending on the application.
you SHOULD NOT touch any ID registers after this call.
Arguments: game_code game code
Returns: None
*---------------------------------------------------------------------------*/
void AESi_InitKeysForApp( u8 game_code[4] )
{
AES_Lock();
AES_WaitKey();
reg_AES_AES_ID_A2 = AES_IDS_ID0_C(game_code);
reg_AES_AES_ID_A3 = AES_IDS_ID0_D(game_code);
AES_Unlock();
}
/*---------------------------------------------------------------------------*
Name: AESi_InitKeysForHard
Description: set IDs depending on the system hardware.
you SHOULD NOT use this for standard applications.
Arguments: fuse camouflaged fuse id
Returns: None
*---------------------------------------------------------------------------*/
void AESi_InitKeysForHard( u8 fuse[8] )
{
AES_Lock();
AES_WaitKey();
reg_AES_AES_ID_B2 = *(u32*)&fuse[4];
reg_AES_AES_ID_B3 = *(u32*)&fuse[0];
reg_AES_AES_ID_D0 = *(u32*)&fuse[0];
reg_AES_AES_ID_D3 = *(u32*)&fuse[4];
AES_Unlock();
}
/*---------------------------------------------------------------------------*
Name: AESi_InitSeedWithRomHeader
Description: set SEED/KEY from ROM header
Arguments: rom_header ROM header
Returns: None
*---------------------------------------------------------------------------*/
void AESi_InitSeedWithRomHeader( ROM_Header* rom_header )
{
AES_Lock();
AES_WaitKey();
if ( !rom_header )
{
return;
}
if ( rom_header->s.developer_encrypt )
{
AES_SetKeyA( (AESKey*)rom_header->s.title_name );
}
else
{
AES_SetKeySeedA( (AESKeySeed*)rom_header->s.main_ltd_static_digest );
}
AES_Unlock();
}

View File

@ -0,0 +1,31 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - libraries - aes
# 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:$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = ARM7
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,42 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - fatfs
# 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$
#----------------------------------------------------------------------------
SUBDIRS =
SUBMAKES =
#----------------------------------------------------------------------------
SRCS = fatfs_firm.c
TARGET_LIB = libfatfs$(FIRM_LIBSUFFIX).a
#----------------------------------------------------------------------------
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
#===== End of Makefile =====

View File

@ -0,0 +1,35 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - fatfs
File: fatfs_firm.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 <firm.h>
#include <twl/types.h>
#include <twl/fatfs/common/api.h>
void FATFS_InitFIRM( void )
{
MI_CpuClearFast( (void*)HW_FIRM_FATFS_COMMAND_BUFFER, HW_FIRM_FATFS_COMMAND_BUFFER_SIZE );
MI_CpuClearFast( (void*)HW_FIRM_FATFS_ARCHNAME_LIST, HW_FIRM_FATFS_ARCHNAME_LIST_SIZE );
FATFSiCommandBuffer = (void*)HW_FIRM_FATFS_COMMAND_BUFFER;
FATFSiArcnameList = (void*)HW_FIRM_FATFS_ARCHNAME_LIST;
FATFS_Init();
}
void FATFSi_GetUnicodeConversionTable(const u8 **u2s, const u16 **s2u)
{
*u2s = NULL;
*s2u = NULL;
}

View File

@ -0,0 +1,31 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - libraries - fatfs
# 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:$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = ARM9
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,54 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - fs
# 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$
#----------------------------------------------------------------------------
SUBDIRS =
SUBMAKES =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= TRUE
# Codegen for sub processer
TWL_PROC = ARM7
LINCLUDES = \
$(ROOT)/build/libraries/fatfs/ARM7.TWL/include \
$(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7
SRCS = fs_firm.c fs_firm_ex.c fs_loader.c
TARGET_LIB = libfs_sp$(FIRM_LIBSUFFIX).a
#----------------------------------------------------------------------------
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
#===== End of Makefile =====

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - fs
File: fs_firm.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 <symbols.h>
#include <firm.h>
#include <rtfs.h>
static void ConvertPath( u16* dest, const char* src, u32 max)
{
dest[0] = 0;
{
const OSMountInfo *info;
int len;
// デバイス部分を取得
for (len = 0; src[len] && src[len] != ':'; len++)
{
if (len >= max) // もっと手前で止めても良い?
{
OS_TPrintf("%s: Cannot detect ':' in %d charactors.\n", __func__, len);
return;
}
}
// ドライブ名の解決
for (info = (void*)HW_FIRM_MOUNT_INFO_BUF; *info->drive; ++info)
{
if ((STD_CompareNString(src, info->archiveName, len) == 0) &&
(info->archiveName[len] == 0))
{
if (info->target != OS_MOUNT_TGT_ROOT) // 多重マウント未対応
{
return;
}
dest[0] = (u16)*info->drive;
break;
}
}
max --;
dest++;
src += len;
}
{
int len;
// 残りunicode化 (ASCIIのみ)
for (len = 0; len < max && src[len]; len++)
{
if (src[len] == '/')
{
dest[len] = L'\\';
}
#ifndef SDK_FINALROM
else if (src[len] & 0x80)
{
OS_TPrintf("%s: Multi-byte charactor was detected (0x%02X).\n", __func__, src[len]);
dest[len] = (u16)src[len]; // ignore but maybe broken
}
#endif
else
{
dest[len] = (u16)src[len];
}
}
if (len < max)
{
dest[len] = 0;
}
else // l type (ensure to terminate zero)
{
dest[max-1] = 0;
}
}
}
/*---------------------------------------------------------------------------*
Name: FS_InitMountInfo
Description: set mount info for firm
Arguments: nand TRUE if set nand entry
sdmc TRUE if set sdmc entry
Returns: None
*---------------------------------------------------------------------------*/
void FS_InitMountInfo( BOOL nand, BOOL sdmc )
{
const OSMountInfo nandSetting = { 'A', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "nand", "/" };
const OSMountInfo sdmcSetting = { 'B', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" };
OSMountInfo* dest = (OSMountInfo*)HW_FIRM_MOUNT_INFO_BUF;
if ( nand )
{
MI_CpuCopy8(&nandSetting, dest++, sizeof(OSMountInfo));
}
if ( sdmc )
{
MI_CpuCopy8(&sdmcSetting, dest++, sizeof(OSMountInfo));
}
if ( dest < (void*)HW_FIRM_BOOT_SRL_PATH_BUF )
{
*(u32*)dest = 0;
}
*(u8*)HW_TWL_RED_LAUNCHER_VER = 1;
*(char*)HW_FIRM_BOOT_SRL_PATH_BUF = 0; // no rom archive
}
/*---------------------------------------------------------------------------*
Name: FS_OpenSrl
Description: open srl file named via HW_FIRM_TEMP_SRL_PATH_BUF
Arguments: None
Returns: file discriptor
*---------------------------------------------------------------------------*/
int FS_OpenSrl( void )
{
u16 fatpath[HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE];
ConvertPath(fatpath, (void*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE);
return FATFSi_rtfs_po_open((u8*)fatpath, 0, 0);
}

View File

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - fs
File: fs_firm_ex.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.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <firm.h>
#if 0
REBOOT内部でコピーする必要がある
#endif
/*---------------------------------------------------------------------------*
Name: FS_SetMountInfoForSrl
Description: set mount info for srl file
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void FS_SetMountInfoForSrl( void )
{
const OSMountInfo defaultMountList[] ATTRIBUTE_ALIGN(4) = {
// drive device target pertitionIdx resource userPermission rsvA B archive path
{ 'A', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, 0, 0, 0, "nand", "/" }, // ユーザーアプリはこのアーカイブではR/W不可
{ 'B', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 1, OS_MOUNT_RSC_WRAM, 0, 0, 0, "nand2", "/" }, // ユーザーアプリはこのアーカイブではR/W不可
{ 'C', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R), 0, 0, "content", NULL }, // Write不可
{ 'D', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R), 0, 0, "shared1", "nand:/shared1" }, // Write不可
{ 'E', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "shared2", "nand:/shared2" },
{ 'F', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 1, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "photo", "nand2:/photo" },
{ 'G', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_FILE, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "dataPrv", NULL }, // NANDにセーブデータがないアプリの場合は、マウントされない。
{ 'H', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_FILE, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "dataPub", NULL }, // NANDにセーブデータがないアプリの場合は、マウントされない。
{ 'I', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" },
};
#define NAND_MOUNT_INDEX 0
#define NAND2_MOUNT_INDEX 1
#define CONTENT_MOUNT_INDEX 2
const ROM_Header_Short* const rhs = HW_TWL_ROM_HEADER_BUF;
const char* const srl = HW_TWL_FS_BOOT_SRL_PATH_BUF;
OSMountInfo* dest = (OSMountInfo *)HW_TWL_FS_MOUNT_INFO_BUF;
MI_CpuCopy8(defaultMountList, dest, sizeof(defaultMountList));
// nandアプリならパスを追加
if ( *srl )
{
const char* lastpath = STD_SearchCharReverse( srl, '/' );
u32 len = (u32)(lastpath - srl);
if (len > OS_MOUNT_PATH_LEN)
{
len = OS_MOUNT_PATH_LEN;
}
MI_CpuCopy8(srl, dest[CONTENT_MOUNT_INDEX].path, len);
if (len != OS_MOUNT_PATH_LEN)
{
dest[CONTENT_MOUNT_INDEX].path[len] = 0;
}
}
// secureアプリならアクセス許可
if ( rhs->titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK )
{
dest[NAND_MOUNT_INDEX].userPermission = dest[NAND2_MOUNT_INDEX].userPermission = (OS_MOUNT_USR_R|OS_MOUNT_USR_W);
}
}

View File

@ -0,0 +1,274 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - fs
File: fs_loader.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 <symbols.h>
#include <firm.h>
#include <rtfs.h>
//#define WORKAROUND_NAND_2KB_BUG
#define FS_HEADER_AUTH_SIZE 0xe00
#define MODULE_ALIGNMENT 0x20 // 16*2バイト単位で読み込む
//#define MODULE_ALIGNMENT 0x200 // 512バイト単位で読み込む
#define RoundUpModuleSize(value) (((value) + MODULE_ALIGNMENT - 1) & -MODULE_ALIGNMENT)
static ROM_Header* const rh= (ROM_Header*)HW_TWL_ROM_HEADER_BUF;
static BOOL aesFlag;
static AESCounter aesCounter;
#define DMA_SEND 2
#define DMA_RECV 3
static void ReplaceWithAes( void* ptr, u32 size )
{
AES_Lock();
AES_Reset();
AES_Reset();
AES_WaitKey();
AES_LoadKey( AES_KEY_SLOT_A );
AES_WaitKey();
AES_DmaSend( DMA_SEND, ptr, size, NULL, NULL );
AES_DmaRecv( DMA_RECV, ptr, size, NULL, NULL );
AES_SetCounter( &aesCounter );
AES_Run( AES_MODE_CTR, 0, size / AES_BLOCK_SIZE, NULL, NULL );
AES_AddToCounter( &aesCounter, size / AES_BLOCK_SIZE );
MI_WaitNDma( DMA_RECV );
AES_Unlock();
}
static void EnableAes( u32 offset )
{
aesFlag = TRUE;
MI_CpuCopy8( rh->s.main_static_digest, &aesCounter, AES_BLOCK_SIZE );
AES_AddToCounter( &aesCounter, (offset - rh->s.aes_target_rom_offset) / AES_BLOCK_SIZE );
}
static void EnableAes2( u32 offset )
{
aesFlag = TRUE;
MI_CpuCopy8( rh->s.sub_static_digest, &aesCounter, AES_BLOCK_SIZE );
AES_AddToCounter( &aesCounter, (offset - rh->s.aes_target2_rom_offset) / AES_BLOCK_SIZE );
}
static void DisableAes( void )
{
aesFlag = FALSE;
}
static u32 GetTransferSize( u32 offset, u32 size )
{
if ( rh->s.enable_aes )
{
u32 end = offset + RoundUpModuleSize(size);
u32 aes_offset = rh->s.aes_target_rom_offset;
u32 aes_end = aes_offset + RoundUpModuleSize(rh->s.aes_target_size);
u32 aes_offset2 = rh->s.aes_target2_rom_offset;
u32 aes_end2 = aes_offset2 + RoundUpModuleSize(rh->s.aes_target2_size);
if ( offset >= aes_offset && offset < aes_end )
{
if ( end > aes_end )
{
size = aes_end - offset;
}
EnableAes( offset );
}
else if ( offset >= aes_offset2 && offset < aes_end2 )
{
if ( end > aes_end2 )
{
size = aes_end2 - offset;
}
EnableAes2( offset );
}
else
{
if ( offset < aes_offset && offset + size > aes_offset )
{
size = aes_offset - offset;
}
DisableAes();
}
}
else
{
DisableAes();
}
return size;
}
/*---------------------------------------------------------------------------*
Name: FS_LoadBuffer
Description: load data in file and pass to ARM9 via WRAM-B
Arguments: fd file discriptor to read
offset offset to start to read in bytes
size total length to read in bytes
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadBuffer( int fd, u32 offset, u32 size )
{
static int count = 0;
if ( fd < 0 )
{
return FALSE;
}
// seek
if ( FATFSi_rtfs_po_lseek( fd, (long)offset, PSEEK_SET ) != (long)offset )
{
OS_TPrintf("Failed to seek file. (offset=0x%X)\n", offset);
return FALSE;
}
while ( size > 0 )
{
u8* dest = (u8*)HW_FIRM_LOAD_BUFFER_BASE + count * HW_FIRM_LOAD_BUFFER_UNIT_SIZE;
u32 unit = size < HW_FIRM_LOAD_BUFFER_UNIT_SIZE ? size : HW_FIRM_LOAD_BUFFER_UNIT_SIZE;
PXI_AcquireLoadBufferSemaphore(); // wait to be ready
if ( MI_GetWramBankMaster_B( count ) != MI_WRAM_ARM7 )
{
OS_TPanic("PROGRAM ERROR!");
}
#ifdef WORKAROUND_NAND_2KB_BUG
{
u32 done;
for ( done = 0; done < unit; done += 2048 )
{
u8* d = dest + done;
u32 u = unit - done < 2048 ? unit - done : 2048;
if ( FATFSi_rtfs_po_read( fd, (u8*)d, (int)u ) != (int)u )
{
OS_TPrintf("Failed to read file. (dest=%p, size=0x%X)\n", d, u);
return FALSE;
}
}
}
#else
if ( FATFSi_rtfs_po_read( fd, (u8*)dest, (int)unit ) != (int)unit )
{
OS_TPrintf("Failed to read file. (dest=%p, size=0x%X)\n", dest, unit);
return FALSE;
}
#endif
if ( aesFlag )
{
ReplaceWithAes( dest, unit );
}
PXI_ReleaseLoadBufferSemaphore();
count = ( count + 1 ) % HW_FIRM_LOAD_BUFFER_UNIT_NUMS;
size -= unit;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS_LoadModule
Description: load data in file and pass to ARM9 via WRAM-B in view of AES
settings in the ROM header in HW_TWL_ROM_HEADER_BUF
Arguments: fd file discriptor to read
offset offset to start to read in bytes
length total length to read in bytes
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadModule( int fd, u32 offset, u32 size )
{
size = RoundUpModuleSize( size );
while ( size > 0 )
{
u32 unit = GetTransferSize( offset, size );
if ( !FS_LoadBuffer( fd, offset, unit ) )
{
return FALSE;
}
offset += unit;
size -= unit;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS_LoadHeader
Description: load ROM header in the head of file and pass to ARM9 via WRAM-B
Arguments: fd file discriptor to read
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadHeader( int fd )
{
if (fd < 0)
{
return FALSE;
}
DisableAes();
if ( !FS_LoadBuffer(fd, 0, FS_HEADER_AUTH_SIZE) ||
!FS_LoadBuffer(fd, FS_HEADER_AUTH_SIZE, HW_TWL_ROM_HEADER_BUF_SIZE - FS_HEADER_AUTH_SIZE) )
{
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS_LoadStatic
Description: load static regions in file and pass to ARM9 via WRAM-B
specified by ROM header at HW_TWL_ROM_HEADER_BUF
Arguments: fd file discriptor to read
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadStatic( int fd )
{
if ( rh->s.main_size > 0 )
{
if ( !FS_LoadModule( fd, rh->s.main_rom_offset, rh->s.main_size ) )
{
return FALSE;
}
}
if ( rh->s.sub_size > 0 )
{
if ( !FS_LoadModule( fd, rh->s.sub_rom_offset, rh->s.sub_size ) )
{
return FALSE;
}
}
if ( rh->s.main_ltd_size > 0 )
{
if ( !FS_LoadModule( fd, rh->s.main_ltd_rom_offset, rh->s.main_ltd_size ) )
{
return FALSE;
}
}
if ( rh->s.sub_ltd_size > 0 )
{
if ( !FS_LoadModule( fd, rh->s.sub_ltd_rom_offset, rh->s.sub_ltd_size ) )
{
return FALSE;
}
}
return TRUE;
}

View File

@ -0,0 +1,47 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - fs
# 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$
#----------------------------------------------------------------------------
SUBDIRS =
SUBMAKES =
#----------------------------------------------------------------------------
LINCLUDES = $(ES_ROOT)/twl/include
SRCS = fs_firm.c fs_loader.c
TARGET_LIB = libfs$(FIRM_LIBSUFFIX).a
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/add-ins/es/commondefs.es
INSTALL_TARGETS = $(TARGETS)
INSTALL_DIR = $(FIRM_INSTALL_LIBDIR)
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,268 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - fs
File: fs_firm.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 <firm.h>
#include <es.h>
// bootContent を表す特殊な contentIndex
#define CONTENT_INDEX_BOOT 0xFFFF
#define PATH_FORMAT_TMD "nand:/title/%08x/%08x/content/title.tmd"
#define PATH_FORMAT_CONTENT "nand:/title/%08x/%08x/content/%08x.app"
/*---------------------------------------------------------------------------*
Name: FS_InitFIRM
Description: initialize FS/FATFS for firm
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void FS_InitFIRM( void )
{
FSiTemporaryBuffer = (void*)HW_FIRM_FS_TEMP_BUFFER;
FATFS_InitFIRM();
FS_Init( FS_DMA_NOT_USE );
}
/*---------------------------------------------------------------------------*
Name: LoadTMD
Description: TMD
NAMi_Free
Arguments: pTmd:
titleId: TitleID
Returns: TRUEを返します
FALSE
*---------------------------------------------------------------------------*/
static BOOL LoadTMD(ESTitleMeta* pTmd, OSTitleId titleId)
{
char path[64];
FSFile f;
BOOL bSuccess;
u32 fileSize;
s32 readSize;
s32 readResult;
// TMD のパスを生成
STD_TSPrintf(path, PATH_FORMAT_TMD, (u32)(titleId >> 32), (u32)titleId);
FS_InitFile(&f);
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_R);
if( ! bSuccess )
{
// ファイルが開けなかった
return FALSE;
}
fileSize = FS_GetFileLength(&f);
// ファイルサイズをチェック 1
// 固定部分サイズ <= fileSize <= 固定部分サイズ + 可変長部分最大サイズ
if( (fileSize < sizeof(IOSCSigRsa2048) + sizeof(ESTitleMetaHeader))
|| (sizeof(ESTitleMeta) < fileSize) )
{
// ファイルサイズが異常
FS_CloseFile(&f);
return FALSE;
}
readSize = (s32)fileSize;
readResult = FS_ReadFile(&f, pTmd, readSize);
FS_CloseFile(&f);
if( readResult != readSize )
{
// ファイルからの読み込みに失敗
return FALSE;
}
// ファイルサイズをチェック 2
// 可変長部分を正しく考慮
if( fileSize != sizeof(IOSCSigRsa2048)
+ sizeof(ESTitleMetaHeader)
+ sizeof(ESContentMeta) * MI_SwapEndian16(pTmd->head.numContents) )
{
// ファイルサイズが異常
return FALSE;
}
// タイトル ID の一致をチェック
if( titleId != MI_SwapEndian64(pTmd->head.titleId) )
{
// タイトル ID が一致しない
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS_GetTitleBootContentPathFast
Description: NAND
Arguments: buf:
FS_ENTRY_LONGNAME_MAX
titleId: Title ID
Returns: TRUE
*---------------------------------------------------------------------------*/
BOOL FS_GetTitleBootContentPathFast(char* buf, OSTitleId titleId)
{
ESTitleMeta tmd;
u32 bootContentId;
int bootContentIndex;
int numContents;
int i;
SDK_POINTER_ASSERT(buf);
if( !LoadTMD(&tmd, titleId) )
{
return FALSE;
}
// 生の TMD は BigEndian
bootContentIndex = MI_SwapEndian16(tmd.head.bootIndex);
numContents = MI_SwapEndian16(tmd.head.numContents);
// bootContentIndex に一致するコンテンツを探す
for( i = 0; i < numContents; ++i )
{
const ESContentMeta* pContent = &tmd.contents[i];
if( MI_SwapEndian16(pContent->index) == bootContentIndex )
{
bootContentId = MI_SwapEndian32(pContent->cid);
break;
}
}
if( i >= numContents )
{
return FALSE;
}
// コンテンツのパスを生成
STD_TSPrintf(buf, PATH_FORMAT_CONTENT, (u32)(titleId >> 32), (u32)titleId, bootContentId);
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: SEA_Decrypt
Description: stub function
Arguments:
Returns:
*---------------------------------------------------------------------------*/
AESResult SEA_Decrypt(const void* src, u32 srcSize, void* dst);
SDK_WEAK_SYMBOL AESResult SEA_Decrypt(const void* src, u32 srcSize, void* dst)
__attribute__((never_inline))
{
(void)src;
(void)srcSize;
(void)dst;
return AES_RESULT_SUCCESS;
}
/*---------------------------------------------------------------------------*
Name: FS_ResolveSrl
Description: resolve srl filename and store to HW_TWL_FS_BOOT_SRL_PATH_BUF
Arguments: titleId title id for srl file
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_ResolveSrl( OSTitleId titleId )
{
MI_CpuClearFast( (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE );
if ( ES_ERR_OK != ES_InitLib() ||
ES_ERR_OK != ES_GetContentPath(titleId, CONTENT_INDEX_BOOT, (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF) ||
ES_ERR_OK != ES_CloseLib() )
{
return FALSE;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS_ResolveSrlList
Description: resolve srl filename with list and store to
HW_TWL_FS_BOOT_SRL_PATH_BUF
Arguments: titleIdList pointer to title id array for srl file
nums number of title id
Returns: -1 if failed, otherwise succeeded titile id number
*---------------------------------------------------------------------------*/
int FS_ResolveSrlList( const OSTitleId* titleIdList, u32 nums )
{
int i;
MI_CpuClearFast( (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE );
if ( !titleIdList || !nums || ES_ERR_OK != ES_InitLib() )
{
return FALSE;
}
for ( i = 0; i < nums; i++ )
{
if ( ES_ERR_OK == ES_GetContentPath(titleIdList[i], CONTENT_INDEX_BOOT, (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF) )
{
break;
}
}
if ( ES_ERR_OK != ES_CloseLib() )
{
return FALSE;
}
return (i == nums ? -1 : i);
}
/*---------------------------------------------------------------------------*
Name: FS_ResolveSrlUnsecured
Description: resolve srl filename and store to HW_TWL_FS_BOOT_SRL_PATH_BUF
without almost security check
Arguments: titleId title id for srl file
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_ResolveSrlUnsecured( OSTitleId titleId )
{
MI_CpuClearFast( (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, HW_FIRM_FS_BOOT_SRL_PATH_BUF_SIZE );
if ( !FS_GetTitleBootContentPathFast((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, titleId) )
{
return FALSE;
}
return TRUE;
}

View File

@ -0,0 +1,393 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - fs
File: fs_loader.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 <firm.h>
#include <estypes.h>
#include <es.h>
#define FS_HEADER_AUTH_SIZE 0xe00
#define HASH_UNIT 0x1000
static ROM_Header* const rh = (ROM_Header*)HW_TWL_ROM_HEADER_BUF;
static u8 currentKey[ SVC_SHA1_BLOCK_SIZE ];
static const u8 defaultKey[ SVC_SHA1_BLOCK_SIZE ] =
{
0x21, 0x06, 0xc0, 0xde,
0xba, 0x98, 0xce, 0x3f,
0xa6, 0x92, 0xe3, 0x9d,
0x46, 0xf2, 0xed, 0x01,
0x76, 0xe3, 0xcc, 0x08,
0x56, 0x23, 0x63, 0xfa,
0xca, 0xd4, 0xec, 0xdf,
0x9a, 0x62, 0x78, 0x34,
0x8f, 0x6d, 0x63, 0x3c,
0xfe, 0x22, 0xca, 0x92,
0x20, 0x88, 0x97, 0x23,
0xd2, 0xcf, 0xae, 0xc2,
0x32, 0x67, 0x8d, 0xfe,
0xca, 0x83, 0x64, 0x98,
0xac, 0xfd, 0x3e, 0x37,
0x87, 0x46, 0x58, 0x24,
};
/*---------------------------------------------------------------------------*
Name: FS_SetDigestKey
Description: set specified key or default key for HMAC-SHA-1
Arguments: digestKey pointer to key
if NULL, use default key
Returns: TRUE if success
*---------------------------------------------------------------------------*/
static inline void FS_SetDigestKey( const u8* digestKey )
{
if ( digestKey )
{
MI_CpuCopy8(digestKey, currentKey, SVC_SHA1_BLOCK_SIZE);
}
else
{
MI_CpuCopy8(defaultKey, currentKey, SVC_SHA1_BLOCK_SIZE);
}
}
static inline BOOL CheckDigest( u8* a, u8* b, BOOL aClr, BOOL bClr )
{
BOOL result = TRUE;
int i;
for ( i = 0; i < SVC_SHA1_DIGEST_SIZE; i++ )
{
if ( a[i] != b[i] )
{
result = FALSE;
}
}
if ( aClr ) MI_CpuClear8(a, SVC_SHA1_DIGEST_SIZE);
if ( bClr ) MI_CpuClear8(b, SVC_SHA1_DIGEST_SIZE);
return result;
}
#ifdef SUPPORT_CERTIFICATION
/*---------------------------------------------------------------------------*
Name: CheckRomCertificate
Description: check the certification in the ROM
ROMヘッダに付加された証明書のチェックを行います
makerom.TWL内のコードに依存します
Arguments: pool pointer to the SVCSignHeapContext
pCert pointer to the certification
pCAPubKey pointer to the public key for the certification
gameCode initial code
Returns: TRUE if success
*---------------------------------------------------------------------------*/
static BOOL CheckRomCertificate( SVCSignHeapContext* pool, const RomCertificate *pCert, const void* pCAPubKey, u32 gameCode )
{
u8 digest[SVC_SHA1_DIGEST_SIZE];
u8 md[SVC_SHA1_DIGEST_SIZE];
// 証明書ヘッダのマジックナンバーチェック
if( pCert->header.magicNumber != TWL_ROM_CERT_MAGIC_NUMBER ||
// 証明書ヘッダとROMヘッダのゲームコード一致チェック
pCert->header.gameCode != gameCode )
{
return FALSE;
}
// 証明書署名チェック
SVC_DecryptSign( pool, &digest, pCert->sign, pCAPubKey );
// ダイジェストの計算
SVC_CalcSHA1( md, pCert, ROM_CERT_SIGN_OFFSET );
// 比較
return CheckDigest(md, digest, TRUE, TRUE);
}
#endif
/*---------------------------------------------------------------------------*
Name: FS_LoadBuffer
Description: receive data from ARM7 via WRAM-B and store in destination address,
calculate SHA1 in parallel if ctx is specified
Arguments: dest destination address to read
size total length to read in bytes
ctx pointer to SHA1 context or NULL
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadBuffer( u8* dest, u32 size, SVCSHA1Context *ctx )
{
static int count = 0;
while ( size > 0 )
{
u8* src = (u8*)HW_FIRM_LOAD_BUFFER_BASE + count * HW_FIRM_LOAD_BUFFER_UNIT_SIZE;
u32 unit = size < HW_FIRM_LOAD_BUFFER_UNIT_SIZE ? size : HW_FIRM_LOAD_BUFFER_UNIT_SIZE;
PXI_AcquireLoadBufferSemaphore(); // wait to be ready
MIi_SetWramBankMaster_B( count, MI_WRAM_ARM9 );
if (ctx)
{
int done;
for ( done = 0; done < unit; done += HASH_UNIT )
{
u8* s = src + done;
u8* d = dest + done;
u32 u = unit - done < HASH_UNIT ? unit - done : HASH_UNIT;
SVC_SHA1Update( ctx, s, u );
MI_CpuCopyFast( s, d, u );
}
}
else
{
MI_CpuCopyFast( src, dest, unit );
}
DC_InvalidateRange( src, unit );
size -= unit;
dest += unit;
MIi_SetWramBankMaster_B( count, MI_WRAM_ARM7 );
PXI_ReleaseLoadBufferSemaphore();
count = ( count + 1 ) % HW_FIRM_LOAD_BUFFER_UNIT_NUMS;
}
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: GetTransferSize
Description: get size to transfer once
AES領域をまたぐ場合は (
)
makerom.TWLまたはIPLの使用に依存します
Arguments: offset offset of region from head of ROM_Header
size size of region
Returns: size to transfer once
*---------------------------------------------------------------------------*/
static u32 GetTransferSize( u32 offset, u32 size )
{
if ( rh->s.enable_aes )
{
u32 end = offset + size;
u32 aes_offset = rh->s.aes_target_rom_offset;
u32 aes_end = aes_offset + rh->s.aes_target_size;
u32 aes_offset2 = rh->s.aes_target2_rom_offset;
u32 aes_end2 = aes_offset2 + rh->s.aes_target2_size;
if ( offset >= aes_offset && offset < aes_end )
{
if ( end > aes_end )
{
size = aes_end - offset;
}
}
else if ( offset >= aes_offset2 && offset < aes_end2 )
{
if ( end > aes_end2 )
{
size = aes_end2 - offset;
}
}
else
{
if ( offset < aes_offset && offset + size > aes_offset )
{
size = aes_offset - offset;
}
}
}
return size;
}
/*---------------------------------------------------------------------------*
Name: FS_LoadModule
Description: receive data from ARM7 via WRAM-B and store in destination address
in view of AES settings in the ROM header at HW_TWL_ROM_HEADER_BUF,
then verify the digest
Arguments: dest destination address to read
offset file offset to start to read in bytes
size total length to read in bytes
digest digest to verify
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadModule( u8* dest, u32 offset, u32 size, const u8 digest[SVC_SHA1_DIGEST_SIZE] )
{
#ifndef NO_SECURITY_CHECK
SVCHMACSHA1Context ctx;
u8 md[SVC_SHA1_DIGEST_SIZE];
SVC_HMACSHA1Init(&ctx, currentKey, SVC_SHA1_BLOCK_SIZE );
while ( size > 0 )
{
u32 unit = GetTransferSize( offset, size );
if ( !FS_LoadBuffer( dest, unit, &ctx.sha1_ctx ) )
{
return FALSE;
}
dest += unit;
offset += unit;
size -= unit;
}
SVC_HMACSHA1GetHash(&ctx, md);
return CheckDigest(md, (u8*)digest, TRUE, FALSE);
#else
(void)digest;
while ( size > 0 )
{
u32 unit = GetTransferSize( offset, size );
if ( !FS_LoadBuffer( dest, unit, NULL ) )
{
return FALSE;
}
dest += unit;
offset += unit;
size -= unit;
}
return TRUE;
#endif
}
/*---------------------------------------------------------------------------*
Name: FS_LoadHeader
Description: receive ROM header, store to HW_TWL_ROM_HEADER_BUF,
and verify signature
Arguments: pool heap context to call SVC_DecryptSign
rsa_key_user public key to verify the signature for user application
rsa_key_sys public key to verify the signature for system application
rsa_key_secure public key to verify the signature for secure application
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadHeader( SVCSignHeapContext* pool, const void* rsa_key_user, const void* rsa_key_sys, const void* rsa_key_secure )
{
#ifndef NO_SECURITY_CHECK
const void* rsa_key;
SVCSHA1Context ctx;
u8 md[SVC_SHA1_DIGEST_SIZE];
SignatureData sd;
SVC_SHA1Init( &ctx );
if ( !FS_LoadBuffer( (u8*)rh, FS_HEADER_AUTH_SIZE, &ctx ) )
{
return FALSE;
}
SVC_SHA1GetHash( &ctx, md );
if ( !FS_LoadBuffer( (u8*)rh + FS_HEADER_AUTH_SIZE, HW_TWL_ROM_HEADER_BUF_SIZE - FS_HEADER_AUTH_SIZE, NULL ) )
{
return FALSE;
}
// 鍵の確定
rsa_key = (rh->s.titleID_Hi & TITLE_ID_HI_SECURE_FLAG_MASK)
? rsa_key_secure
: ( (rh->s.titleID_Hi & TITLE_ID_HI_APP_TYPE_MASK) ? rsa_key_sys : rsa_key_user );
#ifdef SUPPORT_CERTIFICATION
// コンテンツ証明書
if ( CheckRomCertificate( pool, &rh->certificate, rsa_key, *(u32*)rh->s.game_code ) )
{
rsa_key = rh->certificate.pubKeyMod; // ヘッダ用の鍵の取り出し
}
else
{
// とりあえずコンテンツ証明書用の鍵がそのまま使えると仮定
}
#endif
// ヘッダ署名チェック
SVC_DecryptSign( pool, &sd, rh->signature, rsa_key );
if ( !CheckDigest( md, sd.digest, TRUE, FALSE ) )
{
MI_CpuClear8( &sd, sizeof(sd) ); // 残り削除 (他に必要なものはない?)
return FALSE;
}
// ダイジェスト以外のデータのチェックが必要!!
MI_CpuClear8( &sd, sizeof(sd) ); // 残り削除 (他に必要なものはない?)
#else
(void)pool;
(void)rsa_key1;
(void)rsa_key2;
FS_LoadBuffer( (u8*)rh, FS_HEADER_AUTH_SIZE, NULL );
FS_LoadBuffer( (u8*)rh + FS_HEADER_AUTH_SIZE, HW_TWL_ROM_HEADER_BUF_SIZE - FS_HEADER_AUTH_SIZE, NULL );
#endif
// ROMヘッダのコピー
MI_CpuCopyFast( rh, (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF );
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS_LoadStatic
Description: receive static regions from ARM6 via WRAM-B and store them
specified by ROM header at HW_TWL_ROM_HEADER_BUF
Arguments: digestKey pointer to key for HMAC-SHA1
if NULL, use default key
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadStatic( const u8* digestKey )
{
FS_SetDigestKey( digestKey );
if ( rh->s.main_size > 0 )
{
if ( !FS_LoadModule( rh->s.main_ram_address, rh->s.main_rom_offset, rh->s.main_size, rh->s.main_static_digest ) )
{
return FALSE;
}
}
if ( rh->s.sub_size > 0 )
{
if ( !FS_LoadModule( rh->s.sub_ram_address, rh->s.sub_rom_offset, rh->s.sub_size, rh->s.sub_static_digest ) )
{
return FALSE;
}
}
if ( rh->s.main_ltd_size > 0 )
{
if ( !FS_LoadModule( rh->s.main_ltd_ram_address, rh->s.main_ltd_rom_offset, rh->s.main_ltd_size, rh->s.main_ltd_static_digest ) )
{
return FALSE;
}
}
if ( rh->s.sub_ltd_size > 0 )
{
if ( !FS_LoadModule( rh->s.sub_ltd_ram_address, rh->s.sub_ltd_rom_offset, rh->s.sub_ltd_size, rh->s.sub_ltd_static_digest ) )
{
return FALSE;
}
}
return TRUE;
}

Some files were not shown because too many files have changed in this diff Show More