aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/templates/hal_mac_lld.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_mac_lld.h')
-rw-r--r--lib/chibios/os/hal/templates/hal_mac_lld.h181
1 files changed, 181 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_mac_lld.h b/lib/chibios/os/hal/templates/hal_mac_lld.h
new file mode 100644
index 000000000..c49a377db
--- /dev/null
+++ b/lib/chibios/os/hal/templates/hal_mac_lld.h
@@ -0,0 +1,181 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_mac_lld.h
19 * @brief PLATFORM MAC subsystem low level driver header.
20 *
21 * @addtogroup MAC
22 * @{
23 */
24
25#ifndef HAL_MAC_LLD_H
26#define HAL_MAC_LLD_H
27
28#if (HAL_USE_MAC == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @brief This implementation supports the zero-copy mode API.
36 */
37#define MAC_SUPPORTS_ZERO_COPY TRUE
38
39/*===========================================================================*/
40/* Driver pre-compile time settings. */
41/*===========================================================================*/
42
43/**
44 * @name PLATFORM configuration options
45 * @{
46 */
47/**
48 * @brief MAC driver enable switch.
49 * @details If set to @p TRUE the support for MAC1 is included.
50 * @note The default is @p FALSE.
51 */
52#if !defined(PLATFORM_MAC_USE_MAC1) || defined(__DOXYGEN__)
53#define PLATFORM_MAC_USE_MAC1 FALSE
54#endif
55/** @} */
56
57/*===========================================================================*/
58/* Derived constants and error checks. */
59/*===========================================================================*/
60
61/*===========================================================================*/
62/* Driver data structures and types. */
63/*===========================================================================*/
64
65/**
66 * @brief Driver configuration structure.
67 */
68typedef struct {
69 /**
70 * @brief MAC address.
71 */
72 uint8_t *mac_address;
73 /* End of the mandatory fields.*/
74} MACConfig;
75
76/**
77 * @brief Structure representing a MAC driver.
78 */
79struct MACDriver {
80 /**
81 * @brief Driver state.
82 */
83 macstate_t state;
84 /**
85 * @brief Current configuration data.
86 */
87 const MACConfig *config;
88 /**
89 * @brief Transmit semaphore.
90 */
91 threads_queue_t tdqueue;
92 /**
93 * @brief Receive semaphore.
94 */
95 threads_queue_t rdqueue;
96#if (MAC_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
97 /**
98 * @brief Receive event.
99 */
100 event_source_t rdevent;
101#endif
102 /* End of the mandatory fields.*/
103};
104
105/**
106 * @brief Structure representing a transmit descriptor.
107 */
108typedef struct {
109 /**
110 * @brief Current write offset.
111 */
112 size_t offset;
113 /**
114 * @brief Available space size.
115 */
116 size_t size;
117 /* End of the mandatory fields.*/
118} MACTransmitDescriptor;
119
120/**
121 * @brief Structure representing a receive descriptor.
122 */
123typedef struct {
124 /**
125 * @brief Current read offset.
126 */
127 size_t offset;
128 /**
129 * @brief Available data size.
130 */
131 size_t size;
132 /* End of the mandatory fields.*/
133} MACReceiveDescriptor;
134
135/*===========================================================================*/
136/* Driver macros. */
137/*===========================================================================*/
138
139/*===========================================================================*/
140/* External declarations. */
141/*===========================================================================*/
142
143#if (PLATFORM_MAC_USE_MAC1 == TRUE) && !defined(__DOXYGEN__)
144extern MACDriver ETHD1;
145#endif
146
147#ifdef __cplusplus
148extern "C" {
149#endif
150 void mac_lld_init(void);
151 void mac_lld_start(MACDriver *macp);
152 void mac_lld_stop(MACDriver *macp);
153 msg_t mac_lld_get_transmit_descriptor(MACDriver *macp,
154 MACTransmitDescriptor *tdp);
155 void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp);
156 msg_t mac_lld_get_receive_descriptor(MACDriver *macp,
157 MACReceiveDescriptor *rdp);
158 void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp);
159 bool mac_lld_poll_link_status(MACDriver *macp);
160 size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
161 uint8_t *buf,
162 size_t size);
163 size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
164 uint8_t *buf,
165 size_t size);
166#if MAC_USE_ZERO_COPY == TRUE
167 uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp,
168 size_t size,
169 size_t *sizep);
170 const uint8_t *mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp,
171 size_t *sizep);
172#endif
173#ifdef __cplusplus
174}
175#endif
176
177#endif /* HAL_USE_MAC == TRUE */
178
179#endif /* HAL_MAC_LLD_H */
180
181/** @} */