1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     hio_SerialChannel.h
4 
5   Copyright (C)2009-2012 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: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_HIO_CTR_HIO_SERIALCHANNEL_H_
17 #define NN_HIO_CTR_HIO_SERIALCHANNEL_H_
18 #ifdef  NN_SWITCH_ENABLE_HOST_IO
19 
20 /* Please see man pages for details
21 
22 
23 
24 */
25 
26 #include <nn/types.h>
27 
28 namespace nn {
29 namespace hio {
30 namespace CTR {
31 
32     /* Please see man pages for details
33 
34 
35 
36 
37 
38 
39     */
40     class SerialChannel
41     {
42     public:
43         /* Please see man pages for details
44 
45         */
46         enum Attribute
47         {
48             ATTRIBUTE_NONE      = 0,            //
49             ATTRIBUTE_NO_WAIT   = (1u << 0),    //
50             ATTRIBUTE_IN_PC     = (1u << 1)     //
51         };
52 
53     private:
54         s32     m_Ch;
55 
56     public:
57         /* Please see man pages for details
58 
59         */
SerialChannel()60         SerialChannel() : m_Ch(-1) {}
61 
62         /* Please see man pages for details
63 
64         */
~SerialChannel()65         ~SerialChannel()
66         {
67             if( m_Ch >= 0 )
68             {
69                 Close();
70             }
71         }
72 
73         /* Please see man pages for details
74 
75 
76 
77 
78 
79 
80 
81         */
82         Result Open(s32 ch, void* pWorkMemory);
83 
84 
85         /* Please see man pages for details
86 
87 
88 
89 
90         */
91         Result Close();
92 
93         /* Please see man pages for details
94 
95 
96 
97 
98         */
99         Result Connect();
100 
101 
102         /* Please see man pages for details
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115         */
116         Result WaitHost(bit32 attr=ATTRIBUTE_NONE);
117 
118 
119         /* Please see man pages for details
120 
121 
122 
123 
124         */
125         Result Disconnect();
126 
127         /* Please see man pages for details
128 
129 
130 
131 
132         */
133         Result Flush();
134 
135 
136         /* Please see man pages for details
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147         */
148         Result GetReadableSize(size_t* pSize, bit32 attr=ATTRIBUTE_NONE);
149 
150 
151         /* Please see man pages for details
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168         */
169         Result Read(size_t* pReadSize, void* buf, size_t size, bit32 attr=ATTRIBUTE_NONE);
170 
171         /* Please see man pages for details
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187         */
188         s32 Read(void* buf, size_t size, bit32 attr=ATTRIBUTE_NONE)
189         {
190             size_t read;
191             return Read(&read, buf, size, attr).IsFailure() ? -1: static_cast<s32>(read);
192         }
193 
194         /* Please see man pages for details
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205         */
206         Result GetWritableSize(size_t* pSize, bit32 attr=ATTRIBUTE_NONE);
207 
208         /* Please see man pages for details
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226         */
227         Result Write(size_t* pWrittenSize, const void* buf, size_t size, bit32 attr=ATTRIBUTE_NONE);
228 
229         /* Please see man pages for details
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245         */
246         s32 Write(const void* buf, size_t size, bit32 attr=ATTRIBUTE_NONE)
247         {
248             size_t written;
249             return Write(&written, buf, size,  attr).IsFailure() ? -1: static_cast<s32>(written);
250         }
251     };
252 
253     /* Please see man pages for details
254 
255 
256     */
257     nn::Result ResultNoConnected();
258 
259     /* Please see man pages for details
260 
261 
262     */
263     nn::Result ResultConnected();
264 
ResultNoConnected()265     inline nn::Result ResultNoConnected()
266     {
267         return nn::Result(nn::Result::LEVEL_SUCCESS, nn::Result::SUMMARY_SUCCESS, nn::Result::MODULE_COMMON, 0);
268     }
269 
ResultConnected()270     inline nn::Result ResultConnected()
271     {
272         return nn::Result(nn::Result::LEVEL_SUCCESS, nn::Result::SUMMARY_SUCCESS, nn::Result::MODULE_COMMON, 1);
273     }
274 
275 }
276 }
277 }
278 
279 
280 #endif  // ifdef NN_SWITCH_ENABLE_HOST_IO
281 #endif  // ifndef NN_HIO_CTR_HIO_SERIALCHANNEL_H_
282