1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - ELF Loader
3 File: arch.c
4
5 Copyright 2006-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 #include "el_config.h"
19
20 #ifdef SDK_TWL
21 #include <twl.h>
22 #else
23 #include <nitro.h>
24 #endif
25
26 #include "arch.h"
27
28
29 /*---------------------------------------------------------
30 Find size of entry from entry header
31 --------------------------------------------------------*/
AR_GetEntrySize(ArchHdr * ArHdr)32 u32 AR_GetEntrySize( ArchHdr* ArHdr)
33 {
34 u16 i;
35 u32 digit = 1;
36 u32 size = 0;
37
38 /*----- Check how many digits there are -----*/
39 for( i=0; i<10; i++) {
40 if( ArHdr->ar_size[i] == 0x20) {
41 break;
42 }else{
43 digit *= 10;
44 }
45 }
46 digit /= 10;
47 /*----------------------------*/
48
49 /*----- Calculate size -----*/
50 for( i=0; i<10; i++) {
51 size += (*(((u8*)(ArHdr->ar_size))+i) - 0x30) * digit; //Convert char to u8
52 if( digit == 1) {
53 break;
54 }else{
55 digit /= 10;
56 }
57 }
58 /*----------------------------*/
59
60 return size;
61 }
62