1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - MB - include
3   File:     mb_rom_header.h
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-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef _ROM_HEADER_H_
19 #define _ROM_HEADER_H_
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 
26 #include <nitro.h>
27 #include <nitro/fs.h>
28 
29 
30 
31 // ROM header
32 //----------------------------------------------------------------------
33 typedef struct
34 {
35     //
36     // 0x000 System Reserved
37     //
38     char    title_name[12];            // Soft title name
39     u32     game_code;                 // Game code
40 
41     u16     maker_code;                // Maker code
42     u8      machine_code;              // Machine code
43     u8      rom_type;                  // Rom type
44     u8      rom_size;                  // Rom size
45 
46     u8      reserved_A[9];             // System Reserved A ( Set ALL 0 )
47 
48     u8      soft_version;              // Soft version
49     u8      comp_arm9_boot_area:1;     // Compress arm9 boot area
50     u8      comp_arm7_boot_area:1;     // Compress arm7 boot area
51     u8      inspectCard:1;             // The inspect card flag
52     u8      disableClearMemoryPad:1;   // The IPL memory pad clear/disable flag
53     u8:     0;
54 
55     //
56     // 0x020 for Static modules (Section:B)
57     //
58     //      ARM9
59     u32     main_rom_offset;           // ROM offset
60     void   *main_entry_address;        // Entry point
61     void   *main_ram_address;          // RAM address
62     u32     main_size;                 // Module size
63 
64     //      ARM7
65     u32     sub_rom_offset;            // ROM offset
66     void   *sub_entry_address;         // Entry point
67     void   *sub_ram_address;           // RAM address
68     u32     sub_size;                  // Module size
69 
70     //
71     // 0x040 for File Name Table[FNT] (Section:C)
72     //
73     u32     fnt_offset;                // ROM offset
74     u32     fnt_size;                  // Table size
75 
76     //
77     // 0x048 for File Allocation Table[FAT] (Section:E)
78     //
79     u32     fat_offset;                // ROM offset
80     u32     fat_size;                  // Table size
81 
82     //
83     // 0x050 for Overlay Tables[OVT] (Section:D)
84     //
85     //      ARM9
86     u32     main_ovt_offset;           // ROM offset
87     u32     main_ovt_size;             // Table size
88 
89     //      ARM7
90     u32     sub_ovt_offset;            // ROM offset
91     u32     sub_ovt_size;              // Table size
92 
93     // 0x060 for ROM control parameter
94     u8      reserved_A2[32];
95 
96     // 0x080
97     u32     own_size;
98 
99     // 0x084 - 0x0C0 System Reserved
100     u8      reserved_B[60];            // System Reserved B (Set 0)
101 
102     // 0x0C0 for NINTENDO logo data
103     u8      nintendo_logo[0x9c];       // NINTENDO logo data
104     u16     nintendo_logo_crc16;       //            CRC-16
105 
106     // 0x15E ROM header CRC-16
107     u16     header_crc16;              // ROM header CRC-16
108 
109     //
110     // 0x0160 - 0x0180 System Reserved
111     //
112     u8      reserved_C[32];            // Debugger Reserved (Set ALL 0)
113 
114 }
115 RomHeader;
116 
117 
118 //----------------------------------------------------------------------
119 // ROM header address acquisition
120 //----------------------------------------------------------------------
121 
122 #define GetRomHeaderAddr()  ((RomHeader *)HW_ROM_HEADER_BUF)
123 
124 //- Gets the ROM header address
125 
126 
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif // _ROM_HEADER_H_
133