summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarcus Shawcroft <marcus.shawcroft@arm.com>2016-10-23 08:53:21 +0100
committerAnas Nashif <nashif@linux.intel.com>2016-10-25 11:31:08 +0000
commit1bc999cb8d9d71dcaaaf86e0eb736d99ade2d3bd (patch)
treec3d0750f73c978c0489682ea445d0f44c25b5df7 /include
parentf60398170728cce96cbdce8a6bb9769ee686426f (diff)
drivers/uart: Refactor UART input hook.
This refactor is in preparation for making driver API structures const. The console driver provides a mechanism to install an input and an output hook function. These are primarily used by the onboard gdb-server. The output hook is entirely implemented within the console driver. The input hook is partially implemented in the top of the uart driver and within the console driver. The hook function itself is installed in the uart API structure, but is invoked only by the console driver. Installing the hook function directly into the uart API structure prevents the API structure being const. There are two approaches to fixing this: 1) Implement setting of the input hook in the same way as uart_irq_callback_set(). 2) Move the input hook entirely to the console driver. We implement the latter. This approach has two benefits, first it removes the need for every uart driver to implement the behaviour and second, the current placement of the callback function in the uart API seems odd given that the callback is only invoked by the console driver, never by a uart driver. Change-Id: I258b312d3055df1c2bdeb896bd4f4f39c40838f7 Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/drivers/console/uart_console.h7
-rw-r--r--include/uart.h50
2 files changed, 6 insertions, 51 deletions
diff --git a/include/drivers/console/uart_console.h b/include/drivers/console/uart_console.h
index ace834cd8..c3e29936f 100644
--- a/include/drivers/console/uart_console.h
+++ b/include/drivers/console/uart_console.h
@@ -57,8 +57,13 @@ void uart_register_input(struct nano_fifo *avail, struct nano_fifo *lines,
#define UART_CONSOLE_OUT_DEBUG_HOOK_SIG(x) int(x)(char c)
typedef UART_CONSOLE_OUT_DEBUG_HOOK_SIG(uart_console_out_debug_hook_t);
-extern void uart_console_out_debug_hook_install(
+void uart_console_out_debug_hook_install(
uart_console_out_debug_hook_t *hook);
+
+typedef int (*uart_console_in_debug_hook_t) (uint8_t);
+
+void uart_console_in_debug_hook_install(uart_console_in_debug_hook_t hook);
+
#endif
#ifdef __cplusplus
diff --git a/include/uart.h b/include/uart.h
index 4775133e8..1179d199b 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -166,9 +166,6 @@ struct uart_driver_api {
/** Interrupt driven interrupt update function */
int (*irq_update)(struct device *dev);
- /** Interrupt driven input hook function */
- int (*irq_input_hook)(struct device *dev, uint8_t byte);
-
/** Set the callback function */
void (*irq_callback_set)(struct device *dev, uart_irq_callback_t cb);
@@ -499,53 +496,6 @@ static inline int uart_irq_update(struct device *dev)
}
/**
- * @brief Invoke the UART input hook routine if it is installed.
- *
- * The input hook is a custom handler invoked by the ISR on each received
- * character. It allows the detection of a character escape sequence that can
- * be used to override the behavior of the ISR handler.
- *
- * @param dev UART device structure.
- * @param byte Byte to process.
- *
- * @retval 1 If character processing must stop.
- * @retval 0 If it should continue.
- */
-static inline int uart_irq_input_hook(struct device *dev, uint8_t byte)
-{
- struct uart_driver_api *api;
-
- api = (struct uart_driver_api *)dev->driver_api;
-
- if ((api != NULL) && (api->irq_input_hook != NULL)) {
- return api->irq_input_hook(dev, byte);
- }
-
- return 0;
-}
-
-/**
- * @brief Set the UART input hook routine.
- *
- * @param dev UART device structure.
- * @param hook Routine to use as UART input hook.
- *
- * @return N/A
- */
-static inline void uart_irq_input_hook_set(struct device *dev,
- int (*hook)(struct device *, uint8_t))
-{
- struct uart_driver_api *api;
-
- api = (struct uart_driver_api *)dev->driver_api;
-
- if (api != NULL) {
- api->irq_input_hook = hook;
- }
-}
-
-
-/**
* @brief Set the IRQ callback function pointer.
*
* This sets up the callback for IRQ. When an IRQ is triggered,