20
20
#ifndef GRUB_SERIAL_HEADER
21
21
#define GRUB_SERIAL_HEADER 1
25
/* The offsets of UART registers. */
40
#define UART_DATA_READY 0x01
41
#define UART_EMPTY_TRANSMITTER 0x20
23
#include <grub/types.h>
24
#include <grub/cpu/io.h>
26
#include <grub/list.h>
27
#include <grub/term.h>
29
struct grub_serial_port;
30
struct grub_serial_config;
32
struct grub_serial_driver
34
grub_err_t (*configure) (struct grub_serial_port *port,
35
struct grub_serial_config *config);
36
int (*fetch) (struct grub_serial_port *port);
37
void (*put) (struct grub_serial_port *port, const int c);
38
void (*fini) (struct grub_serial_port *port);
43
41
/* The type of parity. */
44
#define UART_NO_PARITY 0x00
45
#define UART_ODD_PARITY 0x08
46
#define UART_EVEN_PARITY 0x18
48
/* The type of word length. */
49
#define UART_5BITS_WORD 0x00
50
#define UART_6BITS_WORD 0x01
51
#define UART_7BITS_WORD 0x02
52
#define UART_8BITS_WORD 0x03
54
/* The type of the length of stop bit. */
55
#define UART_1_STOP_BIT 0x00
56
#define UART_2_STOP_BITS 0x04
58
/* the switch of DLAB. */
59
#define UART_DLAB 0x80
61
/* Enable the FIFO. */
62
#define UART_ENABLE_FIFO_TRIGGER14 0xC7
64
/* Enable the FIFO. */
65
#define UART_ENABLE_FIFO_TRIGGER1 0x07
67
/* Turn on DTR, RTS, and OUT2. */
68
#define UART_ENABLE_DTRRTS 0x03
70
/* Turn on DTR, RTS, and OUT2. */
71
#define UART_ENABLE_OUT2 0x08
73
#endif /* ! GRUB_SERIAL_MACHINE_HEADER */
44
GRUB_SERIAL_PARITY_NONE,
45
GRUB_SERIAL_PARITY_ODD,
46
GRUB_SERIAL_PARITY_EVEN,
47
} grub_serial_parity_t;
51
GRUB_SERIAL_STOP_BITS_1,
52
GRUB_SERIAL_STOP_BITS_2,
53
} grub_serial_stop_bits_t;
55
struct grub_serial_config
59
grub_serial_parity_t parity;
60
grub_serial_stop_bits_t stop_bits;
63
struct grub_serial_port
65
struct grub_serial_port *next;
67
struct grub_serial_driver *driver;
68
struct grub_serial_config config;
70
/* This should be void *data but since serial is useful as an early console
71
when malloc isn't available it's a union.
82
grub_usb_device_t usbdev;
87
struct grub_usb_desc_endp *in_endp;
88
struct grub_usb_desc_endp *out_endp;
91
grub_term_output_t term_out;
92
grub_term_input_t term_in;
95
grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port);
97
void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port);
99
/* Set default settings. */
100
static inline grub_err_t
101
grub_serial_config_defaults (struct grub_serial_port *port)
103
struct grub_serial_config config =
105
#ifdef GRUB_MACHINE_MIPS_YEELOONG
111
.parity = GRUB_SERIAL_PARITY_NONE,
112
.stop_bits = GRUB_SERIAL_STOP_BITS_1
115
return port->driver->configure (port, &config);
118
void grub_ns8250_init (void);
119
char *grub_serial_ns8250_add_port (grub_port_t port);
120
extern struct grub_serial_driver grub_ns8250_driver;
121
void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver);