git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4994 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
5b3b5aa160
commit
8e8aff84b3
|
@ -109,7 +109,6 @@ typedef struct MACDriver MACDriver;
|
||||||
#define macGetReceiveEventSource(macp) (&(macp)->rdevent)
|
#define macGetReceiveEventSource(macp) (&(macp)->rdevent)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !MAC_USE_ZERO_COPY || defined(__DOXYGEN__)
|
|
||||||
/**
|
/**
|
||||||
* @brief Writes to a transmit descriptor's stream.
|
* @brief Writes to a transmit descriptor's stream.
|
||||||
*
|
*
|
||||||
|
@ -140,7 +139,6 @@ typedef struct MACDriver MACDriver;
|
||||||
*/
|
*/
|
||||||
#define macReadReceiveDescriptor(rdp, buf, size) \
|
#define macReadReceiveDescriptor(rdp, buf, size) \
|
||||||
mac_lld_read_receive_descriptor(rdp, buf, size)
|
mac_lld_read_receive_descriptor(rdp, buf, size)
|
||||||
#endif /* !MAC_USE_ZERO_COPY */
|
|
||||||
|
|
||||||
#if MAC_USE_ZERO_COPY || defined(__DOXYGEN__)
|
#if MAC_USE_ZERO_COPY || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -612,6 +612,69 @@ bool_t mac_lld_poll_link_status(MACDriver *macp) {
|
||||||
return macp->link_up = TRUE;
|
return macp->link_up = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Writes to a transmit descriptor's stream.
|
||||||
|
*
|
||||||
|
* @param[in] tdp pointer to a @p MACTransmitDescriptor structure
|
||||||
|
* @param[in] buf pointer to the buffer containing the data to be
|
||||||
|
* written
|
||||||
|
* @param[in] size number of bytes to be written
|
||||||
|
* @return The number of bytes written into the descriptor's
|
||||||
|
* stream, this value can be less than the amount
|
||||||
|
* specified in the parameter @p size if the maximum
|
||||||
|
* frame size is reached.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
|
||||||
|
uint8_t *buf,
|
||||||
|
size_t size) {
|
||||||
|
|
||||||
|
chDbgAssert(!(tdp->physdesc->tdes0 & STM32_TDES0_OWN),
|
||||||
|
"mac_lld_write_transmit_descriptor(), #1",
|
||||||
|
"attempt to write descriptor already owned by DMA");
|
||||||
|
|
||||||
|
if (size > tdp->size - tdp->offset)
|
||||||
|
size = tdp->size - tdp->offset;
|
||||||
|
|
||||||
|
if (size > 0) {
|
||||||
|
memcpy((uint8_t *)(tdp->physdesc->tdes2) + tdp->offset, buf, size);
|
||||||
|
tdp->offset += size;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads from a receive descriptor's stream.
|
||||||
|
*
|
||||||
|
* @param[in] rdp pointer to a @p MACReceiveDescriptor structure
|
||||||
|
* @param[in] buf pointer to the buffer that will receive the read data
|
||||||
|
* @param[in] size number of bytes to be read
|
||||||
|
* @return The number of bytes read from the descriptor's
|
||||||
|
* stream, this value can be less than the amount
|
||||||
|
* specified in the parameter @p size if there are
|
||||||
|
* no more bytes to read.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
|
||||||
|
uint8_t *buf,
|
||||||
|
size_t size) {
|
||||||
|
|
||||||
|
chDbgAssert(!(rdp->physdesc->rdes0 & STM32_RDES0_OWN),
|
||||||
|
"mac_lld_read_receive_descriptor(), #1",
|
||||||
|
"attempt to read descriptor already owned by DMA");
|
||||||
|
|
||||||
|
if (size > rdp->size - rdp->offset)
|
||||||
|
size = rdp->size - rdp->offset;
|
||||||
|
|
||||||
|
if (size > 0) {
|
||||||
|
memcpy(buf, (uint8_t *)(rdp->physdesc->rdes2) + rdp->offset, size);
|
||||||
|
rdp->offset += size;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
#if MAC_USE_ZERO_COPY || defined(__DOXYGEN__)
|
#if MAC_USE_ZERO_COPY || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief Returns a pointer to the next transmit buffer in the descriptor
|
* @brief Returns a pointer to the next transmit buffer in the descriptor
|
||||||
|
@ -675,71 +738,6 @@ const uint8_t *mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp,
|
||||||
}
|
}
|
||||||
#endif /* MAC_USE_ZERO_COPY */
|
#endif /* MAC_USE_ZERO_COPY */
|
||||||
|
|
||||||
#if !MAC_USE_ZERO_COPY || defined(__DOXYGEN__)
|
|
||||||
/**
|
|
||||||
* @brief Writes to a transmit descriptor's stream.
|
|
||||||
*
|
|
||||||
* @param[in] tdp pointer to a @p MACTransmitDescriptor structure
|
|
||||||
* @param[in] buf pointer to the buffer containing the data to be
|
|
||||||
* written
|
|
||||||
* @param[in] size number of bytes to be written
|
|
||||||
* @return The number of bytes written into the descriptor's
|
|
||||||
* stream, this value can be less than the amount
|
|
||||||
* specified in the parameter @p size if the maximum
|
|
||||||
* frame size is reached.
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
|
|
||||||
uint8_t *buf,
|
|
||||||
size_t size) {
|
|
||||||
|
|
||||||
chDbgAssert(!(tdp->physdesc->tdes0 & STM32_TDES0_OWN),
|
|
||||||
"mac_lld_write_transmit_descriptor(), #1",
|
|
||||||
"attempt to write descriptor already owned by DMA");
|
|
||||||
|
|
||||||
if (size > tdp->size - tdp->offset)
|
|
||||||
size = tdp->size - tdp->offset;
|
|
||||||
|
|
||||||
if (size > 0) {
|
|
||||||
memcpy((uint8_t *)(tdp->physdesc->tdes2) + tdp->offset, buf, size);
|
|
||||||
tdp->offset += size;
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Reads from a receive descriptor's stream.
|
|
||||||
*
|
|
||||||
* @param[in] rdp pointer to a @p MACReceiveDescriptor structure
|
|
||||||
* @param[in] buf pointer to the buffer that will receive the read data
|
|
||||||
* @param[in] size number of bytes to be read
|
|
||||||
* @return The number of bytes read from the descriptor's
|
|
||||||
* stream, this value can be less than the amount
|
|
||||||
* specified in the parameter @p size if there are
|
|
||||||
* no more bytes to read.
|
|
||||||
*
|
|
||||||
* @notapi
|
|
||||||
*/
|
|
||||||
size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
|
|
||||||
uint8_t *buf,
|
|
||||||
size_t size) {
|
|
||||||
|
|
||||||
chDbgAssert(!(rdp->physdesc->rdes0 & STM32_RDES0_OWN),
|
|
||||||
"mac_lld_read_receive_descriptor(), #1",
|
|
||||||
"attempt to read descriptor already owned by DMA");
|
|
||||||
|
|
||||||
if (size > rdp->size - rdp->offset)
|
|
||||||
size = rdp->size - rdp->offset;
|
|
||||||
|
|
||||||
if (size > 0) {
|
|
||||||
memcpy(buf, (uint8_t *)(rdp->physdesc->rdes2) + rdp->offset, size);
|
|
||||||
rdp->offset += size;
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
#endif /* !MAC_USE_ZERO_COPY */
|
|
||||||
|
|
||||||
#endif /* HAL_USE_MAC */
|
#endif /* HAL_USE_MAC */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -340,20 +340,19 @@ extern "C" {
|
||||||
MACReceiveDescriptor *rdp);
|
MACReceiveDescriptor *rdp);
|
||||||
void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp);
|
void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp);
|
||||||
bool_t mac_lld_poll_link_status(MACDriver *macp);
|
bool_t mac_lld_poll_link_status(MACDriver *macp);
|
||||||
#if MAC_USE_ZERO_COPY
|
|
||||||
uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp,
|
|
||||||
size_t size,
|
|
||||||
size_t *sizep);
|
|
||||||
const uint8_t *mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp,
|
|
||||||
size_t *sizep);
|
|
||||||
#else /* !MAC_USE_ZERO_COPY */
|
|
||||||
size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
|
size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
|
||||||
uint8_t *buf,
|
uint8_t *buf,
|
||||||
size_t size);
|
size_t size);
|
||||||
size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
|
size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
|
||||||
uint8_t *buf,
|
uint8_t *buf,
|
||||||
size_t size);
|
size_t size);
|
||||||
#endif /* !MAC_USE_ZERO_COPY */
|
#if MAC_USE_ZERO_COPY
|
||||||
|
uint8_t *mac_lld_get_next_transmit_buffer(MACTransmitDescriptor *tdp,
|
||||||
|
size_t size,
|
||||||
|
size_t *sizep);
|
||||||
|
const uint8_t *mac_lld_get_next_receive_buffer(MACReceiveDescriptor *rdp,
|
||||||
|
size_t *sizep);
|
||||||
|
#endif /* MAC_USE_ZERO_COPY */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue