AM64x MCU+ SDK  10.00.00
enet_mod.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
40 #ifndef ENET_MOD_H_
41 #define ENET_MOD_H_
42 
43 /* ========================================================================== */
44 /* Include Files */
45 /* ========================================================================== */
46 
47 #include <stdint.h>
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 /* ========================================================================== */
56 /* Macros */
57 /* ========================================================================== */
58 
60 #define ENET_MOD(mod) ((EnetMod_Handle)mod)
61 
62 /* ========================================================================== */
63 /* Structures and Enums */
64 /* ========================================================================== */
65 
71 typedef struct EnetMod_Obj_s *EnetMod_Handle;
72 
87 typedef int32_t (*const EnetMod_Open)(EnetMod_Handle hMod,
88  Enet_Type enetType,
89  uint32_t instId,
90  const void *cfg,
91  uint32_t cfgSize);
92 
105 typedef int32_t (* const EnetMod_Rejoin)(EnetMod_Handle hMod,
106  Enet_Type enetType,
107  uint32_t instId);
108 
120 typedef int32_t (* const EnetMod_Ioctl)(EnetMod_Handle hMod,
121  uint32_t cmd,
122  Enet_IoctlPrms *prms);
123 
131 typedef void (* const EnetMod_Close)(EnetMod_Handle hMod);
132 
140 typedef void (* const EnetMod_SaveCtxt)(EnetMod_Handle hMod);
141 
156 typedef int32_t (* const EnetMod_RestoreCtxt)(EnetMod_Handle hMod,
157  Enet_Type enetType,
158  uint32_t instId,
159  const void *cfg,
160  uint32_t cfgSize);
164 typedef struct EnetMod_Obj_s
165 {
167  const char *name;
168 
170  uint64_t physAddr;
171 
173  void *virtAddr;
174 
176  uint64_t physAddr2;
177 
179  void *virtAddr2;
180 
182  uint32_t features;
183 
185  uint32_t errata;
186 
189 
192 
195 
198 
201 
204 
207 } EnetMod_Obj;
208 
209 /* ========================================================================== */
210 /* Global Variables Declarations */
211 /* ========================================================================== */
212 
213 /* None */
214 
215 /* ========================================================================== */
216 /* Function Declarations */
217 /* ========================================================================== */
218 
231  Enet_Type enetType,
232  uint32_t instId,
233  const void *cfg,
234  uint32_t cfgSize);
235 
246  Enet_Type enetType,
247  uint32_t instId);
248 
259  uint32_t cmd,
260  Enet_IoctlPrms *prms);
261 
276  uint32_t cmdBase,
277  uint32_t cmd,
278  Enet_IoctlPrms *prms);
290  uint32_t cmd,
291  Enet_IoctlPrms *prms);
292 
299 
306 
319  Enet_Type enetType,
320  uint32_t instId,
321  const void *cfg,
322  uint32_t cfgSize);
330 static inline bool EnetMod_isOpen(EnetMod_Handle hMod);
331 
332 /* ========================================================================== */
333 /* Deprecated Function Declarations */
334 /* ========================================================================== */
335 
336 /* None */
337 
338 /* ========================================================================== */
339 /* Static Function Definitions */
340 /* ========================================================================== */
341 
342 static inline bool EnetMod_isOpen(EnetMod_Handle hMod)
343 {
344  return (hMod->magic == ENET_MAGIC);
345 }
346 
347 #ifdef __cplusplus
348 }
349 #endif
350 
351 #endif /* ENET_MOD_H_ */
EnetMod_SaveCtxt
void(*const EnetMod_SaveCtxt)(EnetMod_Handle hMod)
Saves and closes the Enet Module context before resetting.
Definition: enet_mod.h:140
EnetMod_Obj::rejoin
EnetMod_Rejoin rejoin
Definition: enet_mod.h:194
enet_types.h
This file contains the basic types using across the Enet driver.
EnetMod_Obj::ioctl
EnetMod_Ioctl ioctl
Definition: enet_mod.h:197
EnetMod_close
void EnetMod_close(EnetMod_Handle hMod)
Wrapper function to close an Enet Module.
EnetMod_Rejoin
int32_t(*const EnetMod_Rejoin)(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId)
Rejoin the Enet Module.
Definition: enet_mod.h:105
enet_ioctl.h
This file contains the type definitions and helper macros for the Enet IOCTL interface.
EnetMod_Obj::errata
uint32_t errata
Definition: enet_mod.h:185
ENET_MAGIC
@ ENET_MAGIC
Definition: enet_types.h:237
Enet_Magic
Enet_Magic
Enet driver magic value, used to indicate if driver is open or not.
Definition: enet_types.h:235
EnetMod_Obj::open
EnetMod_Open open
Definition: enet_mod.h:191
EnetMod_Obj::virtAddr2
void * virtAddr2
Definition: enet_mod.h:179
EnetMod_Obj::virtAddr
void * virtAddr
Definition: enet_mod.h:173
Enet_IoctlPrms
Enet IOCTL param.
Definition: enet_ioctl.h:275
EnetMod_Close
void(*const EnetMod_Close)(EnetMod_Handle hMod)
Close the Enet Module.
Definition: enet_mod.h:131
EnetMod_Handle
struct EnetMod_Obj_s * EnetMod_Handle
Ethernet Module handle.
Definition: enet_mod.h:71
EnetMod_Obj::restoreCtxt
EnetMod_RestoreCtxt restoreCtxt
Definition: enet_mod.h:206
EnetMod_RestoreCtxt
int32_t(*const EnetMod_RestoreCtxt)(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId, const void *cfg, uint32_t cfgSize)
Restores and opens the Enet Module after reset.
Definition: enet_mod.h:156
EnetMod_Obj
Ethernet Module object.
Definition: enet_mod.h:165
EnetMod_Open
int32_t(*const EnetMod_Open)(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId, const void *cfg, uint32_t cfgSize)
Open and initialize the Enet Module.
Definition: enet_mod.h:87
EnetMod_restoreCtxt
int32_t EnetMod_restoreCtxt(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId, const void *cfg, uint32_t cfgSize)
Wrapper to retore and open Enet Module.
EnetMod_Ioctl
int32_t(*const EnetMod_Ioctl)(EnetMod_Handle hMod, uint32_t cmd, Enet_IoctlPrms *prms)
Issue an operation on the Enet Module.
Definition: enet_mod.h:120
EnetMod_isOpen
static bool EnetMod_isOpen(EnetMod_Handle hMod)
Check if Enet Module is open or not.
Definition: enet_mod.h:342
EnetMod_registerMacportIoctlHandler
int32_t EnetMod_registerMacportIoctlHandler(EnetMod_Handle hMod, uint32_t cmdBase, uint32_t cmd, Enet_IoctlPrms *prms)
Wrapper function to register IOCTL for Macport Module. This function is defined for the cases when ON...
Enet_Type
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:199
EnetMod_Obj::physAddr
uint64_t physAddr
Definition: enet_mod.h:170
EnetMod_ioctl
int32_t EnetMod_ioctl(EnetMod_Handle hMod, uint32_t cmd, Enet_IoctlPrms *prms)
Wrapper function to issue an operation on an Enet Module.
EnetMod_saveCtxt
void EnetMod_saveCtxt(EnetMod_Handle hMod)
Wrapper function to save and close Enet Module.
EnetMod_Obj::close
EnetMod_Close close
Definition: enet_mod.h:200
EnetMod_Obj::features
uint32_t features
Definition: enet_mod.h:182
EnetMod_rejoin
int32_t EnetMod_rejoin(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId)
Wrapper to rejoin an Enet Module.
EnetMod_Obj::name
const char * name
Definition: enet_mod.h:167
EnetMod_Obj::physAddr2
uint64_t physAddr2
Definition: enet_mod.h:176
EnetMod_open
int32_t EnetMod_open(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId, const void *cfg, uint32_t cfgSize)
Wrapper to open and initialize an Enet Module.
EnetMod_ioctlFromIsr
int32_t EnetMod_ioctlFromIsr(EnetMod_Handle hMod, uint32_t cmd, Enet_IoctlPrms *prms)
Wrapper function to issue an operation on an Enet Module from ISR context.
EnetMod_Obj::magic
Enet_Magic magic
Definition: enet_mod.h:188
EnetMod_Obj::saveCtxt
EnetMod_SaveCtxt saveCtxt
Definition: enet_mod.h:203