1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2 * Copyright 2008-2012 Freescale Semiconductor Inc.
3 * Copyright 2017-2020 NXP
11 #define PTR_TO_UINT(_ptr) ((uintptr_t)(_ptr))
12 #define UINT_TO_PTR(_val) ((void *)(uintptr_t)(_val))
14 /* phys_address_t should be uintptr_t */
15 typedef uint64_t phys_address_t;
18 * @Description Possible RxStore callback responses.
20 typedef enum e_rx_store_response {
21 e_RX_STORE_RESPONSE_PAUSE
22 /**< Pause invoking callback with received data; in polling
23 * mode, start again invoking callback only next time user
24 * invokes the receive routine; in interrupt mode, start again
25 * invoking callback only next time a receive event triggers an
26 * interrupt; in all cases, received data that are pending are
27 * not lost, rather, their processing is temporarily deferred;
28 * in all cases, received data are processed in the order in
29 * which they were received.
31 , e_RX_STORE_RESPONSE_CONTINUE
32 /**< Continue invoking callback with received data. */
33 } e_rx_store_response;
37 * @Description General Handle
39 typedef void *t_handle; /**< handle, used as object's descriptor */
44 * @Function t_get_buf_function
46 * @Description User callback function called by driver to get data buffer.
48 * User provides this function. Driver invokes it.
50 * @Param[in] h_buffer_pool A handle to buffer pool manager
51 * @Param[out] p_buf_context_handle Returns the user's private context that
52 * should be associated with the buffer
54 * @Return Pointer to data buffer, NULL if error
56 typedef uint8_t * (t_get_buf_function)(t_handle h_buffer_pool,
57 t_handle *p_buf_context_handle);
60 * @Function t_put_buf_function
62 * @Description User callback function called by driver to return data buffer.
63 * User provides this function. Driver invokes it.
65 * @Param[in] h_buffer_pool A handle to buffer pool manager
66 * @Param[in] p_buffer A pointer to buffer to return
67 * @Param[in] h_buf_context The user's private context associated
68 * with the returned buffer
70 * @Return E_OK on success; Error code otherwise
72 typedef uint32_t (t_put_buf_function)(t_handle h_buffer_pool,
74 t_handle h_buf_context);
77 * @Function t_phys_to_virt
79 * @Description Translates a physical address to the matching virtual address.
81 * @Param[in] addr The physical address to translate.
83 * @Return Virtual address.
85 typedef void *t_phys_to_virt(phys_address_t addr);
88 * @Function t_virt_to_phys
90 * @Description Translates a virtual address to the matching physical address.
92 * @Param[in] addr The virtual address to translate.
94 * @Return Physical address.
96 typedef phys_address_t t_virt_to_phys(void *addr);
99 * @Description Buffer Pool Information Structure.
101 typedef struct t_buffer_pool_info {
102 t_handle h_buffer_pool;
103 /**< A handle to the buffer pool mgr */
104 t_get_buf_function *f_get_buf;
105 /**< User callback to get a free buffer */
106 t_put_buf_function *f_put_buf;
107 /**< User callback to return a buffer */
108 uint16_t buffer_size;
109 /**< Buffer size (in bytes) */
110 t_phys_to_virt *f_phys_to_virt;
111 /**< User callback to translate pool buffers physical addresses
112 * to virtual addresses
114 t_virt_to_phys *f_virt_to_phys;
115 /**< User callback to translate pool buffers virtual addresses
116 * to physical addresses
118 } t_buffer_pool_info;
121 * @Description User callback function called by driver with receive data.
122 * User provides this function. Driver invokes it.
124 * @Param[in] h_app Application's handle, as was provided to the
126 * @Param[in] queue_id Receive queue ID
127 * @Param[in] p_data Pointer to the buffer with received data
128 * @Param[in] h_buf_context The user's private context associated with the
130 * @Param[in] length Length of received data
131 * @Param[in] status Receive status and errors
132 * @Param[in] position Position of buffer in frame
133 * @Param[in] flags Driver-dependent information
135 * @Retval e_RX_STORE_RESPONSE_CONTINUE order the driver to continue Rx
136 * operation for all ready data.
137 * @Retval e_RX_STORE_RESPONSE_PAUSE order the driver to stop Rx ops.
139 typedef e_rx_store_response(t_rx_store_function)(t_handle h_app,
142 t_handle h_buf_context,
148 typedef struct t_device {
149 uintptr_t id; /**< the device id */
150 int fd; /**< the device file descriptor */
151 t_handle h_user_priv;
155 t_handle create_device(t_handle h_user_priv, t_handle h_dev_id);
156 t_handle get_device_id(t_handle h_dev);
158 #endif /* __NCSW_EXT_H */