1 /*---------------------------------------------------------------------------*
2   Project:     USB Host Stack (UHS)
3   File:        uhs_cos.h
4   Description: Top level public COS header
5 
6   Copyright (C) Nintendo.  All rights reserved.
7 
8   These coded instructions, statements, and computer programs contain
9   proprietary information of Nintendo of America Inc. and/or Nintendo
10   Company Ltd., and are protected by Federal copyright law.  They may
11   not be disclosed to third parties or copied or duplicated in any form,
12   in whole or in part, without the prior written consent of Nintendo.
13 
14   *---------------------------------------------------------------------------*/
15 #ifndef __UHS_COS_H__
16 #define __UHS_COS_H__
17 
18 #include <types.h>
19 #include <cafe/sys_io_error.h>
20 #include <cafe/uhs_ch9.h>
21 #include <cafe/uhs_types.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*---------------------------------------------------------------------------*
28  *
29  *    Constants defined for this file
30  *    -- #Defines --
31  *
32  *---------------------------------------------------------------------------*/
33 #define UHS_CLIENT_MINIMUM_ASYNC_TXN_ALLOCATION 3
34 
35 
36 
37 /*---------------------------------------------------------------------------*
38  *
39  *    Data types defined for this file
40  *    -- Structs, Typedefs, Enums --
41  *
42  *---------------------------------------------------------------------------*/
43     typedef enum {
44         UHS_COS_CLIENT_STATE_INVALID,
45         UHS_COS_CLIENT_STATE_OPEN_IN_PROGRESS,
46         UHS_COS_CLIENT_STATE_OPENED,
47         UHS_COS_CLIENT_STATE_CLOSE_IN_PROGRESS,
48         UHS_COS_CLIENT_STATE_CLOSED,
49         UHS_COS_CLIENT_STATE_ERROR
50     }UhsCosClientState;
51 
52     typedef struct {
53         UhsCosClientState  state;
54         void*              bufPoolHandle;
55         s32                stateSequence;
56         UhsClientHandle    handle;
57         void*              pCfg;
58         UhsInterfaceHandle lastProbedIf;
59     }UhsCosClientInstance;
60 
61     typedef struct {
62         s32                hostStackInstance;
63         void*              pTxnMemory;
64         u32                txnMemorySize;
65     }UhsCosClientConfig;
66 
67 /*---------------------------------------------------------------------------*
68  *
69  *    -- Interface Function Prototypes --
70  *
71  *---------------------------------------------------------------------------*/
72     UhsStatus UhsClientOpen(UhsCosClientInstance*     pI,
73                             const UhsCosClientConfig* pC);
74     UhsStatus UhsClientClose(UhsCosClientInstance*  pI);
75     UhsDevRegHandle UhsClassDrvReg(UhsCosClientInstance*  pI,
76                                    UhsDeviceId*           pDevId,
77                                    UhsClientContext       clientContext,
78                                    UhsIfProbeFunction     probeFunction);
79     UhsStatus UhsClassDrvUnReg(UhsCosClientInstance*    pI,
80                                UhsDevRegHandle          devRegHandle);
81     UhsStatus UhsAcquireInterface(UhsCosClientInstance*     pI,
82                                   UhsInterfaceHandle        ifHandle,
83                                   UhsClientContext          clientContext,
84                                   UhsIfIndicationFunction   indicationFunction);
85     UhsStatus UhsReleaseInterface(UhsCosClientInstance*     pI,
86                                   UhsInterfaceHandle        ifHandle,
87                                   BOOL                      lockOut);
88     UhsStatus UhsQueryInterfaces(UhsCosClientInstance* pI,
89                                  UhsDeviceId*          pDevId,
90                                  UhsInterfaceProfile   ifProfileList[],
91                                  u32                   maxProfiles);
92     UhsStatus UhsSetInterface(UhsCosClientInstance*         pI,
93                               UhsInterfaceHandle            ifHandle,
94                               u8                            bAlternateSetting);
95     UhsStatus UhsGetInterface(UhsCosClientInstance*     pI,
96                               UhsInterfaceHandle        ifHandle,
97                               UhsInterfaceProfile*      pIfProfile);
98     UhsStatus UhsGetAlternateInterface(UhsCosClientInstance*     pI,
99                                        UhsInterfaceHandle        ifHandle,
100                                        u8                        bAlternateSetting,
101                                        UhsInterfaceProfile*      pIfProfile);
102     UhsStatus UhsAdministerEndpoint(UhsCosClientInstance* pI,
103                                     UhsInterfaceHandle    ifHandle,
104                                     UhsEpCommandType      command,
105                                     UhsEndpointMask       endpointMask,
106                                     s32                   maxUrb,
107                                     u32                   maxXferSize);
108     UhsStatus UhsAdministerEndpointOpt(UhsCosClientInstance*       pI,
109                                        UhsInterfaceHandle          ifHandle,
110                                        UhsEpCommandType            command,
111                                        UhsEndpointMask             endpointMask,
112                                        s32                         maxUrb,
113                                        u32                         maxXferSize,
114                                        UhsEndpointOptions          options);
115     UhsStatus UhsClearEndpointHalt(UhsCosClientInstance*       pI,
116                                    UhsInterfaceHandle          ifHandle,
117                                    UhsEndpointNumber           epNumber,
118                                    UhsDirection                direction);
119     UhsStatus UhsAdministerDevice(UhsCosClientInstance*       pI,
120                                   UhsInterfaceHandle          ifHandle,
121                                   UhsDeviceCommandType        command,
122                                   UhsDeviceOptions            options);
123     UhsStatus UhsGetDescriptorString(UhsCosClientInstance* pI,
124                                      UhsInterfaceHandle    ifHandle,
125                                      u8                    index,
126                                      BOOL                  unicode,
127                                      char*                 pString,
128                                      u32                   size);
129     UhsStatus UhsGetFullConfigDescriptor(UhsCosClientInstance* pI,
130                                          UhsInterfaceHandle    ifHandle,
131                                          void*                 pData,
132                                          u32                   size);
133     UhsStatus UhsSubmitControlRequest(UhsCosClientInstance*     pI,
134                                       UhsInterfaceHandle        ifHandle,
135                                       void*                     pData,
136                                       u8                        bRequest,
137                                       u8                        bRequestType,
138                                       u16                       wValue,
139                                       u16                       wIndex,
140                                       u16                       wLength,
141                                       UhsTime                   timeout);
142     UhsStatus UhsSubmitControlRequestAsync(UhsCosClientInstance*    pI,
143                                            UhsInterfaceHandle       ifHandle,
144                                            void*                    pData,
145                                            u8                       bRequest,
146                                            u8                       bRequestType,
147                                            u16                      wValue,
148                                            u16                      wIndex,
149                                            u16                      wLength,
150                                            UhsClientContext         clientContext,
151                                            UhsControlUrbCompletionCallback callback);
152     UhsStatus UhsSubmitInterruptRequest(UhsCosClientInstance*   pI,
153                                         UhsInterfaceHandle      ifHandle,
154                                         UhsEndpointNumber       epNumber,
155                                         UhsDirection            direction,
156                                         void*                   pData,
157                                         u32                     size,
158                                         UhsTime                 timeout);
159     UhsStatus UhsSubmitInterruptRequestAsync(UhsCosClientInstance*    pI,
160                                              UhsInterfaceHandle       ifHandle,
161                                              UhsEndpointNumber        epNumber,
162                                              UhsDirection             direction,
163                                              void*                    pData,
164                                              u32                      size,
165                                              UhsClientContext         clientContext,
166                                              UhsInterruptUrbCompletionCallback callback);
167     UhsStatus UhsSubmitBulkRequest(UhsCosClientInstance*    pI,
168                                    UhsInterfaceHandle       ifHandle,
169                                    UhsEndpointNumber        epNumber,
170                                    UhsDirection             direction,
171                                    void*                    pData,
172                                    u32                      size,
173                                    UhsTime                  timeout);
174     UhsStatus UhsSubmitBulkRequestAsync(UhsCosClientInstance*    pI,
175                                         UhsInterfaceHandle       ifHandle,
176                                         UhsEndpointNumber        epNumber,
177                                         UhsDirection             direction,
178                                         void*                    pData,
179                                         u32                      size,
180                                         UhsClientContext         clientContext,
181                                         UhsBulkUrbCompletionCallback callback);
182     UhsStatus UhsSubmitIsocRequest(UhsCosClientInstance*    pI,
183                                    UhsInterfaceHandle       ifHandle,
184                                    UhsEndpointNumber        epNumber,
185                                    UhsDirection             direction,
186                                    u32                      start_frm,
187                                    UhsIsocStartType         startType,
188                                    UhsIsocPayload*          pPayload,
189                                    UhsTime                  timeout);
190     UhsStatus UhsSubmitIsocRequestAsync(UhsCosClientInstance*   pI,
191                                         UhsInterfaceHandle      ifHandle,
192                                         UhsEndpointNumber       epNumber,
193                                         UhsDirection            direction,
194                                         u32                     start_frm,
195                                         UhsIsocStartType        startType,
196                                         UhsIsocPayload*         pPayload,
197                                         UhsClientContext        clientContext,
198                                         UhsIsocUrbCompletionCallback callback);
199     UhsStatus UhsGetCurrentFrame(UhsCosClientInstance*  pI,
200                                  UhsInterfaceHandle     ifHandle,
201                                  u32*                   pFrame);
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif // __UHS_COS_H__
208