1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     fs_Parameters.h
4 
5   Copyright (C)2009 Nintendo Co., Ltd.  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   $Rev: 23174 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_FS_FS_PARAMETERS_H_
17 #define NN_FS_FS_PARAMETERS_H_
18 
19 #include <nn/types.h>
20 #include <nn/config.h>
21 #include <nn/dbg/dbg_Logger.h>
22 #include <nn/assert.h>
23 #include <nn/util.h>
24 #include <nn/util/util_Int64.h>
25 #include <nn/fs/fs_IpcParameters.h>
26 
27 namespace nn {
28 namespace fs {
29 
30 static const size_t MAX_ARCHIVE_NAME_LENGTH = 7;
31 static const size_t MAX_FILE_PATH_LENGTH = MAX_ARCHIVE_NAME_LENGTH + 1 + 253;
32 
33 // 下記二つは非推奨
34 static const size_t MAX_FILENAME_WCHAR_LEN = (MAX_FILE_PATH_LENGTH + 1) * sizeof(wchar_t);
35 static const size_t MAX_PATHNAME_WCHAR_LEN = (MAX_FILE_PATH_LENGTH + 1) * sizeof(wchar_t);
36 
37 enum OpenMode
38 {
39     OPEN_MODE_READ    = (1u << 0),
40     OPEN_MODE_WRITE   = (1u << 1),
41     OPEN_MODE_CREATE  = (1u << 2)
42 };
43 
44 /*!
45     @brief ファイルの読み書きの位置を指定することを示す定数群です。
46 */
47 enum PositionBase
48 {
49     /*!
50         @brief ファイルの先頭を基準としてファイルのカレント位置を設定することを示す定数です。
51     */
52     POSITION_BASE_BEGIN,
53 
54     /*!
55         @brief ファイルのカレント位置を基準としてファイルのカレント位置を設定することを示す定数です。
56     */
57     POSITION_BASE_CURRENT,
58 
59     /*!
60         @brief ファイルの末尾を基準としてファイルのカレント位置を設定することを示す定数です。
61     */
62     POSITION_BASE_END
63 };
64 
65 enum OpenModeRaw {
66 #if defined(NN_DEBUGGER_KMC_PARTNER)
67     READ_ONLY = 0
68 #elif defined(NN_DEBUGGER_ARM_REALVIEW)
69     READ_ONLY = 1
70 #endif
71 };
72 
73 enum MediaType
74 {
75     MEDIA_TYPE_NAND = 0,
76     MEDIA_TYPE_SDMC = 1,
77     MEDIA_TYPE_CTRCARD = 2
78 };
79 
80 struct Attributes
81 {
82     bool isDirectory;
83     bool isHidden;
84     bool isArchive;
85     bool isReadOnly;
86 };
87 
88 struct Transaction
89 {
90     bit32   dummy;
91 };
92 
93 struct ShortName
94 {
95     char body[10];
96     char ext[4];
97     bool valid;
98     bit8 pad;
99 };
100 
101 struct DirectoryEntry
102 {
103     wchar_t            entryName[MAX_FILE_PATH_LENGTH + 1];
104     ShortName          shortName;
105     nn::fs::Attributes attributes;
106     s64                entrySize;
107 };
108 
109 struct PathMark
110 {
111     bit32 rawPathMark;
112 };
113 
114 
115 typedef bit64 SaveDataId;
116 typedef bit64 ExtSaveDataId;
117 typedef bit32 ContentIdx;
118 typedef bit64 TitleId;
119 
120 struct TitleDataSpecifier
121 {
122     TitleId id;
123     nn::util::SizedEnum1<MediaType> media;
124     NN_PADDING3;
125     NN_PADDING4;
126 
MakeTitleDataSpecifier127     static TitleDataSpecifier Make(MediaType media, TitleId id)
128     {
129         TitleDataSpecifier ret;
130         ret.id = id;
131         ret.media = media;
132         return ret;
133     }
134 };
135 
136 typedef TitleDataSpecifier ProgramLaunchInfo;
137 
138 namespace detail { struct ArchiveHandleTag {}; }
139 typedef nn::util::Int64<bit64, detail::ArchiveHandleTag> ArchiveHandle;
140 
141 } // end of namespace tcb
142 } // end of namespace nn
143 
144 #endif  // ifndef NN_FS_FS_ENUMS_H_
145