In order to reuse some ns8250 functions in other ns8250 compatible drivers this change makes a few functions non-static and adds them to the ns8250 interface in the ns8250.h header file.
Signed-off-by: Matthias Lange <[email protected]> --- grub-core/term/ns8250.c | 8 ++++---- include/grub/ns8250.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/grub-core/term/ns8250.c b/grub-core/term/ns8250.c index acc05eb..051021a 100644 --- a/grub-core/term/ns8250.c +++ b/grub-core/term/ns8250.c @@ -57,7 +57,7 @@ io_port_write (struct grub_serial_port *port, unsigned char value, grub_addr_t r } /* Convert speed to divisor. */ -static unsigned short +unsigned short serial_get_divisor (const struct grub_serial_port *port, const struct grub_serial_config *config) { @@ -153,7 +153,7 @@ do_real_config (struct grub_serial_port *port) } /* Fetch a key. */ -static int +int serial_hw_fetch (struct grub_serial_port *port) { do_real_config (port); @@ -164,7 +164,7 @@ serial_hw_fetch (struct grub_serial_port *port) } /* Put a character. */ -static void +void serial_hw_put (struct grub_serial_port *port, const int c) { grub_uint64_t endtime; @@ -201,7 +201,7 @@ serial_hw_put (struct grub_serial_port *port, const int c) STOP_BIT_LEN is the length of the stop bit. The possible values for WORD_LEN, PARITY and STOP_BIT_LEN are defined in the header file as macros. */ -static grub_err_t +grub_err_t serial_hw_configure (struct grub_serial_port *port, struct grub_serial_config *config) { diff --git a/include/grub/ns8250.h b/include/grub/ns8250.h index 7947ba9..8c15855 100644 --- a/include/grub/ns8250.h +++ b/include/grub/ns8250.h @@ -20,6 +20,8 @@ #ifndef GRUB_NS8250_HEADER #define GRUB_NS8250_HEADER 1 +#include <grub/serial.h> + /* Macros. */ /* The offsets of UART registers. */ @@ -75,6 +77,52 @@ grub_port_t grub_ns8250_hw_get_port (const unsigned int unit); + +/** + * \brief Configure and setup a serial port. + * + * \param port The serial port that should be set up. + * \param config The configuration that should be applied to the serial port. + * + * \retval GRUB_ERR_NONE Serial port setup and configured successfully. + * \retval GRUB_ERR_BAD_ARGUMENT Unsupported serial configuration. + */ +grub_err_t +serial_hw_configure (struct grub_serial_port *port, + struct grub_serial_config *config); + +/** + * \brief Calculate the divisor for a given baud rate. + * + * \param port The serial port for which the divisor needs to be calculated. + * \param config The configuration with the wanted baud rate. + * + * \retval 0 No divisor could be calculated + * \retval >0 The divisor that needs to be programmed into the UART. + */ +unsigned short +serial_get_divisor (const struct grub_serial_port *port, + const struct grub_serial_config *config); + +/** + * \brief Send a character over a serial port. + * + * \param port The serial port over which the character should be send. + * \param c The character to send over the serial port. + */ +void +serial_hw_put (struct grub_serial_port *port, const int c); + +/** + * \brief Read a character from a serial port. + * + * \param port The serial port to read the character from. + * + * \return The character read from the serial port. + */ +int +serial_hw_fetch (struct grub_serial_port *port); + #endif #endif /* ! GRUB_SERIAL_MACHINE_HEADER */ -- 2.7.4 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
