Ensure all lines that should be omitted from public includes are marked
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / serial.h
blob9540bee64e1a23059eb3994ce42a101252db5152
1 /* serial.h - serial device interface */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2010 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef GRUB_SERIAL_HEADER
21 #define GRUB_SERIAL_HEADER 1
23 #include <grub/types.h>
24 #include <grub/cpu/io.h>
25 #include <grub/usb.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);
41 /* The type of parity. */
42 typedef enum
44 GRUB_SERIAL_PARITY_NONE,
45 GRUB_SERIAL_PARITY_ODD,
46 GRUB_SERIAL_PARITY_EVEN,
47 } grub_serial_parity_t;
49 typedef enum
51 GRUB_SERIAL_STOP_BITS_1,
52 GRUB_SERIAL_STOP_BITS_2,
53 } grub_serial_stop_bits_t;
55 struct grub_serial_config
57 unsigned speed;
58 int word_len;
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;
66 char *name;
67 struct grub_serial_driver *driver;
68 struct grub_serial_config config;
69 int configured;
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.
73 union
75 struct
77 grub_port_t port;
78 int broken;
80 struct
82 grub_usb_device_t usbdev;
83 int configno;
84 int interfno;
85 char buf[64];
86 int bufstart, bufend;
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
106 .speed = 115200,
107 #else
108 .speed = 9600,
109 #endif
110 .word_len = 8,
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);
123 #endif