(更新:Akabane Jumpei) 活線挿抜検証用ブランチ

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/branches/20080206_hotsw@591 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
(no author) 2008-02-06 00:15:40 +00:00
commit 50a8457972
735 changed files with 125698 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:: 2007-11-21#$
# $Rev: 237 $
# $Author: yosiokat $
#----------------------------------------------------------------------------
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 =====

37
Makefile.full Normal file
View File

@ -0,0 +1,37 @@
#! 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
SUBDIRS = \
$(ROOT)/build/libraries/reboot \
$(ROOT)/build/demos/gx/UnitTours/DEMOLib \
$(TWLSYSTEM_ROOT) \
build
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

35
Makefile.sysmenu Normal file
View File

@ -0,0 +1,35 @@
#! 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$
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
export TWL_ARCHGEN = ALL
SUBDIRS = \
build/libraries_sysmenu\
build/components \
build/systemmenu_RED
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

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 を削除。

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 \
nandfirm \
libraries_sysmenu\
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,35 @@
#! 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
#----------------------------------------------------------------------------
endif # TWL_IPL_COMMONDEFS_
#----- End of commondefs -----

View File

@ -0,0 +1,144 @@
#! 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)
ifndef TWL_KEYSDIR
DUMMY_KEYS_SUFFIX = .dummykey
endif
TWL_KEYSDIR ?= $(FIRM_ROOT)/keys/dummy
TARGET_BIN ?= $(subst .,$(DUMMY_KEYS_SUFFIX).,$(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 \
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 := $(FIRM_TOOLSDIR)/bin/makebanner.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,129 @@
#! 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
#----------------------------------------------------------------------------
# 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/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 \
libmbloader$(TWL_LIBSUFFIX).a \
libacsign$(TWL_LIBSUFFIX).a \
libboot$(TWL_LIBSUFFIX).a \
else # ($(CODEGEN_PROC),ARM7)
SYSMENU_LIBS ?= \
libsysmenu_sp$(TWL_LIBSUFFIX).a \
libmbloader_sp$(TWL_LIBSUFFIX).a \
libboot_sp$(TWL_LIBSUFFIX).a \
libhotsw_sp$(TWL_LIBSUFFIX).a
endif
#----------------------------------------------------------------------------
# MY BUILD TOOLS
#
OPENSSL := $(SYSMENU_TOOLSDIR)/openssl/openssl.exe
NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe
MAKEBANNER := $(SYSMENU_TOOLSDIR)/bin/makebanner.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,86 @@
#! 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:: 2007-10-09#$
# $Rev: 1499 $
# $Author: hatamoto_minoru $
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
override TARGET_PLATFORM = TWL
override TWL_PROC = ARM7
override TWL_ARCHGEN = LIMITED
TWL_NO_STD_PCHDR = True
TWL_CODEGEN ?= ARM
#----------------------------------------------------------------------------
SUBDIRS = wram_regs
SRCS = main.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.LTD.TWL.o
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot
ifdef TWLSDK_NOCRYPTO
CCFLAGS += -DSDK_NOCRYPTO
endif
ifndef TWLSDK_NOCRYPTO
MAKELCF_FLAGS += -DUSE_CRYPTO_LIBS='libaes_sp$(TWL_LIBSUFFIX).a'
endif
#MACRO_FLAGS += -DSDK_ARM7COMP_LTD
MAKELCF_FLAGS += -DADDRESS_LTDWRAM='0x037b8000' \
-DADDRESS_FLXMAIN='0x02280000' \
-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'
#--------------------------------
# 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 \
$(SYSMENU_ROOT)/build/libraries_sysmenu/sysmenu/common/include
LLIBRARIES += libwl_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,915 @@
#---------------------------------------------------------------------------
# Project: TwlIPL
# File: hyena.lcf.template
#
# 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$
#---------------------------------------------------------------------------
MEMORY
{
<STATIC.NAME> (RWX) : ORIGIN = <STATIC.ADDRESS>, LENGTH = 0x0 > <STATIC.NAME><PROPERTY.FLXSUFFIX>
<FOREACH.AUTOLOADS>
<AUTOLOAD.NAME> (RWX) : ORIGIN = <AUTOLOAD.ADDRESS>, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.FLXSUFFIX>
<END.AUTOLOADS>
binary.AUTOLOAD_INFO (RWX) : ORIGIN = 0, 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>
<PROPERTY.OVERLAYTABLE>F (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.OVERLAYTABLE><PROPERTY.FLXSUFFIX>
<FOREACH.OVERLAYS>
<OVERLAY.NAME> (RWXO): ORIGIN = <OVERLAY.ADDRESS>, LENGTH = 0x0 > <OVERLAY.NAME><PROPERTY.FLXSUFFIX>
<END.OVERLAYS>
check.WORKRAM (RWX) : ORIGIN = 0x037b8000, LENGTH = 0x58000 > workram.check
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>
<PROPERTY.LTDOVERLAYTABLE>L (RW) : ORIGIN = 0, LENGTH = 0x0 > <PROPERTY.LTDOVERLAYTABLE><PROPERTY.LTDSUFFIX>
<FOREACH.LTDOVERLAYS>
<LTDOVERLAY.NAME> (RWXO): ORIGIN = <LTDOVERLAY.ADDRESS>, LENGTH = 0x0 > <LTDOVERLAY.NAME><PROPERTY.LTDSUFFIX>
<END.LTDOVERLAYS>
check.LTDMAIN (RWX) : ORIGIN = 0x02280000, LENGTH = 0x74000 > ltdmain.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 =.;
SDK_STATIC_TEXT_START =.;
#:::::::::: text/rodata
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 =.;
#:::::::::: ctor
<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;
#:::::::::: ctor
SDK_STATIC_SINIT_END =.;
#:::::::::: text/rodata
SDK_STATIC_TEXT_END =.;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
SDK_STATIC_DATA_START =.;
#:::::::::: data
<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>
#:::::::::: data
SDK_STATIC_DATA_END =.;
. = ALIGN(4);
SDK_STATIC_END =.;
SDK_STATIC_TEXT_SIZE = SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START;
SDK_STATIC_DATA_SIZE = SDK_STATIC_DATA_END - SDK_STATIC_DATA_START;
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 =.;
#:::::::::: bss
<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>
#:::::::::: bss
. = ALIGN(4);
SDK_STATIC_BSS_END = .;
SDK_STATIC_BSS_SIZE = SDK_STATIC_BSS_END - SDK_STATIC_BSS_START;
} >> <STATIC.NAME>
############################ AUTOLOADS ##############################
SDK_AUTOLOAD.WRAM.START = 0x037c0000;
SDK_AUTOLOAD.WRAM.END = SDK_AUTOLOAD.WRAM.START;
SDK_AUTOLOAD.WRAM.BSS_END = SDK_AUTOLOAD.WRAM.START;
SDK_AUTOLOAD.WRAM.SIZE = 0;
SDK_AUTOLOAD.WRAM.BSS_SIZE = 0;
SDK_AUTOLOAD_START = SDK_STATIC_END;
SDK_AUTOLOAD_SIZE = 0;
SDK_AUTOLOAD_NUMBER = <NUMBER.AUTOLOADS>;
<FOREACH.AUTOLOADS>
.<AUTOLOAD.NAME>:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.AUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <AUTOLOAD.SEARCHSYMBOL>;
<END.AUTOLOAD.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_AUTOLOAD_<AUTOLOAD.NAME>_ID =<AUTOLOAD.ID>;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.ID =<AUTOLOAD.ID>;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.START =.;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.AUTOLOAD.OBJECTS=.text>
<AUTOLOAD.OBJECT=.text:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.text>
<AUTOLOAD.LIBRARY=.text:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.etable>
<AUTOLOAD.OBJECT=.exception:t>
. = ALIGN(4);
SDK_STATIC_ETABLE_START =.;
__exception_table_start__ =.;
EXCEPTION
__exception_table_end__ =.;
SDK_STATIC_ETABLE_END =.;
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.OBJECTS=.rodata>
<AUTOLOAD.OBJECT=.rodata:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.rodata>
<AUTOLOAD.LIBRARY=.rodata:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.init>
<AUTOLOAD.OBJECT=.init:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.init>
<AUTOLOAD.LIBRARY=.init:t>
<END.AUTOLOAD.LIBRARIES>
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.AUTOLOAD.OBJECTS=.ctor>
<AUTOLOAD.OBJECT=.ctor:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.ctor>
<AUTOLOAD.LIBRARY=.ctor:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.sinit>
<AUTOLOAD.OBJECT=.sinit:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.sinit>
<AUTOLOAD.LIBRARY=.sinit:t>
<END.AUTOLOAD.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_AUTOLOAD.<AUTOLOAD.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE BLOCK
#
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.AUTOLOAD.OBJECTS=.wram>
<AUTOLOAD.OBJECT=.wram:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.wram>
<AUTOLOAD.LIBRARY=.wram:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.ltdwram>
<AUTOLOAD.OBJECT=.ltdwram:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.ltdwram>
<AUTOLOAD.LIBRARY=.ltdwram:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.sdata>
<AUTOLOAD.OBJECT=.sdata:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.sdata>
<AUTOLOAD.LIBRARY=.sdata:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.data>
<AUTOLOAD.OBJECT=.data:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.data>
<AUTOLOAD.LIBRARY=.data:t>
<END.AUTOLOAD.LIBRARIES>
#:::::::::: data
SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.END =.;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.TEXT_START;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.DATA_START;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.START;
SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE;
} > <AUTOLOAD.NAME>
.<AUTOLOAD.NAME>.bss:
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.AUTOLOAD.SEARCHSYMBOLS>
SEARCH_SYMBOL <AUTOLOAD.SEARCHSYMBOL>;
<END.AUTOLOAD.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_START = .;
#:::::::::: bss
<FOREACH.AUTOLOAD.OBJECTS=.wram>
<AUTOLOAD.OBJECT=.wram.bss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.wram>
<AUTOLOAD.LIBRARY=.wram.bss:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.ltdwram>
<AUTOLOAD.OBJECT=.ltdwram.bss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.ltdwram>
<AUTOLOAD.LIBRARY=.ltdwram.bss:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.sbss>
<AUTOLOAD.OBJECT=.sbss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.sbss>
<AUTOLOAD.LIBRARY=.sbss:t>
<END.AUTOLOAD.LIBRARIES>
<FOREACH.AUTOLOAD.OBJECTS=.bss>
<AUTOLOAD.OBJECT=.bss:t>
<END.AUTOLOAD.OBJECTS>
<FOREACH.AUTOLOAD.LIBRARIES=.bss>
<AUTOLOAD.LIBRARY=.bss:t>
<END.AUTOLOAD.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_END = .;
SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_SIZE = SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_END - SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_START;
} >> <AUTOLOAD.NAME>
<END.AUTOLOADS>
SDK_AUTOLOAD_WRAM_START = SDK_AUTOLOAD.WRAM.START;
SDK_AUTOLOAD_WRAM_END = SDK_AUTOLOAD.WRAM.END;
SDK_AUTOLOAD_WRAM_BSS_END = SDK_AUTOLOAD.WRAM.BSS_END;
SDK_AUTOLOAD_WRAM_SIZE = SDK_AUTOLOAD.WRAM.SIZE;
SDK_AUTOLOAD_WRAM_BSS_SIZE = SDK_AUTOLOAD.WRAM.BSS_SIZE;
############################ AUTOLOAD_INFO ##########################
.binary.AUTOLOAD_INFO:
{
<FOREACH.AUTOLOADS>
WRITEW ADDR(.<AUTOLOAD.NAME>);
WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE;
WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.SINIT_START;
WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_SIZE;
<END.AUTOLOADS>
} > binary.AUTOLOAD_INFO
SDK_AUTOLOAD_LIST = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE;
SDK_AUTOLOAD_LIST_END = SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO);
SDK_AUTOLOAD_SIZE = SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO);
############################ 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
############################ OVERLAYS ###############################
SDK_OVERLAY_NUMBER = <NUMBER.OVERLAYS>;
<FOREACH.OVERLAYS>
.<OVERLAY.NAME>:<OVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.OVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <OVERLAY.SEARCHSYMBOL>;
<END.OVERLAY.SEARCHSYMBOLS>
#
# TEXT BLOCK: READ ONLY
#
SDK_OVERLAY_<OVERLAY.NAME>_ID =<OVERLAY.ID>; ### SEGMENT <OVERLAY.NAME> OVERLAY ID
SDK_OVERLAY.<OVERLAY.NAME>.ID =<OVERLAY.ID>;
SDK_OVERLAY.<OVERLAY.NAME>.START =.;
SDK_OVERLAY.<OVERLAY.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.OVERLAY.OBJECTS=.text>
<OVERLAY.OBJECT=.text:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.text>
<OVERLAY.LIBRARY=.text:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.rodata>
<OVERLAY.OBJECT=.rodata:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.rodata>
<OVERLAY.LIBRARY=.rodata:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.init>
<OVERLAY.OBJECT=.init:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.init>
<OVERLAY.LIBRARY=.init:t>
<END.OVERLAY.LIBRARIES>
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.OVERLAY.OBJECTS=.ctor>
<OVERLAY.OBJECT=.ctor:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.ctor>
<OVERLAY.LIBRARY=.ctor:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.sinit>
<OVERLAY.OBJECT=.sinit:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.sinit>
<OVERLAY.LIBRARY=.sinit:t>
<END.OVERLAY.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_OVERLAY.<OVERLAY.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_OVERLAY.<OVERLAY.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.OVERLAY.OBJECTS=.sdata>
<OVERLAY.OBJECT=.sdata:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.sdata>
<OVERLAY.LIBRARY=.sdata:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.data>
<OVERLAY.OBJECT=.data:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.data>
<OVERLAY.LIBRARY=.data:t>
<END.OVERLAY.LIBRARIES>
#:::::::::: data
SDK_OVERLAY.<OVERLAY.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.END =.;
SDK_OVERLAY.<OVERLAY.NAME>.TEXT_SIZE = SDK_OVERLAY.<OVERLAY.NAME>.TEXT_END - SDK_OVERLAY.<OVERLAY.NAME>.TEXT_START;
SDK_OVERLAY.<OVERLAY.NAME>.DATA_SIZE = SDK_OVERLAY.<OVERLAY.NAME>.DATA_END - SDK_OVERLAY.<OVERLAY.NAME>.DATA_START;
SDK_OVERLAY.<OVERLAY.NAME>.SIZE = SDK_OVERLAY.<OVERLAY.NAME>.END - SDK_OVERLAY.<OVERLAY.NAME>.START;
} > <OVERLAY.NAME>
.<OVERLAY.NAME>.bss:<OVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.OVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <OVERLAY.SEARCHSYMBOL>;
<END.OVERLAY.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_OVERLAY.<OVERLAY.NAME>.BSS_START = .;
#:::::::::: bss
<FOREACH.OVERLAY.OBJECTS=.bss>
<OVERLAY.OBJECT=.bss:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.bss>
<OVERLAY.LIBRARY=.bss:t>
<END.OVERLAY.LIBRARIES>
<FOREACH.OVERLAY.OBJECTS=.sbss>
<OVERLAY.OBJECT=.sbss:t>
<END.OVERLAY.OBJECTS>
<FOREACH.OVERLAY.LIBRARIES=.sbss>
<OVERLAY.LIBRARY=.sbss:t>
<END.OVERLAY.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_OVERLAY.<OVERLAY.NAME>.BSS_END = .;
SDK_OVERLAY.<OVERLAY.NAME>.BSS_SIZE = SDK_OVERLAY.<OVERLAY.NAME>.BSS_END - SDK_OVERLAY.<OVERLAY.NAME>.BSS_START;
} >> <OVERLAY.NAME>
<END.OVERLAYS>
############################ OVERLAYDEFS ############################
.<PROPERTY.OVERLAYDEFS>F:
{
### <STATIC.NAME> module information
WRITEW ADDR(.<STATIC.NAME>); # load address
WRITEW _start; # entry address
WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE; # size of module
WRITEW _start_AutoloadDoneCallback; # callback autoload done
### overlay filename
<FOREACH.OVERLAYS>
WRITES ("<OVERLAY.NAME><PROPERTY.FLXSUFFIX>"); # Overlay <OVERLAY.ID>
<END.OVERLAYS>
} > <PROPERTY.OVERLAYDEFS>F
############################ OVERLAYTABLE ###########################
.<PROPERTY.OVERLAYTABLE>F:
{
<FOREACH.OVERLAYS>
WRITEW <OVERLAY.ID>; # overlay ID
WRITEW ADDR(.<OVERLAY.NAME>); # load address
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.SIZE; # size of module
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.BSS_SIZE; # size of bss
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.SINIT_START; # start address of static init
WRITEW SDK_OVERLAY.<OVERLAY.NAME>.SINIT_END; # end address of static init
WRITEW <OVERLAY.ID>; # ROM file ID
WRITEW 0; # Reserved
<END.OVERLAYS>
} > <PROPERTY.OVERLAYTABLE>F
############################ OTHERS #################################
SDK_WRAM_ARENA_LO = SDK_AUTOLOAD.WRAM.BSS_END;
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_AUTOLOAD.WRAM.BSS_END - SDK_AUTOLOAD.WRAM.START + 0x080 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
} > check.WORKRAM
########################### LTDAUTOLOADS ############################
SDK_LTDAUTOLOAD.LTDMAIN.START = SDK_STATIC_BSS_END;
SDK_LTDAUTOLOAD.LTDMAIN.END = SDK_LTDAUTOLOAD.LTDMAIN.START;
SDK_LTDAUTOLOAD.LTDMAIN.BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.START;
SDK_LTDAUTOLOAD.LTDMAIN.SIZE = 0;
SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE = 0;
SDK_LTDAUTOLOAD_TOP_START = 0x02e80000;
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_NUMBER = <NUMBER.LTDAUTOLOADS>;
.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>
SDK_LTDAUTOLOAD_<LTDAUTOLOAD.NAME>_ID =<LTDAUTOLOAD.ID>;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.ID =<LTDAUTOLOAD.ID>;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.START =.;
#
# TEXT BLOCK: READ ONLY
#
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<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=.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 =.;
#:::::::::: ctor
<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;
#:::::::::: ctor
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE BLOCK
#
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_START =.;
#:::::::::: data
<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=.ltdmain>
<LTDAUTOLOAD.OBJECT=.ltdmain:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdmain>
<LTDAUTOLOAD.LIBRARY=.ltdmain:t>
<END.LTDAUTOLOAD.LIBRARIES>
#:::::::::: data
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.END =.;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.TEXT_START;
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_SIZE = SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_END - SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.DATA_START;
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 =.;
#:::::::::: bss
<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=.ltdmain>
<LTDAUTOLOAD.OBJECT=.ltdmain.bss:t>
<END.LTDAUTOLOAD.OBJECTS>
<FOREACH.LTDAUTOLOAD.LIBRARIES=.ltdmain>
<LTDAUTOLOAD.LIBRARY=.ltdmain.bss:t>
<END.LTDAUTOLOAD.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_LTDAUTOLOAD.<LTDAUTOLOAD.NAME>.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_LTDAUTOLOAD_LTDMAIN_START = SDK_LTDAUTOLOAD.LTDMAIN.START;
SDK_LTDAUTOLOAD_LTDMAIN_END = SDK_LTDAUTOLOAD.LTDMAIN.END;
SDK_LTDAUTOLOAD_LTDMAIN_BSS_END = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END;
SDK_LTDAUTOLOAD_LTDMAIN_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.SIZE;
SDK_LTDAUTOLOAD_LTDMAIN_BSS_SIZE = SDK_LTDAUTOLOAD.LTDMAIN.BSS_SIZE;
######################### 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);
########################### LTDOVERLAYS #############################
SDK_LTDOVERLAY_NUMBER = <NUMBER.LTDOVERLAYS>;
<FOREACH.LTDOVERLAYS>
.<LTDOVERLAY.NAME>:<LTDOVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDOVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDOVERLAY.SEARCHSYMBOL>;
<END.LTDOVERLAY.SEARCHSYMBOLS>
SDK_LTDOVERLAY_<LTDOVERLAY.NAME>_ID =<LTDOVERLAY.ID>;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.ID =<LTDOVERLAY.ID>;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.START =.;
#
# TEXT BLOCK: READ ONLY
#
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_START =.;
#:::::::::: text/rodata
<FOREACH.LTDOVERLAY.OBJECTS=.text>
<LTDOVERLAY.OBJECT=.text:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.text>
<LTDOVERLAY.LIBRARY=.text:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.rodata>
<LTDOVERLAY.OBJECT=.rodata:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.rodata>
<LTDOVERLAY.LIBRARY=.rodata:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.init>
<LTDOVERLAY.OBJECT=.init:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.init>
<LTDOVERLAY.LIBRARY=.init:t>
<END.LTDOVERLAY.LIBRARIES>
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_START =.;
#:::::::::: ctor
<FOREACH.LTDOVERLAY.OBJECTS=.ctor>
<LTDOVERLAY.OBJECT=.ctor:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.ctor>
<LTDOVERLAY.LIBRARY=.ctor:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.sinit>
<LTDOVERLAY.OBJECT=.sinit:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.sinit>
<LTDOVERLAY.LIBRARY=.sinit:t>
<END.LTDOVERLAY.LIBRARIES>
WRITEW 0;
#:::::::::: ctor
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_END =.;
#:::::::::: text/rodata
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_END =.;
#
# DATA BLOCK: READ WRITE
#
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_START =.;
#:::::::::: data
<FOREACH.LTDOVERLAY.OBJECTS=.sdata>
<LTDOVERLAY.OBJECT=.sdata:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.sdata>
<LTDOVERLAY.LIBRARY=.sdata:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.data>
<LTDOVERLAY.OBJECT=.data:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.data>
<LTDOVERLAY.LIBRARY=.data:t>
<END.LTDOVERLAY.LIBRARIES>
#:::::::::: data
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_END =.;
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.END =.;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.TEXT_START;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.DATA_START;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.START;
} > <LTDOVERLAY.NAME>
.<LTDOVERLAY.NAME>.bss:<LTDOVERLAY.NAME>
{
ALIGNALL(4);
. = ALIGN(4);
#
# Definition to refer overlay segment, when same name symbols exist in multiple overlays.
#
<FOREACH.LTDOVERLAY.SEARCHSYMBOLS>
SEARCH_SYMBOL <LTDOVERLAY.SEARCHSYMBOL>;
<END.LTDOVERLAY.SEARCHSYMBOLS>
#
# BSS BLOCK
#
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_START =.;
#:::::::::: bss
<FOREACH.LTDOVERLAY.OBJECTS=.bss>
<LTDOVERLAY.OBJECT=.bss:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.bss>
<LTDOVERLAY.LIBRARY=.bss:t>
<END.LTDOVERLAY.LIBRARIES>
<FOREACH.LTDOVERLAY.OBJECTS=.sbss>
<LTDOVERLAY.OBJECT=.sbss:t>
<END.LTDOVERLAY.OBJECTS>
<FOREACH.LTDOVERLAY.LIBRARIES=.sbss>
<LTDOVERLAY.LIBRARY=.sbss:t>
<END.LTDOVERLAY.LIBRARIES>
#:::::::::: bss
. = ALIGN(4);
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_END =.;
SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_SIZE = SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_END - SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_START;
} >> <LTDOVERLAY.NAME>
<END.LTDOVERLAYS>
########################## LTDOVERLAYDEFS ###########################
.<PROPERTY.LTDOVERLAYDEFS>L:
{
### TWL limited extended static module information
WRITEW SDK_LTDAUTOLOAD_TOP_START; # load address
WRITEW 0; # padding
WRITEW SDK_LTDAUTOLOAD_SIZE + SDK_LTDAUTOLOAD_TOP_SIZE; # size of module
WRITEW 0; # padding
### TWL limited overlay filename
<FOREACH.LTDOVERLAYS>
WRITES ("<LTDOVERLAY.NAME><PROPERTY.LTDSUFFIX>");
<END.LTDOVERLAYS>
} > <PROPERTY.LTDOVERLAYDEFS>L
######################### LTDOVERLAYTABLE ###########################
.<PROPERTY.LTDOVERLAYTABLE>L:
{
<FOREACH.LTDOVERLAYS>
WRITES <LTDOVERLAY.ID> # overlay ID
WRITEW ADDR(.<LTDOVERLAY.NAME>); # load address
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SIZE; # size of module
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.BSS_SIZE; # size of bss
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_START; # start address of static init
WRITEW SDK_LTDOVERLAY.<LTDOVERLAY.NAME>.SINIT_END; # end address of static init
WRITEW <LTDOVERLAY.ID> # ROM file ID
WRITEW 0; # Reserved
<END.LTDOVERLAYS>
} > <PROPERTY.LTDOVERLAYTABLE>L
############################ OTHERS #################################
SDK_SUBPRIV_ARENA_LO = SDK_LTDAUTOLOAD.LTDMAIN.BSS_END;
.check.LTDMAIN:
{
. = SDK_SUBPRIV_ARENA_LO;
} > check.LTDMAIN
}

View File

