ヘッダファイル群&スタートアップコード追加。

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_firmware@41 b871894f-2f95-9b40-918c-086798483c85
This commit is contained in:
nakasima 2008-11-28 09:23:30 +00:00
parent be7dc50306
commit 89f91e6a66
35 changed files with 2486 additions and 8 deletions

View File

@ -0,0 +1,54 @@
#! make -f
#----------------------------------------------------------------------------
# Project: CtrBrom - libraries_sp - 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:: 2008-11-28#$
# $Rev: 41 $
# $Author: nakasima $
#----------------------------------------------------------------------------
SUBDIRS =
#----------------------------------------------------------------------------
# build ARM & THUMB libraries
BROM_CODEGEN_ALL ?= True
# Codegen for sub processer
BROM_PROC = ARM9
SRCDIR = ../common .
SRCS = crt0.c crt0_secure_sp.c crt0_scat.c crt0_app.c
TARGET_OBJ = crt0.o crt0_secure_sp.o crt0_scat.o crt0_app.o
#----------------------------------------------------------------------------
include $(CTRBROM_ROOT)/build/buildtools/commondefs
INSTALL_TARGETS = $(TARGETS)
INSTALL_DIR = $(BROM_INSTALL_LIBDIR)
MACRO_FLAGS += -DSDK_NOINIT
#----------------------------------------------------------------------------
do-build: $(TARGETS) # $(TARGETS)
include $(CTRBROM_ROOT)/build/buildtools/modulerules
#===== End of Makefile =====

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - library - init
File: crt0.c
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#include <brom/code32.h>
#include <brom/os.h>
//#include <brom/mi.h>
void _start(void);
/*---------------------------------------------------------------------------*
Name: _start
Description: Start up
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void _start( void )
{
PRESERVE8
CODE32 // for _start reference
INASM_EXTERN( STUPi_StartHandler )
b stupStartHandlerVeneer // don't change for NULL access compatibility
undef b STUPi_DbgHandler
swi b STUPi_SwiHandler
iabt b STUPi_DbgHandler
dabt b STUPi_DbgHandler
reserve b reserve
irq b STUPi_IrqHandler
fiq b STUPi_DbgHandler
stupStartHandlerVeneer
b STUPi_StartHandler
}
#include <../common/crt0_excpHandler.c>

View File

@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - library - init
File: crt0_app.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 <brom/code32.h>
#include <brom/os.h>
#include <brom/mi.h>
void _start(void);
/*---------------------------------------------------------------------------*
Name: _start
Description: Start up
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void _start( void )
{
PRESERVE8
b stupStartHandlerVeneer // don't change for NULL access compatibility
stupStartHandlerVeneer
b STUPi_StartHandler
}
/*---------------------------------------------------------------------------*
Name: STUPi_StartHandler
Description: start handler
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void STUPi_StartHandler( void )
{
INASM_EXTERN( BromSpMain )
INASM_EXTERN( main )
#ifndef BROM_ENABLE_BOOTROM_WRITE
ldr r3, =REG_DEVROM_ADDR
ldrb r1, [r3]
bic r1, #REG_CFG_DEVROM_WE_MASK
strb r1, [r3]
#endif // BROM_ENABLE_BOOTROM_WRITE
//---- set IME = 0
// ( use that LSB of HW_REG_BASE equal to 0 )
mov r12, #HW_REG_BASE
str r12, [r12, #REG_IME_OFFSET]
// init BROM prot
ldr r3, =REG_PROT_ADDR
ldr r1, =4*8 // 0x1204
strh r1, [r3]
//---- initialize stack pointer
// SVC mode
mov r0, #HW_PSR_SVC_MODE
msr cpsr_c, r0
ldr sp, =HW_PRV_WRAM_SVC_STACK_END
// IRQ mode
mov r0, #HW_PSR_IRQ_MODE
msr cpsr_c, r0
ldr r0, =HW_PRV_WRAM_IRQ_STACK_END
mov sp, r0
// System mode
ldr r1, =HW_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
//---- lnitialize sections
bl stupInitSections
//---- start (to 16bit code)
ldr r1, =BromSpMain
adr lr, terminate
bx r1
terminate
b terminate
}
#undef BROM_TARGET_BROM
#include <./crt0_misc_sp.c>

View File

@ -0,0 +1,235 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - library - init
File: crt0_misc_sp.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 <brom/code32.h>
#include <brom/os.h>
#include <brom/mi.h>
/*---------------------------------------------------------------------------*
Name: STUPi_MappingWram
Description: mapping WRAM for ARM7
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
ASM void STUPi_MappingWram( void )
{
// mapping WRAM-A
ldr r3, =REG_WRAM_A_MAP_ADDR
ldr r1, =REG_WRAM_A_MAP_PACK( MI_WRAM_MAP_NULL, MI_WRAM_MAP_NULL, __cpp(MI_WRAM_A_IMG_MAX) )
str r1, [r3]
// mapping WRAM-B
ldr r3, =REG_WRAM_B_MAP_ADDR
ldr r1, =REG_WRAM_A_MAP_PACK( MI_WRAM_MAP_NULL, MI_WRAM_MAP_NULL, __cpp(MI_WRAM_A_IMG_MAX) )
str r1, [r3]
// mapping WRAM-C
ldr r3, =REG_WRAM_C_MAP_ADDR
ldr r1, =REG_WRAM_C_MAP_PACK( MI_WRAM_MAP_NULL, MI_WRAM_MAP_NULL, __cpp(MI_WRAM_A_IMG_MAX) )
str r1, [r3]
bx lr
}
/*---------------------------------------------------------------------------*
Name: __user_initial_stackheap
Description: called from __scatterload
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
ASM void __user_initial_stackheap( void )
{
#ifdef BROM_ENABLE_INITIAL_STACKHEAP
INASM_EXTERN( |Image$$ZI$$ZI$$Limit| )
ldr r0, =|Image$$ZI$$ZI$$Limit| // heap base
ldr r1, =HW_PRV_WRAM_IRQ_STACK_END
sub r1, r1, #HW_IRQ_STACK_SIZE
mov r2, r0
mov r3, r0
#endif // BROM_ENABLE_INITIAL_STACKHEAP
bx lr
}
/*---------------------------------------------------------------------------*
Name: stupInitSections
Description: Initialize Sections
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
ASM void stupInitSections( void )
{
b stupInitStaticSections
}
/*---------------------------------------------------------------------------*
Name: stupInitStaticSections
Description: Initialize Static Sections
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
ASM void stupInitStaticSections( void )
{
#ifdef BROM_TARGET_BROM
INASM_EXTERN( |Image$$SEC_RO$$Limit| )
ldr r0, =|Image$$SEC_RO$$Limit|
#else // BROM_TARGET_NORFIRM || BROM_TARGET_APP
INASM_EXTERN( |Image$$RO$$Limit| )
ldr r0, =|Image$$RO$$Limit|
#endif // BROM_TARGET_NORFIRM || BROM_TARGET_APP
INASM_EXTERN( |Image$$RW$$Base| )
INASM_EXTERN( |Image$$ZI$$ZI$$Base| )
INASM_EXTERN( |Image$$ZI$$ZI$$Limit| )
ldr r1, =|Image$$RW$$Base|
ldr r3, =|Image$$ZI$$ZI$$Base|
cmp r0, r1
beq FSYM(20)
LSYM(10)
cmp r1, r3
ldrcc r2, [r0], #4
strcc r2, [r1], #4
bcc BSYM(10)
LSYM(20)
ldr r1, =|Image$$ZI$$ZI$$Limit|
mov r2, #0
LSYM(30)
cmp r3, r1
strcc r2, [r3], #4
bcc BSYM(30)
bx lr
}
/*---------------------------------------------------------------------------*
Name: STUPi_CpuCopy32
Description: copy memory by CPU
32bit version
Arguments: srcp : source address
destp : destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
ASM void STUPi_CpuCopy32( const void *srcp, void *destp, u32 size )
{
add r12, r1, r2
LSYM(10)
cmp r1, r12
ldmltia r0!, {r2}
stmltia r1!, {r2}
blt BSYM(10)
bx lr
}
/*---------------------------------------------------------------------------*
Name: STUPi_CpuClear32
Description: fill memory with specified data.
32bit version
Arguments: data : fill data
destp : destination address
size : size (byte)
Returns: None
*---------------------------------------------------------------------------*/
ASM void STUPi_CpuClear32( u32 data, void *destp, u32 size )
{
add r12, r1, r2
LSYM(10)
cmp r1, r12
stmltia r1!, {r0}
blt BSYM(10)
bx lr
}
/*---------------------------------------------------------------------------*
Name: STUPi_NotifyToARM9
Description: notify 4bit id to ARM9
Arguments: id notifying id
Returns: None
*---------------------------------------------------------------------------*/
ASM void STUPi_NotifyToARM9( u32 id )
{
ldr r3, =REG_MAINPINTF_ADDR
mov r0, r0, lsl #REG_PXI_MAINPINTF_A7STATUS_SHIFT
and r0, r0, #REG_PXI_MAINPINTF_A7STATUS_MASK
str r0, [r3]
bx lr
}
/*---------------------------------------------------------------------------*
Name: STUPi_WaitARM9
Description: Wait 4bit id from ARM9
Arguments: id waiting id
Returns: None
*---------------------------------------------------------------------------*/
ASM void STUPi_WaitARM9( u32 id )
{
ldr r3, =REG_MAINPINTF_ADDR
LSYM(10)
ldr r1, [r3]
and r1, r1, #REG_PXI_MAINPINTF_A9STATUS_MASK
cmp r0, r1
bne BSYM(10)
bx lr
}
/*---------------------------------------------------------------------------*
Name: STUPi_WaitCpuCycles
Description: Loop and Wait for specified CPU cycles at least
Arguments: cycles waiting CPU cycle
Returns: None
*---------------------------------------------------------------------------*/
ASM void STUPi_WaitCpuCycles( u32 cycle )
{
sub r0, r0, #(6-2) // subtract call-return overhead and add the margin of 2 cycles
LSYM(10)
subs r0, r0, #4 // 1 cycle
bcs BSYM(10) // 3 cycle
bx lr
}

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - library - init
File: crt0_scat.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 <brom/code32.h>
#include <brom/os.h>
/*---------------------------------------------------------------------------*
Name: $Sub$$stupInitSections
Description: Initialize Sections Patch
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
ASM void $Sub$$stupInitSections(void)
{
INASM_EXTERN( __main )
b __main // call __scatterload and __rt_entry
}
/*---------------------------------------------------------------------------*
Name: main
Description: BromSpMain hook for scatterload
Arguments: None
Returns: None
*---------------------------------------------------------------------------*/
int main( void )
{
BromSpMain();
return 0;
}

