1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - demos - CARD - card-mrom
3 File: main.c
4
5 Copyright 2007-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2008-09-17#$
14 $Rev: 8556 $
15 $Author: okubata_ryoma $
16 *---------------------------------------------------------------------------*/
17
18
19 #include <nitro.h>
20
21
22 /*---------------------------------------------------------------------------*
23 Name: NitroMain
24
25 Description: Main entry point.
26
27 Arguments: None.
28
29 Returns: None.
30 *---------------------------------------------------------------------------*/
NitroMain(void)31 void NitroMain(void)
32 {
33 OS_Init();
34 OS_InitTick();
35 CARD_Init();
36 (void)OS_EnableIrq();
37 (void)OS_EnableInterrupts();
38
39 // Repeat a large read access 10 times and measure the transfer speed.
40 // Use a CPU transfer because a DMA transfer has the overhead of an interrupt handler.
41 {
42 enum
43 { BUFFER_SIZE = 1 * 1024 * 1024 };
44 static u8 buf[BUFFER_SIZE];
45 int i;
46 OSTick t;
47 const u16 id = (u16)OS_GetLockID();
48
49 CARD_LockRom(id);
50 for (i = 0; i < 10; ++i)
51 {
52 t = OS_GetTick();
53 CARD_ReadRom(MI_DMA_NOT_USE, CARD_GetOwnRomHeader()->main_rom_offset, buf, BUFFER_SIZE);
54 t = OS_GetTick() - t;
55 /* n[B/s] = 1[MB] / t[microsecond] */
56 OS_Printf("[%2d] ... %10.6f[B/s]\n", i + 1,
57 1.0 * BUFFER_SIZE / OS_TicksToMicroSeconds(t));
58 }
59 CARD_UnlockRom(id);
60
61 OS_TPrintf("[end]\n");
62 }
63
64 OS_Terminate();
65 }
66