AM64x MCU+ SDK  08.02.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 (*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 (*EnetMod_Rejoin)(EnetMod_Handle hMod,
106  Enet_Type enetType,
107  uint32_t instId);
108 
120 typedef int32_t (*EnetMod_Ioctl)(EnetMod_Handle hMod,
121  uint32_t cmd,
122  Enet_IoctlPrms *prms);
123 
131 typedef void (*EnetMod_Close)(EnetMod_Handle hMod);
132 
136 typedef struct EnetMod_Obj_s
137 {
139  const char *name;
140 
142  uint64_t physAddr;
143 
145  void *virtAddr;
146 
148  uint64_t physAddr2;
149 
151  void *virtAddr2;
152 
154  uint32_t features;
155 
157  uint32_t errata;
158 
161 
164 
167 
170 
173 } EnetMod_Obj;
174 
175 /* ========================================================================== */
176 /* Global Variables Declarations */
177 /* ========================================================================== */
178 
179 /* None */
180 
181 /* ========================================================================== */
182 /* Function Declarations */
183 /* ========================================================================== */
184 
197  Enet_Type enetType,
198  uint32_t instId,
199  const void *cfg,
200  uint32_t cfgSize);
201 
212  Enet_Type enetType,
213  uint32_t instId);
214 
225  uint32_t cmd,
226  Enet_IoctlPrms *prms);
227 
239  uint32_t cmd,
240  Enet_IoctlPrms *prms);
241 
248 
256 static inline bool EnetMod_isOpen(EnetMod_Handle hMod);
257 
258 /* ========================================================================== */
259 /* Deprecated Function Declarations */
260 /* ========================================================================== */
261 
262 /* None */
263 
264 /* ========================================================================== */
265 /* Static Function Definitions */
266 /* ========================================================================== */
267 
268 static inline bool EnetMod_isOpen(EnetMod_Handle hMod)
269 {
270  return (hMod->magic == ENET_MAGIC);
271 }
272 
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif /* ENET_MOD_H_ */
EnetMod_Obj::rejoin
EnetMod_Rejoin rejoin
Definition: enet_mod.h:166
EnetMod_Open
int32_t(* 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
enet_types.h
This file contains the basic types using across the Enet driver.
EnetMod_Obj::ioctl
EnetMod_Ioctl ioctl
Definition: enet_mod.h:169
EnetMod_close
void EnetMod_close(EnetMod_Handle hMod)
Wrapper function to close an Enet Module.
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:157
EnetMod_Rejoin
int32_t(* EnetMod_Rejoin)(EnetMod_Handle hMod, Enet_Type enetType, uint32_t instId)
Rejoin the Enet Module.
Definition: enet_mod.h:105
ENET_MAGIC
@ ENET_MAGIC
Definition: enet_types.h:234
Enet_Magic
Enet_Magic
Enet driver magic value, used to indicate if driver is open or not.
Definition: enet_types.h:232
EnetMod_Obj::open
EnetMod_Open open
Definition: enet_mod.h:163
EnetMod_Obj::virtAddr2
void * virtAddr2
Definition: enet_mod.h:151
EnetMod_Obj::virtAddr
void * virtAddr
Definition: enet_mod.h:145
Enet_IoctlPrms
Enet IOCTL param.
Definition: enet_ioctl.h:233
EnetMod_Handle
struct EnetMod_Obj_s * EnetMod_Handle
Ethernet Module handle.
Definition: enet_mod.h:71
EnetMod_Obj
Ethernet Module object.
Definition: enet_mod.h:137
EnetMod_isOpen
static bool EnetMod_isOpen(EnetMod_Handle hMod)
Check if Enet Module is open or not.
Definition: enet_mod.h:268
Enet_Type
Enet_Type
Ethernet peripheral type.
Definition: enet_types.h:196
EnetMod_Obj::physAddr
uint64_t physAddr
Definition: enet_mod.h:142
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_Obj::close
EnetMod_Close close
Definition: enet_mod.h:172
EnetMod_Close
void(* EnetMod_Close)(EnetMod_Handle hMod)
Close the Enet Module.
Definition: enet_mod.h:131
EnetMod_Obj::features
uint32_t features
Definition: enet_mod.h:154
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:139
EnetMod_Obj::physAddr2
uint64_t physAddr2
Definition: enet_mod.h:148
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_Ioctl
int32_t(* EnetMod_Ioctl)(EnetMod_Handle hMod, uint32_t cmd, Enet_IoctlPrms *prms)
Issue an operation on the Enet Module.
Definition: enet_mod.h:120
EnetMod_Obj::magic
Enet_Magic magic
Definition: enet_mod.h:160