@ -0,0 +1,192 @@
#----------------------------------------------------------------------------
# Project: TwlIPL
# File: hyena.lsf
#
# Copyright 2007 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 $(ADDRESS_FLXMAIN)
Library $(CRT0_O)
StackSize 1024 1024
}
#--------
Autoload WRAM
{
Address $(ADDRESS_LTDWRAM)
Library libsubpsyscall.a \
libsyscall_sp.twl.a \
$(CW_LIBS) \
libos_sp$(LIBSUFFIX).a \
libmi_sp$(LIBSUFFIX).a \
libpad_sp$(LIBSUFFIX).a \
libpxi_sp$(LIBSUFFIX).a \
libstd_sp$(LIBSUFFIX).a \
libexi_sp$(LIBSUFFIX).a \
libsnd_sp$(LIBSUFFIX).a \
libspi_sp$(LIBSUFFIX).a \
libpm_sp$(LIBSUFFIX).a \
libmath_sp$(LIBSUFFIX).a \
libscfg_sp$(LIBSUFFIX).a \
libtp_sp$(LIBSUFFIX).a \
libmic_sp$(LIBSUFFIX).a \
libfs_sp$(LIBSUFFIX).a \
libcard_sp$(LIBSUFFIX).a \
libi2c_sp$(LIBSUFFIX).a \
libcamera_sp$(LIBSUFFIX).a \
libcdc_sp$(LIBSUFFIX).a \
libsndex_sp$(LIBSUFFIX).a \
libtpex_sp$(LIBSUFFIX).a \
libmicex_sp$(LIBSUFFIX).a \
libmcu_sp$(LIBSUFFIX).a \
libboot_sp$(LIBSUFFIX).a \
libreboot_sp$(LIBSUFFIX).a \
libhotsw_sp$(LIBSUFFIX).a \
libreloc_info_sp$(LIBSUFFIX).a \
libsysmenu_sp$(LIBSUFFIX).a
Library libsdio_sp$(LIBSUFFIX).a
Library libnvram_sp$(LIBSUFFIX).a
Library librtc_sp$(LIBSUFFIX).a
Object * (.etable)
Object * (.wram)
Object * (.ltdwram)
Object $(OBJDIR)/main.o
# caches in fatfs library, that should be on WRAM.
# 2007/12/11 OBJECT() による .bss シンボルのリンクがうまくいかないので、
# 変数定義箇所に pragma で .ltdwram セクションに含まれるように暫定対策しました。
# Object OBJECT( FATFSi___mem_drives_structures , libfatfs_sp$(LIBSUFFIX).a) (.bss)
#####
# Sub-routines in WL library , that should be on WRAM.
# in TaskMan.o
Object OBJECT( MainTaskRoutine , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AddTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( DeleteTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( LowestIdleTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ExecuteMessage , libwl_sp$(LIBSUFFIX).a ) (.text)
# in BufMan.o
Object OBJECT( NewHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( DeleteHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AllocateHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ReleaseHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( MoveHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AddHeapBuf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( GetHeapBufNextAdrs , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlCmdIf.o
Object OBJECT( RequestCmdTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( SendMessageToWmDirect , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlNic.o
Object OBJECT( WStart , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WStop , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WSetStaState , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlIntr.o
Object OBJECT( WlIntr , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrPreTbtt , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTbtt , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrActEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
# Object OBJECT( WlIntrAckCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrCntOvf , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTxErr , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrRxCntup , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrRxEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrMpEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrStartTx , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrStartRx , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( SetParentTbttTxq , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( MacBugTxMp , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( AdjustRingPointer , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( CheckKeyTxEnd , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WlIntrTask.o
Object OBJECT( WlIntrTxBeaconTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrTxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrRxEndTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WlIntrMpEndTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( SetParentTbttTxqTask , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( TakeoutRxFrame , libwl_sp$(LIBSUFFIX).a ) (.text)
# in TxCtrl.o
Object OBJECT( InitTxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text)
# in RxCtrl.o
Object OBJECT( InitRxCtrl , libwl_sp$(LIBSUFFIX).a ) (.text)
# in WaitLoop.o
Object OBJECT( WaitLoop_Rxpe , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_Waitus , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_ClrAid , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_BbpAccess , libwl_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( WaitLoop_RfAccess , libwl_sp$(LIBSUFFIX).a ) (.text)
# Object OBJECT( s_ar_cookie_mem , libathdrv_sp$(LIBSUFFIX).a ) (.bss)
# Object OBJECT( nin_ar , libathdrv_sp$(LIBSUFFIX).a ) (.bss)
Object OBJECT( a_netbuf_alloc_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( a_netbuf_register_rx_callback , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_driver_tx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_tx_queue_full , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_tx_complete , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_bitrate_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_channelList_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_txPwr_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_gpio_intr_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_gpio_data_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_gpio_ack_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_drv_BmiWriteSocReg , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ar6000_control_tx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_drv_BmiReadMemory , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( nin_drv_BmiWriteMemory , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( BMI_read_reg , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( BMI_write_reg , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( BMI_read_mem , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( BMI_write_mem , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( wmi_dix_2_dot3 , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( wmi_control_rx_xtnd , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( wmi_control_rx , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( wmi_cmd_send , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( wmi_cmd_send_xtnd , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( HIFReadWrite , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( ath_ioctl , libathdrv_sp$(LIBSUFFIX).a ) (.text)
Object OBJECT( wpa_sm_rx_eapol , libwpa_sp$(LIBSUFFIX).a ) (.text)
}
#--------
Ltdautoload LTDMAIN
{
After $(TARGET_NAME)
Object * (.ltdmain)
Library libwm_sp$(LIBSUFFIX).a \
libnwm_sp$(LIBSUFFIX).a \
libwvr_sp$(LIBSUFFIX).a \
libwl_sp$(LIBSUFFIX).a
Library libwpa_sp$(LIBSUFFIX).a
Library libathdrv_sp$(LIBSUFFIX).a
Library libfatfs_sp$(LIBSUFFIX).a \
$(USE_CRYPTO_LIBS)
Library $(ISDBG_LIBS_TWL)
Library $(ISDBG_LIBS_NITRO)
}

View File

@ -0,0 +1,692 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - components - mongoose.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/aes.h>
#include <twl/mcu.h>
#include <twl/hw/common/mmap_wramEnv.h>
#include <sysmenu.h>
#include "nvram_sp.h"
#include "pm_pmic.h"
#include "internal_api.h"
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
/* [TODO] Work around. Should be defined in wm_sp.h */
#define WM_WL_HEAP_SIZE 0x2100
/* Priorities of each threads */
#define THREAD_PRIO_SPI 2
#define THREAD_PRIO_MCU 4 // 暫定
#define THREAD_PRIO_SND 6
#define THREAD_PRIO_FATFS 8
#define THREAD_PRIO_RTC 12
#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 SetSCFGWork( void );
static void ResetRTC( void );
static void ReadLauncherParameter( void );
static void PrintDebugInfo(void);
static OSHeapHandle InitializeAllocateSystem(void);
static void InitializeFatfs(void);
static void InitializeNwm(void);
static void InitializeCdc(void);
static void DummyThread(void* arg);
static void ReadUserInfo(void);
static void VBlankIntr(void);
/*---------------------------------------------------------------------------*
*---------------------------------------------------------------------------*/
#ifdef SDK_TWLHYB
extern void SDK_LTDAUTOLOAD_LTDWRAM_BSS_END(void);
extern void SDK_LTDAUTOLOAD_LTDMAIN_BSS_END(void);
#endif
/*---------------------------------------------------------------------------*
Name: TwlSpMain
Description:
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void
TwlSpMain(void)
{
OSHeapHandle heapHandle;
// SYSMワークのクリア
MI_CpuClear32( SYSMi_GetWork(), sizeof(SYSM_work) );
// MMEMサイズチェックは、ARM7の_start内でやっているので、ーケアでOK.
// SCFGレジスタ→HWi_WSYS04 etc.→system shared領域への値セットは、ランチャー起動時点では行われていないので、
// ランチャー自身がこれらの値を使うには、自身でこれらの値をセットしてやる必要がある。
// ランチャーからアプリを起動する際には、reboot.cが値を再セットしてくれる。
SetSCFGWork(); // [TODO]未デバッグ
// バックライトON
while ( (reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK) == FALSE )
{
}
PMi_SetControl( PMIC_CTL_BKLT1 | PMIC_CTL_BKLT2 );
// OS 初期化
OS_Init();
OS_InitTick();
PrintDebugInfo();
// PXIコールバックの設定
// PXI_SetFifoRecvCallback( SYSMENU_PXI_FIFO_TAG, SYSMi_PXIFifoRecvCallback );
// ランチャーパラメター取得Cold/Hotスタート判定含む
ReadLauncherParameter();
// RTCリセット
ResetRTC(); // 330usくらい
// NVRAM からユーザー情報読み出し
ReadUserInfo();
// [TODO:] カード電源ONして、ROMヘッダのみリードチェックくらいはやっておきたい
SYSMi_GetWork()->flags.common.isARM9Start = TRUE; // [TODO:] HW_RED_RESERVEDはNANDファームでクリアしておいて欲しい
// ヒープ領域設定
{
void *wram = OS_GetWramSubPrivArenaHi();
void *mmem = OS_GetSubPrivArenaHi();
OS_SetSubPrivArenaHi( (void*)SYSM_OWN_ARM7_MMEM_ADDR_END ); // メモリ配置をいじっているので、アリーナHiも変更しないとダメ
OS_SetWramSubPrivArenaHi( (void*)SYSM_OWN_ARM7_WRAM_ADDR_END );
OS_TPrintf( "MMEM SUBPRV ARENA HI : %08x -> %08x\n", mmem, OS_GetSubPrivArenaHi() );
OS_TPrintf( "WRAM SUBPRV ARENA HI : %08x -> %08x\n", wram, OS_GetWramSubPrivArenaHi() );
}
heapHandle = InitializeAllocateSystem();
// ボタン入力サーチ初期化
(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();
// ファイルシステム初期化
FS_Init(FS_DMA_NOT_USE);
FS_CreateReadServerThread(THREAD_PRIO_FS);
if (OS_IsRunOnTwl() == TRUE)
{
OSTick start = OS_GetTick();
InitializeFatfs(); // FATFS 初期化
OS_TPrintf( "FATFS init time = %dms\n", OS_TicksToMilliSeconds( OS_GetTick() - start ) );
InitializeNwm(); // NWM 初期化
#ifndef SDK_NOCRYPTO
AES_Init(); // AES 初期化
#endif
MCU_InitIrq(THREAD_PRIO_MCU); // MCU 初期化
}
if (OSi_IsCodecTwlMode() == TRUE)
{
// CODEC 初期化
InitializeCdc();
// カメラ初期化
CAMERA_Init();
/* CODEC が TWL モードでないとシャッター音を強制的に鳴らす
使CODEC TWL
使 */
}
// サウンド初期化
SND_Init(THREAD_PRIO_SND);
// RTC 初期化
RTC_Init(THREAD_PRIO_RTC);
// 旧無線初期化
WVR_Begin(heapHandle);
// 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 )
) {
// ランチャーパラメータでダイレクトカードブート以外の指定がある時は、活線挿抜をOFFにする。
SYSMi_GetWork()->flags.common.isEnableHotSW = 0;
}else {
// それ以外の時は活線挿抜ON
SYSMi_GetWork()->flags.common.isEnableHotSW = 1;
}
HOTSW_Init();
while (TRUE)
{
OS_Halt();
//---- check reset
if (OS_IsResetOccurred())
{
OS_ResetSystem();
}
BOOT_WaitStart();
}
}
// システム領域(WRAM & MMEM)にSCFG情報をセット [TODO:]最終的にNANDファームからブートされたらいらないかも
static void SetSCFGWork( void )
{
// SCFGレジスタが有効な場合のみセット
if( reg_SCFG_EXT & REG_SCFG_EXT_CFG_MASK ) {
// WRAMのシステム領域にセット
u32 *wsys4 = (void*)HWi_WSYS04_ADDR;
u8 *wsys8 = (void*)HWi_WSYS08_ADDR;
u8 *wsys9 = (void*)HWi_WSYS09_ADDR;
// copy scfg registers
*wsys4 = reg_SCFG_EXT;
*wsys8 = (u8)(((reg_SCFG_OP & REG_SCFG_OP_OPT_MASK)) |
((reg_SCFG_A9ROM & (REG_SCFG_A9ROM_RSEL_MASK | REG_SCFG_A9ROM_SEC_MASK)) << (HWi_WSYS08_ROM_ARM9RSEL_SHIFT - REG_SCFG_A9ROM_RSEL_SHIFT)) |
((reg_SCFG_A7ROM & (REG_SCFG_A7ROM_RSEL_MASK | REG_SCFG_A7ROM_FUSE_MASK)) << (HWi_WSYS08_ROM_ARM7RSEL_SHIFT - REG_SCFG_A7ROM_RSEL_SHIFT)) |
((reg_SCFG_WL & REG_SCFG_WL_OFFB_MASK) << (HWi_WSYS08_WL_OFFB_SHIFT - REG_SCFG_WL_OFFB_SHIFT))
);
*wsys9 = (u8)((*wsys9 & (HWi_WSYS09_JTAG_DSPJE_MASK | HWi_WSYS09_JTAG_CPUJE_MASK | HWi_WSYS09_JTAG_ARM7SEL_MASK)) |
((reg_SCFG_JTAG & (REG_SCFG_JTAG_CPUJE_MASK | REG_SCFG_JTAG_ARM7SEL_MASK))) |
((reg_SCFG_JTAG & REG_SCFG_JTAG_DSPJE_MASK) >> (REG_SCFG_JTAG_DSPJE_SHIFT - HWi_WSYS09_JTAG_DSPJE_SHIFT)) |
((reg_SCFG_CLK & (REG_SCFG_CLK_AESHCLK_MASK | REG_SCFG_CLK_SD2HCLK_MASK | REG_SCFG_CLK_SD1HCLK_MASK)) << (HWi_WSYS09_CLK_SD1HCLK_SHIFT - REG_SCFG_CLK_SD1HCLK_SHIFT)) |
((reg_SCFG_CLK & (REG_SCFG_CLK_SNDMCLK_MASK | REG_SCFG_CLK_WRAMHCLK_MASK)) >> (REG_SCFG_CLK_WRAMHCLK_SHIFT - HWi_WSYS09_CLK_WRAMHCLK_SHIFT))
);
// MMEMのシステム領域にコピー
MI_CpuCopy8( (void*)HWi_WSYS04_ADDR, (void *)HW_SYS_CONF_BUF, 6 );
}
}
// RTCのリセットチェック
static void ResetRTC( void )
{
// ランチャーでリセットを検出するためにこの処理をしているが、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 );
SYSMi_GetWork()->flags.common.isResetRTC = TRUE;
}
}
// ランチャーパラメータのリードおよび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_CpuClear32( SYSMi_GetLauncherParamAddr(), 0x100 );
}
/*---------------------------------------------------------------------------*
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
#ifdef FATFS_AES_MOUNT_FOR_NAND
if(!FATFS_Init( FATFS_DMA_4, FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS))
#else
if (FATFS_Init(FATFS_DMA_NOT_USE, FATFS_DMA_NOT_USE, THREAD_PRIO_FATFS))
#endif
#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(void)
{
NwmspInit nwmInit;
OSHeapHandle heapHandle;
void* Lo = (void*)OS_GetSubPrivArenaLo();
void* Hi = (void*)OS_GetSubPrivArenaHi();
heapHandle = OS_CreateHeap(OS_ARENA_MAIN_SUBPRIV, Lo, Hi);
/* [TODO] 確保したヒープ領域が新無線一式が必要としているメモリ量以上かのチェックが必要 */
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 = heapHandle;
#ifdef WPA_BUILT_IN /* WPA が組み込まれる場合、以下のメンバが追加される */
nwmInit.wpaPrio = THREAD_PRIO_NWM_WPA;
nwmInit.wpaHeap.id = OS_ARENA_MAIN_SUBPRIV; /* [TODO] */
nwmInit.wpaHeap.handle = heapHandle;
#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];
// ダミースレッド作成
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_Init();
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(void)
{
OSHeapHandle hh;
#ifdef SDK_TWLHYB
if (OS_IsRunOnTwl() == TRUE)
{
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 (ATH_DRV_HEAP_SIZE > heapSize)
{
OS_Panic("Insufficient heap size. (0x%x < 0x%x)\n", heapSize, ATH_DRV_HEAP_SIZE);
}
OS_TPrintf("ARM7: MAIN heap size is %d (before AddToHead)\n", heapSize);
}
// ヒープに拡張ブロックを追加
OS_AddToHeap(OS_ARENA_MAIN_SUBPRIV, hh, extraLo, extraHi);
}
else
#endif
{
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);
OS_TPrintf("ARM7: MAIN heap size is %d\n", heapSize);
}
#ifdef SDK_TWLHYB
if (OS_IsRunOnTwl() == TRUE)
{
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 (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);
}
else
#endif
{
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 (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 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_WRAM_A_LTD_END - HW_WRAM_BASE)
#define HW_HYENA_WRAM_B_OFS (HW_HYENA_WRAM_A_OFS - HW_WRAM_B_SIZE)
#define HW_HYENA_WRAM_B_OFS_END (HW_HYENA_WRAM_A_OFS)
#define HW_HYENA_WRAM_C_OFS (HW_HYENA_WRAM_B_OFS - HW_WRAM_C_SIZE)
#define HW_HYENA_WRAM_C_OFS_END (HW_HYENA_WRAM_B_OFS)
// 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:Slot7 (32Kbytes), Address(7):0x037b8000-0x037bffff, Address(9):None
// WRAM-B Lock:OFF, Master:ARM9, Enable:Slot0-6(224Kbytes), Address(7):0x03780000-0x037b7fff, Address(9):0x03780000-0x037bffff
// WRAM-C Lock:OFF, Msster:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03740000-0x0377ffff, Address(9):0x03740000-0x0377ffff
// 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):0x03900000-0x0393ffff, Address(9):0x03900000-0x0393ffff
// WRAM-C Lock:OFF, Msster:ARM9, Enable:Slot0-7(256Kbytes), Address(7):0x03940000-0x0397ffff, Address(9):0x03940000-0x0397ffff
// 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_ARM9,
TRUE, MI_WRAM_OFFSET_160KB, MI_WRAM_ARM9,
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) |
(0x80 << 8) |
(0x00 << 16) |
// WRAM-0/1
(0 << 24) |
// VRAM-C
(7 << 26) |
// VRAM-D
(7 << 29)
),
};

34
build/gcdfirm/Makefile Normal file
View File

@ -0,0 +1,34 @@
#! 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 \
#----------------------------------------------------------------------------
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,66 @@
/*---------------------------------------------------------------------------*
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();
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 );
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,52 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - nandfirm - 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:$
#----------------------------------------------------------------------------
# if you have valid keys, set environment value like below
#export TWL_KEYSDIR='$(FIRM_ROOT)/../twl_firmware/bootrom/build/keys'
#----------------------------------------------------------------------------
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: 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:$
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
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,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 = ../include
#----------------------------------------------------------------------------
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,314 @@
/*---------------------------------------------------------------------------*
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 3
#define DMA_FATFS_2 2
extern void* SDNandContext; /* NAND初期化パラメータ */
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);
}
/***************************************************************
PreInit
FromBootの対応
OS_Init前なので注意 (ARM9によるメインメモリ初期化で消されないように注意)
***************************************************************/
static void PreInit(void)
{
/*
*/
if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 )
{
OS_TPrintf("Battery is empty.\n");
OS_Terminate();
}
/*
FromBrom関連
*/
if ( !OSi_FromBromToMenu() )
{
OS_Terminate();
}
/*
(1)(1)
*/
#define HOTSTART_FLAG_ENABLE 0x80
*(u8 *)HW_NAND_FIRM_HOTSTART_FLAG = (u8)(MCU_GetFreeRegister( OS_MCU_RESET_VALUE_OFS ) | HOTSTART_FLAG_ENABLE);
}
/***************************************************************
PostInit
***************************************************************/
static void PostInit(void)
{
// PMICの設定 for old version
PM_InitFIRM();
// AESの初期化
AES_Init(); // for encrypted NAND
// アイドルスレッドの作成
CreateIdleThread();
/*
*/
if ( (MCUi_ReadRegister( MCU_REG_POWER_INFO_ADDR ) & MCU_REG_POWER_INFO_LEVEL_MASK) == 0 )
{
OS_TPrintf("Battery is empty.\n");
OS_Terminate();
}
}
/***************************************************************
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 );
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
PM_BackLightOn( FALSE );
SDNandContext = &OSi_GetFromFirmAddr()->SDNandContext;
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
PM_BackLightOn( FALSE );
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
PM_BackLightOn( FALSE );
if ( (fd = FS_OpenSrl()) < 0 )
{
OS_TPrintf("Failed to call FS_OpenSrl().\n");
goto end;
}
// 6: after FS_OpenSrl
PUSH_PROFILE();
SetDebugLED(++step); // 0x87
PM_BackLightOn( FALSE );
if ( !FS_LoadHeader( fd ) )
{
OS_TPrintf("Failed to call FS_LoadHeader().\n");
goto end;
}
// 7: after FS_LoadHeader
PUSH_PROFILE();
SetDebugLED(++step); // 0x88
PM_BackLightOn( FALSE );
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
PM_BackLightOn( FALSE );
AESi_InitKeysFIRM();
AESi_RecvSeed( rh->s.developer_encrypt );
// 9: after AESi_RecvSeed
PUSH_PROFILE();
SetDebugLED(++step); // 0x8a
PM_BackLightOn( FALSE );
if ( !FS_LoadStatic( fd ) )
{
OS_TPrintf("Failed to call FS_LoadStatic().\n");
goto end;
}
// 10: after FS_LoadStatic
PUSH_PROFILE();
SetDebugLED(++step); // 0x8b
PM_BackLightOn( FALSE );
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 );
PM_BackLightOn( TRUE ); // last chance
PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, 22, PMIC_BL_BRT_B_MASK );
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 = ../include
#----------------------------------------------------------------------------
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,327 @@
/*---------------------------------------------------------------------------*
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>
#define RSA_KEY_ADDR rsa_key
#ifndef FIRM_USE_TWLSDK_KEYS
static const u8 rsa_key[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[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
};
#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)
{
static const OSMountInfo firmSettings[] =
{
// drive device target pertitionIdx resource userPermission rsvA B archive path
{ 'A', OS_MOUNT_DEVICE_SD, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "sdmc", "/" },
{ 'B', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 0, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "nand", "/" }, // ユーザーアプリはこのアーカイブではWrite不可
{ 'C', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_ROOT, 1, OS_MOUNT_RSC_WRAM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "nand2", "/" }, // ユーザーアプリはこのアーカイブではWrite不可
{ 'D', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "shared2", "nand2:/shared2" },
{ 'E', OS_MOUNT_DEVICE_NAND, OS_MOUNT_TGT_DIR, 0, OS_MOUNT_RSC_MMEM, (OS_MOUNT_USR_R|OS_MOUNT_USR_W), 0, 0, "photo", "nand2:/photo" },
{ 0 }
};
/*
*/
// 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));
// FS_MOUNT領域の初期化
MI_CpuCopy8(firmSettings, (char*)HW_TWL_FS_MOUNT_INFO_BUF, sizeof(firmSettings));
/*
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) );
// HMAC用鍵準備
FS_SetDigestKey( NULL );
// FS/FATFS初期化
FS_InitFIRM();
}
/***************************************************************
CheckHeader
***************************************************************/
static BOOL CheckHeader(void)
{
static 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 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_TWL_MAIN_MEM_END <= (u32)rhs->main_ram_address + rhs->main_size ||
HW_TWL_MAIN_MEM_END <= (u32)rhs->sub_ram_address + rhs->sub_size ||
HW_TWL_MAIN_MEM_END <= (u32)rhs->main_ltd_ram_address + rhs->main_ltd_size ||
HW_TWL_MAIN_MEM_END <= (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;
}
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_ADDR ) || !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();
AESi_SendSeed( FS_GetAesKeySeed() );
FS_DeleteAesKeySeed();
// 8: after AESi_SendSeed
PUSH_PROFILE();
if ( !FS_LoadStatic() )
{
OS_TPrintf("Failed to call FS_LoadStatic().\n");
goto end;
}
// 9: after FS_LoadStatic
PUSH_PROFILE();
PXI_NotifyID( FIRM_PXI_ID_DONE_STATIC );
// 10: 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,52 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - nandfirm - 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$
#----------------------------------------------------------------------------
# if you have valid keys, set environment value like below
#export TWL_KEYSDIR='$(TWL_IPL_RED_ROOT)/../twl_firmware/bootrom/build/keys'
#----------------------------------------------------------------------------
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 = ../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,
};

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 \
gcd \
#----------------------------------------------------------------------------
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,137 @@
/*---------------------------------------------------------------------------*
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/aes.h>
#include <firm/pxi.h>
/*---------------------------------------------------------------------------*
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);
reg_AES_AES_ID_B0 = AES_IDS_ID1_A(game_code);
reg_AES_AES_ID_B1 = AES_IDS_ID1_B(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_ResetAesKey
Description: set SEED/KEYs filler data without seed[3]
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void AESi_ResetAesKey( void )
{
AES_Lock();
AES_WaitKey();
// set dummy without seed[3]
reg_AES_AES_SEED_A0 = 1;
reg_AES_AES_SEED_A1 = 2;
reg_AES_AES_SEED_A2 = 3;
reg_AES_AES_SEED_B0 = 4;
reg_AES_AES_SEED_B1 = 5;
reg_AES_AES_SEED_B2 = 6;
reg_AES_AES_SEED_C0 = 7;
reg_AES_AES_SEED_C1 = 8;
reg_AES_AES_SEED_C2 = 9;
reg_AES_AES_SEED_D0 = 10;
reg_AES_AES_SEED_D1 = 11;
reg_AES_AES_SEED_D2 = 12;
reg_AES_AES_KEY_A0 = 1;
reg_AES_AES_KEY_A1 = 2;
reg_AES_AES_KEY_A2 = 3;
reg_AES_AES_KEY_A3 = 3;
reg_AES_AES_KEY_B0 = 4;
reg_AES_AES_KEY_B1 = 5;
reg_AES_AES_KEY_B2 = 6;
reg_AES_AES_KEY_B3 = 6;
reg_AES_AES_KEY_C0 = 7;
reg_AES_AES_KEY_C1 = 8;
reg_AES_AES_KEY_C2 = 9;
reg_AES_AES_KEY_C3 = 9;
reg_AES_AES_KEY_D0 = 10;
reg_AES_AES_KEY_D1 = 11;
reg_AES_AES_KEY_D2 = 12;
reg_AES_AES_KEY_D3 = 12;
AES_Unlock();
}
/*---------------------------------------------------------------------------*
Name: AESi_RecvSeed
Description: set SEED/KEY from ARM9 via PXI.
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void AESi_RecvSeed( BOOL developer_encrypt )
{
AESKey seed;
// PXI_RecvDataByFifo( PXI_FIFO_TAG_DATA, &seed, AES_BLOCK_SIZE );
PXI_RecvStream( &seed, AES_BLOCK_SIZE );
AES_Lock();
AES_WaitKey();
if ( developer_encrypt )
{
AES_SetKeyA(&seed); // Direct
}
else
{
AES_SetKeySeedA((AESKeySeed*)&seed); // APP
}
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,32 @@
/*---------------------------------------------------------------------------*
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>
void FATFS_InitFIRM( void )
{
MI_CpuClearFast( (void*)HW_FIRM_FATFS_COMMAND_BUFFER, HW_FIRM_FATFS_COMMAND_BUFFER_SIZE );
FATFSiCommandBuffer = (void*)HW_FIRM_FATFS_COMMAND_BUFFER;
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_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,117 @@
/*---------------------------------------------------------------------------*
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>
//#define WORKAROUND_NAND_2KB_BUG
#define FS_HEADER_AUTH_SIZE 0xe00
#define MODULE_ALIGNMENT 0x10 // 16バイト単位で読み込む
//#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;
static u8 aesBuffer[HW_FIRM_LOAD_BUFFER_UNIT_SIZE] ATTRIBUTE_ALIGN(32);
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 = OS_GetMountInfo(); *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_OpenSrl
Description: open srl file named in HW_TWL_FS_BOOT_SRL_PATH_BUF
Arguments: None
Returns: file discriptor
*---------------------------------------------------------------------------*/
int FS_OpenSrl( void )
{
const char *fspath = (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF;
u16 fatpath[OS_MOUNT_PATH_LEN];
ConvertPath(fatpath, fspath, OS_MOUNT_PATH_LEN);
return FATFSi_rtfs_po_open((u8*)fatpath, 0, 0);
}

View File

@ -0,0 +1,259 @@
/*---------------------------------------------------------------------------*
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 0x10 // 16バイト単位で読み込む
//#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;
static u8 aesBuffer[HW_FIRM_LOAD_BUFFER_UNIT_SIZE] ATTRIBUTE_ALIGN(32);
#define DMA_SEND 2
#define DMA_RECV 3
static void CopyWithAes( const void* src, void* dest, u32 size )
{
AES_Lock();
AES_Reset();
AES_Reset();
AES_WaitKey();
AES_LoadKey( AES_KEY_SLOT_A );
AES_WaitKey();
AES_DmaSend( DMA_SEND, src, size, NULL, NULL );
AES_DmaRecv( DMA_RECV, dest, 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 DisableAes( void )
{
aesFlag = FALSE;
}
static u32 GetTransferSize( u32 offset, u32 size )
{
u32 aes_offset = rh->s.aes_target_rom_offset;
u32 aes_end = aes_offset + RoundUpModuleSize(rh->s.aes_target_size);
u32 end = offset + RoundUpModuleSize(size);
if ( rh->s.enable_aes )
{
if ( offset >= aes_offset && offset < aes_end )
{
if ( end > aes_end )
{
size = aes_end - offset;
}
EnableAes( 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 = aesFlag ? aesBuffer :
(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 )
{
CopyWithAes( dest, (u8*)HW_FIRM_LOAD_BUFFER_BASE + count * HW_FIRM_LOAD_BUFFER_UNIT_SIZE, 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 fs_loader2.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,214 @@
/*---------------------------------------------------------------------------*
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 )
{
MI_CpuClearFast( (void*)HW_FIRM_FS_TEMP_BUFFER, HW_FIRM_FS_TEMP_BUFFER_SIZE );
FSiTemporaryBuffer = (void*)HW_FIRM_FS_TEMP_BUFFER;
FATFS_InitFIRM();
FS_Init( FS_DMA_NOT_USE );
}
/*---------------------------------------------------------------------------*
Name: LoadTMD
Description: TMD
NAMi_Free
Arguments: titleId: TitleID
Returns: TRUEを返します
FALSE
*---------------------------------------------------------------------------*/
static BOOL LoadTMD(ESTitleMeta* pTmd, u64 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, u64 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: 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( u64 titleId )
{
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_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( u64 titleId )
{
if ( !FS_GetTitleBootContentPathFast((char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, titleId) )
{
return FALSE;
}
return TRUE;
}

View File

@ -0,0 +1,386 @@
/*---------------------------------------------------------------------------*
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 MODULE_ALIGNMENT 0x10 // 16バイト単位で読み込む
//#define MODULE_ALIGNMENT 0x200 // 512バイト単位で読み込む
#define RoundUpModuleSize(value) (((value) + MODULE_ALIGNMENT - 1) & -MODULE_ALIGNMENT)
#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,
};
static AESKey FSiAesKeySeed;
/*---------------------------------------------------------------------------*
Name: FS_GetAesKeySeed
Description: retreive aes key seed in the signature
Arguments: None
Returns: pointer to seed
*---------------------------------------------------------------------------*/
AESKey* const FS_GetAesKeySeed( void )
{
return &FSiAesKeySeed;
}
/*---------------------------------------------------------------------------*
Name: FS_DeleteAesKeySeed
Description: delete aes key seed in the signature
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void FS_DeleteAesKeySeed( void )
{
MI_CpuClear8( &FSiAesKeySeed, sizeof(FSiAesKeySeed) );
}
/*---------------------------------------------------------------------------*
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
*---------------------------------------------------------------------------*/
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;
}
/*---------------------------------------------------------------------------*
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);
}
/*---------------------------------------------------------------------------*
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_FlushRange( 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 )
{
u32 aes_offset = rh->s.aes_target_rom_offset;
u32 aes_end = aes_offset + rh->s.aes_target_size;
u32 end = offset + size;
if ( rh->s.enable_aes )
{
if ( offset >= aes_offset && offset < aes_end )
{
if ( end > aes_end )
{
size = aes_end - 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] )
{
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);
}
/*---------------------------------------------------------------------------*
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 public key to verify the signature
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadHeader( SVCSignHeapContext* pool, 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;
}
// コンテンツ証明書
if ( CheckRomCertificate( pool, &rh->certificate, rsa_key, *(u32*)rh->s.game_code ) )
{
rsa_key = rh->certificate.pubKeyMod; // ヘッダ用の鍵の取り出し
}
else
{
// とりあえずコンテンツ証明書用の鍵がそのまま使えると仮定
}
// ヘッダ署名チェック
SVC_DecryptSign( pool, &sd, rh->signature, rsa_key );
if ( !CheckDigest( md, sd.digest, TRUE, FALSE ) )
{
MI_CpuClear8( &sd, sizeof(sd) ); // 残り削除 (他に必要なものはない?)
return FALSE;
}
// ダイジェスト以外のデータのチェックが必要!!
// 鍵の保存
MI_CpuCopy8( (AESKey*)sd.aes_key_seed, &FSiAesKeySeed, sizeof(FSiAesKeySeed) );
MI_CpuClear8( &sd, sizeof(sd) ); // 残り削除 (他に必要なものはない?)
// 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: None
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS_LoadStatic( void )
{
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;
}

View File

@ -0,0 +1,422 @@
/*---------------------------------------------------------------------------*
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>
#include <twl/aes.h>
#include <twl/aes_private.h>
#define FS_HEADER_AUTH_SIZE 0xe00
#define MODULE_ALIGNMENT 0x10 // 16バイト単位で読み込む
//#define MODULE_ALIGNMENT 0x200 // 512バイト単位で読み込む
#define RoundUpModuleSize(value) (((value) + MODULE_ALIGNMENT - 1) & -MODULE_ALIGNMENT)
#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,
};
static AESKey FSiAesKeySeed;
static BOOL aesFlag;
static AESCounter aesCounter;
static u8* const aesBuffer = (u8*)HW_FIRM_FS_AES_BUFFER; // 0x2ff3800
/*---------------------------------------------------------------------------*
Name: FS2_GetAesKeySeed
Description: retreive aes key seed in the signature
Arguments: None
Returns: pointer to seed
*---------------------------------------------------------------------------*/
AESKey* const FS2_GetAesKeySeed( void )
{
return &FSiAesKeySeed;
}
/*---------------------------------------------------------------------------*
Name: FS2_DeleteAesKeySeed
Description: delete aes key seed in the signature
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void FS2_DeleteAesKeySeed( void )
{
MI_CpuClear8( &FSiAesKeySeed, sizeof(FSiAesKeySeed) );
}
/*---------------------------------------------------------------------------*
Name: FS2_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
*---------------------------------------------------------------------------*/
void FS2_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;
}
/*---------------------------------------------------------------------------*
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);
}
static void AesCallback(AESResult result, void* arg)
{
volatile BOOL *pBusy = (BOOL*)arg;
*pBusy = FALSE;
if (result != AES_RESULT_SUCCESS)
{
OS_TPrintf("Failed to decrypt by AES (%d)\n", result);
}
}
static void CopyWithAes( const void* src, void* dest, u32 size )
{
volatile BOOL aesBusy = TRUE;
AES_SetKeySlot( AES_KEY_SLOT_A );
aesBusy = TRUE;
if ( AES_RESULT_SUCCESS == AES_Ctr( &aesCounter, src, size, dest, AesCallback, (void*)&aesBusy ) )
{
while ( aesBusy )
{
}
}
AES_AddToCounter( &aesCounter, size / AES_BLOCK_SIZE );
}
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 DisableAes( void )
{
aesFlag = FALSE;
}
/*---------------------------------------------------------------------------*
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 )
{
u32 aes_offset = rh->s.aes_target_rom_offset;
u32 aes_end = aes_offset + RoundUpModuleSize(rh->s.aes_target_size);
u32 end = offset + RoundUpModuleSize(size);
if ( rh->s.enable_aes )
{
if ( offset >= aes_offset && offset < aes_end )
{
if ( end > aes_end )
{
size = aes_end - offset;
}
if ( size > HW_FIRM_FS_AES_BUFFER_SIZE )
{
size = HW_FIRM_FS_AES_BUFFER_SIZE;
}
EnableAes( offset );
}
else
{
if ( offset < aes_offset && offset + size > aes_offset )
{
size = aes_offset - offset;
}
DisableAes();
}
}
else
{
DisableAes();
}
return size;
}
/*---------------------------------------------------------------------------*
Name: FS2_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: pFile pointer to FSFile streucture
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 FS2_LoadModule( FSFile *pFile, u8* dest, u32 offset, u32 size, const u8 digest[SVC_SHA1_DIGEST_SIZE] )
{
u8 md[SVC_SHA1_DIGEST_SIZE];
u8* hmacDest = dest;
u32 hmacSize = size;
if ( !FS_SeekFile( pFile, (s32)offset, FS_SEEK_SET ) )
{
return FALSE;
}
size = RoundUpModuleSize( size );
while ( size > 0 )
{
u32 unit = GetTransferSize( offset, size );
if ( aesFlag )
{
if ( !FS_ReadFile( pFile, aesBuffer, (s32)unit ) )
{
return FALSE;
}
DC_FlushRange( aesBuffer, unit );
CopyWithAes( aesBuffer, dest, unit );
}
else
{
if ( !FS_ReadFile( pFile, dest, (s32)unit ) )
{
return FALSE;
}
}
dest += unit;
offset += unit;
size -= unit;
}
SVC_CalcHMACSHA1( md, hmacDest, hmacSize, currentKey, SVC_SHA1_BLOCK_SIZE );
return CheckDigest(md, (u8*)digest, TRUE, FALSE);
}
/*---------------------------------------------------------------------------*
Name: FS2_OpenSrl
Description: open srl file named at HW_TWL_FS_BOOT_SRL_PATH_BUF
Arguments: pFile pointer to FSFile streucture
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS2_OpenSrl( FSFile *pFile )
{
return FS_OpenFileEx( pFile, (char*)HW_TWL_FS_BOOT_SRL_PATH_BUF, FS_FILEMODE_R );
}
/*---------------------------------------------------------------------------*
Name: FS2_LoadHeader
Description: load ROM header to HW_TWL_ROM_HEADER_BUF using normal FS,
and verify signature
Arguments: pFile pointer to FSFile streucture
pool heap context to call SVC_DecryptSign
rsa_key public key to verify the signature
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS2_LoadHeader( FSFile *pFile, SVCSignHeapContext* pool, const void* rsa_key )
{
u8 md[SVC_SHA1_DIGEST_SIZE];
SignatureData sd;
if ( !FS_SeekFile( pFile, 0, FS_SEEK_SET ) )
{
return FALSE;
}
if ( !FS_ReadFile( pFile, rh, HW_TWL_ROM_HEADER_BUF_SIZE ) )
{
return FALSE;
}
SVC_CalcSHA1( md, rh, FS_HEADER_AUTH_SIZE );
// コンテンツ証明書
if ( CheckRomCertificate( pool, &rh->certificate, rsa_key, *(u32*)rh->s.game_code ) )
{
rsa_key = rh->certificate.pubKeyMod; // ヘッダ用の鍵の取り出し
}
else
{
// とりあえずコンテンツ証明書用の鍵がそのまま使えると仮定
}
// ヘッダ署名チェック
SVC_DecryptSign( pool, &sd, rh->signature, rsa_key );
if ( !CheckDigest( md, sd.digest, TRUE, FALSE ) )
{
MI_CpuClear8( &sd, sizeof(sd) ); // 残り削除 (他に必要なものはない?)
return FALSE;
}
// ダイジェスト以外のデータのチェックが必要!!
// 鍵の保存
MI_CpuCopy8( (AESKey*)sd.aes_key_seed, &FSiAesKeySeed, sizeof(FSiAesKeySeed) );
MI_CpuClear8( &sd, sizeof(sd) ); // 残り削除 (他に必要なものはない?)
// ROMヘッダのコピー
MI_CpuCopyFast( rh, (void*)HW_ROM_HEADER_BUF, HW_ROM_HEADER_BUF_END-HW_ROM_HEADER_BUF );
return TRUE;
}
/*---------------------------------------------------------------------------*
Name: FS2_LoadStatic
Description: receive static regions from ARM6 via WRAM-B and store them
specified by ROM header at HW_TWL_ROM_HEADER_BUF
Arguments: pFile pointer to FSFile streucture
Returns: TRUE if success
*---------------------------------------------------------------------------*/
BOOL FS2_LoadStatic( FSFile *pFile )
{
if ( rh->s.main_size > 0 )
{
if ( !FS2_LoadModule( pFile, 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 ( !FS2_LoadModule( pFile, 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 ( !FS2_LoadModule( pFile, 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 ( !FS2_LoadModule( pFile, 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;
}

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 ARM7
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,52 @@
#! 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= True
TWL_PROC = ARM7
SRCDIR = . ../common
SRCS = \
gcd.c \
gcd_init.c \
blowfish.c \
ds_blowfish.c \
ds_blowfish_table.c \
TARGET_LIB = libgcd_sp$(FIRM_LIBSUFFIX).a
INCDIR = ../include
#----------------------------------------------------------------------------
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,57 @@
#! 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= True
SRCDIR = . ../common
SRCS = \
gcd.c \
gcd_init.c \
blowfish.c \
ds_blowfish.c \
ds_blowfish_table.c \
TARGET_LIB = libgcd$(FIRM_LIBSUFFIX).a
INCDIR = ../include
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
INSTALL_TARGETS = $(TARGETS)
INSTALL_DIR = $(FIRM_INSTALL_LIBDIR)
#----------------------------------------------------------------------------
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
LDEPENDS_OBJ := $(MAKEFIRM_RSA_PUBKEY) \
gcd_acsign.c : $(LDEPENDS_OBJ)
touch gcd_acsign.c
#===== End of Makefile =====

View File

@ -0,0 +1,34 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - gcd
# 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: $
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS = ARM9
#ifdef TWL_WITH_ARM7
SUBDIRS += ARM7
#endif
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - libraries - init
# 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 =
#----------------------------------------------------------------------------
# Codegen for sub processer
override TWL_PROC = ARM7
# Avoid to use pre-compile-header of "nitro.h"
TWL_NO_STD_PCHDR = True
# Avoid to build THUMB version object
override TWL_CODEGEN = ARM
SRCS = crt0_firm.c
TARGET_OBJ = crt0_firm.o
MACRO_FLAGS += -DSDK_NOINIT
#----------------------------------------------------------------------------
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,650 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - init
File: crt0_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/hw/common/mmap_wramEnv.h>
#include <twl/code32.h>
void _start(void);
void _start_AutoloadDoneCallback(void *argv[]);
#define SDK_NITROCODE_LE 0x2106c0de
#define SDK_NITROCODE_BE 0xdec00621
#define SDK_TWLCODE_LE 0x6314c0de
#define SDK_TWLCODE_BE 0xdec01463
/* 外部関数参照定義 */
extern void OS_IrqHandler(void);
extern void _fp_init(void);
extern void __call_static_initializers(void);
static void INITi_CpuClear32(register u32 data, register void *destp, register u32 size);
static void INITi_CpuClearFast(register u32 data, register void* destp, register u32 size);
static void INITi_DoAutoload(void);
static void INITi_ShelterLtdBinary(void);
static void INITi_CopySysConfig( void );
static void INITi_DetectMainMemorySize(void);
#ifndef SDK_NOINIT
static void INITi_ShelterStaticInitializer(u32* ptr);
static void INITi_CallStaticInitializers(void);
#endif
/* リンカスクリプトにより定義されるシンボル参照 */
extern void SDK_AUTOLOAD_LIST(void);
extern void SDK_AUTOLOAD_LIST_END(void);
extern void SDK_AUTOLOAD_START(void);
extern void SDK_STATIC_BSS_START(void);
extern void SDK_STATIC_BSS_END(void);
void *const _start_ModuleParams[] =
{
(void *)SDK_AUTOLOAD_LIST,
(void *)SDK_AUTOLOAD_LIST_END,
(void *)SDK_AUTOLOAD_START,
(void *)SDK_STATIC_BSS_START,
(void *)SDK_STATIC_BSS_END,
(void*)0, // CompressedStaticEnd. This fixed number will be updated by compstatic tool.
(void*)0, // SDK_VERSION_ID // SDK version info /* [TODO] ビルドを通すため */
(void*)SDK_NITROCODE_BE,
(void*)SDK_NITROCODE_LE,
};
extern void SDK_LTDAUTOLOAD_LIST(void);
extern void SDK_LTDAUTOLOAD_LIST_END(void);
extern void SDK_LTDAUTOLOAD_START(void);
void* const _start_LtdModuleParams[] =
{
(void*)SDK_LTDAUTOLOAD_LIST,
(void*)SDK_LTDAUTOLOAD_LIST_END,
(void*)SDK_LTDAUTOLOAD_START,
(void*)0, // CompressedLtdautoloadEnd. This fixed number will be updated by compstatic tool.
(void*)SDK_TWLCODE_BE,
(void*)SDK_TWLCODE_LE,
};
/*---------------------------------------------------------------------------*
Name: _start
Description: Start up
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
SDK_WEAK_SYMBOL asm void _start( void )
{
//---- set IME = 0
// ( use that LSB of HW_REG_BASE equal to 0 )
mov r12, #HW_REG_BASE
str r12, [r12, #REG_IME_OFFSET]
//---- initialize stack pointer
// SVC mode
mov r0, #HW_PSR_SVC_MODE
msr cpsr_c, r0
ldr sp, =HW_FIRM_SVC_STACK_END
// IRQ mode
mov r0, #HW_PSR_IRQ_MODE
msr cpsr_c, r0
ldr r0, =HW_FIRM_IRQ_STACK_END
mov sp, r0
// System mode
ldr r1, =HW_FIRM_IRQ_STACK_SIZE
sub r1, r0, r1
mov r0, #HW_PSR_SYS_MODE
msr cpsr_csfx, r0
sub sp, r1, #4 // 4byte for stack check code
#ifdef FIRM_DISABLE_CR_AT_WARMBOOT
//---- read reset flag from mcu
#ifdef SDK_TS
#if 0
mov r0, #REG_PMIC_SW_FLAGS_ADDR
bl PMi_GetRegister
ands r0, r0, #PMIC_SW_FLAGS_WARMBOOT
#else
mov r0, #I2C_SLAVE_MICRO_CONTROLLER
mov r1, #MCU_REG_TEMP_ADDR
bl I2Ci_ReadRegister
ldr r2, =HW_RESET_PARAMETER_BUF
str r0, [r2] // store 4 bytes
cmp r0, #0
#endif
movne r0, #FIRM_PXI_ID_WARMBOOT
moveq r0, #FIRM_PXI_ID_COLDBOOT
bl PXIi_SendByIntf
#endif // SDK_TS
#endif // FIRM_DISABLE_CR_AT_WARMBOOT
//---- wait for main memory mode into burst mode
ldr r3, =REG_EXMEMCNT_L_ADDR
mov r1, #REG_MI_EXMEMCNT_L_EMODE_MASK
@1:
ldrh r2, [r3]
tst r2, r1
beq @1
mov r0, #FIRM_PXI_ID_INIT_MMEM
bl PXIi_WaitIDByIntf
//---- clear HW_TWL_MAIN_MEM_SHARED
mov r0, #0
ldr r1, =HW_TWL_MAIN_MEM_SHARED
mov r2, #HW_TWL_MAIN_MEM_SHARED_SIZE
bl INITi_CpuClearFast
//---- notify to clear HW_MAIN_MEM_SHARED
mov r0, #FIRM_PXI_ID_INIT_MMEM
bl PXIi_SendIDByIntf
/* SCFG を HW_SYS_CONF_BUF へコピー */
bl INITi_CopySysConfig
//---- load autoload block and initialize bss
//bl INITi_DoAutoload
#ifndef SDK_FINALROM // for IS-TWL-DEBUGGER
bl _start_AutoloadDoneCallback
#endif
//---- fill static bss with 0
ldr r0, =_start_ModuleParams
ldr r1, [r0, #12] // BSS segment start
ldr r2, [r0, #16] // BSS segment end
mov r0, #0
sub r2, r2, r1
bl INITi_CpuClearFast
//---- detect main memory size
bl INITi_DetectMainMemorySize
#ifndef SDK_FINALROM
//---- set debug print window
ldr r1, =HW_PRINT_OUTPUT_ARM9
mov r0, #OS_PRINT_OUTPUT_DEFAULT_ARM9
orr r0, r0, #(OS_PRINT_OUTPUT_DEFAULT_ARM7<<8)
strh r0, [r1]
mov r0, #OS_PRINT_OUTPUT_DEFAULT_ARM9ERR
orr r0, r0, #(OS_PRINT_OUTPUT_DEFAULT_ARM7ERR<<8)
strh r0, [r1, #2]
#endif
//---- set interrupt vector
ldr r1, =HW_INTR_VECTOR_BUF
ldr r0, =OS_IrqHandler
str r0, [r1, #0]
#ifndef SDK_NOINIT
//---- for C++
bl _fp_init
bl TwlSpStartUp
bl __call_static_initializers
// bl INITi_CallStaticInitializers
#endif
//---- start (to 16bit code)
ldr r1, =TwlSpMain
ldr lr, =HW_RESET_VECTOR
bx r1
}
/*---------------------------------------------------------------------------*
Name: INITi_CpuClearFast
Description: 32 Byte
Arguments: r0 -
r1 -
r2 -
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_CpuClearFast(register u32 data, register void* destp, register u32 size)
{
stmfd sp!, {r4-r9}
add r9, r1, r2 // r9: destEndp = destp + size
mov r12, r2, lsr #5 // r12: destBlockEndp = destp + size/32*32
add r12, r1, r12, lsl #5
mov r2, r0
mov r3, r2
mov r4, r2
mov r5, r2
mov r6, r2
mov r7, r2
mov r8, r2
@40:
cmp r1, r12 // while (destp < destBlockEndp)
stmltia r1!, {r0, r2-r8} // *((vu32 *)(destp++)) = data
blt @40
@41:
cmp r1, r9 // while (destp < destEndp)
stmltia r1!, {r0} // *((vu32 *)(destp++)) = data
blt @41
ldmfd sp!, {r4-r9}
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_CpuClear32
Description: 32 bit
Arguments: r0 -
r1 -
r2 -
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_CpuClear32(register u32 data, register void* destp, register u32 size)
{
add r12, r1, r2
@001: cmp r1, r12
strlt r0, [r1], #4
blt @001
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_DoAutoload
Description: 沿
0
Arguments:
Returns:
*---------------------------------------------------------------------------*/
/*
* < >
* 0x02f88000 crt0
* NITRO WRAM 0x037c0000
* TWL WRAM
* 0x02e80000
* 0x04000 ROM 0x02f84000 - 0x02f88000 退
* NITRO MAIN 0x02f88000 + sizeof(crt0)
* TWL MAIN
*/
static asm void
INITi_DoAutoload(void)
{
@000:
stmdb sp!, {lr}
/* WRAM 用ブロックをオートロード */
ldr r1, =_start_ModuleParams
ldr r12, [r1] // r12 = SDK_AUTOLOAD_LIST
ldr r0, [r1, #4] // r0 = SDK_AUTOLOAD_LIST_END
ldr r1, [r1, #8] // r1 = SDK_AUTOLOAD_START
@001: cmp r12, r0
bge @010
/* 固定セクションをロード */
stmdb sp!, {r0}
ldr r2, [r12], #4 // r2 = start address of destination range
ldr r3, [r12], #4 // r3 = size of fixed section
add r3, r3, r2 // r3 = end address of destination range of fixed section
@002: cmp r2, r3
ldrlt r0, [r1], #4
strlt r0, [r2], #4
blt @002
/* static initializer テーブル情報を読み出し */
ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers
#ifndef SDK_NOINIT
stmdb sp!, {r0-r3, r12}
bl INITi_ShelterStaticInitializer
ldmia sp!, {r0-r3, r12}
#endif
/* .bss セクションを 0 クリア */
mov r0, #0
ldr r3, [r12], #4 // r3 = size of .bss section
add r3, r3, r2 // r3 = end address of destination range of .bss section
@003: cmp r2, r3
strlt r0, [r2], #4
blt @003
@004: ldmia sp!, {r0}
b @001
@010: /* メインメモリ用ブロックの存在を確認 */
ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1dc /* ARM7 用拡張常駐モジュール ROM サイズ */
ldr r0, [r1]
cmp r0, #0
beq @020
/* 再読み出し不可部分を退避 */
bl INITi_ShelterLtdBinary
/* メインメモリ用ブロックをオートロード */
ldr r1, =_start_LtdModuleParams
ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST
ldr r0, [r1, #4] // r0 = SDK_LTDAUTOLOAD_LIST_END
ldr r1, [r1, #8] // r1 = SDK_LTDAUTOLOAD_START
@011: cmp r12, r0
bge @020
/* 固定セクションをロード */
stmdb sp!, {r0}
ldr r2, [r12], #4 // r2 = start address of destination range
ldr r3, [r12], #4 // r3 = size of fixed section
add r3, r3, r2 // r3 = end address of destination range of fixed section
@012: cmp r2, r3
ldrlt r0, [r1], #4
strlt r0, [r2], #4
blt @012
/* static initializer テーブル情報を読み出し */
ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers
#ifndef SDK_NOINIT
stmdb sp!, {r0-r3, r12}
bl INITi_ShelterStaticInitializer
ldmia sp!, {r0-r3, r12}
#endif
/* .bss セクションを 0 クリア */
mov r0, #0
ldr r3, [r12], #4 // r3 = size of .bss section
add r3, r3, r2 // r3 = end address of destination range of .bss section
@013: cmp r2, r3
strlt r0, [r2], #4
blt @013
@014: ldmia sp!, {r0}
b @011
@020: /* オートロード完了コールバック関数呼び出し */
ldr r0, =_start_ModuleParams
ldr r1, =_start_LtdModuleParams
ldmia sp!, {lr}
b _start_AutoloadDoneCallback
}
/*---------------------------------------------------------------------------*
Name: INITi_ShelterLtdBinary
Description: TWL ROM
退退
ARM7 ARM9
0x4000 退
Arguments:
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_ShelterLtdBinary(void)
{
/* 退避元・先アドレスを調査 */
ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1d8 /* ARM7 用拡張常駐モジュール RAM アドレス */
ldr r1, [r1]
ldr r3, =HW_TWL_ROM_HEADER_BUF + 0x038 /* ARM7 用常駐モジュール RAM アドレス */
ldr r3, [r3]
sub r2, r3, #0x4000 /* 再読み出し不可領域サイズ */ /* ARM7 用退避エリア */
/* コピー */
@loop: ldr r0, [r1], #4
str r0, [r2], #4
cmp r2, r3
blt @loop
bx lr
}
#ifndef SDK_NOINIT
/*---------------------------------------------------------------------------*
Name: INITi_ShelterStaticInitializer
Description: static initializer
IRQ 退
Arguments: ptr -
NULL
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_ShelterStaticInitializer(u32* ptr)
{
/* 引数確認 */
cmp r0, #0
bxeq lr
/* 退避場所先頭アドレスを計算 */
ldr r1, =HW_FIRM_IRQ_STACK_END
ldr r2, =HW_FIRM_IRQ_STACK_SIZE
sub r1, r1, r2
add r1, r1, #4
/* 退避場所先頭から空き場所を調査 */
@001: ldr r2, [r1]
cmp r2, #0
addne r1, r1, #4
bne @001
/* 空き場所にテーブルをコピー */
@002: ldr r2, [r0], #4
str r2, [r1], #4
cmp r2, #0
bne @002
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_CallStaticInitializers
Description: static initializer
IRQ 退
Arguments:
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_CallStaticInitializers(void)
{
stmdb sp!, {lr}
/* テーブル退避場所先頭アドレスを計算 */
ldr r1, =HW_FIRM_IRQ_STACK_END
ldr r2, =HW_FIRM_IRQ_STACK_SIZE
sub r1, r1, r2
add r1, r1, #4
/* テーブルに管理されているポインタを一つずつ呼び出し */
@001: ldr r0, [r1]
cmp r0, #0
beq @002
stmdb sp!, {r1}
mov lr, pc
bx r0
ldmia sp!, {r1}
/* 一旦呼び出したポインタはゼロクリア (IRQスタックを間借りしている為) */
mov r0, #0
str r0, [r1], #4
b @001
@002: ldmia sp!, {lr}
bx lr
}
#endif
/*---------------------------------------------------------------------------*
Name: _start_AutoloadDoneCallback
Description:
Arguments: argv -
argv[0] = SDK_AUTOLOAD_LIST
argv[1] = SDK_AUTOLOAD_LIST_END
argv[2] = SDK_AUTOLOAD_START
argv[3] = SDK_STATIC_BSS_START
argv[4] = SDK_STATIC_BSS_END
Returns:
*---------------------------------------------------------------------------*/
SDK_WEAK_SYMBOL asm void
_start_AutoloadDoneCallback(void* argv[])
{
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_CopySysConfig
Description: copy SCFG registers to HW_SYS_CONF_BUF and HW_PRV_WRAM_SYSRV
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
static asm void INITi_CopySysConfig( void )
{
//################ temp: this process will be done in IPL
// SCFG enable?
ldr r2, =REG_EXT_ADDR
ldr r0, [r2]
tst r0, #0x80000000
beq @9
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_A7ROM_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]
@9:
//################
//---- copy scfg setting
ldr r2, =HW_PRV_WRAM_SYSRV
ldr r3, =HW_SYS_CONF_BUF
ldr r0, [r2, #HWi_WSYS04_WRAMOFFSET]
str r0, [r3, #HWi_WSYS04_OFFSET]
ldrh r0, [r2, #HWi_WSYS08_WRAMOFFSET]
strh r0, [r3, #HWi_WSYS08_OFFSET]
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_DetectMainMemorySize
Description: detect main memory size.
result is written into (u32*)HW_MMEMCHECKER_SUB.
value is [OS_CONSOLE_SIZE_4MB|OS_CONSOLE_SIZE_8MB|
OS_CONSOLE_SIZE_16MB|OS_CONSOLE_SIZE_32MB]
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
#define OSi_IMAGE_DIFFERENCE 0x400000
#define OSi_IMAGE_DIFFERENCE2 0xb000000
#define OSi_DETECT_NITRO_MASK (REG_SND_SMX_CNT_E_MASK | REG_SND_SMX_CNT_FSEL_MASK)
#define OSi_DETECT_NITRO_VAL (REG_SND_SMX_CNT_E_MASK)
static asm void INITi_DetectMainMemorySize( void )
{
stmfd sp!, {r4,lr}
//---- detect memory size
#if 0
mov r4, #OS_CONSOLE_SIZE_4MB
mov r1, #0
ldr r2, =HW_MMEMCHECKER_SUB
sub r3, r2, #OSi_IMAGE_DIFFERENCE
@1:
strh r1, [r2]
ldrh r12, [r3]
cmp r1, r12
bne @2
add r1, r1, #1
cmp r1, #2 // check 2 loop
bne @1
//---- 4MB
b @4
//---- 8MB or 16MB or 32MB
@2:
// check if running on twl/nitro
bl INITi_IsRunOnTwl
movne r4, #OS_CONSOLE_SIZE_8MB
bne @4
#else
ldr r2, =HW_MMEMCHECKER_SUB
#endif
//---- 16MB or 32MB
mov r1, #0
add r3, r2, #OSi_IMAGE_DIFFERENCE2
@3:
strh r1, [r2]
ldrh r12, [r3]
cmp r1, r12
movne r4, #OS_CONSOLE_SIZE_32MB
bne @4
add r1, r1, #1
cmp r1, #2 // check 2 loop
bne @3
mov r4, #OS_CONSOLE_SIZE_16MB
@4:
//---- check SMX_CNT
ldr r3, =REG_SMX_CNT_ADDR
ldrh r1, [r3]
and r1, r1, #OSi_DETECT_NITRO_MASK
cmp r1, #OSi_DETECT_NITRO_VAL
orreq r4, r4, #OS_CHIPTYPE_SMX_MASK
strb r4, [r2]
ldmfd sp!, {r4,lr}
bx lr
}
/*---------------------------------------------------------------------------*
Name: TwlSpStartUp
Description: hook for user start up
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
SDK_WEAK_SYMBOL void TwlSpStartUp(void)
{
}
#include <twl/codereset.h>

View File

@ -0,0 +1,50 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - libraries - init
# 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 =
#----------------------------------------------------------------------------
# Avoid to use pre-compile-header of "nitro.h"
TWL_NO_STD_PCHDR = True
# Avoid to build THUMB version object
override TWL_CODEGEN = ARM
SRCS = crt0_firm.c
TARGET_OBJ = crt0_firm.o
MACRO_FLAGS += -DSDK_NOINIT
#----------------------------------------------------------------------------
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,946 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - init
File: crt0_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/code32.h>
void _start(void);
void _start_AutoloadDoneCallback(void *argv[]);
#define SDK_NITROCODE_LE 0x2106c0de
#define SDK_NITROCODE_BE 0xdec00621
#define SDK_TWLCODE_LE 0x6314c0de
#define SDK_TWLCODE_BE 0xdec01463
/* 外部関数参照定義 */
extern void OS_IrqHandler(void);
extern void _fp_init(void);
extern void __call_static_initializers(void);
/* 内部関数プロトタイプ定義 */
static void INITi_CpuClear32(register u32 data, register void *destp, register u32 size);
static void INITi_CpuClearFast(register u32 data, register void* destp, register u32 size);
static void INITi_InitCoprocessor(void);
static void INITi_InitRegion(void);
static void INITi_DoAutoload(void);
static void INITi_ShelterLtdBinary(void);
#ifndef SDK_NOINIT
static void INITi_ShelterStaticInitializer(u32* ptr);
static void INITi_CallStaticInitializers(void);
#endif
/* リンカスックリプトにより定義されるシンボル参照 */
extern void SDK_AUTOLOAD_LIST(void);
extern void SDK_AUTOLOAD_LIST_END(void);
extern void SDK_AUTOLOAD_START(void);
extern void SDK_STATIC_BSS_START(void);
extern void SDK_STATIC_BSS_END(void);
//#include <nitro/version.h>
#define SDK_VERSION_ID ((u32)SDK_VERSION_MAJOR<<24|\
(u32)SDK_VERSION_MINOR<<16|\
(u32)SDK_VERSION_RELSTEP)
void* const _start_ModuleParams[] =
{
(void*)SDK_AUTOLOAD_LIST,
(void*)SDK_AUTOLOAD_LIST_END,
(void*)SDK_AUTOLOAD_START,
(void*)SDK_STATIC_BSS_START,
(void*)SDK_STATIC_BSS_END,
(void*)0, // CompressedStaticEnd. This fixed number will be updated by compstatic tool.
(void*)SDK_VERSION_ID, // SDK version info /* [TODO] ビルドを通すため */
(void*)SDK_NITROCODE_BE,
(void*)SDK_NITROCODE_LE,
};
extern void SDK_LTDAUTOLOAD_LIST(void);
extern void SDK_LTDAUTOLOAD_LIST_END(void);
extern void SDK_LTDAUTOLOAD_START(void);
void* const _start_LtdModuleParams[] =
{
(void*)SDK_LTDAUTOLOAD_LIST,
(void*)SDK_LTDAUTOLOAD_LIST_END,
(void*)SDK_LTDAUTOLOAD_START,
(void*)0, // CompressedLtdautoloadEnd. This fixed number will be updated by compstatic tool.
(void*)SDK_TWLCODE_BE,
(void*)SDK_TWLCODE_LE,
};
/*---------------------------------------------------------------------------*
Name: _start
Description:
Arguments:
Returns:
*---------------------------------------------------------------------------*/
#define INITi_HW_DTCM SDK_AUTOLOAD_DTCM_START
SDK_WEAK_SYMBOL asm void _start( void )
{
//---- set IME = 0
// ( use that LSB of HW_REG_BASE equal to 0 )
mov r12, #HW_REG_BASE
str r12, [r12, #REG_IME_OFFSET]
//---- initialize stack pointer
// SVC mode
mov r0, #HW_PSR_SVC_MODE
msr cpsr_c, r0
ldr r0, =INITi_HW_DTCM
add r0, r0, #0x3fc0
mov sp, r0
// IRQ mode
mov r0, #HW_PSR_IRQ_MODE
msr cpsr_c, r0
ldr r0, =INITi_HW_DTCM
add r0, r0, #0x3fc0
sub r0, r0, #HW_SVC_STACK_SIZE
sub sp, r0, #4 // 4byte for stack check code
tst sp, #4
subeq sp, sp, #4 // for 8byte-alignment
// System mode
ldr r1, =SDK_IRQ_STACKSIZE
sub r1, r0, r1
mov r0, #HW_PSR_SYS_MODE
msr cpsr_csfx, r0
sub sp, r1, #4 // 4byte for stack check code
tst sp, #4
subeq sp, sp, #4 // for 8byte-alignment
//---- read reset flag from pmic
#ifdef SDK_TS
#ifdef FIRM_DISABLE_CR_AT_WARMBOOT
@0: bl PXIi_RecvIDByIntf
cmp r0, #FIRM_PXI_ID_COLDBOOT
cmpne r0, #FIRM_PXI_ID_WARMBOOT
bne @0
//---- initialize Main Memory
cmp r0, #FIRM_PXI_ID_COLDBOOT
moveq r0, #TRUE
movne r0, #FALSE
bl MIi_InitMainMemCR
#else // !FIRM_DISABLE_CR_AT_WARMBOOT
//---- initialize Main Memory
bl MIi_InitMainMemCR
#endif // !FIRM_DISABLE_CR_AT_WARMBOOT
#endif // SDK_TS
//---- notify main memory mode into burst mode
mov r0, #FIRM_PXI_ID_INIT_MMEM
bl PXIi_SendIDByIntf
//---- wait to clear HW_MAIN_MEM_SHARED
mov r0, #FIRM_PXI_ID_INIT_MMEM
bl PXIi_WaitIDByIntf
/* システム制御コプロセッサ初期化 */
bl INITi_InitCoprocessor
/* リージョン初期設定 */
bl INITi_InitRegion
//---- clear memory
// DTCM (16KB)
mov r0, #0
ldr r1, =INITi_HW_DTCM
mov r2, #HW_DTCM_SIZE
bl INITi_CpuClear32
//---- load autoload block and initialize bss
// bl INITi_DoAutoload
#ifndef SDK_FINALROM // for IS-TWL-DEBUGGER
bl _start_AutoloadDoneCallback
#endif
//---- fill static static bss with 0
mov r0, #0
ldr r3, =_start_ModuleParams
ldr r1, [r3, #12] // SDK_STATIC_BSS_START
ldr r2, [r3, #16] // SDK_STATIC_BSS_END
sub r2, r2, r1
bl INITi_CpuClearFast
//---- flush static bss region
// (r0 == #0, r3 == _start_ModuleParams::BSS_segment_start)
bic r1, r3, #HW_CACHE_LINE_SIZE - 1
@cacheflush:
mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty
mcr p15, 0, r1, c7, c5, 1 // ICache
mcr p15, 0, r1, c7, c14, 1 // DCache
add r1, r1, #HW_CACHE_LINE_SIZE
cmp r1, r2
blt @cacheflush
// print buffer (used for ARM7's printing)
ldr r1, =HW_COMPONENT_PARAM
str r0, [r1, #0]
//---- set interrupt vector
ldr r1, =INITi_HW_DTCM
add r1, r1, #0x3fc0
add r1, r1, #HW_DTCM_SYSRV_OFS_INTR_VECTOR
ldr r0, =OS_IrqHandler
str r0, [r1, #0]
#ifndef SDK_NOINIT
//---- for C++
bl _fp_init
bl TwlStartUp
bl __call_static_initializers
// bl INITi_CallStaticInitializers
#endif
//---- start (to 16bit code)
ldr r1, =TwlMain
ldr lr, =HW_RESET_VECTOR
bx r1
}
/*---------------------------------------------------------------------------*
Name: INITi_CpuClearFast
Description: 32 Byte
Arguments: r0 -
r1 -
r2 -
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_CpuClearFast(register u32 data, register void* destp, register u32 size)
{
stmfd sp!, {r4-r9}
add r9, r1, r2 // r9: destEndp = destp + size
mov r12, r2, lsr #5 // r12: destBlockEndp = destp + size/32*32
add r12, r1, r12, lsl #5
mov r2, r0
mov r3, r2
mov r4, r2
mov r5, r2
mov r6, r2
mov r7, r2
mov r8, r2
@40:
cmp r1, r12 // while (destp < destBlockEndp)
stmltia r1!, {r0, r2-r8} // *((vu32 *)(destp++)) = data
blt @40
@41:
cmp r1, r9 // while (destp < destEndp)
stmltia r1!, {r0} // *((vu32 *)(destp++)) = data
blt @41
ldmfd sp!, {r4-r9}
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_CpuClear32
Description: 32 bit
Arguments: r0 -
r1 -
r2 -
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_CpuClear32(register u32 data, register void* destp, register u32 size)
{
add r12, r1, r2
@001: cmp r1, r12
strlt r0, [r1], #4
blt @001
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_InitCoprocessor
Description:
I-TCM D-TCM 使
Arguments:
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_InitCoprocessor(void)
{
/* コプロセッサの状態取得 */
mrc p15, 0, r0, c1, c0, 0
tst r0, #HW_C1_PROTECT_UNIT_ENABLE
beq @010
tst r0, #HW_C1_DCACHE_ENABLE
beq @003
/* D-Cache 内容をメモリにライトバック */
mov r1, #0
@001: mov r2, #0
@002: orr r3, r1, r2
mcr p15, 0, r3, c7, c10, 2
add r2, r2, #HW_CACHE_LINE_SIZE
cmp r2, #HW_DCACHE_SIZE / 4
blt @002
adds r1, r1, #1 << HW_C7_CACHE_SET_NO_SHIFT
bne @001
@003: /* ライトバッファが空になるのを待つ */
mov r1, #0
mcr p15, 0, r1, c7, c10, 4
@010: /* コプロセッサの状態を初期化 */
ldr r1, = HW_C1_ITCM_LOAD_MODE \
| HW_C1_DTCM_LOAD_MODE \
| HW_C1_ITCM_ENABLE \
| HW_C1_DTCM_ENABLE \
| HW_C1_LD_INTERWORK_DISABLE \
| HW_C1_ICACHE_ENABLE \
| HW_C1_DCACHE_ENABLE \
| HW_C1_PROTECT_UNIT_ENABLE
bic r0, r0, r1
ldr r1, = HW_C1_SB1_BITSET \
| HW_C1_EXCEPT_VEC_UPPER
orr r0, r0, r1
mcr p15, 0, r0, c1, c0, 0
/* I-TCM のサイズを設定 */
mov r1, #HW_C9_TCMR_32MB
mcr p15, 0, r1, c9, c1, 1
/* D-TCM のサイズ及び領域ベースアドレスを設定 */
ldr r1, =SDK_AUTOLOAD_DTCM_START
orr r1, r1, #HW_C9_TCMR_16KB
mcr p15, 0, r1, c9, c1, 0
/* I-TCM / D-TCM 使用許可設定 */
mov r1, #HW_C1_ITCM_ENABLE | HW_C1_DTCM_ENABLE
orr r0, r0, r1
mcr p15, 0, r0, c1, c0, 0
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_InitRegion
Description:
Arguments:
Returns:
*---------------------------------------------------------------------------*/
/* When hardware is TWL
; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA
; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW
; Region 1: MAINMEM_WRAM: Base = 0x02000000, Size = 32MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW
; Region 2: ARM7_RESERVE: Base = 0x02f80000, Size = 512KB, I:NC NB / D:NC NB, I:NA / D:NA
; Region 3: EX_MAINMEM: Base = 0x0d000000, Size = 16MB, I:Cach Buf / D:Cach Buf, I:RW / D:RW
; Region 4: DTCM: Base = 0x02fe0000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW
; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW
; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO
; Region 7: SHARED_WORK: Base = 0x02ffc000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW
*/
/* When hardware is NITRO
; Region G: BACK_GROUND: Base = 0x0, Size = 4GB, I:NC NB / D:NC NB, I:NA / D:NA
; Region 0: IO_VRAM: Base = 0x04000000, Size = 64MB, I:NC NB / D:NC NB, I:RW / D:RW
; Region 1: MAIN_MEM: Base = 0x02000000, Size = 8MB*, I:Cach Buf / D:Cach Buf, I:RW / D:RW
; (* When hardware is not debugger, size will be reduced to 4MB in OS_InitArena() )
;// Region 2: ARM7_RESERVE: Base = 0x027e0000, Size = 128KB, I:NC NB / D:NC NB, I:NA / D:NA
;// (* When hardware is not debugger, base will be moved to 0x023e0000 in OS_InitArena() )
; Region 2: SHARED_WORK: Base = 0x027ff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW
; Region 3: CARTRIDGE: Base = 0x08000000, Size = 128MB, I:NC NB / D:NC NB, I:NA / D:RW
; Region 4: DTCM: Base = 0x02fe0000, Size = 16KB, I:NC NB / D:NC NB, I:NA / D:RW
; Region 5: ITCM: Base = 0x01000000, Size = 16MB, I:NC NB / D:NC NB, I:RW / D:RW
; Region 6: BIOS: Base = 0xffff0000, Size = 32KB, I:Cach NB / D:Cach NB, I:RO / D:RO
; Region 7: SHARED_WORK: Base = 0x02fff000, Size = 4KB, I:NC NB / D:NC NB, I:NA / D:RW
*/
static asm void
INITi_InitRegion(void)
{
mov r12, lr
#define SET_PROTECTION_A(id, adr, siz) ldr r0, =(adr|HW_C6_PR_##siz|HW_C6_PR_ENABLE)
#define SET_PROTECTION_B(id, adr, siz) mcr p15, 0, r0, c6, id, 0
#define REGION_BIT(a, b, c, d, e, f, g, h) (((a) << 0) | ((b) << 1) | ((c) << 2) | ((d) << 3) | ((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7))
#define REGION_ACC(a, b, c, d, e, f, g, h) (((a) << 0) | ((b) << 4) | ((c) << 8) | ((d) << 12) | ((e) << 16) | ((f) << 20) | ((g) << 24) | ((h) << 28))
#define NA 0
#define RW 1
#define RO 5
/* (0) I/O レジスタ及び VRAM 等 */
SET_PROTECTION_A(c0, HW_IOREG, 64MB)
SET_PROTECTION_B(c0, HW_IOREG, 64MB)
/* (4) D-TCM */
ldr r0, =SDK_AUTOLOAD_DTCM_START
orr r0, r0, #HW_C6_PR_16KB | HW_C6_PR_ENABLE
SET_PROTECTION_B(c4, SDK_AUTOLOAD_DTCM_START, 16KB)
/* (5) I-TCM */
SET_PROTECTION_A(c5, HW_ITCM_IMAGE, 16MB)
SET_PROTECTION_B(c5, HW_ITCM_IMAGE, 16MB)
/* (6) システムコール ROM */
SET_PROTECTION_A(c6, HW_BIOS, 32KB)
SET_PROTECTION_B(c6, HW_BIOS, 32KB)
/* TWL ハードウェア上で動作しているかどうかを調査 */
#if 0
bl INITi_IsRunOnTwl
bne @002
#endif
@001: /* ハードウェアが TWL の場合 */
/* (1) メインメモリ及び WRAM */
SET_PROTECTION_A(c1, HW_TWL_MAIN_MEM_MAIN, 32MB)
SET_PROTECTION_B(c1, HW_TWL_MAIN_MEM_MAIN, 32MB)
/* (2) ARM7 専用メインメモリ空間 */
SET_PROTECTION_A(c2, HW_TWL_MAIN_MEM_SUB, 512KB)
SET_PROTECTION_B(c2, HW_TWL_MAIN_MEM_SUB, 512KB)
/* (3) 拡張メインメモリ */
SET_PROTECTION_A(c3, HW_TWL_MAIN_MEM_EX, 16MB)
SET_PROTECTION_B(c3, HW_TWL_MAIN_MEM_EX, 16MB)
/* (7) ARM9/ARM7 共有メインメモリ空間 */
SET_PROTECTION_A(c7, HW_TWL_MAIN_MEM_SHARED, 16KB)
SET_PROTECTION_B(c7, HW_TWL_MAIN_MEM_SHARED, 16KB)
/* 命令キャッシュ許可 */
mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0)
mcr p15, 0, r0, c2, c0, 1
/* データキャッシュ許可 */
// mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0)
mov r0, #REGION_BIT(0, 1, 1, 1, 0, 0, 1, 0)
mcr p15, 0, r0, c2, c0, 0
/* ライトバッファ許可 */
// mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 0, 0)
mov r0, #REGION_BIT(0, 1, 1, 1, 0, 0, 0, 0)
mcr p15, 0, r0, c3, c0, 0
/* 命令アクセス許可 */
ldr r0, =REGION_ACC(RW, RW, NA, RW, NA, RW, RO, NA)
mcr p15, 0, r0, c5, c0, 3
/* データアクセス許可 */
// ldr r0, =REGION_ACC(RW, RW, NA, RW, RW, RW, RO, RW)
ldr r0, =REGION_ACC(RW, RW, RW, RW, RW, RW, RO, RW)
mcr p15, 0, r0, c5, c0, 2
#if 0
b @003
@002: /* ハードウェアが NITRO の場合 */
/* (1) メインメモリ */
//SET_PROTECTION_A(c1, HW_MAIN_MEM_MAIN, 8MB)
//SET_PROTECTION_B(c1, HW_MAIN_MEM_MAIN, 8MB)
SET_PROTECTION_A(c1, HW_MAIN_MEM_MAIN, 32MB)
SET_PROTECTION_B(c1, HW_MAIN_MEM_MAIN, 32MB)
/* Size will be arranged in OS_InitArena(). */
/* (2) ARM7 専用メインメモリ空間 */
SET_PROTECTION_A(c2, (HW_MAIN_MEM_EX_END - HW_MAIN_MEM_SHARED_SIZE - HW_MAIN_MEM_SUB_SIZE), 128KB)
SET_PROTECTION_B(c2, (HW_MAIN_MEM_EX_END - HW_MAIN_MEM_SHARED_SIZE - HW_MAIN_MEM_SUB_SIZE), 128KB)
/* Base address will be moved in OS_InitArena(). */
/* (3) カートリッジ */
//SET_PROTECTION_A(c3, HW_CTRDG_ROM, 128MB)
//SET_PROTECTION_B(c3, HW_CTRDG_ROM, 128MB)
SET_PROTECTION_A(c3, HW_CTRDG_ROM, 32MB)
SET_PROTECTION_B(c3, HW_CTRDG_ROM, 32MB)
/* (7) ARM9/ARM7 共有メインメモリ空間 */
SET_PROTECTION_A(c7, HW_MAIN_MEM_SHARED, 4KB)
SET_PROTECTION_B(c7, HW_MAIN_MEM_SHARED, 4KB)
/* 命令キャッシュ許可 */
mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 1, 0)
mcr p15, 0, r0, c2, c0, 1
/* データキャッシュ許可 */
//mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 1, 0)
mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 1, 0)
mcr p15, 0, r0, c2, c0, 0
/* ライトバッファ許可 */
//mov r0, #REGION_BIT(0, 1, 0, 0, 0, 0, 0, 0)
mov r0, #REGION_BIT(0, 1, 0, 1, 0, 0, 0, 0)
mcr p15, 0, r0, c3, c0, 0
/* 命令アクセス許可 */
//ldr r0, =REGION_ACC(RW, RW, NA, NA, NA, RW, RO, NA)
ldr r0, =REGION_ACC(RW, RW, NA, RW, NA, RW, RO, NA)
mcr p15, 0, r0, c5, c0, 3
/* データアクセス許可 */
ldr r0, =REGION_ACC(RW, RW, NA, RW, RW, RW, RO, RW)
mcr p15, 0, r0, c5, c0, 2
#endif
@003: /* プロテクションユニット及びキャッシュ使用許可設定 */
mrc p15, 0, r0, c1, c0, 0
ldr r1, = HW_C1_ICACHE_ENABLE \
| HW_C1_DCACHE_ENABLE \
| HW_C1_CACHE_ROUND_ROBIN \
| HW_C1_PROTECT_UNIT_ENABLE
orr r0, r0, r1
mcr p15, 0, r0, c1, c0, 0
/* キャッシュの内容を破棄 */
mov r1, #0
mcr p15, 0, r1, c7, c6, 0
mcr p15, 0, r1, c7, c5, 0
bx r12
}
/*---------------------------------------------------------------------------*
Name: INITi_DoAutoload
Description: 沿
0 4M bytes PSRAM
TWL
Arguments:
Returns:
*---------------------------------------------------------------------------*/
/*
* < >
* 0x02000000 Static ()
* 0x02000000
* NITRO ITCM 0x01ff8000
* NITRO DTCM 0x02fe0000
* 0x02400000 ()
* 0x04000 ROM 0x02f80000 - 0x02f84000 退
* 0x02400000
* TWL WRAM
* TWL
* NITRO 0x02400000
* 0x02400000
* .bss
*
*/
static asm void
INITi_DoAutoload(void)
{
@000:
stmdb sp!, {lr}
/* NITRO 共用ブロックの解凍 */
ldr r1, =_start_ModuleParams
ldr r0, [r1, #20] // r0 = bottom of compressed data
bl MIi_UncompressBackward
@010:
/* NITRO 共用ブロックをオートロード */
ldr r1, =_start_ModuleParams
ldr r12, [r1] // r12 = SDK_AUTOLOAD_LIST
ldr r0, [r1, #4] // r0 = SDK_AUTOLOAD_LIST_END
ldr r1, [r1, #8] // r1 = SDK_AUTOLOAD_START
@011: cmp r12, r0
bge @020
/* 固定セクションをロード */
stmdb sp!, {r0}
ldr r2, [r12], #4 // r2 = start address of destination range
stmdb sp!, {r2}
ldr r3, [r12], #4 // r3 = size of fixed section
add r3, r3, r2 // r3 = end address of destination range of fixed section
@012: cmp r2, r3
ldrlt r0, [r1], #4
strlt r0, [r2], #4
blt @012
/* static initializer テーブル情報を読み出し */
ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers
#ifndef SDK_NOINIT
stmdb sp!, {r0-r3, r12}
bl INITi_ShelterStaticInitializer
ldmia sp!, {r0-r3, r12}
#endif
/* .bss セクションを 0 クリア */
mov r0, #0 // r0 = number to fill .bss section
ldr r3, [r12], #4 // r3 = size of .bss section
add r3, r3, r2 // r3 = end address of destination range of .bss section
@013: cmp r2, r3
strlt r0, [r2], #4
blt @013
/* キャッシュを調整 */
ldmia sp!, {r2} // r2 = start address of destination range
mov r0, #HW_ITCM_IMAGE
cmp r2, r0
movge r0, #HW_ITCM_END
cmpge r0, r2
bgt @015 // If I-TCM autoload block, skip cache control logic.
ldr r0, =SDK_AUTOLOAD_DTCM_START
cmp r2, r0
addge r0, r0, #HW_DTCM_SIZE
cmpge r0, r2
bgt @015 // If D-TCM autoload block, skip cache control logic.
bic r2, r2, #HW_CACHE_LINE_SIZE - 1 // RoundDown32
@014: cmp r2, r3
bge @015
mcr p15, 0, r2, c7, c14, 1 // Store and Invalidate D-Cache
mcr p15, 0, r2, c7, c5, 1 // Invalidate I-Cache
add r2, r2, #HW_CACHE_LINE_SIZE
b @014
@015: ldmia sp!, {r0}
b @011
@020:
/* TWL ハードウェア上で動作しているかどうかを調査 */
#if 0
bl INITi_IsRunOnTwl
bne @030
#endif
/* TWL 専用ブロックの存在を確認 */
ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1cc /* ARM9 用拡張常駐モジュール ROM サイズ */
ldr r0, [r1]
cmp r0, #0
beq @030
/* 再読み出し不可部分を退避 */
bl INITi_ShelterLtdBinary
/* TWL 専用ブロックの解凍 */
ldr r1, =_start_LtdModuleParams
ldr r0, [r1, #12]
bl MIi_UncompressBackward
/* TWL 専用ブロックをオートロード */
ldr r1, =_start_LtdModuleParams
ldr r12, [r1] // r12 = SDK_LTDAUTOLOAD_LIST
ldr r0, [r1, #4] // r0 = SDK_LTDAUTOLOAD_LIST_END
ldr r1, [r1, #8] // r1 = SDK_LTDAUTOLOAD_START
@021: cmp r12, r0
bge @030
/* 固定セクションをロード */
stmdb sp!, {r0}
ldr r2, [r12], #4 // r2 = start address of destination range
stmdb sp!, {r2}
ldr r3, [r12], #4 // r3 = size of fixed section
add r3, r3, r2 // r3 = end address of destination range of fixed section
@022: cmp r2, r3
ldrlt r0, [r1], #4
strlt r0, [r2], #4
blt @022
/* static initializer テーブル情報を読み出し */
ldr r0, [r12], #4 // r0 = address of the table managing pointers of static initializers
#ifndef SDK_NOINIT
stmdb sp!, {r0-r3, r12}
bl INITi_ShelterStaticInitializer
ldmia sp!, {r0-r3, r12}
#endif
/* .bss セクションを 0 クリア */
mov r0, #0 // r0 = number to fill .bss section
ldr r3, [r12], #4 // r3 = size of .bss section
add r3, r3, r2 // r3 = end address of destination range of .bss section
@023: cmp r2, r3
strlt r0, [r2], #4
blt @023
/* キャッシュを調整 */
ldmia sp!, {r2} // r2 = start address of destination range
mov r0, #HW_ITCM_IMAGE
cmp r2, r0
movge r0, #HW_ITCM_END
cmpge r0, r2
bgt @025 // If I-TCM autoload block, skip cache control logic.
ldr r0, =SDK_AUTOLOAD_DTCM_START
cmp r2, r0
addge r0, r0, #HW_DTCM_SIZE
cmpge r0, r2
bgt @025 // If D-TCM autoload block, skip cache control logic.
bic r2, r2, #HW_CACHE_LINE_SIZE - 1 // RoundDown32
@024: cmp r2, r3
bge @025
mcr p15, 0, r2, c7, c14, 1 // Store and Invalidate D-Cache
mcr p15, 0, r2, c7, c5, 1 // Invalidate I-Cache
add r2, r2, #HW_CACHE_LINE_SIZE
b @024
@025: ldmia sp!, {r0}
b @021
@030: /* ライトバッファが空になるのを待つ */
mov r0, #0
mcr p15, 0, r0, c7, c10, 4
/* オートロード完了コールバック関数呼び出し */
ldr r0, =_start_ModuleParams
ldr r1, =_start_LtdModuleParams
ldmia sp!, {lr}
b _start_AutoloadDoneCallback
}
/*---------------------------------------------------------------------------*
Name: INITi_ShelterLtdBinary
Description: TWL ROM
退退
ARM7 ARM9
0x4000 退
Arguments:
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_ShelterLtdBinary(void)
{
/* ARM7 専用メインメモリ空間保護リージョンを一旦アクセス可能に変更 */
mrc p15, 0, r0, c5, c0, 3
mrc p15, 0, r1, c5, c0, 2
stmdb sp!, {r0, r1}
bic r0, r0, #(0xf << 8)
orr r0, r0, #(0x1 << 8)
bic r1, r1, #(0xf << 8)
orr r1, r1, #(0x1 << 8)
mcr p15, 0, r0, c5, c0, 3
mcr p15, 0, r1, c5, c0, 2
/* 退避元・先アドレスを調査 */
ldr r1, =HW_TWL_ROM_HEADER_BUF + 0x1c8 /* ARM9 用拡張常駐モジュール RAM アドレス */
ldr r1, [r1]
ldr r3, =HW_TWL_ROM_HEADER_BUF + 0x038 /* ARM7 用常駐モジュール RAM アドレス */
ldr r3, [r3]
sub r3, r3, #0x4000 /* 再読み出し不可領域サイズ */ /* ARM7 用退避エリア */
sub r2, r3, #0x4000 /* 再読み出し不可領域サイズ */ /* ARM9 用退避エリア */
/* コピー */
@loop: ldr r0, [r1], #4
str r0, [r2], #4
cmp r2, r3
blt @loop
/* ARM7 専用メインメモリ空間保護リージョン設定を元に戻す */
ldmia sp!, {r0, r1}
mcr p15, 0, r0, c5, c0, 3
mcr p15, 0, r1, c5, c0, 2
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_ShelterStaticInitializer
Description: static initializer
IRQ ( 4 )
退
Arguments: ptr -
NULL
Returns:
*---------------------------------------------------------------------------*/
#ifndef SDK_NOINIT
static asm void
INITi_ShelterStaticInitializer(u32* ptr)
{
/* 引数確認 */
cmp r0, #0
bxeq lr
/* 退避場所先頭アドレスを計算 */
ldr r1, =SDK_AUTOLOAD_DTCM_START
add r1, r1, #HW_DTCM_SIZE
sub r1, r1, #HW_DTCM_SYSRV_SIZE
sub r1, r1, #HW_SVC_STACK_SIZE
ldr r2, =SDK_IRQ_STACKSIZE
sub r1, r1, r2
add r1, r1, #4
/* 退避場所先頭から空き場所を調査 */
@001: ldr r2, [r1]
cmp r2, #0
addne r1, r1, #4
bne @001
/* 空き場所にテーブルをコピー */
@002: ldr r2, [r0], #4
str r2, [r1], #4
cmp r2, #0
bne @002
bx lr
}
/*---------------------------------------------------------------------------*
Name: INITi_CallStaticInitializers
Description: static initializer
IRQ ( 4
) 退
Arguments:
Returns:
*---------------------------------------------------------------------------*/
static asm void
INITi_CallStaticInitializers(void)
{
stmdb sp!, {lr}
/* テーブル退避場所先頭アドレスを計算 */
ldr r1, =SDK_AUTOLOAD_DTCM_START
add r1, r1, #HW_DTCM_SIZE
sub r1, r1, #HW_DTCM_SYSRV_SIZE
sub r1, r1, #HW_SVC_STACK_SIZE
ldr r2, =SDK_IRQ_STACKSIZE
sub r1, r1, r2
add r1, r1, #4
/* テーブルに管理されているポインタを一つずつ呼び出し */
@001: ldr r0, [r1]
cmp r0, #0
beq @002
stmdb sp!, {r1}
blx r0
ldmia sp!, {r1}
/* 一旦呼び出したポインタはゼロクリア (IRQスタックを間借りしている為) */
mov r0, #0
str r0, [r1], #4
b @001
@002:
ldmia sp!, {lr}
bx lr
}
#endif
/*---------------------------------------------------------------------------*
Name: MIi_UncompressBackward
Description: Uncompress special archive for module compression.
Arguments: bottom = Bottom adrs of packed archive + 1
bottom[-8..-6] = offset for top of compressed data
inp_top = bottom - bottom[-8..-6]
bottom[-5] = offset for bottom of compressed data
inp = bottom - bottom[-5]
bottom[-4..-1] = offset for bottom of original data
outp = bottom + bottom[-4..-1]
typedef struct
{
u32 bufferTop:24;
u32 compressBottom:8;
u32 originalBottom;
} CompFooter;
Returns: None.
*---------------------------------------------------------------------------*/
asm void
MIi_UncompressBackward(register void* bottom)
{
#define data r0
#define inp_top r1
#define outp r2
#define inp r3
#define outp_save r4
#define flag r5
#define count8 r6
#define index r7
#define len r12
cmp bottom, #0
beq @exit
stmfd sp!, {r4-r7}
ldmdb bottom, {r1-r2}
add outp, bottom, outp
sub inp, bottom, inp_top, LSR #24
bic inp_top, inp_top, #0xff000000
sub inp_top, bottom, inp_top
mov outp_save, outp
@loop:
cmp inp, inp_top // exit if inp==inp_top
ble @end_loop
ldrb flag, [inp, #-1]! // r4 = compress_flag = *--inp
mov count8, #8
@loop8:
subs count8, count8, #1
blt @loop
tst flag, #0x80
bne @blockcopy
@bytecopy:
ldrb data, [inp, #-1]!
strb data, [outp, #-1]! // Copy 1 byte
b @joinhere
@blockcopy:
ldrb len, [inp, #-1]!
ldrb index, [inp, #-1]!
orr index, index, len, LSL #8
bic index, index, #0xf000
add index, index, #0x0002
add len, len, #0x0020
@patterncopy:
ldrb data, [outp, index]
strb data, [outp, #-1]!
subs len, len, #0x0010
bge @patterncopy
@joinhere:
cmp inp, inp_top
mov flag, flag, LSL #1
bgt @loop8
@end_loop:
// DC_FlushRange & IC_InvalidateRange
mov r0, #0
bic inp, inp_top, #HW_CACHE_LINE_SIZE - 1
@cacheflush:
mcr p15, 0, r0, c7, c10, 4 // wait writebuffer empty
mcr p15, 0, inp, c7, c5, 1 // ICache
mcr p15, 0, inp, c7, c14, 1 // DCache
add inp, inp, #HW_CACHE_LINE_SIZE
cmp inp, outp_save
blt @cacheflush
ldmfd sp!, {r4-r7}
@exit bx lr
}
/*---------------------------------------------------------------------------*
Name: _start_AutoloadDoneCallback
Description:
Arguments: argv -
argv[0] = SDK_AUTOLOAD_LIST
argv[1] = SDK_AUTOLOAD_LIST_END
argv[2] = SDK_AUTOLOAD_START
argv[3] = SDK_STATIC_BSS_START
argv[4] = SDK_STATIC_BSS_END
Returns:
*---------------------------------------------------------------------------*/
SDK_WEAK_SYMBOL asm void
_start_AutoloadDoneCallback(void* argv[])
{
bx lr
}
/*---------------------------------------------------------------------------*
Name: TwlStartUp
Description: hook for user start up
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
SDK_WEAK_SYMBOL void TwlStartUp(void)
{
}
/*---------------------------------------------------------------------------*
Name: OSi_ReferSymbol
Description: used by SDK_REFER_SYMBOL macro to avoid dead-strip.
Arguments: symbol unused
Returns: None.
*---------------------------------------------------------------------------*/
void OSi_ReferSymbol(void *symbol)
{
#pragma unused(symbol)
}
#include <twl/codereset.h>

View File

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

View File

@ -0,0 +1,46 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - mi
# 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
SRCDIR = . ../common
SRCS = \
mi_init_mainMemory.c \
TARGET_LIB = libmi$(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,169 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - mi
File: mi_init_mainMemory.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/mi.h>
void MIi_InitMainMemCRCore( void );
/*---------------------------------------------------------------------------*
Name: MIi_IsMainMemoryInitialized
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
BOOL MIi_IsMainMemoryInitialized( void )
{
return (BOOL)((reg_MI_EXMEMCNT & REG_MI_EXMEMCNT_CE2_MASK) >> REG_MI_EXMEMCNT_CE2_SHIFT);
}
/*---------------------------------------------------------------------------*
Name: MIi_WaitMainMemoryInitialize
Description:
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void MIi_WaitMainMemoryInitialize( void )
{
while( MIi_IsMainMemoryInitialized() == FALSE )
{
}
}
/*---------------------------------------------------------------------------*
Name: MIi_InitMainMemCR
Description: change mainmem into the burst mode
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
#include <nitro/code32.h>
asm void MIi_InitMainMemCR( BOOL setCR )
{
mov r12, lr
mov r2, r0
mov r0, #0x8000 // low period 0.97ms
bl OS_SpinWaitCpuCycles
ldr r3, =REG_EXMEMCNT_ADDR
mov r1, #REG_MI_EXMEMCNT_CE2_MASK
ldrh r0, [r3]
tst r0, r1
bxne r12
strh r1, [r3]
mov r0, #0x8000 // high period 0.97ms
bl OS_SpinWaitCpuCycles
cmp r2, #FALSE
beq @10
// メインメモリが同期モード時(ハードリセット時)に
// 非同期モードCLK固定でコマンド発行しても大丈夫
ldr r3, =HW_WRAM_AREA - 2
bl MIi_InitMainMemCRCore
#ifdef SDK_TS
ldr r3, =HW_MAIN_MEM + HW_MAIN_MEM_EX_SIZE - 2
bl MIi_InitMainMemCRCore
#endif // SDK_TS
@10:
ldr r3, =REG_EXMEMCNT_ADDR
ldr r1, = (1 << REG_MI_EXMEMCNT_IFM_SHIFT) | \
(1 << REG_MI_EXMEMCNT_CE2_SHIFT) | \
(MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_EP_SHIFT) | \
(MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_MPA_SHIFT) | \
(MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_MPB_SHIFT) | \
(MI_PROCESSOR_ARM7 << REG_MI_EXMEMCNT_CP_SHIFT) | \
(MIi_PHI_CLOCK_LOW << REG_MI_EXMEMCNT_PHI_SHIFT) | \
(MI_CTRDG_ROMCYCLE1_18 << REG_MI_EXMEMCNT_ROM1st_SHIFT) | \
(MI_CTRDG_ROMCYCLE2_6 << REG_MI_EXMEMCNT_ROM2nd_SHIFT) | \
(MI_CTRDG_RAMCYCLE_10 << REG_MI_EXMEMCNT_RAM_SHIFT)
strh r1, [r3]
bx r12
}
asm void MIi_InitMainMemCRCore( void )
{
// stmfd sp!, { lr }
#ifdef TWL_PLATFORM_BB
mov r2, lr
ldr r0, =MMEM_DCR0_BURST_MODE | MMEM_DCR0_BURST_CONTINUOUS \
| MMEM_DCR0_PARTIAL_REFRESH_NONE | MMEM_DCR0_SB1
ldr r1, =MMEM_DCR1_1ST_R4_W3 | MMEM_DCR1_BURST_WRITE | MMEM_DCR1_BURST_LINER \
| MMEM_DCR1_CLOCK_TRIGGER_UP | MMEM_DCR1_SB1
ldrh lr, [r3]
strh lr, [r3]
strh lr, [r3]
mov lr, r2
ldr r2, =HW_MAIN_MEM | MMEM_DCR2_CLOCK_TRIGGER_UP \
| MMEM_DCR2_BURST_MODE | MMEM_DCR2_BURST_CONTINUOUS \
| MMEM_DCR2_1ST_R4_W3 | MMEM_DCR2_BURST_WRITE | MMEM_DCR2_BURST_LINER \
| MMEM_DCR2_PARTIAL_REFRESH_NONE | MMEM_DCR2_SB1
strh r0, [r3]
strh r1, [r3]
ldrh r3, [r2]
#else // SDK_TS
mov r2, lr
ldr r0, =MMEM_TCR0
ldr r1, =MMEM_TCR1
ldrh lr, [r3]
strh lr, [r3]
strh lr, [r3]
mov lr, r2
ldr r2, =MMEM_TCR2
strh r0, [r3]
strh r1, [r3]
strh r2, [r3]
#endif // SDK_TS
// ldmfd sp!, { lr }
bx lr
}
asm void MIi_GetMainMemCR( MIMmemCR* dest )
{
#ifdef SDK_TS
ldr r3, =HW_WRAM_AREA - 2
ldr r1, =MMEM_TCR0_R
ldrh r2, [r3]
strh r2, [r3]
strh r2, [r3]
strh r1, [r3]
ldrh r1, [r3]
ldrh r2, [r3]
strh r2, [r0, #4]
strh r1, [r0, #2]
ldr r1, =MMEM_TCR0_R
strh r1, [r0, #0]
#endif // SDK_TS
bx lr
}

View File

@ -0,0 +1,31 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - libraries - mi
# 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,56 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries_sp - os
# 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 =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= TRUE
# Codegen for sub processer
TWL_PROC = ARM7
SRCDIR = ../common .
INCDIR = ./include ../common/include \
$(ROOT)/build/libraries/fatfs/ARM7.TWL/include \
$(ROOT)/build/libraries/fatfs/ARM7.TWL/include/twl/fatfs/ARM7 \
SRCS = \
os_init_firm.c \
os_boot.c \
TARGET_LIB = libos_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,47 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - os
# 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
SRCDIR = ../common .
SRCS = \
os_init_firm.c \
os_boot.c \
TARGET_LIB = libos$(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,269 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - OS
File: os_cache_tag.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/ARM9/os_cache_tag.h>
#include <nitro/code32.h>
//===========================================================================
// DATA CACHE (for specified range)
//===========================================================================
/*---------------------------------------------------------------------------*
Name: DC_ClearTagAll
Description: clear tag in data cache
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void DC_ClearTagAll( void )
{
DC_FillTagAll( 0 );
}
/*---------------------------------------------------------------------------*
Name: DC_FillTagAll
Description: clear tag in data cache
Arguments: data : fill data
Returns: None.
*---------------------------------------------------------------------------*/
asm void DC_FillTagAll( u32 data )
{
mov r12, #0
@1:
mov r2, #0
@2:
orr r3, r2, r12
mcr p15, 3, r3, c15, c0, 0 // set index
mcr p15, 3, r0, c15, c2, 0 // clear tag
add r2, r2, #HW_CACHE_LINE_SIZE
cmp r2, #HW_DCACHE_SIZE/4
blt @2
add r12, r12, #1<<HW_C7_CACHE_SET_NO_SHIFT
cmp r12, #0
bne @1
bx lr
}
/*---------------------------------------------------------------------------*
Name: DC_ClearDataAll
Description: clear data in data cache
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void DC_ClearDataAll( void )
{
DC_FillDataAll( 0 );
}
/*---------------------------------------------------------------------------*
Name: DC_FillDataAll
Description: fill data in data cache
Arguments: data : fill data
Returns: None.
*---------------------------------------------------------------------------*/
asm void DC_FillDataAll( u32 data )
{
mov r12, #0
@1:
mov r2, #0
@2:
orr r3, r2, r12
mcr p15, 3, r3, c15, c0, 0 // set index
mcr p15, 3, r0, c15, c4, 0 // clear data
add r2, r2, #4
cmp r2, #HW_DCACHE_SIZE/4
blt @2
add r12, r12, #1<<HW_C7_CACHE_SET_NO_SHIFT
cmp r12, #0
bne @1
bx lr
}
/*---------------------------------------------------------------------------*
Name: DC_GetTagAndDataAll
Description: get tag and data in data cache
Arguments: tag tag address
data data address
Returns: None.
*---------------------------------------------------------------------------*/
asm void DC_GetTagAndDataAll( void* tag, void* data )
{
mov r12, #0
@1:
mov r2, #0
@2:
orr r3, r2, r12
mcr p15, 3, r3, c15, c0, 0 // set index
tst r2, #HW_CACHE_LINE_SIZE - 1
mrceq p15, 3, r3, c15, c2, 0 // get tag
streq r3, [r0], #4
mrc p15, 3, r3, c15, c4, 0 // get data
str r3, [r1], #4
add r2, r2, #4
cmp r2, #HW_DCACHE_SIZE/4
blt @2
add r12, r12, #1<<HW_C7_CACHE_SET_NO_SHIFT
cmp r12, #0
bne @1
bx lr
}
//===========================================================================
// INSTRUCTION CACHE
//===========================================================================
/*---------------------------------------------------------------------------*
Name: IC_ClearTagAll
Description: clear tag in instruction cache
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void IC_ClearTagAll( void )
{
IC_FillTagAll( 0 );
}
/*---------------------------------------------------------------------------*
Name: IC_FillTagAll
Description: fill tag in instruction cache
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void IC_FillTagAll( u32 data )
{
mov r12, #0
@1:
mov r2, #0
@2:
orr r3, r2, r12
mcr p15, 3, r3, c15, c0, 0 // set index
mcr p15, 3, r0, c15, c1, 0 // clear tag
add r2, r2, #HW_CACHE_LINE_SIZE
cmp r2, #HW_ICACHE_SIZE/4
blt @2
add r12, r12, #1<<HW_C7_CACHE_SET_NO_SHIFT
cmp r12, #0
bne @1
bx lr
}
/*---------------------------------------------------------------------------*
Name: IC_ClearInstructionAll
Description: clear instruction in instruction cache
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
void IC_ClearInstructionAll( void )
{
IC_FillInstructionAll( 0 );
}
/*---------------------------------------------------------------------------*
Name: IC_FillInstructionAll
Description: fill instruction in instruction cache
Arguments: data : fill data
Returns: None.
*---------------------------------------------------------------------------*/
asm void IC_FillInstructionAll( u32 data )
{
mov r12, #0
@1:
mov r2, #0
@2:
orr r3, r2, r12
mcr p15, 3, r3, c15, c0, 0 // set index
mcr p15, 3, r0, c15, c3, 0 // clear data
add r2, r2, #4
cmp r2, #HW_ICACHE_SIZE/4
blt @2
add r12, r12, #1<<HW_C7_CACHE_SET_NO_SHIFT
cmp r12, #0
bne @1
bx lr
}
/*---------------------------------------------------------------------------*
Name: IC_GetTagAndInstructionAll
Description: get tag and instruction in instruction cache
Arguments: tag tag address
inst instruction address
Returns: None.
*---------------------------------------------------------------------------*/
asm void IC_GetTagAndInstructionAll( void* tag, void* inst )
{
mov r12, #0
@1:
mov r2, #0
@2:
orr r3, r2, r12
mcr p15, 3, r3, c15, c0, 0 // set index
tst r2, #HW_CACHE_LINE_SIZE - 1
mrceq p15, 3, r3, c15, c1, 0 // get tag
streq r3, [r0], #4
mrc p15, 3, r3, c15, c3, 0 // get data
str r3, [r1], #4
add r2, r2, #4
cmp r2, #HW_ICACHE_SIZE/4
blt @2
add r12, r12, #1<<HW_C7_CACHE_SET_NO_SHIFT
cmp r12, #0
bne @1
bx lr
}
#include <nitro/codereset.h>

View File

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

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - OS
File: os_boot.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 "reboot.h"
extern void SDK_STATIC_START(void); // static and bss start address
extern void SDK_STATIC_BSS_END(void); // static and bss end address
/*---------------------------------------------------------------------------*
Name: OS_BootWithRomHeaderFromFIRM
Description: boot with ROM header
Arguments: rom_header : ROM header
Returns: None
*---------------------------------------------------------------------------*/
void OS_BootWithRomHeaderFromFIRM( ROM_Header* rom_header )
{
#ifdef SDK_ARM9
void *entry = rom_header->s.main_entry_address;
void *code_buf = (void*)OS_BOOT_CODE_BUF; // 0x023fee00
void *stack_top = (void*)OS_BOOT_STACK_TOP; // (HW_DTCM_END - HW_DTCM_SYSRV_SIZE - HW_SVC_STACK_SIZE)
#else
void *entry = rom_header->s.sub_entry_address;
void *code_buf = (void*)OS_BOOT_CODE_BUF; // 0x03fff600
void *stack_top = (void*)OS_BOOT_STACK_TOP; // (HW_WRAM_AREA_END - HW_PRV_WRAM_SYSRV_SIZE - HW_SVC_STACK_SIZE)
#endif
void *wram_reg = rom_header->s.main_wram_config_data;
REBOOTTarget target = REBOOT_TARGET_TWL_SECURE_SYSTEM;
BOOL scfg = TRUE; // no touch
BOOL jtag = FALSE; // no touch
static u32 mem_list[32];
int i = 0;
// pre clear
/* 自身の static & bss のクリア */
mem_list[i++] = (u32)SDK_STATIC_START;
mem_list[i++] = (u32)SDK_STATIC_BSS_END-(u32)SDK_STATIC_START;
#ifdef SDK_ARM9
/* ITCM全クリア (FromFrimを除く) */
mem_list[i++] = HW_ITCM;
mem_list[i++] = HW_FIRM_FROM_FIRM_BUF - HW_ITCM;
mem_list[i++] = HW_FIRM_FROM_FIRM_BUF_END;
mem_list[i++] = HW_ITCM_END - HW_FIRM_FROM_FIRM_BUF_END;
/* FS/FATFSバッファのクリア */
mem_list[i++] = (u32)HW_FIRM_FATFS_COMMAND_BUFFER; // 0x02ff7800 - 0x02ffbfff
mem_list[i++] = (u32)HW_FIRM_FS_TEMP_BUFFER_END - (u32)HW_FIRM_FATFS_COMMAND_BUFFER;
/* 一部鍵バッファのクリア (鍵管理.xls参照) */
mem_list[i++] = (u32)OSi_GetFromFirmAddr()->rsa_pubkey[0];
mem_list[i++] = ACS_PUBKEY_LEN;
#else // SDK_ARM7
/* FS_Loader用バッファのクリア */
mem_list[i++] = HW_FIRM_LOAD_BUFFER_BASE;
mem_list[i++] = HW_FIRM_LOAD_BUFFER_UNIT_SIZE * HW_FIRM_LOAD_BUFFER_UNIT_NUMS;
{ /* REBOOT_ExecuteのCODEとSTACKの隙間をクリア */
u32 stack_bottom = (u32)stack_top - OS_BOOT_STACK_SIZE_MIN - sizeof(mem_list);
u32 code_buf_end = OS_BOOT_CODE_BUF + OS_BOOT_CODE_SIZE;
SDK_ASSERT( stack_bottom > code_buf_end );
mem_list[i++] = code_buf_end;
mem_list[i++] = stack_bottom - code_buf_end;
}
/* 一部鍵バッファのクリア (鍵管理.xls参照) */
// 該当無し
#endif // SDK_ARM7
mem_list[i++] = NULL;
// copy forward
mem_list[i++] = NULL;
// copy backward
mem_list[i++] = NULL;
// post clear
mem_list[i++] = NULL;
SDK_ASSERT(i <= sizeof(mem_list)/sizeof(mem_list[0]));
#ifdef FIRM_USE_TWLSDK_KEYS
// TwlSDK内の鍵を使っている時は量産用CPUではブートしない
#ifdef SDK_ARM9
if ( ! ((*(u8*)OS_CHIPTYPE_DEBUGGER_ADDR & OS_CHIPTYPE_DEBUGGER_MASK)) )
#else // SDK_ARM7
if ( ! ((*(u8*)HWi_WSYS08_ADDR & HWi_WSYS08_OP_OPT_MASK)) )
#endif // SDK_ARM7
{
OS_Terminate();
}
#endif // FIRM_USE_SDK_KEYS
REBOOT_Execute(entry, wram_reg, mem_list, code_buf, stack_top, target, scfg, jtag);
OS_Terminate();
}
/*---------------------------------------------------------------------------*
Name: OSi_FromBromToMenu
Description: convert OSFromBromBuf to OSFromFirmBuf
Arguments: None
Returns: FALSE if FromBrom is broken
*---------------------------------------------------------------------------*/
BOOL OSi_FromBromToMenu( void )
{
OSFromBromBuf* const fromBromBuf = OSi_GetFromBromAddr();
BOOL result = TRUE;
int i;
// check offset (why not to omit by compiler?)
if ( OSi_GetFromFirmAddr()->rsa_pubkey != fromBromBuf->rsa_pubkey ) // same area without header
{
result = FALSE;
}
// check unused signature area
for (i = 0; i < sizeof(fromBromBuf->hash_table_hash); i++) // check all values are same
{
if (fromBromBuf->hash_table_hash[i] != 0x00)
{
result = FALSE;
}
}
// clear out of OSFromFirmBuf area
MI_CpuClearFast( fromBromBuf->header.max, sizeof(fromBromBuf->header.max) );
return result;
}

View File

@ -0,0 +1,166 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - OS
File: os_init_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>
/*---------------------------------------------------------------------------*
Name: OS_InitNOR
Description: initialize sdk os for firm
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
#pragma profile off
void OS_InitFIRM(void)
{
#ifdef SDK_ARM9
//---- system shared area check
// SDK_ASSERT((u32)&(OS_GetSystemWork()->command_area) == HW_CMD_AREA);
//----------------------------------------------------------------
// for ARM9
#ifdef SDK_ENABLE_ARM7_PRINT
// Init PrintServer for ARM7 (if specified)
// OS_InitPrintServer();
#endif
//---- Init interProcessor I/F
// Sync with ARM7 to enable OS_GetConsoleType()
// PXI_Init() must be called before OS_InitArenaEx()
//PXI_Init();
//PXI_InitFifoFIRM();
PXI_InitFIRM();
//---- Init Arena (arenas except SUBPRIV-WRAM)
OS_InitArena();
//---- Init Spinlock
OS_InitLock();
//---- Init Arena (extended main)
OS_InitArenaEx();
//---- Init IRQ Table
OS_InitIrqTable();
//---- Init IRQ Stack checker
OS_SetIrqStackChecker();
//---- Init Exception System
// OS_InitException();
//---- Init MI (Wram bank and DMA0 arranged)
MI_Init();
//---- Init VCountAlarm
OS_InitVAlarm();
//---- Init VRAM exclusive System
OSi_InitVramExclusive();
//---- Init Thread System
#ifndef SDK_NO_THREAD
OS_InitThread();
#endif
//---- Init Reset System
#ifndef SDK_SMALL_BUILD
// OS_InitReset();
#endif
//---- Init Cartridge
#ifndef SDK_TEG
// CTRDG_Init();
#endif
//---- Init Card
#ifndef SDK_SMALL_BUILD
// CARD_Init();
#endif
//---- init System config
#ifdef SDK_TWL
// if (OS_IsRunOnTwl() == TRUE)
// {
SCFG_Init();
// }
#endif
//---- Init Power Manager
#ifndef SDK_TEG
// PM_Init();
#endif
//---- adjust VCOUNT
// OSi_WaitVCount0();
#else // SDK_ARM9
//----------------------------------------------------------------
// for ARM7
//---- Init interProcessor I/F
//PXI_Init();
//PXI_InitFifoFIRM();
PXI_InitFIRM();
//---- Init Arena (SUBPRIV-WRAM arena)
OS_InitArena();
//---- Init Spinlock
OS_InitLock();
//---- Init IRQ Table
OS_InitIrqTable();
#define SDK_EXCEPTION_BUG
#ifndef SDK_EXCEPTION_BUG
//---- Init Exception System
OS_InitException();
#endif
//---- Init Tick
OS_InitTick();
//---- Init Alarm System
OS_InitAlarm();
//---- Init Thread System
OS_InitThread();
//---- Init Reset System
#ifndef SDK_SMALL_BUILD
// OS_InitReset();
#endif
//---- Init Cartridge
#ifndef SDK_TEG
// CTRDG_Init();
#endif
//---- init System config
#ifdef SDK_TWL
// if (OS_IsRunOnTwl() == TRUE)
// {
SCFG_Init();
// }
#endif
#endif // SDK_ARM9
}
#pragma profile reset

View File

@ -0,0 +1,55 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - pm
# 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
INCDIR = $(ROOT)/build/libraries/spi/ARM7/pm/include \
SRCDIR = .
SRCS = \
pm_init.c \
pm_pmic_ex.c \
TARGET_LIB = libpm_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,93 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - pm
File: pm_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/pm.h>
#include <twl/spi/common/pm_common.h>
static BOOL doneBackLight = FALSE;
/*---------------------------------------------------------------------------*
Name: PM_InitFIRM
Description: set default parameters
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
void PM_InitFIRM( void )
{
// LED
PMi_ResetFlags( REG_PMIC_LED_CTL_ADDR, PMIC_LED_CTL_AUTO_BLINK | PMIC_LED_CTL_BLINK_BY_SLEEP );
PMi_SetParams( REG_PMIC_LVL4_BRT_ADDR,
PMIC_LED_1_BRT_LEVEL_4_OFF | PMIC_LED_2_BRT_LEVEL_4_OFF,
PMIC_LVL4_BRT_LED_1_MASK | PMIC_LVL4_BRT_LED_2_MASK
);
PMi_SetParams( REG_PMIC_LVL3_BRT_ADDR,
PMIC_LED_1_BRT_LEVEL_3_100 | PMIC_LED_2_BRT_LEVEL_3_OFF,
PMIC_LVL3_BRT_LED_1_MASK | PMIC_LVL3_BRT_LED_2_MASK
);
PMi_SetParams( REG_PMIC_LVL2_BRT_ADDR,
PMIC_LED_1_BRT_LEVEL_2_OFF | PMIC_LED_1_BRT_LEVEL_2_100,
PMIC_LVL2_BRT_LED_1_MASK | PMIC_LVL2_BRT_LED_2_MASK
);
PMi_SetParams( REG_PMIC_LVL1_BRT_ADDR,
PMIC_LED_1_BRT_LEVEL_1_100 | PMIC_LED_2_BRT_LEVEL_1_100,
PMIC_LVL1_BRT_LED_1_MASK | PMIC_LVL1_BRT_LED_2_MASK
);
// correct battery LED curve
PMi_SetFlags( REG_PMIC_VLBAT_CTL_ADDR, PMIC_VLBAT_CTL_VLBAT_2_ACTIVE | PMIC_VLBAT_CTL_VLBAT_3_ACTIVE );
// LCD ON
PMi_SetFlags( REG_PMIC_CTL2_ADDR, PMIC_CTL2_VDD50 );
// back light
//PMi_SetParams( REG_PMIC_BL_BRT_A_ADDR, PMIC_BACKLIGHT_BRIGHT_MAX, PMIC_BL_BRT_A_MASK ); // TODO: less brightness
//PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, PMIC_BACKLIGHT_BRIGHT_MAX, PMIC_BL_BRT_B_MASK ); // TODO: less brightness
PMi_SetParams( REG_PMIC_BL_BRT_A_ADDR, 0, PMIC_BL_BRT_A_MASK );
PMi_SetParams( REG_PMIC_BL_BRT_B_ADDR, 0, PMIC_BL_BRT_B_MASK );
}
/*---------------------------------------------------------------------------*
Name: PM_BackLightOn
Description: power B/L on if not set yet
Arguments: force TRUE: wait until valid condition
FALSE not set unless valid condition
Returns: None
*---------------------------------------------------------------------------*/
void PM_BackLightOn( BOOL force )
{
if ( doneBackLight )
{
return; // have already set
}
if ( force )
{
while ( (reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK) == FALSE )
{
}
}
if ( reg_GX_DISPSTAT & REG_GX_DISPSTAT_INI_MASK )
{
PMi_SetFlags( REG_PMIC_CTL2_ADDR, PMIC_CTL2_BACK_LIGHT_1 | PMIC_CTL2_BACK_LIGHT_2 );
doneBackLight = TRUE;
}
}

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL - libraries - pm
File: pm_pmic_ex.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/pm.h>
#include <pm_pmic.h>
//================================================================================
// PMIC BIT CONTROL
//================================================================================
/*---------------------------------------------------------------------------*
Name: PMi_SetParams
Description: set control bit to device register
Arguments: reg : device register
setBits : bits to set
maskBits : bits to mask
Returns: None
*---------------------------------------------------------------------------*/
void PMi_SetParams( u8 reg, u8 setBits, u8 maskBits )
{
u8 tmp;
tmp = PMi_GetRegister( reg );
tmp &= ~maskBits;
setBits &= maskBits;
tmp |= setBits;
PMi_SetRegister( reg, tmp );
}
/*---------------------------------------------------------------------------*
Name: PMi_SetFlags
Description: set control bit to device register
Arguments: reg : device register
setBits : bits to set
Returns: None
*---------------------------------------------------------------------------*/
void PMi_SetFlags( u8 reg, u8 setBits )
{
PMi_SetParams( reg, setBits, setBits );
}
/*---------------------------------------------------------------------------*
Name: PMi_ResetFlags
Description: clear control bit to device register
Arguments: reg : device register
clrBits : bits to set
Returns: None
*---------------------------------------------------------------------------*/
void PMi_ResetFlags( u8 reg, u8 clrBits )
{
PMi_SetParams( reg, 0, clrBits );
}

View File

@ -0,0 +1,31 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlIPL - libraries - pm
# 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,53 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries_sp - pxi
# 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 =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
TWL_CODEGEN_ALL ?= TRUE
# Codegen for sub processer
TWL_PROC = ARM7
SRCDIR = ../common .
SRCS = \
pxi_firm.c
# pxi_misc.c \
TARGET_LIB = libpxi_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,47 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - pxi
# 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
SRCDIR = ../common .
SRCS = \
pxi_firm.c
# pxi_misc.c \
TARGET_LIB = libpxi$(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,32 @@
#! make -f
#----------------------------------------------------------------------------
# Project: TwlFirm - libraries - pxi
# 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 \
ARM7 \
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,325 @@
/*---------------------------------------------------------------------------*
Project: TwlFirm - library - pxi
File: pxi_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.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#include <firm/os.h>
#include <twl/memorymap.h>
#include <firm/pxi.h>
#define PXI_FIRM_ID_MAX 8
#define PXI_FIRM_STREAM_MAX 16
typedef struct
{
u32 wp;
u32 rp;
u8 id[PXI_FIRM_ID_MAX];
u32 semaphore; // for fs_loader.c
u32 length;
u32 current;
u8 data[PXI_FIRM_STREAM_MAX];
}
PxiWork;
static PxiWork work;
static void PxiFirmStreamCallback( PXIFifoTag tag, u32 data, BOOL err )
{
(void)tag;
(void)err;
if ( !work.length ) // stream is starting
{
if ( data > PXI_FIRM_STREAM_MAX )
{
OS_TPrintf("Receiving stream has too large size (%d > %d).\n", data, PXI_FIRM_STREAM_MAX);
}
work.length = data;
work.current = 0;
}
else if ( work.current < work.length ) // stream is cotinuous
{
int i;
u8* ptr = (u8*)&data;
for ( i = 0; i < 3 && work.current < work.length; i++ )
{
work.data[ work.current++ ] = *ptr++;
}
}
else
{
OS_TPrintf("Stream buffer was overflow because of multiple usage.\n");
}
}
static void PxiFirmIDCallback( PXIFifoTag tag, u32 data, BOOL err )
{
u32 next_wp = ( work.wp + 1 ) % PXI_FIRM_ID_MAX;
(void)tag;
(void)err;
// special ID
if ( data == FIRM_PXI_ID_LOAD_BUFFER_SEMAPHORE )
{
work.semaphore++;
if ( work.semaphore > HW_FIRM_LOAD_BUFFER_UNIT_NUMS )
{
OS_TPanic("PROGRAM ERROR: Semaphore counter was overlow.");
}
return;
}
if ( next_wp != work.rp )
{
work.wp = next_wp;
work.id[work.wp] = (u8)data;
}
else
{
OS_TPrintf("ID buffer was overflow (%d is ignored).\n", (u8)data);
}
}
/*---------------------------------------------------------------------------*
Name: PXI_InitFIRM
Description: initialize PXI for firm
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void PXI_InitFIRM(void)
{
#ifdef SDK_ARM9
work.semaphore = 0;
#else
work.semaphore = HW_FIRM_LOAD_BUFFER_UNIT_NUMS;
#endif
work.rp = work.wp = work.length = 0;
PXI_Init();
#ifdef SDK_ARM9
while (!PXI_IsCallbackReady(PXI_FIFO_TAG_USER_0, PXI_PROC_ARM7))
{
}
#endif
PXI_SetFifoRecvCallback( PXI_FIFO_TAG_USER_0, PxiFirmStreamCallback );
PXI_SetFifoRecvCallback( PXI_FIFO_TAG_USER_1, PxiFirmIDCallback );
#ifdef SDK_ARM7
while (!PXI_IsCallbackReady(PXI_FIFO_TAG_USER_1, PXI_PROC_ARM9))
{
}
#endif
}
/*---------------------------------------------------------------------------*
Name: PXI_SendStream
Description: Send data stream
Arguments: buf pointer to data buffer
size transfer size
Returns: None.
*---------------------------------------------------------------------------*/
void PXI_SendStream( const void* buf, int size )
{
u8* ptr = (u8*)buf;
while ( 0 > PXI_SendWordByFifo( PXI_FIFO_TAG_USER_0, (u32)size, 0 ) )
{
}
while ( size > 0 )
{
u32 data = (u32)(ptr[0] << 0 | ptr[1] << 8 | ptr[2] << 16);
while ( 0 > PXI_SendWordByFifo( PXI_FIFO_TAG_USER_0, data, 0 ) )
{
}
size -= 3;
ptr += 3;
}
}
/*---------------------------------------------------------------------------*
Name: PXI_RecvStream
Description: Receive data stream
Arguments: buf pointer to data buffer
size transfer size
Returns: None.
*---------------------------------------------------------------------------*/
void PXI_RecvStream( void* buf, int size )
{
while ( 1 )
{
OSIntrMode enabled = OS_DisableInterrupts();
if ( work.length && work.current >= work.length )
{
if ( size != work.length )
{
OS_TPrintf("Stream data size was not expected.");
}
else
{
MI_CpuCopy8( work.data, buf, (u32)size );
work.length = work.current = 0;
}
OS_RestoreInterrupts( enabled );
return;
}
OS_RestoreInterrupts( enabled );
}
}
/*---------------------------------------------------------------------------*
Name: PXI_NotifyID
Description: Send ID
Arguments: id id to send
Returns: None.
*---------------------------------------------------------------------------*/
void PXI_NotifyID( FIRMPxiID id )
{
while ( 0 > PXI_SendWordByFifo( PXI_FIFO_TAG_USER_1, id, 0 ) )
{
}
#if 0
#ifdef SDK_ARM9
OS_TPrintf("[ARM9] Notify: %d\n", (u8)id);
#else
OS_TPrintf("[ARM7] Notify: %d\n", (u8)id);
#endif
#endif
}
/*---------------------------------------------------------------------------*
Name: PXI_RecvID
Description: Receive ID
Arguments: None
Returns: Received ID
*---------------------------------------------------------------------------*/
FIRMPxiID PXI_RecvID( void )
{
while ( 1 )
{
OSIntrMode enabled = OS_DisableInterrupts();
if ( work.rp != work.wp )
{
FIRMPxiID id;
work.rp = ( work.rp + 1 ) % PXI_FIRM_ID_MAX;
id = (FIRMPxiID)work.id[work.rp];
OS_RestoreInterrupts( enabled );
#if 0
#ifdef SDK_ARM9
OS_TPrintf("[ARM9] Received: %d\n", id);
#else
OS_TPrintf("[ARM7] Received: %d\n", id);
#endif
#endif
return id;
}
OS_RestoreInterrupts( enabled );
}
}
/*---------------------------------------------------------------------------*
Name: PXI_ReleaseLoadBufferSemaphore
Description: Release semaphore for *_LoadBuffer
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void PXI_ReleaseLoadBufferSemaphore( void )
{
PXI_NotifyID( FIRM_PXI_ID_LOAD_BUFFER_SEMAPHORE );
}
/*---------------------------------------------------------------------------*
Name: PXI_AcquireLoadBufferSemaphore
Description: Acquire semaphore for *_LoadBuffer
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void PXI_AcquireLoadBufferSemaphore( void )
{
while ( 1 )
{
OSIntrMode enabled = OS_DisableInterrupts();
if ( work.semaphore > 0 )
{
work.semaphore--;
OS_RestoreInterrupts( enabled );
return;
}
OS_RestoreInterrupts( enabled );
}
}
/*---------------------------------------------------------------------------*
Name: PXIi_SendIDByIntf
Description: Send 4bit id to the other processor
Arguments: id sending id
Returns: None
*---------------------------------------------------------------------------*/
void PXIi_SendIDByIntf( u32 id )
{
reg_PXI_INTF = (u16)(id << REG_PXI_INTF_SEND_SHIFT);
}
/*---------------------------------------------------------------------------*
Name: PXIi_RecvIDByIntf
Description: Receive 4bit id from the other processor
Arguments: None
Returns: received id
*---------------------------------------------------------------------------*/
u32 PXIi_RecvIDByIntf( void )
{
return (u32)((reg_PXI_INTF & REG_PXI_INTF_RECV_MASK) >> REG_PXI_INTF_RECV_SHIFT);
}
/*---------------------------------------------------------------------------*
Name: PXIi_WaitIDByIntf
Description: Wait 4bit id from the other processor
Arguments: id waiting id
Returns: None
*---------------------------------------------------------------------------*/
void PXIi_WaitIDByIntf( u32 id )
{
while (PXIi_RecvIDByIntf() != id)
{
}
}

View File

@ -0,0 +1,32 @@
#! 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
#----------------------------------------------------------------------------
SUBDIRS_P = reloc_info sysmenu mb_loader acsign boot hotsw
#----------------------------------------------------------------------------
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,58 @@
#! 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:: 2007-10-03#$
# $Rev: 1319 $
# $Author: kitase_hirotake $
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
SUBDIRS =
SUBMAKES = Makefile.encrypt
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
TARGET_PLATFORM = TWL
TWL_ARCHGEN = LIMITED
TWL_PROC = ARM9
INCDIR = include \
$(ROOT)/build/libraries/mb/common/include
SRCS = acsign.c acmemory.c acsign_util.c \
TARGET_LIB = libacsign$(TWL_LIBSUFFIX).a
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
INSTALL_TARGETS = $(TARGETS)
INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR)
CCFLAGS += -DSMALL_CODE_SIZE \
-DSTANDALONE \
-DOPT_32_BIT \
-DNO_SPLIT \
-DNO_FP_API \
-DNO_R_DIAG \
-DNO_STDIO_H \
-DNO_STDLIB_H
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,57 @@
#! 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$
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
TARGET_FIRM = SYSTEMMENU
TARGET_PLATFORM = TWL
TWL_ARCHGEN = LIMITED
TWL_PROC = ARM9
INCDIR = include
SRCS = acsign_encrypt.c \
ber_lib.c ber_isk.c ber_par.c
TARGET_LIB = libacsign_enc$(TWL_LIBSUFFIX).a
include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs
INSTALL_TARGETS = $(TARGETS)
INSTALL_DIR = $(SYSMENU_INSTALL_LIBDIR)
CCFLAGS += -DSMALL_CODE_SIZE \
-DSTANDALONE \
-DOPT_32_BIT \
-DNO_SPLIT \
-DNO_FP_API \
-DNO_R_DIAG \
-DNO_STDIO_H \
-DNO_STDLIB_H
do-build: $(TARGETS)
include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File: acmemory.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifndef _ACMEMORY_H_
#define _ACMEMORY_H_
#ifdef __cplusplus
extern "C" {
#endif
//
void ACMemory_Clear( );
void* ACMemory_Alloc( u32 size );
void* ACMemory_Realloc( void *adrs, u32 nowsize, u32 newsize );
void ACMemory_Free( void* adrs );
void* ACMemory_Memset( void* adrs, u32 val, u32 cnt );
void* ACMemory_Memcpy( void* dst, void* src, u32 cnt );
#ifdef __cplusplus
}
#endif
#endif //_ACMEMORY_H_

View File

@ -0,0 +1,667 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - tools - makerom.TWL
File: ber.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
/* $Id$ */
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
#ifndef HEADER_COMMON_BER_H
#define HEADER_COMMON_BER_H
#ifdef __cplusplus
extern "C" {
#endif
//#include "r_com.h" // local modified.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
/* The ASN.1 types are in this file */
#include "ber_type.h"
#if defined(VXWORKS) && defined(m_len)
#undef m_len
#endif
/* In the info field */
/**
* The name-space of the object is universal or global.
*/
#define BER_UNIVERSAL 0x00
/**
* The name-space of the object is application specific.
*/
#define BER_APPLICATION 0x40
/**
* The name-space of the object is context specific.
* Context-specific items are constructed types of a value (cont [1]).
*/
#define BER_CONTEXT_SPECIFIC 0x80
/**
* The name-space of the object is private.
*/
#define BER_PRIVATE 0xc0
/**
* Masks the class part of the type of the BER item.
*/
#define BER_CLASS_MASK 0xc0
/**
* The items has no explicit data. All following items that fit in the length
* of the constructed item are part of the data. If the constructed item is
* indefinite encoded, the data finishes with an EOC of 0 length.
* The items that make up the data of this item are said to have a greater
* depth than the constructed item.
*/
#define BER_CONSTRUCTED 0x20
/**
* This mask is used to determine the type of the item.
*/
#define BER_PRIMITIVE_TAG_MASK 0x1f
/* Set in the flags */
/**
* Flag indicates that the stack of items was dynamically allocated and needs
* to be freed.
*/
#define BER_FLAG_DYNAMIC 0x01
/**
* Flag indicates that the items in the #BER_ITEMS_SK were dynamically allocated
* and need to be freed.
*/
#define BER_FLAG_DYNAMIC_ITEMS 0x02
/**
* A prefix byte has been set. A bit string requires a byte to precede the data
* in order to provide information about the number of valid bits.
*/
#define BER_FLAG_PREFIX_BYTE 0x04
/**
* The item has an invalid length value associated with it. This may be because
* the length is greater than the parent's length or because the item has a
* that is required more than five bytes to represent.
*/
#define BER_FLAG_INVALID_LENGTH 0x08
/**
* The header bytes have been seen for this item and any parents will not have
* these bytes available.
*/
#define BER_FLAG_SEEN_HEADER 0x10
/**
* No data for this item has been made available.
*/
#define BER_FLAG_NO_DATA_SEEN 0x20
/**
* Set if the header of the BER_ITEM has already been encoded.
*/
#define BER_FLAG_HEADER_ENCODED 0x40
/**
* @fn int BER_prefix_byte(BER_ITEMS *i)
*
* Returns whether the prefix byte flag has been set for this item.
*
* @param i [In] BER item.
* @return Bit is set.
* <li>0 = False, the bit is not set.</li>
* <li>1 = True, the bit is set.</li>
*
* @note This flag is used for the bit string type as it requires an extra
* byte to indicate a number of valid bits.
*
* @see BER_ITEM_set_prefix_byte().
*/
#define BER_prefix_byte(i) ((i)->flags & BER_FLAG_PREFIX_BYTE)
/**
* @fn int BER_invalid_length(BER_ITEMS *i)
*
* Returns whether the invalid length flag has been set for this item.
*
* @param i [In] BER item.
* @return Bit is set.
* <li>0 = False, the bit is not set.</li>
* <li>1 = True, the bit is set.</li>
*/
#define BER_invalid_length(i) ((i)->flags & BER_FLAG_INVALID_LENGTH)
/* In the info field */
/**
* Mask off the flags of the information field.
*/
#define BER_INFO_MASK 0x0f
/**
* The encoding is BER rather than DER.
*/
#define BER_BER 0x01
/**
* The item is indefinite length encoded. This means that there is no length
* value that can be used to determine the length of the data for this item.
*/
#define BER_ILEN 0x02
/**
* The contents of this item are to be hidden.
*/
#define BER_HIDE_CONTENTS 0x04
/**
* The header of this item has not been set yet.
*/
#define BER_NO_HEADER 0x08
/**
* @fn int BER_hide_contents(BER_ITEMS *i)
*
* Returns whether the hide contents flag has been set for this item.
*
* @param i [In] BER item.
* @return Bit is set.
* <li>0 = False, the bit is not set.</li>
* <li>1 = True, the bit is set.</li>
*/
#define BER_hide_contents(i) ((i)->info & BER_HIDE_CONTENTS)
/**
* @fn int BER_no_header(BER_ITEMS *i)
*
* Returns whether the no header flag has been set for this item.
*
* @param i [In] BER item.
* @return Bit is set.
* <li>0 = False, the bit is not set.</li>
* <li>1 = True, the bit is set.</li>
*
* @note This could be set when the data has been placed in the item but the
* header has not been setup.
*/
#define BER_no_header(i) ((i)->info & BER_NO_HEADER)
/**
* @fn unsigned long BER_MASK(int a)
*
* Returns the BER type as a bit mask.
*
* @param a [In] Type of the item.
* @return Each ASN.1 type maps to a bit in a 32 bit value.
*
* @note There are less than 32 primative ASN.1 types. This
* means a 32bit word can be used to specify acceptable 'types'.
*/
#define BER_MASK(a) (1UL << (a))
/**
* @fn int BER_constructed(BER_ITEMS *a)
*
* Returns a value to indicate that the item is constructed.
*
* @param a [In] BER item.
* @return Constructed bit set.
* <li>0 = False, the bit is not set.</li>
* <li>#BER_CONSTRUCTED = True, the bit is set.</li>
*/
#define BER_constructed(a) (((a)->info) & BER_CONSTRUCTED)
/**
* @fn int BER_class(BER_ITEMS *a)
*
* Returns a value to indicate the name-space of the item.
*
* @param a [In] BER item.
* @return Application and/or context specific bit set.
* <li>#BER_UNIVERSAL = Universal.</li>
* <li>#BER_APPLICATION = application specific item.</li>
* <li>#BER_CONTEXT_SPECIFIC = context specific item.</li>
* <li>#BER_PRIVATE = private item.</li>
*
* @note The top two bits of the type are used to specify the name-space of
* the item and these are pulled out and put in the info field.
*/
#define BER_class(a) (((a)->info) & BER_CLASS_MASK)
/**
* @fn int BER_indefinite_encoding(BER_ITEMS *a)
*
* Returns a value to indicate if the item is indefinite encoded. That is,
* the number of bytes to the data is not known.
*
* @param a [In] BER item.
* @return Indefinite length bit set.
* <li>0 = False, the bit is not set.</li>
* <li>#BER_ILEN = True, the bit is set.</li>
*/
#define BER_indefinite_encoding(a) (((a)->info) & BER_ILEN)
/**
* @fn void BER_ITEMS_SK_clear(BER_ITEMS_SK *sk)
*
* Clears the items out of the stack.
*
* @param sk [In] Stack of BER items.
*
* @note The items in the stack are not freed by this call.
*/
#define BER_ITEMS_SK_clear(sk) ((sk)->num=0)
/**
* Maximum length of the tag/type of an item.
*/
#define BER_MAX_TAG_LEN_IN_BITS (sizeof(int) * 8)
/**
* Minumum length of the data for a header of an item that streaming can use
* when decoding.
*/
#define BER_MIN_HEADER_LEN 2
/**
* Maximum length of the header of an item.
*/
#define BER_MAX_HEADER_LEN (1 + (BER_MAX_TAG_LEN_IN_BITS / 8) + \
1 + sizeof(unsigned long))
#ifndef NO_STREAM
/**
* The initial state in which a new item is created.
*/
#define BER_STATE_READ_NEXT_ITEM 1
/**
* The state in which the item header is read in and processed.
*/
#define BER_STATE_READ_NEXT_ITEM_HEADER 2
/**
* The state in which the data of the item is read in and processed.
*/
#define BER_STATE_READ_NEXT_ITEM_DATA 3
/**
* The state in which the current item is the last for the constructed item
* above.
*/
#define BER_STATE_GO_UP 4
#endif /* !NO_STREAM */
/**
* This structure holds the information about the data part of the BER item.
*/
typedef struct ber_bytes_st
{
/**
* Length of the data for this item.
*/
unsigned long len;
/**
* A pointer to the start of the valid data of this item.
*/
unsigned char *bytes;
} BER_BYTES;
/**
* This structure holds the information about the data part of the BER item.
*/
typedef struct ber_item_st
{
/**
* The data of the item.
*/
BER_BYTES data;
#ifndef NO_STREAM
/**
* The depth of this item. The depth is the number of constructed items this
* item is under.
*/
unsigned char depth;
/**
* The header bytes of the item. They are kept as the buffer it comes from
* may no longer be valid when the header data is needed.
*/
unsigned char header[BER_MAX_HEADER_LEN];
/**
* Number of data bytes seen of this item. When streaming the number of
* bytes seen depends on the number of bytes in the buffer that is being
* parsed.
*/
unsigned long seen;
/**
* Number of data bytes left to get out. When streaming the number of
* valid bytes available depends on the number of bytes in the buffer that
* is being parsed.
*/
unsigned long part_len;
/**
* Number of data bytes already encoded of the BER_ITEM. When
* streaming the number of bytes encoded depends on how much space
* is in the output buffer and how many bytes are available to encode.
*/
unsigned int encoded;
#endif /* !NO_STREAM */
/**
* The tag number that indicates the type of the item.
*/
unsigned int type;
/**
* Information about the item. Includes the name-space, constructed bit
* and whether it is indefinite encoded.
*/
unsigned char info;
/**
* The length of the header bytes. Varies depending on name-space and the
* number of bytes needed to represent data length.
*/
unsigned char hlen;
/**
* The extra flags of the item. Includes flags to indicate what parts of the
* item are dynamic.
*/
unsigned char flags;
/**
* Holds an 'extra' prefix byte. Needed for the bit string type as it
* requires an extra byte to indicate the number of valid bits in the data.
*/
unsigned char prefix_byte;
} BER_ITEM;
/**
* An item and pointer to other items linked to it.
*/
typedef struct ber_items_st
{
/**
* The current item data.
*/
BER_ITEM item;
/**
* The constructed item that this item is the data for.
*/
struct ber_items_st *parent;
/**
* The next item that is also in this constructed item.
*/
struct ber_items_st *next;
/**
* When the item is constructed, this points to the first item that is
* part of the data for this item.
*/
struct ber_items_st *down;
} BER_ITEMS;
/**
* Stack of BER items. The stack is the context of the BER items.
*/
typedef struct ber_items_sk_st
{
/**
* The number of items stored in the stack.
*/
unsigned int num;
/**
* The maximum number of items that can be stored in the stack.
*/
unsigned int max;
/**
* The array of items.
*/
BER_ITEMS *items;
/**
* Flags of the structure. Includes dynamic allocation of data.
* If the data is dynamic, this means that it can grow.
*/
unsigned int flags;
#ifndef NO_STREAM
/**
* Current streaming parsing state.
*/
int state;
/**
* Current item is indefinite encoded.
*/
int inf;
/**
* The parent or the constructed item this item belongs to is indefinite
* encoded.
*/
int pinf;
/**
* The current item is a constructed item.
*/
int con;
/**
* The next item needs to be placed under the current item.
* Alternatively, the previous item was a constructed item.
*/
int down;
/**
* The index into the array of items of the current item.
* Due to the fact that the items may be reallocated an index needs to be
* kept rather than a pointer.
*/
int this_idx;
/**
* The index into the array of items of the next/new item.
* Due to the fact that the items may be reallocated an index needs to be
* kept rather than a pointer.
*/
int next_idx;
/**
* Holds a pointer to the next/new item for the next call to the streaming
* parsing function.
*/
BER_ITEMS *next;
#endif /* !NO_STREAM */
} BER_ITEMS_SK;
/**
* @fn unsigned int BER_ITEMS_SK_num(BER_ITEMS_SK *sk)
*
* Returns the number of items in the stack.
*
* @param sk [In] Stack of BER items.
* @return Number of items in the stack.
*
* @note Useful in calculating the index of the next new item.
*/
#define BER_ITEMS_SK_num(sk) ((sk)->num)
/**
* @fn unsigned BER_ITEMS *BER_ITEMS_SK_items(BER_ITEMS_SK *sk, unsigned int n)
*
* Returns a pointer to a data item in the stack.
*
* @param sk [In] Stack of BER items.
* @param n [In] Array position of the item to obtain.
* @return Pointer to a BER item.
*/
#define BER_ITEMS_SK_items(sk,n) (&((sk)->items[n]))
/**
* Return value indicating no error occurred.
*/
#define BER_OK 0
/**
* Return value indicating no error occurred.
*/
#define BER_ERR_OK 0
/**
* Error indicating that the type/tag of the item was too long.
* This normally indicates that the encoding is invalid.
* Some valid private name-space items may cause this error.
*/
#define BER_ERR_TAG_TOO_LONG 1
/**
* Error indicating that there are not enough bytes in the buffer to complete
* the message. This is not a fatal error when streaming.
*/
#define BER_ERR_NOT_ENOUGH_BYTES 2
/**
* Error indicating that the value of the length of data is too long.
* A length value can be infinitely long but only lengths that can fit in an
* <i>unsigned long</i> are supported.
*/
#define BER_ERR_LENGTH_TOO_LARGE 3
/**
* Error indicating that the item is not constructed as expected or required.
*/
#define BER_ERR_NOT_CONSTRUCTED 4
/**
* Error indicating that the function was unable to allocate the memory
* required.
*/
#define BER_ERR_OUT_OF_MEMORY 5
/**
* Error indicating that the function needed space for more items but was
* unable to grow the stack. This is mostly likely to occur when the array
* of items is static and more items than allocated are required.
*/
#define BER_ERR_OUT_OF_ITEMS_STORAGE 6
/**
* Error indicating that the comparison of the tag/type failed.
*/
#define BER_ERR_CMP_TAG 7
/**
* Error indicating that the item is not an integer as expected or required.
*/
#define BER_ERR_NOT_AN_INTEGER 8
/**
* Error indicating that the length of the data is too large to return in an
* <i>unsigned long</i>.
*/
#define BER_ERR_NUMBER_TOO_LARGE 9
/**
* Error indicating that the bytes of data did not match in the comparison.
*/
#define BER_ERR_CMP_BYTES 10
/**
* Error indicating an end of content item is present when not in an indefinite
* encoded item. Normally occurs when buffer is not filled properly.
*/
#define BER_ERR_UNEXPECTED_EOC 11
/**
* Error indicating that the value of the length is invalid. This occurs when
* the length is an indefinite length value and the item is not constructed.
*/
#define BER_ERR_INVALID_LENGTH_ENCODING 12
/**
* Error indicating that the partial length of the value is not zero. This
* means that there is data in the items that has not been used yet that will
* be invalidated by parsing the new data. Streaming only.
*/
#define BER_ERR_PARTIAL 13
/**
* Error indicating that the various length fields of a BER_ITEM do
* not make sense and therefore processing cannot continue. In this
* case an unidentified logic error earlier in the code has occured.
*/
#define BER_ERR_PAR_ENC_LENGTH 14
/**
* Invalid state in parsing or encoding.
*/
#define BER_ERR_INVALID_STATE 15
/* A description of the BER item header:
* First byte definition
* 5 1 - search for a class
* 0 - search for a number
* for class
* 7-6 - for class, it class field
* 4-0 - tag, normal taging convention
* for number
* 7-6 - 0 - do next operation
* - 0x40 - finished
* - 0x80 - operate on the contents of this item
* - 0xc0 - operate on the contents and return at end
* 4-0 - num to scan, can only do 31 at a time, extend with subsequent calls
* Number counts skip explicit and implicit tags, they only count on
* universal types.
* If bit 5 is set, and 6-7 are 0, then we have 'special' comands
* which we can use WRT class elements.
* These two are needed when we are 'sitting' on a non-primative tag
* item since the normal 'counting' commands will skip the element before
* they perform their command.
* 0x20 return
* 0x21 operate on the contents
*/
/* To get a public key and the algorithm the following strings would work
* 0x80|0,0x40|5 - this will return the pubkey structure
* 0x80,0xc0 - Return the pubkey algorithm (from the pubkey)
* 0x80,0xc1 - Return the pubkey parameters
* 0x81 - Return the pubkey bitstring
* 0x80,0x20|0x80|3,0xc0 - return the first extension
*/
int BER_read_item(BER_ITEM *item,unsigned char *p,unsigned long max);
int BER_find(BER_ITEM *ret,BER_ITEM *in,unsigned char *find);
int BER_ITEMS_SK_get(BER_ITEMS_SK *sk,int *items_idx);
void BER_ITEMS_append(BER_ITEMS *a,BER_ITEMS *b);
int BER_ITEMS_under(BER_ITEMS *a,BER_ITEMS *b);
int BER_ITEMS_SK_grow(BER_ITEMS_SK *ks,unsigned int num);
int BER_parse(BER_ITEMS_SK *ks,unsigned char *in,unsigned long max,
unsigned long *num_used);
int BER_parse_stream(BER_ITEMS_SK *ks,unsigned char **in,long mlen,
long *num_used);
#ifdef HEADER_COMMON_BIO_H
int BER_print(BIO *bio,BER_ITEMS *items);
int BER_out(BIO *out,BER_ITEMS *start);
#else /* !HEADER_COMMON_BIO_H */
int BER_print(char *,BER_ITEMS *items);
int BER_out(char *out,BER_ITEMS *start);
#endif /* !HEADER_COMMON_BIO_H */
void BER_ITEM_init(BER_ITEM *item);
void BER_ITEMS_init(BER_ITEMS *item);
void BER_ITEM_set_all(BER_ITEM *item,unsigned int sclass,unsigned int tag,
unsigned char *data,unsigned int len,unsigned int info, unsigned int flags);
void BER_ITEM_set_header(BER_ITEM *item, unsigned int sclass,unsigned int tag,
unsigned int flags);
void BER_ITEM_set_data(BER_ITEM *item, unsigned char *data, unsigned int len);
int BER_ITEM_cmp_tag(BER_ITEM *a,unsigned int tag);
int BER_ITEM_get_long(BER_ITEM *a,long *l);
int BER_ITEM_set_long(BER_ITEM *a, long lret, unsigned char *buf);
size_t BER_ITEM_header_len(BER_ITEM *item);
unsigned int BER_ITEM_header_write(BER_ITEM *item, unsigned char *out);
unsigned int BER_ITEM_header_swrite(BER_ITEM *item, unsigned char *out);
int BER_ITEM_cmp_bytes(BER_ITEM *a,unsigned char *d, unsigned int l);
void BER_ITEMS_SK_init(BER_ITEMS_SK *sk,BER_ITEMS *items,unsigned int num,
unsigned int max);
void BER_ITEMS_SK_free(BER_ITEMS_SK *sk);
unsigned long BER_ITEMS_recalc_length(BER_ITEMS *a);
int BER_ITEMS_encode(BER_ITEMS *a, unsigned char *out, unsigned long *olen,
unsigned long max);
int BER_ITEMS_encode_stream(BER_ITEMS **a, unsigned char *out,
unsigned long *olen, unsigned long max);
int BER_load_level(BER_ITEMS_SK *sk, unsigned char *ino, unsigned long m_len);
/* We have to make the second parameter 'unsigned int' instead of
* 'unsigned char' because both the Sun and HP compilers complain
* when using a mix of ANSI prototypes and K&R function implementations
*/
void BER_ITEM_set_prefix_byte(BER_ITEM *item, unsigned int byte);
/* Used to count bits in an array of chars, strip leading 0, counts bits */
int R_num_bits(unsigned char *buf, int len, int bigendian);
#ifdef __cplusplus
}
#endif
#endif /* !HEADER_COMMON_BER_H */

View File

@ -0,0 +1,62 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - tools - makerom.TWL
File: ber_lcl.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
/* $Id$ */
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
#ifndef HEADER_COMMON_BER_LCL_H
#define HEADER_COMMON_BER_LCL_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef STANDALONE
#include "r_com.h"
#else
#include <stdio.h>
#include <stdlib.h>
#define NO_STDLIB_MAPPING
#include "acmemory.h"
#define Malloc(a) ACMemory_Alloc(a)
#define Free(a) ACMemory_Free(a)
#define Memset(a,b,c) ACMemory_Memset(a,b,c)
#define Memcpy(a,b,c) ACMemory_Memcpy(a,b,c)
#define Realloc(a,b,c) ACMemory_Realloc(a,b,c)
#define Memcmp(a,b,c) memcmp(a,b,c)
#define Bsearch(a,b,c,d,e) bsearch(a,b,c,d,e)
#endif
#include "ber.h"
#ifdef UNDER_CE
#include "wcestdlb.h" /* include for bsearch */
#endif
#ifdef __cplusplus
}
#endif
#endif /* !HEADER_COMMON_BER_H */

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*
Project: TwlSDK - tools - makerom.TWL
File: ber_type.h
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
/* $Id$ */
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
/**
* @file
* This file contains information on the ASN.1 types used to perform
* Basic Encoding Rules (BER) encoding and decoding operations.
*/
#ifndef HEADER_COMMON_BER_TYPE_H
#define HEADER_COMMON_BER_TYPE_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* Indicates the end of content for encoded items with an unspecified length.
*/
#define BER_EOC 0
/**
* Indicates either "true" or "false" as per the ASN.1 boolean values
* #BER_TRUE and #BER_FALSE.
*/
#define BER_BOOLEAN 1
/**
* Effectively unbounded but commonly used to hold values
* that will fit into a <tt>long</tt>.
*/
#define BER_INTEGER 2
/**
* An array of Bytes in which the first Byte is the number of bits to
* discard from the end.
*/
#define BER_BIT_STRING 3
/**
* An 8-bit (hexadecimal Byte) array or Byte array.
*/
#define BER_OCTET_STRING 4
/**
* A Basic Encoding Rules (BER) object that has no data. It is used when data
* is specified for a general case but not a specific case.
*/
#define BER_NULL 5
/**
* A Basic Encoding Rules (BER) object used to hold an ASN.1 identifier that
* describes the make-up of the rest of the constructed elements.
*/
#define BER_OBJECT 6
/**
* An indefinitely long string of characters (plus space) used to describe an
* object.
*/
#define BER_OBJECT_DESCRIPTOR 7
/**
* Embedded material that is not defined using ASN.1, such as a GIF file. This
* type is deprecated in favour of #BER_EMBEDDED_PDV.
*/
#define BER_EXTERNAL 8
/**
* A comma-separated list of three integers for the mantissa, the base
* (2 or 10), and the exponent. (Also <tt>PLUS-INFINITY</tt> and
* <tt>MINUS-INFINITY</tt>.) <br>
* Hence, <tt>{x, y, z}</tt> is <tt>(x times (y to the power z))</tt>,
* where <tt>y</tt> is allowed to take only the values 2 and 10.
*/
#define BER_REAL 9
/**
* A comma-separated list of names.
*/
#define BER_ENUMERATED 10
/**
* Embedded material that is not defined using ASN.1, such as a GIF file. This
* type supercedes #BER_EXTERNAL.
*/
#define BER_EMBEDDED_PDV 11
/**
* A character string which may contain characters from any language.
*/
#define BER_UTF8STRING 12
/**
* A constructed type that is used to hold an ordered list of elements.
*/
#define BER_SEQUENCE 16
/**
* A constructed type that is used to hold a list of repeating elements.
*/
#define BER_SET 17
/**
* A string of characters containing the digits zero to 9 and space.
*/
#define BER_NUMERICSTRING 18
/**
* A character array that only allows a small subset of values, namely
* [A-Z] [a-z] [0-9] and [ '()+,-./:=?].
*/
#define BER_PRINTABLESTRING 19
/**
* A deprecated synonym for #BER_TELETEXSTRING.
*/
#define BER_T61STRING 20
/**
* A character string that allows register entries 6, 87, 102, 103, 106, 107,
* 126, 144, 150, 153, 156, 164, 165 and 168 (plus space and delete)
* of the International Register of Coded Character Sets.
*/
#define BER_TELETEXSTRING 20
/**
* A character string that enables access to the "characters" used to
* build crude pictures on videotext systems.
*/
#define BER_VIDEOTEXSTRING 21
/**
* A character string that allows the register entries 1 and 6 (plus space and
* delete) of the International Register of Coded Character Sets to be used
* with escape sequences.
*/
#define BER_IA5STRING 22
/**
* A character string representing the date and time in the format: <br>
* <tt>ddmmyyhhmmssZ</tt>.
*/
#define BER_UTCTIME 23
/**
* A character string representing the date and time in the format: <br>
* <tt>ddmmyyyyhhmmssZ</tt>.
*/
#define BER_GENERALIZEDTIME 24
/**
* A character string that allows any of the register entries in the
* International Register for printable characters other than
* the control character entries.
*/
#define BER_GRAPHICSTRING 25
/**
* A deprecated synonym for #BER_VISIBLESTRING.
*/
#define BER_ISO64STRING 26
/**
* A character string that allows register entry 6 of the International
* Register of Coded Character Sets to be used with escape sequences.
*/
#define BER_VISIBLESTRING 26
/**
* A character string that allows any of the register entries in the
* International Register for printable characters.
*/
#define BER_GENERALSTRING 27
/**
* A character string which may contain characters from any language
* without using combining characters.
*/
#define BER_UNIVERSALSTRING 28
/**
* A character string which may contain characters from any living
* language.
*/
#define BER_BMPSTRING 30
/** The boolean value "false" for the #BER_BOOLEAN ASN.1 type. */
#define BER_FALSE 0
/** The boolean value "true" for the #BER_BOOLEAN ASN.1 type. */
#define BER_TRUE 255
#ifdef __cplusplus
}
#endif
#endif /* !HEADER_COMMON_BER_TYPE_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,356 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File:
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$
*---------------------------------------------------------------------------*/
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
#ifndef HEADER_COMMON_BN_LCL_H
#define HEADER_COMMON_BN_LCL_H
#ifdef __cplusplus
extern "C" {
#endif
#if 0 //RSA
#include <stdio.h>
#include <stdlib.h>
#include "r_error.h"
#include "err.h"
#include <string.h>
#else //NITRO
#include "r_error.h"
#ifndef NULL
#define NULL 0
#endif
#endif
#ifndef STANDALONE
#include "r_com.h"
#else
#if 0 //RSA
#define NO_STDLIB_MAPPING
#define Malloc(a) malloc(a)
#define Free(a) free(a)
#define Memset(a,b,c) memset(a,b,c)
#define Memcpy(a,b,c) memcpy(a,b,c)
#else // Nitro
#define NO_STDLIB_MAPPING
#include "acmemory.h"
#define Malloc(a) ACMemory_Alloc(a)
#define Free(a) ACMemory_Free(a)
#define Memset(a,b,c) ACMemory_Memset(a,b,c)
#define Memcpy(a,b,c) ACMemory_Memcpy(a,b,c)
#endif
#endif
/* TEMP FIX */
#undef BNerr
#define BNerr(a,b)
#include "bn.h"
#define BN_EXP_TABLE_SIZE 16
/* see the bn_limit_ fields which are the start of a runtime
* tunable set of values to match these fixed compile-time constants
*/
/* Pentium pro 16,16,16,32,64 */
/* Alpha 16,16,16,16.64 */
/* StrongARM */
#define BN_MULL_SIZE_NORMAL (16) /* 32 */
#define BN_MUL_RECURSIVE_SIZE_NORMAL (16) /* 32 */ /* less than */
#define BN_SQR_RECURSIVE_SIZE_NORMAL (16) /* 32 */
#define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */
#define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */
/*************************************************************
* Using the long long type
*/
#define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
/* These are used for internal error checking and are not normally used */
#ifdef BN_DEBUG
#define bn_check_top(a) \
{ if ( ((a)->top < 0) || \
((a)->top > (a)->max) || \
(((a)->top == 0) && (a)->neg) || \
(((a)->top == 1) && (a->d[0] == 0))) \
{ char *nullp=NULL; *nullp='z'; } }
#define bn_check_num(a) if ((a) < 0) { char *nullp=NULL; *nullp='z'; }
#define bn_assert(a) if (!(a)) { char *nullp=NULL; *nullp='z'; }
#define bn_set_used_check(l,size,num) bn_su_check(l,size,num)
#ifdef BN_DEBUG2
#define bn_do_used_check(fp,str,l,size,num) bn_du_check(fp,str,l,size,num)
#else
#define bn_do_used_check(fp,str,l,size,num)
#endif
#else
#define bn_assert(a)
#define bn_check_top(a)
#define bn_check_num(a)
#define bn_set_used_check(l,size,num)
#define bn_do_used_check(fp,str,l,size,num)
#endif
/***********************************************
* IA64 32 bit build SWIZZLE code
* This essentially casts our points which are
* 32bits under abi32 to 64bit unsigned long
* longs and then grabs the top two bits of the
* pointer and places it in the 2nd and 3rd bits
* of the unsigned long long.
**********************************************/
#ifdef HPUX_IA64_32
#define SWIZLLE(VALUE) ((((unsigned long long)(VALUE) & 0xc0000000LL) <<31)\
|((unsigned long long)(VALUE)))
#else
#define SWIZZLE(VALUE) (VALUE)
#endif
#define bn_neg_words(a,n) \
{ \
int iii; \
\
for (iii=0; iii<n; iii++) \
{ \
a[iii]= (-a[iii])&BN_MASK2; \
} \
for (;;) \
if ((++a[iii])&BN_MASK2) break; \
}
/* This macro is to add extra stuff for development checking */
#ifdef BN_DEBUG
#define bn_set_max(r) ((r)->max=(r)->top,BN_set_flags((r),BN_FLG_STATIC_DATA))
#else
#define bn_set_max(r)
#endif
/* These macros are used to 'take' a section of a bignum for read only use */
#define bn_set_low(r,a,n) \
{ \
(r)->top=((a)->top > (n))?(n):(a)->top; \
(r)->d=(a)->d; \
(r)->neg=(a)->neg; \
(r)->flags|=BN_FLG_STATIC_DATA; \
bn_set_max(r); \
}
#define bn_set_high(r,a,n) \
{ \
if ((a)->top > (n)) \
{ \
(r)->top=(a)->top-n; \
(r)->d= &((a)->d[n]); \
} \
else \
(r)->top=0; \
(r)->neg=(a)->neg; \
(r)->flags|=BN_FLG_STATIC_DATA; \
bn_set_max(r); \
}
/* #define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?(n):bn_expand2((n),(b))) */
#ifdef BN_LLONG
#define mul_add(r,a,w,c) { \
BN_ULLONG t; \
t=(BN_ULLONG)w * (a) + (r) + (c); \
(r)= Lw(t); \
(c)= Hw(t); \
}
#define mul(r,a,w,c) { \
BN_ULLONG t; \
t=(BN_ULLONG)w * (a) + (c); \
(r)= Lw(t); \
(c)= Hw(t); \
}
#else
/*************************************************************
* No long long type
*/
#define LBITS(a) ((a)&BN_MASK2l)
#define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2lh)
#define L2HBITS(a) ((BN_ULONG)((a)&BN_MASK2lh)<<BN_BITS4)
#define mul64(l,h,bl,bh) \
{ \
BN_ULONG m,m1,lt,ht; \
\
lt=l; \
ht=h; \
m =(bh)*(lt); \
lt=(bl)*(lt); \
m1=(bl)*(ht); \
ht =(bh)*(ht); \
m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS(1L); \
ht+=HBITS(m); \
m1=L2HBITS(m); \
lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
(l)=lt; \
(h)=ht; \
}
#define sqr64(lo,ho,in) \
{ \
BN_ULONG l,h,m; \
\
h=(in); \
l=LBITS(h); \
h=HBITS(h); \
m =(l)*(h); \
l*=l; \
h*=h; \
h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
m =((m&BN_MASK2l)<<(BN_BITS4+1))&BN_MASK2; \
l=(l+m)&BN_MASK2; if (l < m) h++; \
(lo)=l; \
(ho)=h; \
}
#if 0
#define mul_add(r,a,bl,bh,b_hl,c) { \
BN_ULONG l,h; \
BN_ULONG lt,mt; \
\
h= (a); \
l=LBITS(h); \
h=HBITS(h); \
mt=bl*l; \
lt=mt+c+(r); \
c=bh*h; \
mt+=c+(l-h)*b_hl; \
mt+=(lt>>BN_BITS4); \
(r)=(lt&BN_MASK2l)|((mt&BN_MASK2l)<<BN_BITS4); \
c+=(mt>>BN_BITS4); \
}
#else /* Normal version */
#define mul_add(r,a,bl,bh,b_hl,c) { \
BN_ULONG l,h; \
\
h= (a); \
l=LBITS(h); \
h=HBITS(h); \
mul64(l,h,(bl),(bh)); \
\
/* non-multiply part */ \
l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
(c)=(r); \
l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
(c)=h&BN_MASK2; \
(r)=l; \
}
#endif
#define mul(r,a,bl,bh,c) { \
BN_ULONG l,h; \
\
h= (a); \
l=LBITS(h); \
h=HBITS(h); \
mul64(l,h,(bl),(bh)); \
\
/* non-multiply part */ \
l+=(c); if ((l&BN_MASK2) < (c)) h++; \
(c)=h&BN_MASK2; \
(r)=l&BN_MASK2; \
}
#endif
#ifndef BN_MUL_COMBA
#define bn_mul_comba4(r,a,b) bn_mul_normal(r,a,4,b,4)
#define bn_mul_comba5(r,a,b) bn_mul_normal(r,a,5,b,5)
#define bn_mul_comba6(r,a,b) bn_mul_normal(r,a,6,b,6)
#define bn_mul_comba8(r,a,b) bn_mul_normal(r,a,8,b,8)
#define bn_mul_comba11(r,a,b) bn_mul_normal(r,a,11,b,11)
#define bn_mul_comba12(r,a,b) bn_mul_normal(r,a,12,b,12)
#define bn_mul_comba16(r,a,b) bn_mul_normal(r,a,16,b,16)
#endif
#if 1
#ifndef BN_SQR_COMBA
#define bn_sqr_comba4(r,a) bn_mul_normal(r,a,4,a,4)
#define bn_sqr_comba5(r,a) bn_mul_normal(r,a,5,a,5)
#define bn_sqr_comba6(r,a) bn_mul_normal(r,a,6,a,6)
#define bn_sqr_comba8(r,a) bn_mul_normal(r,a,8,a,8)
#define bn_sqr_comba11(r,a) bn_mul_normal(r,a,11,a,11)
#define bn_sqr_comba12(r,a) bn_mul_normal(r,a,12,a,12)
#define bn_sqr_comba16(r,a) bn_mul_normal(r,a,16,a,16)
#endif
#else
#ifndef BN_SQR_COMBA
#define bn_sqr_comba4(r,a) bn_mul_comba4(r,a,a)
#define bn_sqr_comba5(r,a) bn_mul_comba5(r,a,a)
#define bn_sqr_comba6(r,a) bn_mul_comba6(r,a,a)
#define bn_sqr_comba8(r,a) bn_mul_comba8(r,a,a)
#define bn_sqr_comba11(r,a) bn_mul_comba11(r,a,a)
#define bn_sqr_comba12(r,a) bn_mul_comba12(r,a,a)
#define bn_sqr_comba16(r,a) bn_mul_comba16(r,a,a)
#endif
#endif
#ifndef BN_REDUCE_COMBA
#define r0_bn_mont_comba4(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#define r0_bn_mont_comba5(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#define r0_bn_mont_comba6(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#define r0_bn_mont_comba8(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#define r0_bn_mont_comba11(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#define r0_bn_mont_comba12(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#define r0_bn_mont_comba16(r,a,n,num,n0) bn_from_montgomery_words(r,a,n,num,n0)
#endif
#ifndef NOPROTO
BIGNUM *bn_expand2(BIGNUM *b, int bits);
#ifdef X86_ASM
void bn_add_words(BN_ULONG *r,BN_ULONG *a,int num);
#endif
#else
BIGNUM *bn_expand2();
#ifdef X86_ASM
BN_ULONG bn_add_words();
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif /* HEADER_COMMON_BN_LCL_H */
void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,BN_ULONG *t);
void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2, BN_ULONG *t);
int BN_gen_exp_string(unsigned char *str, BIGNUM *p, int bits);
void bn_from_montgomery_rec_full(BN_ULONG *rp, BN_ULONG *ap,
BN_ULONG *np, BN_ULONG *nip, BN_ULONG *tmp,BN_REC *rec);
int bn_mont_ctx_new_word(const BN_ME_METH *meth, BN_ME_CTX **retp);

View File

@ -0,0 +1,317 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File:
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$
*---------------------------------------------------------------------------*/
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
/*****************************************************************************
* Copyright (c). 2001 RSA Security Inc. All rights reserved.
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
****************************************************************************/
/**
* @file bn_thx.h
* @brief header file created for used as interface defines for systems
* containing hetergeneous environments where some bn operations
* will be performed in isolation from the rest of the library
*/
#ifndef HEADER_COMMON_BN_THX_H
#define HEADER_COMMON_BN_THX_H
#ifdef __cplusplus
extern "C" {
#endif
/* These defines are required on systems so that the mod_exp code
* to be used in isolation from the bn operation with library will work,
* if these are not available, the header files with equivalent functionality
* should be added inside a CPU or Operating system define
*/
#ifndef NO_STDIO_H
#include <stdio.h>
#endif
#ifndef NO_STDLIB_H
#include <stdlib.h>
#endif
#ifndef NO_STRING_H
#include <string.h>
#endif
/* Interface for ARM/DSP systems, this interface requires only
* the standard defines and includes at the moment
*/
#ifdef CPU_TMS320
#define THX_RECIPIENT
#define CPU_DSP
#endif
#ifdef THX_RECIPIENT
#ifndef restrict
#define restrict
#endif
#ifndef Malloc
#define Malloc malloc
#endif
#ifndef Memcpy
#define Memcpy memcpy
#endif
#ifndef Memmove
#define Memmove memmove
#endif
#ifndef Memset
#define Memset memset
#endif
#ifndef Free
#define Free free
#endif
#endif /* THX_RECIPIENT */
#ifndef THX_RECIPIENT /* not the recipient, we must be the caller */
#include "bn_lcl.h"
#endif /* ! THX_RECIPIENT */
/* The follow define protected inclusions are excerpts from the
* header file bn.h, this has been done, so that code written for the
* THX systems can be used in isolation from the library
* This code may need to be updated in line with changes to the bn.h
* header file.
*/
#ifndef HEADER_COMMON_BN_H
#define HEADER_COMMON_BN_H
#if !defined(CCONV)
#define CCONV
#endif
#ifndef PRE_CCONV
#define PRE_CCONV
#endif
/* convert from the new to the old option names */
#if defined(OPT_BN_LLONG)
#define BN_LLONG /* comment to make sure Configure leaves this alone */
#endif
#if defined(OPT_32_BIT_INT) || defined(OPT_32_BIT)
#define THIRTY_TWO_BIT
#endif
#define BN_ILONG BN_ULONG
#ifdef THIRTY_TWO_BIT
#define BN_ULLONG unsigned long long
#ifdef OPT_32_BIT_INT
#define BN_ULONG unsigned int
#define BN_LONG int
#else
#define BN_ULONG unsigned long
#define BN_LONG long
#endif
#define BN_BITS 64
#define BN_BYTES 4
#define BN_BITS2 32
#define BN_BITS4 16
/* This is needed because the Watcom compiler pre-processor
* under QNX is perverted and tries to parses the 'LL'
* part even though it is never used.
*/
#ifdef BN_LLONG
#define BN_MASK (0xffffffffffffffffL)
#endif
#define BN_MASK2 (0xffffffffL)
#define BN_MASK2l (0xffff)
#define BN_MASK2lh (0xffff)
#define BN_MASK2h1 (0xffff8000L)
#define BN_MASK2h (0xffff0000L)
#define BN_TBIT (0x80000000L)
#define BN_DEC_CONV (1000000000L)
#define BN_DEC_FMT1 "%lu"
#define BN_DEC_FMT2 "%09lu"
#define BN_DEC_NUM 9
#define BN_HEX_FMT "%08lX"
#endif
#define BN_EXP_TABLE_SIZE 16
typedef struct bignum_st BIGNUM;
struct bignum_st
{
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
int top; /* Index of last used d +1. */
/* The next are internal book keeping for bn_expand. */
int max; /* Size of the d array. */
int neg; /* one if the number is negative */
int flags;
};
PRE_CCONV BN_ULONG CCONV bn_mul_add_words(BN_ULONG *rp,BN_ULONG *ap,
int num, BN_ULONG w);
PRE_CCONV BN_ULONG CCONV bn_mul_words(BN_ULONG *rp, BN_ULONG *ap,
int num, BN_ULONG w);
PRE_CCONV void CCONV bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
BN_ULONG CCONV bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
PRE_CCONV BN_ULONG CCONV bn_add_words(BN_ULONG *rp, BN_ULONG *ap,
BN_ULONG *bp,int num);
PRE_CCONV BN_ULONG CCONV bn_sub_words(BN_ULONG *rp, BN_ULONG *ap,
BN_ULONG *bp,int num);
#ifndef BN_ME_METH
#define BN_ME_METH void
#endif
#endif /* ! HEADER_COMMON_BN_H */
/* The follow define protected inclusions are excerpts from the
* header file r_error.h, this has been done, so that code written for the
* THX systems can be used in isolation from the library
* This code may need to be updated in line with changes to the r_error.h
* header file.
*/
#ifndef HEADER_COMMON_R_ERROR_H
#define HEADER_COMMON_R_ERROR_H
/* The FATAL_INTERNAL_ERROR is a flag that is set with the following
* error codes:
* R_ERROR_INVALID_STATE
* R_ERROR_INIT_NOT_CALLED
* R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED
*/
#define R_ERROR_FATAL_INTERNAL_ERROR 64
/* The BAD_PARAMETER is a flag that is set with the following error
* codes:
* R_ERROR_NULL_ARG
* R_ERROR_BUFFER_TOO_SMALL
* R_ERROR_BAD_VALUE
* R_ERROR_BAD_RANGE
* R_ERROR_BAD_FORMAT
* R_ERROR_BAD_TYPE
* R_ERROR_BAD_DATA
* R_ERROR_BAD_LENGTH
*/
#define R_ERROR_BAD_PARAMETER 32
/* Base value for all general errors used through all products */
#define R_ERROR_BASE 10000
#define R_ERROR_NONE 0
#define R_ERROR_FAILED (R_ERROR_BASE+1)
#define R_ERROR_IO (R_ERROR_BASE+2)
#define R_ERROR_PROTOCOL (R_ERROR_BASE+3)
#define R_ERROR_EOF (R_ERROR_BASE+4)
#define R_ERROR_ALLOC_FAILURE (R_ERROR_BASE+5)
#define R_ERROR_EVAL_RESTRICTION (R_ERROR_BASE+6)
#define R_ERROR_EVAL_EXPIRED (R_ERROR_BASE+7)
#define R_ERROR_NOT_FOUND (R_ERROR_BASE+8)
#define R_ERROR_NOT_AVAILABLE (R_ERROR_BASE+9)
#define R_ERROR_NOT_IMPLEMENTED (R_ERROR_BASE+10)
#define R_ERROR_NOT_SUPPORTED (R_ERROR_BASE+11)
#define R_ERROR_INVALID_STATE \
((R_ERROR_BASE+12) | R_ERROR_FATAL_INTERNAL_ERROR)
#define R_ERROR_INIT_NOT_CALLED \
((R_ERROR_BASE+13) | R_ERROR_FATAL_INTERNAL_ERROR)
#define R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED \
((R_ERROR_BASE+14) | R_ERROR_FATAL_INTERNAL_ERROR)
#define R_ERROR_METHOD_UNDEFINED \
((R_ERROR_BASE+15) | R_ERROR_FATAL_INTERNAL_ERROR)
#define R_ERROR_BUFFER_TOO_SMALL \
((R_ERROR_BASE+16) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_NULL_ARG ((R_ERROR_BASE+17) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_BAD_VALUE ((R_ERROR_BASE+18) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_BAD_RANGE ((R_ERROR_BASE+19) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_BAD_FORMAT ((R_ERROR_BASE+20) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_BAD_TYPE ((R_ERROR_BASE+21) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_BAD_DATA ((R_ERROR_BASE+22) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_BAD_LENGTH ((R_ERROR_BASE+23) | R_ERROR_BAD_PARAMETER)
#define R_ERROR_RCOM_LIBRARY_NOT_SUPPORTED (R_ERROR_BASE+24)
/* Resource Manager base for errors */
#define R_COM_ERR_LIB_CTX_BASE 10100
#endif /* HEADER_COMMON_R_ERROR_H */
const BN_ME_METH *BN_ME_METH_thxc(void);
/**
* @note THX code only needs to store rr, n0, str
*
*/
typedef struct thxc_mont_ctx_st
{
BIGNUM *rr;
unsigned char *str;
unsigned int str_len;
BN_ULONG n0;
} THXC_MONT_CTX;
int Rx_thxr_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np,
BN_ULONG *rrp, BN_ULONG n0, int top, int tmp_len, unsigned char *str);
int Ri_thxr_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np,
BN_ULONG *rrp, BN_ULONG *dp, BN_ULONG *aap, BN_ULONG *rp, BN_ULONG *tmp,
BN_ULONG n0, int top, unsigned char *str);
void Ri_thxr_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
void Ri_thxr_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);
void Ri_thxr_from_montgomery_words(BN_ULONG *ret,BN_ULONG *ap,BN_ULONG *np,
int w, BN_ULONG n0);
BN_ULONG Ri_thxr_from_mont_words(BN_ULONG *ap,BN_ULONG *wap,
BN_ULONG *np, int w, BN_ULONG n0);
#ifdef CPU_TMS320
/* Method and functions required for the ARM/DSP interface */
const BN_ME_METH *BN_ME_METH_dspc(void);
int Rx_dsp_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np,
BN_ULONG *rrp, BN_ULONG n0, int top, int tmp_len, unsigned char *str);
int Ri_dsp_mod_exp_mont( BN_ULONG *result, BN_ULONG *ap, BN_ULONG *np,
BN_ULONG *rrp, BN_ULONG *dp, BN_ULONG *aap, BN_ULONG *rp, BN_ULONG *tmp,
BN_ULONG n0, int top, unsigned char *str);
#endif
#ifdef __cplusplus
}
#endif
#endif /* HEADER_COMMON_BN_THX_H */

View File

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File:
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$
*---------------------------------------------------------------------------*/
#ifndef _MD5_H_
#define _MD5_H_
#ifdef __cplusplus
extern "C" {
#endif
/* MD5.H - header file for MD5C.C
*/
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
rights reserved.
License to copy and use this software is granted provided that it
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
Algorithm" in all material mentioning or referencing this software
or this function.
License is also granted to make and use derivative works provided
that such works are identified as "derived from the RSA Data
Security, Inc. MD5 Message-Digest Algorithm" in all material
mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either
the merchantability of this software or the suitability of this
software for any particular purpose. It is provided "as is"
without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
*/
typedef struct MD5_CTX MD5_CTX;
typedef struct MD5_CTX MD5Context;
/* MD5 context. */
struct MD5_CTX{
unsigned long state[4]; /* state (ABCD) */
unsigned long count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} ;
void MD5Init(MD5_CTX *);
void MD5Update(MD5_CTX *, unsigned char *, unsigned int);
void MD5Final(unsigned char digest[16], MD5_CTX *);
#if defined( MD5_TEST )
int MD5Test( );
#endif // MD5_TEST
#ifdef __cplusplus
}
#endif
#endif // _MD5_H_

View File

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File:
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$
*---------------------------------------------------------------------------*/
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
/**
* @file r_error.h
* This file contains the error definitions for the toolkit.
*/
#ifndef HEADER_COMMON_R_ERROR_H
#define HEADER_COMMON_R_ERROR_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup R_ERROR_IDS Error Identifiers
* This section outlines the error codes returned, enabling identification of
* specific errors. For more information, see the
* <a href="pdf/dev_guide.pdf">Developer's Guide</a>.
*
* @{
*/
/**
* Indicates that a fatal error has occurred in the operation performed.
* This flag is set with the following error codes:<br>
* <ul>
* <li>#R_ERROR_INVALID_STATE.</li>
* <li>#R_ERROR_INIT_NOT_CALLED.</li>
* <li>#R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED.</li>
* </ul>
*/
#define R_ERROR_FATAL_INTERNAL_ERROR 64
/**
* Indicates that the specified parameter is incorrect or contains invalid
* information. This flag is set with the following error codes:<br>
* <ul>
* <li>#R_ERROR_NULL_ARG.</li>
* <li>#R_ERROR_BUFFER_TOO_SMALL.</li>
* <li>#R_ERROR_BAD_VALUE.</li>
* <li>#R_ERROR_BAD_RANGE.</li>
* <li>#R_ERROR_BAD_FORMAT.</li>
* <li>#R_ERROR_BAD_TYPE.</li>
* <li>#R_ERROR_BAD_DATA.</li>
* <li>#R_ERROR_BAD_LENGTH.</li>
* </ul>
*/
#define R_ERROR_BAD_PARAMETER 32
/* Indicates the base value for all general errors used through all products */
#define R_ERROR_BASE 10000
/**
* Indicates that no errors were detected in the requested operation.
*/
#define R_ERROR_NONE 0
/**
* Indicates that the requested operation failed.
*/
#define R_ERROR_FAILED (R_ERROR_BASE+1)
/**
* Indicates that the requested operation detected an Input/Output error.
*/
#define R_ERROR_IO (R_ERROR_BASE+2)
/**
* Indicates that the requested operation detected a protocol error.
*/
#define R_ERROR_PROTOCOL (R_ERROR_BASE+3)
/**
* Indicates that the requested operation detected an End-of-File (EOF) error.
*/
#define R_ERROR_EOF (R_ERROR_BASE+4)
/**
* Indicates that the requested operation failed in a memory allocation
* operation.
*/
#define R_ERROR_ALLOC_FAILURE (R_ERROR_BASE+5)
/**
* Indicates that the requested operation is restricted in an evaluation
* version of the library.
*/
#define R_ERROR_EVAL_RESTRICTION (R_ERROR_BASE+6)
/**
* Indicates that the evaluation period of the library has expired.
*/
#define R_ERROR_EVAL_EXPIRED (R_ERROR_BASE+7)
/**
* Indicates that the requested operation detected that a pre-requirement was
* not found.
*/
#define R_ERROR_NOT_FOUND (R_ERROR_BASE+8)
/**
* Indicates that the requested operation detected that a pre-requirement was
* unavailable.
*/
#define R_ERROR_NOT_AVAILABLE (R_ERROR_BASE+9)
/**
* Indicates that the requested operation is not implemented in the current
* instantiation of the library.
*/
#define R_ERROR_NOT_IMPLEMENTED (R_ERROR_BASE+10)
/**
* Indicates that the requested operation is not supported in the current
* instantiation of the library.
*/
#define R_ERROR_NOT_SUPPORTED (R_ERROR_BASE+11)
/**
* Indicates that the requested operation entered an invalid state.
*/
#define R_ERROR_INVALID_STATE \
((R_ERROR_BASE+12) | R_ERROR_FATAL_INTERNAL_ERROR)
/**
* Indicates that the requested operation detected that an initialization
* operation has not been performed.
*/
#define R_ERROR_INIT_NOT_CALLED \
((R_ERROR_BASE+13) | R_ERROR_FATAL_INTERNAL_ERROR)
/**
* Indicates that the requested operation should not have been called.
*/
#define R_ERROR_SHOULD_NOT_HAVE_BEEN_CALLED \
((R_ERROR_BASE+14) | R_ERROR_FATAL_INTERNAL_ERROR)
/**
* Indicates that the requested method is not defined.
*/
#define R_ERROR_METHOD_UNDEFINED \
((R_ERROR_BASE+15) | R_ERROR_FATAL_INTERNAL_ERROR)
/**
* Indicates that the requested operation detected an inadequately sized
* buffer.
*/
#define R_ERROR_BUFFER_TOO_SMALL \
((R_ERROR_BASE+16) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* was passed as <tt>NULL</tt>.
*/
#define R_ERROR_NULL_ARG ((R_ERROR_BASE+17) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* passed contained a bad or incorrect value.
*/
#define R_ERROR_BAD_VALUE ((R_ERROR_BASE+18) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* passed was out of the allowed range.
*/
#define R_ERROR_BAD_RANGE ((R_ERROR_BASE+19) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* passed used a format that is not supported or incorrect.
*/
#define R_ERROR_BAD_FORMAT ((R_ERROR_BASE+20) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* passed used a type that is not supported or incorrect.
*/
#define R_ERROR_BAD_TYPE ((R_ERROR_BASE+21) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* passed contained incorrect or invalid data.
*/
#define R_ERROR_BAD_DATA ((R_ERROR_BASE+22) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the requested operation detected that a required argument
* passed contained an incorrect length value.
*/
#define R_ERROR_BAD_LENGTH ((R_ERROR_BASE+23) | R_ERROR_BAD_PARAMETER)
/**
* Indicates that the library instantiation requested is not supported.
*/
#define R_ERROR_RCOM_LIBRARY_NOT_SUPPORTED (R_ERROR_BASE+24)
/**
* Indicates that the request operation was denied.
*/
#define R_ERROR_DENIED (R_ERROR_BASE+25)
/**
* Indicates that authentication is required before the operation
* can succeed.
*/
#define R_ERROR_AUTHENTICATION_REQUIRED (R_ERROR_BASE+26)
/**
* Indicates that a required module was unable to be loaded.
*/
#define R_ERROR_MODULE_LOAD_FAILED \
((R_ERROR_BASE+27)|R_ERROR_FATAL_INTERNAL_ERROR)
/* Resource Manager base for errors */
#define R_COM_ERR_LIB_CTX_BASE 10100
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* HEADER_COMMON_R_ERROR_H */

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*
Project: TwlIPL
File:
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$
*---------------------------------------------------------------------------*/
/*
* Copyright (C) 1998-2002 RSA Security Inc. All rights reserved.
*
* This work contains proprietary information of RSA Security.
* Distribution is limited to authorized licensees of RSA
* Security. Any unauthorized reproduction, distribution or
* modification of this work is strictly prohibited.
*
*/
/*
* ***************************************************************************
*
* Purpose:
*
* This file defines an API for performing stack diagnostics.
*
* It provides:
* Peek Stack Usage statistics
* To use it:
* 1. Build the library without "NO_R_DIAG" defined
* 2. Make a call to R_DIAG_set_stack_datum() prior to
* calling the first library function.
* 3. Add calls to the macro R_DIAG_CHECK_STACK where potential
* high stack usage points are.
* 4. Call R_DIAG_get_stack_low_water_mark() at then end of the
* library calls to return the maximum stack usage OR
* 5. Call R_DIAG_print_stack_depth() to display the peek stack
* usage
*
*
*
* History:
* 3-Aug-00 mjs development
*
* **************************************************************************
*/
#ifndef HEADER_COMMON_R_STDIAG_H
#define HEADER_COMMON_R_STDIAG_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NO_R_DIAG
#ifdef NOPROTO
int R_DIAG_set_stack_datum(char *ptr);
int R_DIAG_check_stack(char *ptr, char *file, int line, int hit);
int R_DIAG_get_stack_low_water_mark(int *depth, char **file, int *line,
int *hit);
int R_DIAG_print_stack_depth(BIO *bio);
#else
int R_DIAG_set_stack_datum();
int R_DIAG_check_stack();
int R_DIAG_get_stack_low_water_mark();
int R_DIAG_print_stack_depth();
#endif
#define R_DIAG_CHECK_STACK {\
char r_diag_stack_check_var = 0;\
static int r_diag_stack_check_cnt = 0;\
\
R_DIAG_check_stack(&r_diag_stack_check_var, __FILE__,\
__LINE__,++r_diag_stack_check_cnt);\
}
#else
#define R_DIAG_CHECK_STACK
#endif
#ifdef __cplusplus
}
#endif
#endif /* HEADER_COMMON_R_STDIAG_H */

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