From 9501084c1df626e74b857a039c0ed7a2c35143fe Mon Sep 17 00:00:00 2001 From: yosiokat Date: Thu, 6 Sep 2007 08:37:12 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=BBNOR=E3=83=95=E3=82=A1=E3=83=BC?= =?UTF-8?q?=E3=83=A0=E3=81=8C=E3=83=93=E3=83=AB=E3=83=89=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4=E3=80=82=20?= =?UTF-8?q?=E3=83=BB=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E7=94=A8=E3=81=ABnorfirm-print=E3=81=8C?= =?UTF-8?q?=E3=83=93=E3=83=AB=E3=83=89=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@7 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/buildtools/commondefs | 26 +- build/buildtools/modulerules | 25 +- build/libraries/Makefile | 41 +++ build/libraries/os/ARM7/Makefile | 62 ++++ build/libraries/os/ARM9/Makefile | 60 ++++ build/libraries/os/ARM9/os_cache_tag.c | 269 ++++++++++++++++++ build/libraries/os/Makefile | 32 +++ build/libraries/os/common/os_boot.c | 57 ++++ build/libraries/os/common/os_init_firm.c | 146 ++++++++++ build/norfirm/norfirm-print/ARM7/Makefile | 48 ++++ build/norfirm/norfirm-print/ARM7/main.c | 31 ++ build/norfirm/norfirm-print/ARM9/Makefile | 47 +++ build/norfirm/norfirm-print/ARM9/main.c | 31 ++ build/norfirm/norfirm-print/Makefile | 51 ++++ build/norfirm/norfirm-print/norfirm-BB.norsf | 25 ++ .../norfirm/norfirm-print/wram_regs/Makefile | 48 ++++ .../norfirm-print/wram_regs/wram_regs.c | 91 ++++++ include/firm.h | 4 +- include/twl/os/ARM9/os_cache_tag.h | 151 ++++++++++ 19 files changed, 1227 insertions(+), 18 deletions(-) create mode 100644 build/libraries/Makefile create mode 100644 build/libraries/os/ARM7/Makefile create mode 100644 build/libraries/os/ARM9/Makefile create mode 100644 build/libraries/os/ARM9/os_cache_tag.c create mode 100644 build/libraries/os/Makefile create mode 100644 build/libraries/os/common/os_boot.c create mode 100644 build/libraries/os/common/os_init_firm.c create mode 100644 build/norfirm/norfirm-print/ARM7/Makefile create mode 100644 build/norfirm/norfirm-print/ARM7/main.c create mode 100644 build/norfirm/norfirm-print/ARM9/Makefile create mode 100644 build/norfirm/norfirm-print/ARM9/main.c create mode 100644 build/norfirm/norfirm-print/Makefile create mode 100644 build/norfirm/norfirm-print/norfirm-BB.norsf create mode 100644 build/norfirm/norfirm-print/wram_regs/Makefile create mode 100644 build/norfirm/norfirm-print/wram_regs/wram_regs.c create mode 100644 include/twl/os/ARM9/os_cache_tag.h diff --git a/build/buildtools/commondefs b/build/buildtools/commondefs index 3abdb8dc..1b374cb1 100644 --- a/build/buildtools/commondefs +++ b/build/buildtools/commondefs @@ -20,8 +20,6 @@ TWLFIRM_COMMONDEFS_ = TRUE NITRO_NO_STD_PCHDR = TRUE # プリコンパイルヘッダ抑止 -#TWLFIRM_ROOT ?= $(shell cygpath -am ../../) - export TWLBROM_ROOT := $(TWLFIRM_ROOT)/bootrom @@ -166,9 +164,9 @@ ifeq ($(CODEGEN_PROC),ARM9) FIRM_LIBS_BASE ?= \ libos \ - libmi \ - libgcd \ - libacsign \ +# libmi \ +# libgcd \ +# libacsign \ FIRM_TWL_LIBS_BASE ?= \ @@ -176,11 +174,11 @@ else # ($(CODEGEN_PROC),ARM7) FIRM_LIBS_BASE ?= \ libos_sp \ - libnvram_sp \ - libgcd_sp \ - libaes_sp \ - libacsign_sp \ - libfirmsd_sp \ +# libnvram_sp \ +# libgcd_sp \ +# libaes_sp \ +# libacsign_sp \ +# libfirmsd_sp \ FIRM_TWL_LIBS_BASE ?= \ @@ -245,6 +243,14 @@ FIRM_INSTALL_ADDINS := $(FIRM_INSTALL_ROOT)/add-ins # MACRO_FLAGS += -DFIRM_TARGET_$(FIRM_TARGET) + +#---------------------------------------------------------------------------- +# Makelcf change for build firmware +# +ifneq ($(filter NORFIRM NANDFIRM GCDFIRM,$(FIRM_TARGET)),) +MAKELCF := $(NITROSDK_ROOT)/tools/bin/makelcf.exe +endif + #---------------------------------------------------------------------------- endif # TWLFIRM_COMMONDEFS_ #----- End of commondefs ----- diff --git a/build/buildtools/modulerules b/build/buildtools/modulerules index 6f243dd9..01b2f29b 100644 --- a/build/buildtools/modulerules +++ b/build/buildtools/modulerules @@ -56,16 +56,16 @@ firmlib: @$(MAKE) -C $(TWLFIRM_ROOT)/build/libraries # .nor -$(BINDIR)/%.nor: $(SDEPENDS_BIN) $(ROM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) $(MAKENORFIRM) $(MAKEFIRM_RSA_PRVKEY) - $(MAKENORFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(ROM_SPEC) $@ +$(BINDIR)/%.nor: $(SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) $(MAKENORFIRM) $(MAKEFIRM_RSA_PRVKEY) + $(MAKENORFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ # .nand -$(BINDIR)/%.nand: $(SDEPENDS_BIN) $(ROM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) $(MAKENANDFIRM) $(MAKEFIRM_RSA_PRVKEY) - $(MAKENANDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(ROM_SPEC) $@ +$(BINDIR)/%.nand: $(SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) $(MAKENANDFIRM) $(MAKEFIRM_RSA_PRVKEY) + $(MAKENANDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ # .gcd -$(BINDIR)/%.gcd: $(SDEPENDS_BIN) $(ROM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) $(MAKEGCDFIRM) $(MAKEFIRM_RSA_PRVKEY) - $(MAKEGCDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(ROM_SPEC) $@ +$(BINDIR)/%.gcd: $(SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) $(MAKEGCDFIRM) $(MAKEFIRM_RSA_PRVKEY) + $(MAKEGCDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ # .rbin $(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS) @@ -73,7 +73,18 @@ $(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS) # .axf $(BINDIR)/$(TARGET_BIN_BASENAME).axf: $(OBJS) $(LCFILE) $(MAKEFILE) $(LDEPENDS_NEF) $(EDEPENDS_NEF) $(ALIBRARIES) $(LDRES_FILE) $(CW_LIBCXX) - $(LD) $(LDFLAGS) $(LIBRARY_DIRS) @$(call empath,$(LDRES_FILE)) $(call empath,$(LCFILE)) -o $(call empath,$@) +ifeq ($(NITRO_CCTYPE),RVCT) + $(LD) $(LDFLAGS) $(LIBRARY_DIRS) -o $@ $(GLIBRARIES) $(OBJS) +else + $(LD) $(LDFLAGS) $(LIBRARY_DIRS) @$(LDRES_FILE) $(LCFILE) -o $@ +ifeq ($(TWL_PLATFORM),TS) + cp $(BINDIR)/$(TARGET_BIN_BASENAME).axf $(BINDIR)/$(TARGET_BIN_BASENAME).nef +else # ($(TWL_PLATFORM),BB) +ifdef FIRM_STRIP_AXF + $(OBJCOPY) $@ $(BINDIR)/$(TARGET_BIN_BASENAME).sbin +endif +endif +endif #---------------------------------------------------------------------------- TWLFIRM_MODULERULES_ = TRUE diff --git a/build/libraries/Makefile b/build/libraries/Makefile new file mode 100644 index 00000000..d8e78789 --- /dev/null +++ b/build/libraries/Makefile @@ -0,0 +1,41 @@ +#! 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 $(TWLFIRM_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + os \ +# syscall \ +# init \ +# mi \ +# nvram \ +# gcd \ +# aes \ +# acsign \ +# acsign_ecc \ +# devices \ + +#---------------------------------------------------------------------------- + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/os/ARM7/Makefile b/build/libraries/os/ARM7/Makefile new file mode 100644 index 00000000..62ab9efb --- /dev/null +++ b/build/libraries/os/ARM7/Makefile @@ -0,0 +1,62 @@ +#! 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 = +#SUBMAKES = Makefile.CALLTRACE \ +# Makefile.FUNCTIONCOST + +#---------------------------------------------------------------------------- + +# build ARM & THUMB libraries +FIRM_CODEGEN_ALL ?= TRUE + +# Codegen for sub processer +FIRM_PROC = ARM7 + +SRCDIR = ../common . + +SRCS = \ + os_init_firm.c \ + os_boot.c \ + +TARGET_LIB = libos_sp$(FIRM_LIBSUFFIX).a + + +#---------------------------------------------------------------------------- + +# DEBUG版ビルドの場合、RELEASE版でビルドして +# DEBUG版のライブラリを装います。 + +ifdef NITRO_DEBUG +NITRO_BUILD_TYPE = RELEASE +endif + +include $(TWLFIRM_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/os/ARM9/Makefile b/build/libraries/os/ARM9/Makefile new file mode 100644 index 00000000..24a68c79 --- /dev/null +++ b/build/libraries/os/ARM9/Makefile @@ -0,0 +1,60 @@ +#! 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 +FIRM_CODEGEN_ALL ?= TRUE + +SRCDIR = ../common . + +SRCS = \ + os_init_firm.c \ + os_boot.c \ + os_cache_tag.c \ + +TARGET_LIB = libos$(FIRM_LIBSUFFIX).a + +include $(TWLFIRM_ROOT)/build/buildtools/commondefs + +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(FIRM_INSTALL_LIBDIR) + +ifdef NITRO_CALLTRACE +CCFLAGS += -DOS_PROFILE_AVAILABLE -DOS_PROFILE_CALL_TRACE +endif + +ifdef NITRO_FUNCTIONCOST +CCFLAGS += -DOS_PROFILE_AVAILABLE -DOS_PROFILE_FUNCTION_COST +endif + +ifdef NITRO_TCM_APPLY +CCFLAGS += -DSDK_TCM_APPLY +endif + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + +#===== End of Makefile ===== diff --git a/build/libraries/os/ARM9/os_cache_tag.c b/build/libraries/os/ARM9/os_cache_tag.c new file mode 100644 index 00000000..3ea8a89d --- /dev/null +++ b/build/libraries/os/ARM9/os_cache_tag.c @@ -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 +#include + + +//=========================================================================== +// 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< diff --git a/build/libraries/os/Makefile b/build/libraries/os/Makefile new file mode 100644 index 00000000..722c058d --- /dev/null +++ b/build/libraries/os/Makefile @@ -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 $(TWLFIRM_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = ARM9 \ + ARM7 \ + +#---------------------------------------------------------------------------- + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/libraries/os/common/os_boot.c b/build/libraries/os/common/os_boot.c new file mode 100644 index 00000000..39bd9f34 --- /dev/null +++ b/build/libraries/os/common/os_boot.c @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------* + 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 +#include +#ifdef SDK_ARM9 +#include +#endif + +/*---------------------------------------------------------------------------* + Name: OSi_Finalize + + Description: finalize + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +void OSi_Finalize(void) +{ + (void)OS_DisableIrq(); + reg_OS_IE = 0; + reg_OS_IF = 0xffffffff; +#ifdef SDK_ARM7 + reg_OS_IE2 = 0; + reg_OS_IF2 = 0xffffffff; +#else // SDK_ARM9 + (void)OS_DisableInterrupts(); + DC_Disable(); + DC_FlushAll(); + DC_WaitWriteBufferEmpty(); + IC_Disable(); + IC_InvalidateAll(); + + // clear cache + IC_ClearTagAll(); + IC_ClearInstructionAll(); + DC_ClearTagAll(); + DC_ClearDataAll(); + + OS_DisableProtectionUnit(); +#endif // SDK_ARM9 +} + diff --git a/build/libraries/os/common/os_init_firm.c b/build/libraries/os/common/os_init_firm.c new file mode 100644 index 00000000..58d1c165 --- /dev/null +++ b/build/libraries/os/common/os_init_firm.c @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------* + 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 + +/*---------------------------------------------------------------------------* + Name: OS_InitNOR + + Description: initialize sdk os for norfirm + + Arguments: None + + Returns: None + *---------------------------------------------------------------------------*/ +#pragma profile off +void OS_InitNOR(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 Arena (arenas except SUBPRIV-WRAM) + OS_InitArena(); + + //---- Init interProcessor I/F + // Sync with ARM7 to enable OS_GetConsoleType() + // PXI_Init() must be called before OS_InitArenaEx() + PXI_Init(); + + //---- 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 Power Manager +#ifndef SDK_TEG +// PM_Init(); +#endif + + //---- adjust VCOUNT +// OSi_WaitVCount0(); + +#else // SDK_ARM9 + //---------------------------------------------------------------- + // for ARM7 + + //---- Init Arena (SUBPRIV-WRAM arena) + OS_InitArena(); + + //---- Init interProcessor I/F + PXI_Init(); + + //---- 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 + +#endif // SDK_ARM9 +} + +#pragma profile reset diff --git a/build/norfirm/norfirm-print/ARM7/Makefile b/build/norfirm/norfirm-print/ARM7/Makefile new file mode 100644 index 00000000..b58044db --- /dev/null +++ b/build/norfirm/norfirm-print/ARM7/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +FIRM_PROC = ARM7 +FIRM_TARGET = NORFIRM + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = twl_norfirm7_print.axf + +SRCS = \ + main.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWLFIRM_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/ARM7/main.c b/build/norfirm/norfirm-print/ARM7/main.c new file mode 100644 index 00000000..80c63f4f --- /dev/null +++ b/build/norfirm/norfirm-print/ARM7/main.c @@ -0,0 +1,31 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - norfirm-print + 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 + + +void TwlSpMain( void ) +{ + OS_TPrintf( "\nNOR Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + OS_InitNOR(); + + OS_TPrintf( "\nARM7 starts.\n" ); + OS_TPrintf( "\nARM7 ends.\n" ); + + OS_Terminate(); +} + diff --git a/build/norfirm/norfirm-print/ARM9/Makefile b/build/norfirm/norfirm-print/ARM9/Makefile new file mode 100644 index 00000000..8fdefc6a --- /dev/null +++ b/build/norfirm/norfirm-print/ARM9/Makefile @@ -0,0 +1,47 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +FIRM_TARGET = NORFIRM + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = twl_norfirm9_print.axf + +SRCS = \ + main.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWLFIRM_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/ARM9/main.c b/build/norfirm/norfirm-print/ARM9/main.c new file mode 100644 index 00000000..e10429fe --- /dev/null +++ b/build/norfirm/norfirm-print/ARM9/main.c @@ -0,0 +1,31 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - norfirm-print + 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 + + +void TwlMain( void ) +{ + OS_TPrintf( "\nNOR Boot time is %d msec.\n", OS_TicksToMilliSecondsBROM32(OS_GetTick())); + + OS_InitNOR(); + + OS_TPrintf( "\nARM9 starts.\n" ); + OS_TPrintf( "\nARM9 ends.\n" ); + + OS_Terminate(); +} + diff --git a/build/norfirm/norfirm-print/Makefile b/build/norfirm/norfirm-print/Makefile new file mode 100644 index 00000000..0882ebe9 --- /dev/null +++ b/build/norfirm/norfirm-print/Makefile @@ -0,0 +1,51 @@ +#! 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:$ +#---------------------------------------------------------------------------- + + +FIRM_TARGET = NORFIRM + + +include $(TWLFIRM_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + ARM7 \ + ARM9 \ + wram_regs \ + +TARGET_BIN = norfirm_print.nor +BINDIR = . +MAKEFIRM_ARM9 = ARM9/bin/ARM9-$(FIRM_PLATFORM)$(CODEGEN_ARCH)/$(FIRM_BUILD_DIR)/twl_norfirm9_print.axf +MAKEFIRM_ARM7 = ARM7/bin/ARM7-$(FIRM_PLATFORM)$(CODEGEN_ARCH)/$(FIRM_BUILD_DIR)/twl_norfirm7_print.axf +MAKEFIRM_RSA_PRVKEY = $(TWL_KEYSDIR)/rsa/private_nor.der +LDEPENDS_BIN += wram_regs/wram_regs.rbin + +NITRO_MAKEROM = TRUE +MAKEFIRM_FLAGS += -p +FIRM_SPEC = norfirm-BB.norsf + +#---------------------------------------------------------------------------- + +do-build: $(TARGET_BIN) + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/norfirm-BB.norsf b/build/norfirm/norfirm-print/norfirm-BB.norsf new file mode 100644 index 00000000..8b50ee2b --- /dev/null +++ b/build/norfirm/norfirm-print/norfirm-BB.norsf @@ -0,0 +1,25 @@ +#NORSF --- Norfirm Spec File + +VERSION : GENERATE + +BOOT_NAND : TRUE # TRUE or FALSE + +RSA_KEY : $(MAKEFIRM_RSA_PRVKEY) +OUT_KEY : rsa_public.sbin + +WRAM_RBIN: ./wram_regs/wram_regs.rbin + +DECOMP_PROC : ARM9 # ARM9 or ARM7 + +ARM9_COMP : TRUE # TRUE or FALSE, should be before ARM9_SBIN +ARM9_SBIN : $(MAKEFIRM_ARM9).sbin +ARM9_ELF : $(MAKEFIRM_ARM9).axf + +ARM7_COMP : TRUE # TRUE or FALSE, should be before ARM7_SBIN +ARM7_SBIN : $(MAKEFIRM_ARM7).sbin +ARM7_ELF : $(MAKEFIRM_ARM7).axf + +NCD_ROMOFS : 0x07fe00 + +BAUDRATE : 8M # 4M or 8M +ARM9_X2 : TRUE # TRUE or FALSE diff --git a/build/norfirm/norfirm-print/wram_regs/Makefile b/build/norfirm/norfirm-print/wram_regs/Makefile new file mode 100644 index 00000000..7c687c34 --- /dev/null +++ b/build/norfirm/norfirm-print/wram_regs/Makefile @@ -0,0 +1,48 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - tools - norfirm-print +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded instructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: $ +# $Rev:$ +# $Author:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +LINCLUDES = ../include + +#---------------------------------------------------------------------------- + +TARGET_BIN = wram_regs.rbin + +SRCS = \ + wram_regs.c \ + +#SRCDIR = # using default +#LCFILE = # using default + + +include $(TWLFIRM_ROOT)/build/buildtools/commondefs + +INSTALL_DIR = . +INSTALL_TARGETS = $(BINDIR)/$(TARGET_BIN) + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(TWLFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/build/norfirm/norfirm-print/wram_regs/wram_regs.c b/build/norfirm/norfirm-print/wram_regs/wram_regs.c new file mode 100644 index 00000000..ea59c659 --- /dev/null +++ b/build/norfirm/norfirm-print/wram_regs/wram_regs.c @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - tools - makenorfirm + 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 +#include + +MIHeader_WramRegs wram_regs_init = +{ + // ARM9 + { + REG_MI_MBK_A0_FIELD( 1, MI_WRAM_A_OFFSET_0KB , MI_WRAM_ARM7 ), + REG_MI_MBK_A1_FIELD( 1, MI_WRAM_A_OFFSET_64KB , MI_WRAM_ARM7 ), + REG_MI_MBK_A2_FIELD( 1, MI_WRAM_A_OFFSET_128KB, MI_WRAM_ARM7 ), + REG_MI_MBK_A3_FIELD( 1, MI_WRAM_A_OFFSET_192KB, MI_WRAM_ARM7 ), + }, + { + 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_ARM9 ), + REG_MI_MBK_C1_FIELD( 1, MI_WRAM_BC_OFFSET_32KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C2_FIELD( 1, MI_WRAM_BC_OFFSET_64KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C3_FIELD( 1, MI_WRAM_BC_OFFSET_96KB , MI_WRAM_ARM9 ), + REG_MI_MBK_C4_FIELD( 1, MI_WRAM_BC_OFFSET_128KB, MI_WRAM_ARM9 ), + REG_MI_MBK_C5_FIELD( 1, MI_WRAM_BC_OFFSET_160KB, MI_WRAM_ARM9 ), + REG_MI_MBK_C6_FIELD( 1, MI_WRAM_BC_OFFSET_192KB, MI_WRAM_ARM9 ), + REG_MI_MBK_C7_FIELD( 1, MI_WRAM_BC_OFFSET_224KB, MI_WRAM_ARM9 ), + }, + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, MI_WRAM_MAP_NULL ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, HW_WRAM_AREA_HALF + 0x00020000 ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, HW_WRAM_AREA_HALF ) + ), + + // ARM7 + REG_MI_MBK6_FIELD( REG_WRAM_MAP_CONV_ADDR( 6, A, EADDR, HW_WRAM_AREA_HALF + 0x00020000 ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 6, A, SADDR, HW_WRAM_AREA_HALF ) + ), + REG_MI_MBK7_FIELD( REG_WRAM_MAP_CONV_ADDR( 7, B, EADDR, HW_WRAM_AREA_HALF + 0x00040000 ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 7, B, SADDR, HW_WRAM_AREA_HALF + 0x00020000 ) + ), + REG_MI_MBK8_FIELD( REG_WRAM_MAP_CONV_ADDR( 8, C, EADDR, MI_WRAM_MAP_NULL ), + MI_WRAM_IMAGE_128KB, + REG_WRAM_MAP_CONV_ADDR( 8, C, SADDR, MI_WRAM_MAP_NULL ) + ), + + // WRAM Lock + { + 0, + 0, + 0, + }, + + // WRAM-0/1 + 3, + + // VRAM-C + 7, + // VRAM-D + 7, +}; + diff --git a/include/firm.h b/include/firm.h index 07668f25..f3fbfdc9 100644 --- a/include/firm.h +++ b/include/firm.h @@ -19,12 +19,14 @@ #include -#include #include +/* +#include #include #include #include #include +*/ /* FIRM_H_ */ #endif diff --git a/include/twl/os/ARM9/os_cache_tag.h b/include/twl/os/ARM9/os_cache_tag.h new file mode 100644 index 00000000..4d877566 --- /dev/null +++ b/include/twl/os/ARM9/os_cache_tag.h @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------* + Project: TwlFirm - OS - include + File: os_cache_tag.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 TWL_OS_CACHE_TAG_H_ +#define TWL_OS_CACHE_TAG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +//=========================================================================== +// DATA CACHE (for specified range) +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: DC_ClearTagAll + + Description: clear tag in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearTagAll( void ); + +/*---------------------------------------------------------------------------* + Name: DC_ClearDataAll + + Description: clear data in data cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_ClearDataAll( void ); + +/*---------------------------------------------------------------------------* + Name: DC_FillTagAll + + Description: clear tag in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_FillTagAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: DC_FillDataAll + + Description: fill data in data cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_FillDataAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: DC_GetTagAndDataAll + + Description: get tag and data in data cache + + Arguments: tag tag address + data data address + + Returns: None. + *---------------------------------------------------------------------------*/ +void DC_GetTagAndDataAll( void* tag, void* data ); + +//=========================================================================== +// INSTRUCTION CACHE +//=========================================================================== +/*---------------------------------------------------------------------------* + Name: IC_ClearTagAll + + Description: clear tag in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_ClearTagAll( void ); + +/*---------------------------------------------------------------------------* + Name: IC_ClearInstructionAll + + Description: clear instruction in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_ClearInstructionAll( void ); + +/*---------------------------------------------------------------------------* + Name: IC_FillTagAll + + Description: fill tag in instruction cache + + Arguments: None + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_FillTagAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: IC_FillInstructionAll + + Description: fill instruction in instruction cache + + Arguments: data : fill data + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_FillInstructionAll( u32 data ); + +/*---------------------------------------------------------------------------* + Name: IC_GetTagAndInstructionAll + + Description: get tag and instruction in instruction cache + + Arguments: tag tag address + inst instruction address + + Returns: None. + *---------------------------------------------------------------------------*/ +void IC_GetTagAndInstructionAll( void* tag, void* inst ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +/* TWL_OS_CACHE_TAG_H_ */ +#endif