aboutsummaryrefslogtreecommitdiffstats
path: root/os/io/templates
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-09-29 19:29:59 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-09-29 19:29:59 +0000
commitea9916ae798da3689d64689b88343d26508d137e (patch)
treea9b5a44a6bd7be5b15b3ab421803b74f41a5a7cd /os/io/templates
parentc9bfcaa15ec3d03ee088ecfa5cf6cf82e718cb38 (diff)
downloadChibiOS-ea9916ae798da3689d64689b88343d26508d137e.tar.gz
ChibiOS-ea9916ae798da3689d64689b88343d26508d137e.tar.bz2
ChibiOS-ea9916ae798da3689d64689b88343d26508d137e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1193 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/io/templates')
-rw-r--r--os/io/templates/mac_lld.c80
-rw-r--r--os/io/templates/mac_lld.h59
2 files changed, 85 insertions, 54 deletions
diff --git a/os/io/templates/mac_lld.c b/os/io/templates/mac_lld.c
index a780a32ff..08ffa8d79 100644
--- a/os/io/templates/mac_lld.c
+++ b/os/io/templates/mac_lld.c
@@ -52,75 +52,85 @@ void mac_lld_set_address(MACDriver *macp, const uint8_t *p) {
* returned.
*
* @param[in] macp pointer to the @p MACDriver object
- * @param[in] size size of the frame to be transmitted
- * @return A pointer to a @p MACTransmitDescriptor structure or @p NULL if
- * a descriptor is not available.
+ * @param[out] tdp pointer to a @p MACTransmitDescriptor structure
+ * @return The operation status.
+ * @retval RDY_OK the descriptor was obtained.
+ * @retval RDY_TIMEOUT descriptor not available.
*/
-MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp,
- size_t size) {
+msg_t max_lld_get_transmit_descriptor(MACDriver *macp,
+ MACTransmitDescriptor *tdp) {
- return NULL;
+ return RDY_OK;
}
/**
- * @brief Releases a transmit descriptor and starts the transmission of the
- * enqueued data as a single frame.
+ * @brief Writes to a transmit descriptor's stream.
*
- * @param[in] macp pointer to the @p MACDriver object
- * @param[in] tdp the pointer to the @p MACTransmitDescriptor structure
+ * @param[in] tdp pointer to a @p MACTransmitDescriptor structure
+ * @param[in] buf pointer to the buffer cointaining 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.
*/
-void mac_lld_release_transmit_descriptor(MACDriver *macp,
- MACTransmitDescriptor *tdp) {
+size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
+ uint8_t *buf,
+ size_t size) {
+ return 0;
}
/**
- * @brief Returns the buffer associated to a @p MACTransmitDescriptor.
+ * @brief Releases a transmit descriptor and starts the transmission of the
+ * enqueued data as a single frame.
*
* @param[in] tdp the pointer to the @p MACTransmitDescriptor structure
- * @return The pointer to the transmit buffer.
*/
-uint8_t *mac_lld_get_transmit_buffer(MACTransmitDescriptor *tdp) {
+void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp) {
- return NULL;
}
/**
- * @brief Returns a received frame.
+ * @brief Returns a receive descriptor.
*
* @param[in] macp pointer to the @p MACDriver object
- * @param[out szp size of the received frame
- * @return A pointer to a @p MACReceiveDescriptor structure or @p NULL if
- * the operation timed out or some transient error happened.
+ * @param[out] rdp pointer to a @p MACReceiveDescriptor structure
+ * @return The operation status.
+ * @retval RDY_OK the descriptor was obtained.
+ * @retval RDY_TIMEOUT descriptor not available.
*/
-MACReceiveDescriptor *max_lld_get_receive_descriptor(MACDriver *macp,
- size_t *szp) {
+msg_t max_lld_get_receive_descriptor(MACDriver *macp,
+ MACReceiveDescriptor *rdp) {
- return NULL;
+ return RDY_OK;
}
/**
- * @brief Releases a receive descriptor.
- * @details The descriptor and its buffer is made available for more incoming
- * frames.
+ * @brief Reads from a receive descriptor's stream.
*
- * @param[in] macp pointer to the @p MACDriver object
- * @param[in] rdp the pointer to the @p MACReceiveDescriptor structure
+ * @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.
*/
-void mac_lld_release_receive_descriptor(MACDriver *macp,
- MACReceiveDescriptor *rdp) {
+size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
+ uint8_t *buf,
+ size_t size) {
+ return 0;
}
/**
- * @brief Returns the buffer associated to a @p MACTransmitDescriptor.
+ * @brief Releases a receive descriptor.
+ * @details The descriptor and its buffer are made available for more incoming
+ * frames.
*
- * @param[in] tdp the pointer to the @p MACTransmitDescriptor structure
- * @return The pointer to the transmit buffer.
+ * @param[in] rdp the pointer to the @p MACReceiveDescriptor structure
*/
-uint8_t *mac_lld_get_receive_buffer(MACReceiveDescriptor *rdp) {
+void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) {
- return NULL;
}
/**
diff --git a/os/io/templates/mac_lld.h b/os/io/templates/mac_lld.h
index 377a18ea1..2b6e19c26 100644
--- a/os/io/templates/mac_lld.h
+++ b/os/io/templates/mac_lld.h
@@ -32,10 +32,24 @@
/*===========================================================================*/
/**
- * @brief Number of available descriptors/buffers.
+ * @brief Number of available transmit buffers.
*/
-#if !defined(MAC_TRANSMIT_DESCRIPTORS) || defined(__DOXYGEN__)
-#define MAC_TRANSMIT_DESCRIPTORS 2
+#if !defined(MAC_TRANSMIT_BUFFERS) || defined(__DOXYGEN__)
+#define MAC_TRANSMIT_BUFFERS 2
+#endif
+
+/**
+ * @brief Number of available receive buffers.
+ */
+#if !defined(MAC_RECEIVE_BUFFERS) || defined(__DOXYGEN__)
+#define MAC_RECEIVE_BUFFERS 2
+#endif
+
+/**
+ * @brief Maximum supported frame size.
+ */
+#if !defined(MAC_BUFFERS_SIZE) || defined(__DOXYGEN__)
+#define MAC_BUFFERS_SIZE 1518
#endif
/*===========================================================================*/
@@ -46,25 +60,30 @@
* @brief Structure representing a MAC driver.
*/
typedef struct {
- Semaphore md_tdsem; /**< Transmit semaphore.*/
- Semaphore md_rdsem; /**< Receive semaphore.*/
+ Semaphore md_tdsem; /**< Transmit semaphore. */
+ Semaphore md_rdsem; /**< Receive semaphore. */
#if CH_USE_EVENTS
- EventSource md_rdevent; /**< Receive event source.*/
+ EventSource md_rdevent; /**< Receive event source. */
#endif
+ /* End of the mandatory fields.*/
} MACDriver;
/**
- * @brief Structure representing a transmission descriptor.
+ * @brief Structure representing a transmit descriptor.
*/
typedef struct {
-
+ size_t td_offset; /**< Current write offset. */
+ size_t td_size; /**< Available space size. */
+ /* End of the mandatory fields.*/
} MACTransmitDescriptor;
/**
* @brief Structure representing a receive descriptor.
*/
typedef struct {
-
+ size_t rd_offset; /**< Current read offset. */
+ size_t rd_size; /**< Available data size. */
+ /* End of the mandatory fields.*/
} MACReceiveDescriptor;
/*===========================================================================*/
@@ -76,16 +95,18 @@ extern "C" {
#endif
void mac_lld_init(void);
void mac_lld_set_address(MACDriver *macp, const uint8_t *p);
- MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp,
- size_t size);
- void mac_lld_release_transmit_descriptor(MACDriver *macp,
- MACTransmitDescriptor *tdp);
- uint8_t *mac_lld_get_transmit_buffer(MACTransmitDescriptor *tdp);
- MACReceiveDescriptor *max_lld_get_receive_descriptor(MACDriver *macp,
- size_t *szp);
- void mac_lld_release_receive_descriptor(MACDriver *macp,
- MACReceiveDescriptor *rdp);
- uint8_t *mac_lld_get_receive_buffer(MACReceiveDescriptor *rdp);
+ msg_t max_lld_get_transmit_descriptor(MACDriver *macp,
+ MACTransmitDescriptor *tdp);
+ size_t mac_lld_write_transmit_descriptor(MACTransmitDescriptor *tdp,
+ uint8_t *buf,
+ size_t size);
+ void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp);
+ msg_t max_lld_get_receive_descriptor(MACDriver *macp,
+ MACReceiveDescriptor *rdp);
+ size_t mac_lld_read_receive_descriptor(MACReceiveDescriptor *rdp,
+ uint8_t *buf,
+ size_t size);
+ void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp);
bool_t mac_lld_poll_link_status(MACDriver *macp);
#ifdef __cplusplus
}