Driver_ETH_MAC.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include "Driver_ETH_MAC.h"
  19. #define ARM_ETH_MAC_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
  20. /* Driver Version */
  21. static const ARM_DRIVER_VERSION DriverVersion = {
  22. ARM_ETH_MAC_API_VERSION,
  23. ARM_ETH_MAC_DRV_VERSION
  24. };
  25. /* Driver Capabilities */
  26. static const ARM_ETH_MAC_CAPABILITIES DriverCapabilities = {
  27. 0, /* 1 = IPv4 header checksum verified on receive */
  28. 0, /* 1 = IPv6 checksum verification supported on receive */
  29. 0, /* 1 = UDP payload checksum verified on receive */
  30. 0, /* 1 = TCP payload checksum verified on receive */
  31. 0, /* 1 = ICMP payload checksum verified on receive */
  32. 0, /* 1 = IPv4 header checksum generated on transmit */
  33. 0, /* 1 = IPv6 checksum generation supported on transmit */
  34. 0, /* 1 = UDP payload checksum generated on transmit */
  35. 0, /* 1 = TCP payload checksum generated on transmit */
  36. 0, /* 1 = ICMP payload checksum generated on transmit */
  37. 0, /* Ethernet Media Interface type */
  38. 0, /* 1 = driver provides initial valid MAC address */
  39. 0, /* 1 = callback event \ref ARM_ETH_MAC_EVENT_RX_FRAME generated */
  40. 0, /* 1 = callback event \ref ARM_ETH_MAC_EVENT_TX_FRAME generated */
  41. 0, /* 1 = wakeup event \ref ARM_ETH_MAC_EVENT_WAKEUP generated */
  42. 0, /* 1 = Precision Timer supported */
  43. 0 /* Reserved (must be zero) */
  44. };
  45. //
  46. // Functions
  47. //
  48. static ARM_DRIVER_VERSION ARM_ETH_MAC_GetVersion(void)
  49. {
  50. return DriverVersion;
  51. }
  52. static ARM_ETH_MAC_CAPABILITIES ARM_ETH_MAC_GetCapabilities(void)
  53. {
  54. return DriverCapabilities;
  55. }
  56. static int32_t ARM_ETH_MAC_Initialize(ARM_ETH_MAC_SignalEvent_t cb_event)
  57. {
  58. }
  59. static int32_t ARM_ETH_MAC_Uninitialize(void)
  60. {
  61. }
  62. static int32_t ARM_ETH_MAC_PowerControl(ARM_POWER_STATE state)
  63. {
  64. switch (state)
  65. {
  66. case ARM_POWER_OFF:
  67. break;
  68. case ARM_POWER_LOW:
  69. break;
  70. case ARM_POWER_FULL:
  71. break;
  72. }
  73. return ARM_DRIVER_OK;
  74. }
  75. static int32_t ARM_ETH_MAC_GetMacAddress(ARM_ETH_MAC_ADDR *ptr_addr)
  76. {
  77. }
  78. static int32_t ARM_ETH_MAC_SetMacAddress(const ARM_ETH_MAC_ADDR *ptr_addr)
  79. {
  80. }
  81. static int32_t ARM_ETH_MAC_SetAddressFilter(const ARM_ETH_MAC_ADDR *ptr_addr, uint32_t num_addr)
  82. {
  83. }
  84. static int32_t ARM_ETH_MAC_SendFrame(const uint8_t *frame, uint32_t len, uint32_t flags)
  85. {
  86. }
  87. static int32_t ARM_ETH_MAC_ReadFrame(uint8_t *frame, uint32_t len)
  88. {
  89. }
  90. static uint32_t ARM_ETH_MAC_GetRxFrameSize(void)
  91. {
  92. }
  93. static int32_t ARM_ETH_MAC_GetRxFrameTime(ARM_ETH_MAC_TIME *time)
  94. {
  95. }
  96. static int32_t ARM_ETH_MAC_GetTxFrameTime(ARM_ETH_MAC_TIME *time)
  97. {
  98. }
  99. static int32_t ARM_ETH_MAC_Control(uint32_t control, uint32_t arg)
  100. {
  101. switch (control)
  102. {
  103. case ARM_ETH_MAC_CONFIGURE:
  104. switch (arg & ARM_ETH_MAC_SPEED_Msk)
  105. {
  106. case ARM_ETH_MAC_SPEED_10M:
  107. break;
  108. case ARM_ETH_SPEED_100M:
  109. break;
  110. default:
  111. return ARM_DRIVER_ERROR_UNSUPPORTED;
  112. }
  113. switch (arg & ARM_ETH_MAC_DUPLEX_Msk)
  114. {
  115. case ARM_ETH_MAC_DUPLEX_FULL:
  116. break;
  117. }
  118. if (arg & ARM_ETH_MAC_LOOPBACK)
  119. {
  120. }
  121. if ((arg & ARM_ETH_MAC_CHECKSUM_OFFLOAD_RX) ||
  122. (arg & ARM_ETH_MAC_CHECKSUM_OFFLOAD_TX))
  123. {
  124. return ARM_DRIVER_ERROR_UNSUPPORTED;
  125. }
  126. if (!(arg & ARM_ETH_MAC_ADDRESS_BROADCAST))
  127. {
  128. }
  129. if (arg & ARM_ETH_MAC_ADDRESS_MULTICAST)
  130. {
  131. }
  132. if (arg & ARM_ETH_MAC_ADDRESS_ALL)
  133. {
  134. }
  135. break;
  136. case ARM_ETH_MAC_CONTROL_TX:
  137. break;
  138. case ARM_ETH_MAC_CONTROL_RX:
  139. break;
  140. case ARM_ETH_MAC_FLUSH:
  141. if (arg & ARM_ETH_MAC_FLUSH_RX)
  142. {
  143. }
  144. if (arg & ARM_ETH_MAC_FLUSH_TX)
  145. {
  146. }
  147. break;
  148. case ARM_ETH_MAC_SLEEP:
  149. break;
  150. case ARM_ETH_MAC_VLAN_FILTER:
  151. break;
  152. default:
  153. return ARM_DRIVER_ERROR_UNSUPPORTED;
  154. }
  155. }
  156. static int32_t ARM_ETH_MAC_ControlTimer(uint32_t control, ARM_ETH_MAC_TIME *time)
  157. {
  158. }
  159. static int32_t ARM_ETH_MAC_PHY_Read(uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
  160. {
  161. }
  162. static int32_t ARM_ETH_MAC_PHY_Write(uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
  163. {
  164. }
  165. static void ARM_ETH_MAC_SignalEvent(uint32_t event)
  166. {
  167. }
  168. // End ETH MAC Interface
  169. extern \
  170. ARM_DRIVER_ETH_MAC Driver_ETH_MAC0;
  171. ARM_DRIVER_ETH_MAC Driver_ETH_MAC0 =
  172. {
  173. ARM_ETH_MAC_GetVersion,
  174. ARM_ETH_MAC_GetCapabilities,
  175. ARM_ETH_MAC_Initialize,
  176. ARM_ETH_MAC_Uninitialize,
  177. ARM_ETH_MAC_PowerControl,
  178. ARM_ETH_MAC_GetMacAddress,
  179. ARM_ETH_MAC_SetMacAddress,
  180. ARM_ETH_MAC_SetAddressFilter,
  181. ARM_ETH_MAC_SendFrame,
  182. ARM_ETH_MAC_ReadFrame,
  183. ARM_ETH_MAC_GetRxFrameSize,
  184. ARM_ETH_MAC_GetRxFrameTime,
  185. ARM_ETH_MAC_GetTxFrameTime,
  186. ARM_ETH_MAC_ControlTimer,
  187. ARM_ETH_MAC_Control,
  188. ARM_ETH_MAC_PHY_Read,
  189. ARM_ETH_MAC_PHY_Write
  190. };