View File

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - library - init
File: crt0_secure.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 <brom/code32.h>
#include <brom/os.h>
#include <brom/mi.h>
//#define BROM_ENABLE_BOOTROM_WRITE
//#define BROM_DISABLE_BOOTROM_PROT
/*---------------------------------------------------------------------------*
Name: STUPi_StartHandler
Description: start handler
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void STUPi_StartHandler( void )
{
PRESERVE8
INASM_EXTERN( SWI_TableEnd )
INASM_EXTERN( BromSpMain )
INASM_EXTERN( main )
#ifndef BROM_ENABLE_BOOTROM_WRITE
ldr r3, =REG_DEVROM_ADDR
ldrb r1, [r3]
bic r1, #REG_CFG_DEVROM_WE_MASK
strb r1, [r3]
#endif // BROM_ENABLE_BOOTROM_WRITE
//---- set IME = 0
// ( use that LSB of HW_REG_BASE equal to 0 )
mov r12, #HW_REG_BASE
str r12, [r12, #REG_IME_OFFSET]
#ifndef BROM_DISABLE_BOOTROM_PROT
// init BROM prot
ldr r3, =REG_PROT_ADDR
ldr r1, =4*8 // 0x1204
strh r1, [r3]
#endif // BROM_DISABLE_BOOTROM_PROT
//---- initialize stack pointer
// SVC mode
mov r0, #HW_PSR_SVC_MODE
msr cpsr_c, r0
ldr sp, =HW_PRV_WRAM_SVC_STACK_END
// IRQ mode
mov r0, #HW_PSR_IRQ_MODE
msr cpsr_c, r0
ldr r0, =HW_PRV_WRAM_IRQ_STACK_END
mov sp, r0
// System mode
ldr r1, =HW_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
//---- clear wram top
// 1KB
mov r0, #0
ldr r1, =HW_WRAM_AREA_END
mov r2, #0x0400
sub r1, r1, r2
bl STUPi_CpuClear32
//---- mapping WRAM for itself
bl STUPi_MappingWram
//---- lnitialize sections
bl stupInitSections
//---- start (to 16bit code)
ldr r1, =BromSpMain
adr lr, terminate
bx r1
terminate
b terminate
}
#include <./crt0_misc_sp.c>

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - library - init
File: crt0_excpHandler.c
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#include <brom/code32.h>
#include <brom/os.h>
#include <brom/swi.h>
/*---------------------------------------------------------------------------*
Name: STUPi_DbgHandler
Description: Debug (FIQ, etc) handler
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
#ifdef SDK_ARM9
#define BROM_EXCP_STACK_SIZE 16
#else // SDK_ARM7
#define BROM_EXCP_STACK_SIZE 12
#endif // SDK_ARM7
asm void STUPi_DbgHandler( void )
{
mrs sp, cpsr // IRQ/FIQ不許可
orr sp, sp, #HW_PSR_IRQ_DISABLE | HW_PSR_FIQ_DISABLE
msr cpsr_cxsf, sp
#ifdef SDK_ARM9
ldr sp, =HW_EXCP_VECTOR_MAIN
#else // SDK_ARM7
ldr sp, =HW_BROM_SYSRV_END - HW_BROM_SYSRV_IOFS_EXCP_VECTOR
#endif // SDK_ARM7
add sp, sp, #1
fiq_m
stmfd sp!, {r12, lr} // レジスタの退避合計4ワード
mrs lr, spsr
#ifdef SDK_ARM7
stmfd sp!, {lr}
#else // SDK_ARM9
mrc p15, 0, r12, c1, c0, 0 // コプロセッサ・マスタ退避
stmfd sp!, {r12, lr}
bic r12, r12, #HW_C1_PROTECT_UNIT_ENABLE
mcr p15, 0, r12, c1, c0, 0
#endif // SDK_ARM9
bic r12, sp, #1 // デバッガ処理へジャンプ
ldr r12, [r12, #BROM_EXCP_STACK_SIZE]
cmp r12, #0
#ifdef SDK_ARM9
blxne r12
#else // SDK_ARM7
adr lr, fiq_return
bxne r12
#endif // SDK_ARM7
fiq_return
#ifdef SDK_ARM9
ldmfd sp!, {r12, lr}
mcr p15, 0, r12, c1, c0, 0
#else // SDK_ARM7
ldmfd sp!, {lr}
#endif // SDK_ARM7
msr spsr_sxcf, lr
ldmfd sp!, {r12, lr}
subs pc, lr, #4
LTORG
}
/*---------------------------------------------------------------------------*
Name: STUPi_IrqHandler
Description: IRQ handler
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void STUPi_IrqHandler( void )
{
stmfd sp!, {r0-r3,r12,lr} // レジスタの退避6ワード
#ifdef SDK_ARM9
mrc p15, 0, r0, c9, c1, 0 // DTCMアドレス獲得
mov r0, r0, lsr #HW_C9_TCMR_BASE_SHIFT
mov r0, r0, lsl #HW_C9_TCMR_BASE_SHIFT
add r0, r0, #HW_DTCM_SIZE
#else // SDK_ARM7
#ifdef BROM_SYSRV_LOWVEC
ldr r0, =HW_BROM_SYSRV_END
#else // BROM_SYSRV_HIGHVEC
mov r0, #HW_BROM_SYSRV_END
#endif // BROM_SYSRV_HIGHVEC
#endif // SDK_ARM7
adr lr, irq_return
ldr pc, [r0, #-HW_BROM_SYSRV_IOFS_INTR_VECTOR]
irq_return
ldmfd sp!, {r0-r3,r12,lr}
subs pc, lr, #4
LTORG
}
/*---------------------------------------------------------------------------*
Name: STUPi_SwiHandler
Description: SWI handler
Arguments: None
Returns: None.
*---------------------------------------------------------------------------*/
asm void STUPi_SwiSemihosting( void )
{
ldmfd sp!, {r11, r12, lr}
semi_vector
movs pc, lr
}
asm void STUPi_SwiHandler( void )
{
stmfd sp!, {r11, r12, lr} // SVCモード レジスタ退避
ldrh r12, [lr, #-2] // システムコールNo取得ハーフワードアクセス対応
mov r12, r12, lsl #1
and r12, r12, #SVC_ID_PREMASK<<SVC_ID_SHIFT
cmp r12, #(SVC_ID_SEMIHOST_ARM & SVC_ID_PREMASK)<<SVC_ID_SHIFT // SVC_ID_SEMIHOST_ARM = 0x12
cmpne r12, #(SVC_ID_SEMIHOST_THUMB & SVC_ID_PREMASK)<<SVC_ID_SHIFT // SVC_ID_SEMIHOST_THUMB = 0xab
beq STUPi_SwiSemihosting
adr r11, SWI_Table // システムコールアドレス 取得
ldrh r12, [r11, r12]
#ifdef SDK_ARM9
adr r11, _start // = HW_BIOS
orr r12, r12, r11
#endif // SDK_ARM9
mrs r11, spsr // SVCモード SPSR退避合計4ワード
stmfd sp!, {r11}
and r11, r11, #HW_PSR_IRQ_DISABLE // IRQ許可状態 コピー
orr r11, r11, #HW_PSR_SYS_MODE // システムモードへ切り換え & FIQ許可
msr cpsr_cxsf,r11
stmfd sp!, {r2, lr} // システムモード レジスタ退避2ワード
#ifdef SDK_ARM9
blx r12
#else // SDK_ARM7
adr lr, swi_return
bx r12
#endif // SDK_ARM7
swi_return
ldmfd sp!, {r2, lr} // システムモード レジスタ復帰
mov r12, #0xc0 | HW_PSR_SVC_MODE // SVCモードへ切り換え
msr cpsr_cxsf, r12 // & IRQ/FIQ不許可
ldmfd sp!, {r11} // SVCモード レジスタ復帰
msr spsr_cxsf, r11
semi_return
ldmfd sp!, {r11, r12, lr}
movs pc, lr
LTORG
#include <../build/libraries/swi/common/swi_table.c>
}

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - SWI
File: swi_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: $
*---------------------------------------------------------------------------*/
// TWL
#ifndef BROMDEV_DISABLE_SECURE_SVC
INASM_EXTERN( ACSign_HeapInit )
INASM_EXTERN( ACSign_DecryptoCore )
INASM_EXTERN( ACSign_Decrypto )
INASM_EXTERN( ACSign_DecryptoDER )
INASM_EXTERN( ACSign_DigestUnit )
INASM_EXTERN( ACSign_CompareUnit )
INASM_EXTERN( ACSign_GetKey )
INASM_EXTERN( SHA1_Init )
INASM_EXTERN( SHA1_Update )
INASM_EXTERN( SHA1_Final )
#endif // BROMDEV_DISABLE_SECURE_SVC
INASM_EXTERN( SWI_UnCompLZ77Stream )
INASM_EXTERN( SWIi_Terminate )
// DS compatible
INASM_EXTERN( SWI_WaitByLoop )
INASM_EXTERN( SWI_WaitIntr )
INASM_EXTERN( SWI_WaitVBlankIntr )
INASM_EXTERN( SWI_Halt )
#ifdef SDK_ARM7
INASM_EXTERN( SWI_Sleep )
INASM_EXTERN( SWI_ChangeSoundBias )
#endif // SDK_ARM7
INASM_EXTERN( SWI_DivS32 )
INASM_EXTERN( SWI_SqrtU32 )
INASM_EXTERN( SWI_GetCRC16 )
INASM_EXTERN( SWI_CpuSet )
INASM_EXTERN( SWI_CpuSetFast )
INASM_EXTERN( SWI_UnPackBits32 )
INASM_EXTERN( SWI_UnCompLZ77Byte )
INASM_EXTERN( SWI_UnCompLZ77Short )
INASM_EXTERN( SWI_UnCompHuffman )
INASM_EXTERN( SWI_UnCompRLByte )
INASM_EXTERN( SWI_UnCompRLShort )
INASM_EXTERN( SWI_GetSinTable )
INASM_EXTERN( SWI_GetPitchTable )
INASM_EXTERN( SWI_GetVolumeTable )
#ifdef SDK_ARM9
INASM_EXTERN( SWI_UnDiffByte2Byte )
INASM_EXTERN( SWI_UnDiffShort2Short )
INASM_EXTERN( SWI_SetPauseReg )
#else // SDK_ARM7
INASM_EXTERN( SWI_GetFuncp4IPL2 )
INASM_EXTERN( SWI_SetPauseHi )
#endif // SDK_ARM7
EXPORT SWI_Table
EXPORT SWI_TableEnd
SWI_Table
DCW SWIi_Terminate // 0
DCW SWI_UnCompLZ77Stream // 1
DCW SWI_UnCompLZ77Short+1 // 2
DCW SWI_WaitByLoop // 3
DCW SWI_WaitIntr // 4
DCW SWI_WaitVBlankIntr // 5
DCW SWI_Halt // 6
#ifdef SDK_ARM9
DCW SWIi_Terminate // 7
DCW SWIi_Terminate // 8
#else // SDK_ARM7
DCW SWI_Sleep // 7
DCW SWI_ChangeSoundBias+1 // 8
#endif // SDK_ARM7
DCW SWI_DivS32 // 9
DCW SWIi_Terminate // 10
DCW SWI_CpuSet+1 // 11
DCW SWI_CpuSetFast // 12
DCW SWI_SqrtU32 // 13
DCW SWI_GetCRC16+1 // 14
DCW SWIi_Terminate // 15
DCW SWI_UnPackBits32 // 16
DCW SWI_UnCompLZ77Byte // 17
DCW SWI_UnCompLZ77Short+1 // 18 overlap semihosting ((0x123456>>16) & 0x3f == 0x12)
DCW SWI_UnCompHuffman+1 // 19
DCW SWI_UnCompRLByte+1 // 20
DCW SWI_UnCompRLShort+1 // 21
#ifdef SDK_ARM9
DCW SWI_UnDiffByte2Byte+1 // 22
DCW SWIi_Terminate // 23
DCW SWI_UnDiffShort2Short+1 // 24
DCW SWI_UnCompLZ77Short+1 // 25
DCW SWIi_Terminate // 26
DCW SWIi_Terminate // 27
DCW SWIi_Terminate // 28
DCW SWIi_Terminate // 29
DCW SWIi_Terminate // 30
DCW SWI_SetPauseReg // 31
#else // SDK_ARM7
DCW SWIi_Terminate // 22
DCW SWIi_Terminate // 23
DCW SWIi_Terminate // 24
DCW SWI_UnCompLZ77Short+1 // 25
DCW SWI_GetSinTable+1 // 26
DCW SWI_GetPitchTable+1 // 27
DCW SWI_GetVolumeTable+1 // 28
DCW SWI_GetFuncp4IPL2 // 29
DCW SWIi_Terminate // 30
DCW SWI_SetPauseHi // 31
#endif // SDK_ARM7
#ifndef BROMDEV_DISABLE_SECURE_SVC
DCW ACSign_HeapInit+1 // 32
DCW ACSign_DecryptoCore+1 // 33
DCW ACSign_Decrypto+1 // 34
DCW ACSign_DecryptoDER+1 // 35
DCW SHA1_Init+1 // 36
DCW SHA1_Update+1 // 37
DCW SHA1_Final+1 // 38
DCW ACSign_DigestUnit+1 // 39
DCW ACSign_CompareUnit+1 // 40
DCW ACSign_GetKey+1 // 41
#else // BROMDEV_DISABLE_SECURE_SVC
DCW SWIi_Terminate // 32
DCW SWIi_Terminate // 33
DCW SWIi_Terminate // 34
DCW SWIi_Terminate // 35
DCW SWIi_Terminate // 36
DCW SWIi_Terminate // 37
DCW SWIi_Terminate // 38
DCW SWIi_Terminate // 39
DCW SWIi_Terminate // 40
DCW SWIi_Terminate // 41
#endif // BROMDEV_DISABLE_SECURE_SVC
DCW SWIi_Terminate // 42
DCW SWIi_Terminate // 43 overlap semihosting (0xab & 0x3f == 0x2b)
DCW SWIi_Terminate // 44
DCW SWIi_Terminate // 45
DCW SWIi_Terminate // 46
DCW SWIi_Terminate // 47
DCW SWIi_Terminate // 48
DCW SWIi_Terminate // 49
DCW SWIi_Terminate // 50
DCW SWIi_Terminate // 51
DCW SWIi_Terminate // 52
DCW SWIi_Terminate // 53
DCW SWIi_Terminate // 54
DCW SWIi_Terminate // 55
DCW SWIi_Terminate // 56
DCW SWIi_Terminate // 57
DCW SWIi_Terminate // 58
DCW SWIi_Terminate // 59
DCW SWIi_Terminate // 60
DCW SWIi_Terminate // 61
DCW SWIi_Terminate // 62
DCW SWIi_Terminate // 63
SWI_TableEnd

View File

@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom
File: brom.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_H_
#define BROM_H_
#include <brom/c_extension.h>
#include <brom/types.h>
#include <brom/memorymap.h>
#include <ctr/hw/common/armArch.h>
#include <brom/init.h>
//#include <brom/os.h>
/* BROM_H_ */
#endif

View File

@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - HW - include
File: brom_defs.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_DEFS_H_
#define BROM_DEFS_H_
//#define BROM_SYSRV_LOWVEC
//#define BROM_ENABLE_BOOTROM_WRITE
//#define BROM_ENABLE_INITIAL_STACKHEAP
//#define BROM_ENABLE_WRAMEMU
//#define BROM_FOR_DSP_DEV
//#define BROM_FORCE_DEBUGGER
/* BROM_DEFS_H_ */
#endif

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - - types definition
File: c_extension.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_C_EXTENSION_H_
#define BROM_C_EXTENSION_H_
#ifdef __cplusplus
extern "C" {
#endif
// INLINE
#if defined( __CC_ARM )
#define inline __inline
#define INLINE __inline
#elif defined( __MWERKS__ )
#define INLINE inline
#elif defined( __GNUC__ )
#define INLINE inline
#endif // __GNUC__
// ASM
#if defined( __CC_ARM )
#define ASM __asm
#define asm __asm
#elif defined( __MWERKS__ )
#define ASM asm
#elif defined( __GNUC__ )
#define ASM asm
#endif // __GNUC__
// INASM_ALIGN
#if defined( __CC_ARM )
#define INASM_ALIGN(align) ALIGN align
#elif defined( __MWERKS__ )
#elif defined( __GNUC__ )
#endif // __GNUC__
// INASM_SECTION
#if defined( __CC_ARM )
#define INASM_SECTION(secname, attr0, attr1) AREA secname,attr0,attr1
#elif defined( __MWERKS__ )
#elif defined( __GNUC__ )
#endif // __GNUC__
// INASM_EXTERN
#if defined( __CC_ARM )
#define INASM_EXTERN(sym) EXTERN sym
#elif defined( __MWERKS__ )
#define INASM_EXTERN(sym)
#elif defined( __GNUC__ )
#define INASM_EXTERN(sym) .extern sym
#endif // __GNUC__
// INASM_SPACE
#if defined( __CC_ARM )
#define INASM_SPACE(size) SPACE (size)
#elif defined( __MWERKS__ )
#define INASM_SPACE(size) .space (size)
#elif defined( __GNUC__ )
#define INASM_SPACE(size) .space (size)
#endif // __GNUC__
// LSYM
#if defined( __CC_ARM )
#define LSYM( no ) no
#define BSYM( no ) %b##no
#define FSYM( no ) %f##no
#elif defined( __MWERKS__ )
#define LSYM( no ) @##no
#define BSYM( no ) @##no
#define FSYM( no ) @##no
#elif defined( __GNUC__ )
#define LSYM( no ) no // add ':' later
#define BSYM( no ) no##b
#define FSYM( no ) no##f
#endif // __GNUC__
// SDK_OP_ADR
#if defined( __CC_ARM )
#define SDK_OP_ADR adr
#elif defined( __MWERKS__ )
#define SDK_OP_ADR lda
#elif defined( __GNUC__ )
#define SDK_OP_ADR adr
#endif // __GNUC__
// ATTRIBUTE_ALIGN
#if defined( __CC_ARM )
#define ATTRIBUTE_ALIGN(n) __attribute__ ((aligned(n)))
#elif defined(__MWERKS__)
#define ATTRIBUTE_ALIGN(n) __attribute__ ((aligned(n)))
#elif defined( __GNUC__ )
#define ATTRIBUTE_ALIGN(n) __attribute__ ((aligned(n)))
#endif
// ATTRIBUTE_SECTION
#if defined( __CC_ARM )
#define ATTRIBUTE_SECTION(s) __attribute__ ((section(#s)))
#elif defined(__MWERKS__)
#define ATTRIBUTE_SECTION(s) __attribute__ ((section(#s)))
#elif defined( __GNUC__ )
#define ATTRIBUTE_SECTION(s) __attribute__ ((section(#s)))
#endif
// ATTRIBUTE_WEAK
#if defined( __CC_ARM )
#define ATTRIBUTE_WEAK(n) __attribute__ ((weak))
#elif defined(__MWERKS__)
#define ATTRIBUTE_WEAK(n) __attribute__ ((weak))
#elif defined( __GNUC__ )
#define ATTRIBUTE_WEAK(n) __attribute__ ((weak))
#endif
// SDK_WEAK_SYMBOL
#if defined( __CC_ARM )
#define SDK_WEAK_SYMBOL __weak
#elif defined(__MWERKS__)
#define SDK_WEAK_SYMBOL __declspec(weak)
#elif defined( __GNUC__ )
#define SDK_WEAK_SYMBOL __attribute__ ((weak))
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // BROM_C_EXTENSION_H_

View File

@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - include
File: code16.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#if defined(SDK_CW) || defined(__MWERKS__)
#pragma thumb on
#elif defined(SDK_RVCT)|| defined(__CC_ARM)
#pragma thumb
#elif defined(SDK_GCC)
TO BE DEFINED
#endif
// Prepare to switch the definition of FX_Mul
#ifdef FX_Mul
#undef FX_Mul
#endif
// Prepare to switch the definition of FX_MulFx64c
#ifdef FX_Mul32x64c
#undef FX_Mul32x64c
#endif
// Prepare to switch the definition of MATH_CountLeadingZeros
#ifdef MATH_CountLeadingZeros
#undef MATH_CountLeadingZeros
#endif
// Because CPU is in ARM mode, function versions are used.
#define FX_Mul(v1, v2) FX_MulFunc(v1, v2)
#define FX_Mul32x64c(v32, v64c) FX_Mul32x64cFunc(v32, v64c)
#define MATH_CountLeadingZeros(x) MATH_CountLeadingZerosFunc(x)

View File

@ -0,0 +1,42 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - include
File: code32.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
//
// include this instead of using C99 pragma extensions for compatibility
//
#if defined(SDK_CW) || defined(__MWERKS__)
#pragma thumb off
#elif defined(SDK_RVCT) || defined(__CC_ARM)
#pragma arm
#elif defined(SDK_GCC)
TO BE DEFINED
#endif
// Prepare to switch the definition of FX_Mul
#ifdef FX_Mul
#undef FX_Mul
#endif
// Prepare to switch the definition of FX_MulFx64c
#ifdef FX_Mul32x64c
#undef FX_Mul32x64c
#endif
// Prepare to switch the definition of MATH_CountLeadingZeros
#ifdef MATH_CountLeadingZeros
#undef MATH_CountLeadingZeros
#endif
// Because CPU is in ARM mode, inline versions are used.
#define FX_Mul(v1, v2) FX_MulInline(v1, v2)
#define FX_Mul32x64c(v32, v64c) FX_Mul32x64cInline(v32, v64c)
#define MATH_CountLeadingZeros(x) MATH_CountLeadingZerosInline(x)

View File

@ -0,0 +1,21 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - include
File: codereset.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifdef SDK_CODE_ARM // switch by default codegen
#include <brom/code32.h>
#else //SDK_CODE_THUMB
#include <brom/code16.h>
#endif

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - HW - include
File: mmap_brom.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_HW_ARM9_MMAP_BROM_H_
#define BROM_HW_ARM9_MMAP_BROM_H_
#include <brom/brom_defs.h>
#include <ctr/hw/ARM9/mmap_global.h>
#include <firm/hw/ARM9/mmap_firm.h>
#ifdef __cplusplus
extern "C" {
#endif
//------------------------------------- BROM
#ifdef BROM_ENABLE_WRAMEMU
#define HW_BROM HW_WRAM
#else // BROM_ENABLE_WRAMEMU
#define HW_BROM HW_BIOS
#endif
#define HW_BROM_END (HW_BROM + HW_BROM_SIZE)
#define HW_BROM_SIZE 0x10000 // 64KB
#define HW_BROM_NML HW_BROM
#define HW_BROM_NML_END (HW_BROM_NML + HW_BROM_NML_SIZE)
#define HW_BROM_NML_SIZE 0x8000 // 32KB
#define HW_BROM_SEC HW_BROM_NML_END
#define HW_BROM_SEC_END (HW_BROM_SEC + HW_BROM_SEC_SIZE)
#define HW_BROM_SEC_SIZE 0x8000 // 32KB
//------------------------------------- BROM_TEMP
#define HW_BROM_TEMP (HW_BROM_TEMP_END - HW_BROM_TEMP_SIZE)
#define HW_BROM_TEMP_END HW_BROM_WRAM
#define HW_BROM_TEMP_SIZE 0x1000 // 4KB
//------------------------------------- BROM_WRAM
#define HW_BROM_WRAM (HW_BROM_WRAM_END - HW_BROM_WRAM_SIZE)
#define HW_BROM_WRAM_END HW_BROM_TO_FIRM_BUF
#define HW_BROM_WRAM_SIZE 0xB000 // 44KB
//------------------------------------- HW_BROM_TO_FIRM_BUF
#define HW_BROM_TO_FIRM_BUF HW_FIRM_FROM_BROM_BUF // defined in mmap_firm.h
#define HW_BROM_TO_FIRM_BUF_END HW_FIRM_FROM_BROM_BUF_END
#define HW_BROM_TO_FIRM_BUF_SIZE HW_FIRM_FROM_BROM_BUF_SIZE // 12KB
//------------------------------------- HW_BROM_STACK
#define HW_BROM_STACK (HW_WRAM_AREA_END - 0x1000)
#define HW_BROM_STACK_END HW_BROM_SYSRV
#define HW_BROM_STACK_SIZE (HW_BROM_STACK_END - HW_BROM_STACK) // <20>à4KB
//------------------------------------- BROM_SYSRV
#ifdef BROM_SYSRV_LOWVEC
#define HW_BROM_SYSRV HW_PRV_WRAM_SYSRV
#define HW_BROM_SYSRV_END (HW_BROM_SYSRV + HW_BROM_SYSRV_SIZE)
#else // BROM_SYSRV_HIGHVEC
#define HW_BROM_SYSRV (HW_BROM_SYSRV_END - HW_BROM_SYSRV_SIZE)
#define HW_BROM_SYSRV_END HW_WRAM_AREA_END
#endif
#define HW_BROM_SYSRV_SIZE HW_PRV_WRAM_SYSRV_SIZE
#define HW_BROM_SYSRV_IOFS_EXCP_VECTOR (HW_PRV_WRAM_SYSRV_SIZE - HW_PRV_WRAM_SYSRV_OFS_EXCP_VECTOR)
#define HW_BROM_SYSRV_IOFS_INTR_CHECK (HW_PRV_WRAM_SYSRV_SIZE - HW_PRV_WRAM_SYSRV_OFS_INTR_CHECK)
#define HW_BROM_SYSRV_IOFS_INTR_CHECK2 (HW_PRV_WRAM_SYSRV_SIZE - HW_PRV_WRAM_SYSRV_OFS_INTR_CHECK2)
#define HW_BROM_SYSRV_IOFS_INTR_VECTOR (HW_PRV_WRAM_SYSRV_SIZE - HW_PRV_WRAM_SYSRV_OFS_INTR_VECTOR)
//------------------------------------- BIOS_ENTRY
#define HW_BIOS_ENTRY (HW_BIOS + 0x00bc)
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_HW_ARM9_MMAP_BROM_H_ */
#endif

View File

@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - HW - include
File: mmap_shared.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_HW_COMMON_MMAP_SHARED_H_
#define BROM_HW_COMMON_MMAP_SHARED_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_HW_COMMON_MMAP_SHARED_H_ */
#endif

View File

@ -0,0 +1,29 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - INIT
File: init.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_INIT_H_
#define BROM_INIT_H_
#include <brom/types.h>
#include <brom/memorymap.h>
#include <ctr/hw/common/arm_reg_common.h>
#include <brom/init/crt0.h>
#include <brom/init/stup.h>
/* BROM_INIT_H_ */
#endif

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - init - include
File: crt0.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_INIT_CRT0_H_
#define BROM_INIT_CRT0_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SDK_ARM11
void BromMain(void);
#else // SDK_ARM9
void BromSpMain(void);
#define BromMain BromSpMain
#endif // SDK_ARM9
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_INIT_CRT0_H_ */
#endif

View File

@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------*
Project: TwlBrom - init - include
File: stup.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.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#ifndef BROM_INIT_STUP_H_
#define BROM_INIT_STUP_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SDK_ARM11
void STUPi_PostMappingWram( void );
void STUPi_NotifyToARM9( u32 id );
void STUPi_WaitARM9( u32 id );
#else // SDK_ARM9
void STUPi_WaitSecureRomMask( void );
void STUPi_PostMappingWram( void );
void STUPi_NotifyToARM7( u32 id );
void STUPi_WaitARM7( u32 id );
#endif // SDK_ARM9
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_INIT_CRT0_H_ */
#endif

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - include - HW
File: memorymap.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_MEMORYMAP_H_
#define BROM_MEMORYMAP_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef SDK_ARM9
#include <brom/hw/ARM9/mmap_brom.h>
#include <firm/hw/ARM9/mmap_firm.h>
//#include <brom/hw/ARM9/mmap_tcm.h>
//#include <nitro/hw/ARM9/mmap_main.h>
//#include <nitro/hw/ARM9/mmap_vram.h>
#include <brom/hw/common/mmap_shared.h>
#else //SDK_ARM11
#include <brom/hw/ARM7/mmap_brom.h>
#include <firm/hw/ARM7/mmap_firm.h>
#include <brom/hw/ARM7/mmap_wram.h>
//#include <nitro/hw/ARM7/mmap_main.h>
#include <brom/hw/common/mmap_shared.h>
#endif
#include <ctr/ioreg.h>
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_MEMORYMAP_H_ */
#endif

View File

@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - include - HW
File: memorymap_sp.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef SDK_ARM9
#define SDK_ARM9
#endif
#ifdef SDK_ARM11
#undef SDK_ARM11
#endif
#include <brom/memorymap.h>

View File

@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - include -
File: misc.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_MISC_H_
#define BROM_MISC_H_
#include <ctr/misc.h>
#ifdef __cplusplus
extern "C" {
#endif
#define offsetof(t, memb) ((size_t)(&(((t *)0)->memb)))
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_MISC_H_ */
#endif

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - OS
File: os.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_OS_H_
#define BROM_OS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <brom/types.h>
#include <brom/memorymap.h>
#include <ctr/hw/common/arm_reg_common.h>
#include <brom/init/crt0.h>
#if 0
#include <brom/os/common/systemWork.h>
#include <brom/os/common/system.h>
#include <brom/os/common/init.h>
#include <brom/os/common/exception.h>
#include <brom/os/common/interrupt.h>
#include <brom/os/common/printf.h>
#include <brom/os/common/spinLock.h>
#include <brom/os/common/systemCall.h>
#include <brom/os/common/timer.h>
#include <brom/os/common/tick.h>
#include <brom/os/common/boot.h>
#ifdef SDK_ARM9
#include <brom/os/ARM9/protectionUnit.h>
#include <brom/os/ARM9/protectionRegion.h>
#include <brom/os/ARM9/cache.h>
#include <brom/os/ARM9/tcm.h>
#endif // SDK_ARM9
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_OS_H_ */
#endif

View File

@ -0,0 +1,32 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - SWI
File: swi.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_SWI_H_
#define BROM_SWI_H_
#ifdef __cplusplus
extern "C" {
#endif
//#include <brom/swi/swi.h>
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_SWI_H_ */
#endif

View File

@ -0,0 +1,188 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - swi - include
File: swi.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Log: $
$NoKeywords: $
*---------------------------------------------------------------------------*/
#ifndef BROM_SWI_SWI_H_
#define BROM_SWI_SWI_H_
#include <brom/misc.h>
#include <brom/types.h>
#include <brom/memorymap.h>
#include <ctr/ioreg.h>
#include <brom/os.h>
#if 0
#include <brom/mi/stream.h>
#include <brom/mi/uncompress.h>
#include <firm/os/common/systemCall.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
void SWI_Halt( void );
void SWI_WaitByLoop( s32 count );
void SWI_WaitIntr( BOOL clear, OSIrqMask mask );
void SWI_WaitVBlankIntr( void );
void SWI_CpuSet( const void* src, void* dest, u32 dmaCntData );
void SWI_CpuSetFast( const void* src, void* dest, u32 dmaCntData );
void SWI_UnPackBits32( const void* src, void* dest, const MIUnpackBitsParam *paramp );
void SWI_UnCompLZ77Byte( const void* src, void* dest );
void SWI_UnCompRLByte( const void* src, void* dest );
s32 SWI_DivS32( s32 number, s32 denom );
u16 SWI_SqrtU32( u32 src );
u16 SWI_GetCRC16( u32 start, const u16 *datap, u32 size );
s32 SWI_UnCompHuffman( const u8 *srcp, u32 *destp, u8 *tableBufp, const MIReadStreamCallbacks *scb );
s32 SWI_UnCompLZ77Short( const u8 *srcp, u16 *destp, const void *paramp, const MIReadStreamCallbacks *scb );
s32 SWI_UnCompRLShort( const u8 *srcp, u16 *destp, const void *paramp, const MIReadStreamCallbacks *scb );
s32 SWI_UnCompLZ77Stream( const u8 *srcp, u8 *destp, const void *paramp, const MIReadStreamCallbacks *scb );
u32 SWI_GetSinTable( s32 index );
u32 SWI_GetPitchTable( s32 index);
u32 SWI_GetVolumeTable( s32 index );
void SWIi_Terminate( void );
#ifdef SDK_ARM9
void SWI_SetPauseReg( u32 w );
void SWI_UnDiffByte2Byte( const void *src, void *dest );
void SWI_UnDiffShort2Short( const void *src, void *dest );
#else // SDK_ARM7
void SWI_Sleep( void );
void SWI_SetPauseHi( u32 dummy0, u32 dummy1, u8 b );
void SWI_SetPauseCheckFlag( void );
void SWI_ChangeSoundBias16( u32 UpDown, u32 stepLoops );
#endif
/*---------------------------------------------------------------------------*
Name: SWI_CpuClear
Description: clear memory by SWI_CpuSet
CPUでRAMクリアします
data
destp
size
bit 16|32
Arguments: data : clear data
destp : destination address
size : clear size ( by byte )
bit : bit width ( 16 or 32 )
Returns: None
*---------------------------------------------------------------------------*/
#define SWI_CpuClear( data, destp, size, bit ) \
do{ \
vu##bit tmp = (vu##bit )(data); \
SWI_CpuSet((u8 *)&(tmp), (u8 *)(destp), ( \
MI_DMA_SRC_FIX | \
MI_DMA_##bit##BIT_BUS | ((size)/((bit)/8) & 0x1fffff))); \
} while(0)
/*---------------------------------------------------------------------------*
Name: SWI_CpuCopy
Description: copy memory by SWI_CpuSet
CPUでコピーします
srcp :
destp :
size :
bit : 16|32
Arguments: srcp : source address
destp : destination address
size : size to copy ( by byte )
bit : bit width ( 16 or 32 )
Returns: None
*---------------------------------------------------------------------------*/
#define SWI_CpuCopy( srcp, destp, size, bit ) \
\
SWI_CpuSet((u8 *)(srcp), (u8 *)(destp), ( \
MI_DMA_SRC_INC | \
MI_DMA_##bit##BIT_BUS | ((size)/((bit)/8) & 0x1fffff)))
/*---------------------------------------------------------------------------*
Name: SWI_CpuClearFast
Description: clear memory by SWI_CpuSetFast quickly
CPUで高速にRAMクリアするシステムコールを呼び出します
32Byte単位でアクセス可能な時には32Byte単位の複数ストア命令が使用され
4Byte単位でアクセスされます
data
destp
size
Arguments: data : clear data
destp : destination address
size : clear size ( by byte )
Returns: None
*---------------------------------------------------------------------------*/
#define SWI_CpuClearFast( data, destp, size ) \
do{ \
vu32 tmp = (vu32 )(data); \
SWI_CpuSetFast((u8 *)&(tmp), (u8 *)(destp), ( \
MI_DMA_SRC_FIX | ((size)/(32/8) & 0x1fffff))); \
} while(0)
/*---------------------------------------------------------------------------*
Name: SWI_CpuCopyFast
Description: clear memory by SWI_CpuSetFast quickly
CPUで高速にコピーします
32Byte単位でアクセス可能な時には複数ロード使
4Byte単位でアクセスされます
srcp
destp
size
Arguments: srcp : source address
destp : destination address
size : size to copy ( by byte )
Returns: None
*---------------------------------------------------------------------------*/
#define SWI_CpuCopyFast( srcp, destp, size ) \
\
SWI_CpuSetFast((u8 *)(srcp), (u8 *)(destp), ( \
MI_DMA_SRC_INC | ((size)/(32/8) & 0x1fffff)))
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_SWI_SWI_H_ */
#endif

View File

@ -0,0 +1,32 @@
/*---------------------------------------------------------------------------*
Project: CtrBrom - - types definition
File: types.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef BROM_TYPES_H_
#define BROM_TYPES_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <ctr/types.h>
#ifdef __cplusplus
} /* extern "C" */
#endif
/* BROM_TYPES_H_ */
#endif

View File

@ -23,6 +23,8 @@ SPACE ?= $(EMPTY) $(EMPTY)
RVCT_PATH ?= $(ARMROOT)\RVCT
RVCT_ROOT = $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(RVCT_PATH))))
RVCT_BINDIR = $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(RVCT30BIN))))
RVCT_ROOT_NOSPACE = $(call encode_specialchar,$(call cygpathm,$(RVCT_ROOT)))
RVCT_BINDIR_NOSPACE = $(call encode_specialchar,$(call cygpathm,$(RVCT30BIN)))
#----------------------------------------------------------------------------

View File

@ -15,7 +15,7 @@
# $NoKeywords: $
#----------------------------------------------------------------------------
AINCLUDE_DIRS = $(LINCLUDES) $(EINCLUDES) $(GINCLUDES) $(RVCT_INCDIRS)
AINCLUDE_DIRS = $(LINCLUDES) $(EINCLUDES) $(GINCLUDES) # $(RVCT_INCDIRS)
ALIBRARY_DIRS = $(LLIBRARY_DIRS) $(ELIBRARY_DIRS) $(GLIBRARY_DIRS) # $(RVCT_LIBDIRS)
ALIBRARIES = $(LLIBRARIES) $(ELIBRARIES) $(GLIBRARIES)
@ -39,7 +39,7 @@ INCLUDE_DIRS = $(subst \ -I,\ ,$(addprefix -I,$(shell $(CYGPATH) -m $(AINCLUDE_
LIBRARY_DIRS = $(subst \ -L,\ ,$(addprefix --userlibpath ,$(shell $(CYGPATH) -m $(ALIBRARY_DIRS))))
LIBRARIES = $(subst \ -l,\ ,$(addprefix -l,$(shell $(CYGPATH) -m $(ALIBRARIES))))
INCLUDES = -I. $(INCLUDE_DIRS)
INCLUDES = -I. $(INCLUDE_DIRS) -I$(RVCT_INCDIRS)
#----------------------------------------------------------------------------

View File

@ -10,9 +10,9 @@
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: #$
$Rev: $
$Author: $
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef CTR_HW_ARM9_MMAP_GLOBAL_H_
#define CTR_HW_ARM9_MMAP_GLOBAL_H_

View File

@ -14,8 +14,8 @@
$Rev: 37 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef CTR_HW_ARM_REG_COMMON_H_
#define CTR_HW_ARM_REG_COMMON_H_
#ifndef CTR_HW_COMMON_ARM_REG_COMMON_H_
#define CTR_HW_COMMON_ARM_REG_COMMON_H_
#ifdef __cplusplus
extern "C" {
@ -70,5 +70,5 @@ extern "C" {
} // extern "C"
#endif
// CTR_HW_ARM_REG_COMMON_H_
// CTR_HW_COMMON_ARM_REG_COMMON_H_
#endif

21
trunk/include/ctr/ioreg.h Normal file
View File

@ -0,0 +1,21 @@
/*---------------------------------------------------------------------------*
Project: CtrFirm - IO Register List -
File: ctr/ioreg.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifdef SDK_ARM11
#include <ctr/hw/ARM11/ioreg.h>
#else //SDK_ARM9
#include <ctr/hw/ARM9/ioreg.h>
#endif

333
trunk/include/ctr/misc.h Normal file
View File

@ -0,0 +1,333 @@
/*---------------------------------------------------------------------------*
Project: CtrFirm - include -
File: misc.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef CTR_MISC_H_
#define CTR_MISC_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SDK_WIN32
#include <ctr/os/common/printf.h>
#endif
//--------------------------------------------------------------------------------
// C++用マクロ
//
#ifdef __cplusplus
#define SDK_IFDEFCPP extern "C" {
#define SDK_ENDIFCPP }
#else
#define SDK_IFDEFCPP
#define SDK_ENDIFCPP
#endif
//--------------------------------------------------------------------------------
// Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_ASSERT
#define SDK_ASSERT(exp) \
(void) ((exp) || (OSi_Panic(__FILE__, __LINE__, "Failed assertion " #exp), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_ASSERT
#define SDK_ASSERT(exp) ((void) 0)
#endif
#endif // SDK_DEBUG
/* コンパイル時チェック */
#define SDK_COMPILER_ASSERT(expr) \
extern void sdk_compiler_assert ## __LINE__ ( char is[(expr) ? +1 : -1] )
//--------------------------------------------------------------------------------
// Assert message
//
#ifdef SDK_DEBUG
#ifndef SDK_ASSERTMSG
#define SDK_ASSERTMSG(exp, ...) \
(void) ((exp) || (OSi_Panic(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#ifndef SDK_TASSERTMSG
#define SDK_TASSERTMSG(exp, ...) \
(void) ((exp) || (OSi_TPanic(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_ASSERTMSG
#define SDK_ASSERTMSG(exp, ...) ((void) 0)
#endif
#ifndef SDK_TASSERTMSG
#define SDK_TASSERTMSG(exp, ...) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Assert value
//
#ifdef SDK_DEBUG
#ifndef SDK_ASSERT_INT
#define SDK_ASSERT_INT(exp, value) \
(void) ((exp) || (OSi_Panic(__FILE__, __LINE__, "Failed assertion %s : %s = %p", #exp, #value, value), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_ASSERT_INT
#define SDK_ASSERT_INT(exp, value) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Warning
//
#ifdef SDK_DEBUG
#ifndef SDK_WARNING
#define SDK_WARNING(exp, ...) \
(void) ((exp) || (OSi_Warning(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#ifndef SDK_TWARNING
#define SDK_TWARNING(exp, ...) \
(void) ((exp) || (OSi_TWarning(__FILE__, __LINE__, __VA_ARGS__), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_WARNING
#define SDK_WARNING(exp, ...) ((void) 0)
#endif
#ifndef SDK_TWARNING
#define SDK_TWARNING(exp, ...) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// NULL Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_NULL_ASSERT
#define SDK_NULL_ASSERT(exp) \
(void) (((exp) != NULL) || (OSi_Panic(__FILE__, __LINE__, "Pointer must not be NULL ("#exp")"), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_NULL_ASSERT
#define SDK_NULL_ASSERT(exp) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Check Pointer
//
#ifdef SDK_DEBUG
#ifndef SDK_IS_VALID_POINTER
#define SDK_IS_VALID_POINTER(exp) ( (0x01000000 <= ((u32)(exp))) && (((u32)(exp)) < 0x10000000) )
//#define SDK_IS_VALID_POINTER(exp) ((exp) != NULL)
#endif
#else // SDK_DEBUG
#ifndef SDK_IS_VALID_POINTER
#define SDK_IS_VALID_POINTER(exp) (TRUE)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Pointer Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_POINTER_ASSERT
#define SDK_POINTER_ASSERT(exp) \
(void) (SDK_IS_VALID_POINTER(exp) || (OSi_Panic(__FILE__, __LINE__, "%s(=%p) is not valid pointer", #exp, (exp)), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_POINTER_ASSERT
#define SDK_POINTER_ASSERT(exp) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Pointer or NULL Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_POINTER_OR_NULL_ASSERT
#define SDK_POINTER_OR_NULL_ASSERT(exp) \
(void) (((exp) == NULL) || SDK_IS_VALID_POINTER(exp) || (OSi_Panic(__FILE__, __LINE__, "%s(=%p) must be NULL or valid pointer", #exp, (exp)), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_POINTER_OR_NULL_ASSERT
#define SDK_POINTER_OR_NULL_ASSERT(exp) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Min Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_MIN_ASSERT
#define SDK_MIN_ASSERT(exp, min) \
(void) (((exp) >= (min)) || \
(OSi_Panic(__FILE__, __LINE__, #exp " is out of bounds(%d)\n%d <= "#exp" not satisfied.", exp, min), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_MIN_ASSERT
#define SDK_MIN_ASSERT(exp, min) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Max Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_MAX_ASSERT
#define SDK_MAX_ASSERT(exp, max) \
(void) (((exp) <= (max)) || \
(OSi_Panic(__FILE__, __LINE__, #exp " is out of bounds(%d)\n"#exp" <= %d not satisfied.", exp, max), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_MAX_ASSERT
#define SDK_MAX_ASSERT(exp, max) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Min Max Assert
//
#ifdef SDK_DEBUG
#ifndef SDK_MINMAX_ASSERT
#define SDK_MINMAX_ASSERT(exp, min, max) \
(void) (((exp) >= (min) && (exp) <= (max)) || \
(OSi_Panic(__FILE__, __LINE__, #exp " is out of bounds(%d)\n%d <= "#exp" <= %d not satisfied.", exp, min, max), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_MINMAX_ASSERT
#define SDK_MINMAX_ASSERT(exp, min, max) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Fatal error
//
#ifdef SDK_DEBUG
#ifndef SDK_FATAL_ERROR
#define SDK_FATAL_ERROR(...) \
(void) (OSi_Panic(__FILE__, __LINE__, "Fatal Error\n"__VA_ARGS__), 0)
#endif
#ifndef SDK_TFATAL_ERROR
#define SDK_TFATAL_ERROR(...) \
(void) (OSi_TPanic(__FILE__, __LINE__, "Fatal Error\n"__VA_ARGS__), 0)
#endif
#else // SDK_DEBUG
#ifndef SDK_FATAL_ERROR
#define SDK_FATAL_ERROR(...) ((void) 0)
#endif
#ifndef SDK_TFATAL_ERROR
#define SDK_TFATAL_ERROR(...) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Internal error
//
#ifdef SDK_DEBUG
#ifndef SDK_INTERNAL_ERROR
#define SDK_INTERNAL_ERROR(...) \
(void) (OSi_Panic(__FILE__, __LINE__, "SDK Internal error\nPlease e-mail to nintendo\n" __VA_ARGS__), 0)
#endif
#ifndef SDK_TINTERNAL_ERROR
#define SDK_TINTERNAL_ERROR(...) \
(void) (OSi_TPanic(__FILE__, __LINE__, "SDK Internal error\nPlease e-mail to nintendo\n" __VA_ARGS__), 0)
#endif
#else // SDK_DEBUG
#ifndef SDK_INTERNAL_ERROR
#define SDK_INTERNAL_ERROR(...) ((void) 0)
#endif
#ifndef SDK_TINTERNAL_ERROR
#define SDK_TINTERNAL_ERROR(...) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Alignment error(4 bytes)
//
#ifdef SDK_DEBUG
#ifndef SDK_ALIGN4_ASSERT
#define SDK_ALIGN4_ASSERT(exp) \
(void) ((((u32)(exp) & 3) == 0) || (OSi_Panic(__FILE__, __LINE__, "Alignment Error(0x%08x)\n"#exp" must be aligned to 4 bytes boundary.", exp), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_ALIGN4_ASSERT
#define SDK_ALIGN4_ASSERT(exp) ((void) 0)
#endif
#endif // SDK_DEBUG
//--------------------------------------------------------------------------------
// Alignment error(2 bytes)
//
#ifdef SDK_DEBUG
#ifndef SDK_ALIGN2_ASSERT
#define SDK_ALIGN2_ASSERT(exp) \
(void) ((((u32)(exp) & 1) == 0) || (OSi_Panic(__FILE__, __LINE__, "Alignment Error(0x%08x)\n"#exp" must be aligned to 2 bytes boundary.", exp), 0))
#endif
#else // SDK_DEBUG
#ifndef SDK_ALIGN2_ASSERT
#define SDK_ALIGN2_ASSERT(exp) ((void) 0)
#endif
#endif // SDK_DEBUG
#if 0
// ** this block is moved to section.h **
//
//--------------------------------------------------------------------------------
// section definition for LCF
#if defined(SDK_CW) || defined(SDK_RX) || defined(__MWERKS__)
#ifdef SDK_ARM9
#pragma define_section ITCM ".itcm" abs32 RWX
#pragma define_section DTCM ".dtcm" abs32 RWX
#else
#pragma define_section WRAM ".wram" abs32 RWX
#endif
#pragma define_section PARENT ".parent" abs32 RWX
#pragma define_section VERSION ".version" abs32 RWX
#elif defined(SDK_PRODG)
#endif
#endif
//--------------------------------------------------------------------------------
// macros for linker
// specify force-link.
void OSi_ReferSymbol(void *symbol);
#define SDK_REFER_SYMBOL(symbol) OSi_ReferSymbol((void*)(symbol))
// for embedding middleware version string in VERSION section.
#define SDK_MIDDLEWARE_STRING(vender, module) "[SDK+" vender ":" module "]"
#define SDK_DEFINE_MIDDLEWARE(id, vender, module) static char id [] = SDK_MIDDLEWARE_STRING(vender, module)
#define SDK_USING_MIDDLEWARE(id) SDK_REFER_SYMBOL(id)
//--------------------------------------------------------------------------------
// macros for obsolete functions
#define OSi_AbortByUnsupportedRegister(regname, file, line) (OSi_TPanic(file, line, " I/O register \"%s\" is unsupported on this platform!", regname), 0)
#define OS_UNSUPPORTED_REGADDR(reg) OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG8(reg) *(REGType8*)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG16(reg) *(REGType16*)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG32(reg) *(REGType32*)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
#define OS_UNSUPPORTED_REG64(reg) *(REGType64*)OSi_AbortByUnsupportedRegister(#reg, __FILE__, __LINE__)
//--------------------------------------------------------------------------------
#ifdef __cplusplus
} /* extern "C" */
#endif
/* CTR_MISC_H_ */
#endif

150
trunk/include/ctr/types.h Normal file
View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*
Project: CtrFirm - - types definition
File: types.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef CTR_TYPES_H_
#define CTR_TYPES_H_
// enum は int 型と同じサイズでないと SDK が正常に動作しないため
#ifdef __MWERKS__
#pragma enumsalwaysint on
#endif
// Endian
#define SDK_LITTLE_ENDIAN
#define SDK_IS_LITTLE_ENDIAN 1
#define SDK_IS_BIG_ENDIAN 0
#ifdef SDK_ASM
#else //SDK_ASM
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned long u32;
#ifdef SDK_HAS_NO_LONG_LONG_INT_
typedef unsigned __int64 u64;
#else
typedef unsigned long long int u64;
#endif
typedef signed char s8;
typedef signed short int s16;
typedef signed long s32;
#ifdef SDK_HAS_NO_LONG_LONG_INT_
typedef signed __int64 s64;
#else
typedef signed long long int s64;
#endif
typedef volatile u8 vu8;
typedef volatile u16 vu16;
typedef volatile u32 vu32;
typedef volatile u64 vu64;
typedef volatile s8 vs8;
typedef volatile s16 vs16;
typedef volatile s32 vs32;
typedef volatile s64 vs64;
typedef float f32;
typedef volatile f32 vf32;
/*
io_register_list_XX.hで使用するマクロと型
*/
typedef u8 REGType8;
typedef u16 REGType16;
typedef u32 REGType32;
typedef u64 REGType64;
typedef vu8 REGType8v;
typedef vu16 REGType16v;
typedef vu32 REGType32v;
typedef vu64 REGType64v;
#ifndef SDK_BOOL_ALREADY_DEFINED_
#ifndef BOOL
typedef int BOOL;
#endif //BOOL
#endif //SDK_ALREAD_DEFINE_BOOL_
#ifndef TRUE
// Any non zero value is considered TRUE
#define TRUE 1
#endif //TRUE
#ifndef FALSE
#define FALSE 0
#endif // FALSE
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else // __cplusplus
#define NULL ((void *)0)
#endif // __cplusplus
#endif // NULL
// for compatibility with GAMECUBE
#if defined(SDK_CW) || defined(SDK_RX) || defined(__MWERKS__)
#ifndef ATTRIBUTE_ALIGN
#define ATTRIBUTE_ALIGN(num) __attribute__ ((aligned(num)))
#endif
#endif
// Weak symbol
#if defined(SDK_CW) || defined(SDK_RX) || defined(__MWERKS__)
#define SDK_WEAK_SYMBOL __declspec(weak)
#elif defined(SDK_PRODG)
#define SDK_WEAK_SYMBOL
#endif
/* option for the compiler which deals dead-strip */
#ifdef SDK_CW_FORCE_EXPORT_SUPPORT
#define SDK_FORCE_EXPORT __declspec(force_export)
#else
#define SDK_FORCE_EXPORT
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif //SDK_ASM
/* static inline を inline にして、コードサイズを削減したい場合は、マクロ SDK_INLINE を変更してください。
(static inline inline SDK_DECL_INLINE )
inline 使
inline static inline
使 static inline inline
FX_, VEC_, MTX_ */
#define SDK_INLINE static inline
#define SDK_DECL_INLINE static
/* CTR_TYPES_H_ */
#endif

View File

@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*
Project: CtrFirm - HW - include
File: mmap_firm.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef FIRM_HW_ARM11_MMAP_FIRM_H_
#define FIRM_HW_ARM11_MMAP_FIRM_H_
#ifdef __cplusplus
extern "C" {
#endif
//------------------------------------- FIRM
#define HW_FIRM HW_AXI_WRAM
#define HW_FIRM_END (HW_FIRM + HW_FIRM_SIZE)
#define HW_FIRM_SIZE 0x80000 // 512KB
//------------------------------------- HW_FIRM_FROM_BROM_BUF
#define HW_FIRM_FROM_BROM_BUF (HW_FIRM_FROM_BROM_BUF_END - HW_FIRM_FROM_BROM_BUF_SIZE)
#define HW_FIRM_FROM_BROM_BUF_END (HW_ITCM_END - 0x1000) // END - 4KB
#define HW_FIRM_FROM_BROM_BUF_SIZE 0x3000 // 12KB
#ifdef __cplusplus
} /* extern "C" */
#endif
/* FIRM_HW_ARM11_MMAP_FIRM_H_ */
#endif

View File

@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*
Project: CtrFirm - HW - include
File: mmap_firm.h
Copyright 2008 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: 2008-11-28#$
$Rev: 41 $
$Author: nakasima $
*---------------------------------------------------------------------------*/
#ifndef FIRM_HW_ARM9_MMAP_FIRM_H_
#define FIRM_HW_ARM9_MMAP_FIRM_H_
#ifdef __cplusplus
extern "C" {
#endif
//------------------------------------- FIRM
#define HW_FIRM HW_PRV_WRAM
#define HW_FIRM_END (HW_FIRM + HW_FIRM_SIZE)
#define HW_FIRM_SIZE 0x100000 // 1MB
//------------------------------------- HW_FIRM_FROM_BROM_BUF
#define HW_FIRM_FROM_BROM_BUF (HW_FIRM_FROM_BROM_BUF_END - HW_FIRM_FROM_BROM_BUF_SIZE)
#define HW_FIRM_FROM_BROM_BUF_END (HW_ITCM_END - 0x1000) // END - 4KB
#define HW_FIRM_FROM_BROM_BUF_SIZE 0x3000 // 12KB
#ifdef __cplusplus
} /* extern "C" */
#endif
/* FIRM_HW_ARM9_MMAP_FIRM_H_ */
#endif