xref: /illumos-gate/usr/src/grub/grub-0.97/stage2/serial.h (revision 5626beece2e5dedec7197ecf325cfaa1854a6c2e)
1 /* serial.h - serial device interface */
2 /*
3  *  GRUB  --  GRand Unified Bootloader
4  *  Copyright (C) 2000,2001,2002  Free Software Foundation, Inc.
5  *
6  *  This program 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 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program 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.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20 
21 #ifndef GRUB_SERIAL_HEADER
22 #define GRUB_SERIAL_HEADER	1
23 
24 /* Macros.  */
25 
26 /* The maximum number of ports we ever try to use. */
27 #define	SERIAL_MAX_PORTS	4
28 
29 /* The offsets of UART registers.  */
30 #define UART_TX		0
31 #define UART_RX		0
32 #define UART_DLL	0
33 #define UART_IER	1
34 #define UART_DLH	1
35 #define UART_IIR	2
36 #define UART_FCR	2
37 #define UART_LCR	3
38 #define UART_MCR	4
39 #define UART_LSR	5
40 #define UART_MSR	6
41 #define UART_SR		7
42 
43 /* For LSR bits.  */
44 #define UART_DATA_READY		0x01
45 #define UART_EMPTY_TRANSMITTER	0x20
46 
47 /* The type of parity.  */
48 #define UART_NO_PARITY		0x00
49 #define UART_ODD_PARITY		0x08
50 #define UART_EVEN_PARITY	0x18
51 
52 /* The type of word length.  */
53 #define UART_5BITS_WORD	0x00
54 #define UART_6BITS_WORD	0x01
55 #define UART_7BITS_WORD	0x02
56 #define UART_8BITS_WORD	0x03
57 
58 /* The type of the length of stop bit.  */
59 #define UART_1_STOP_BIT		0x00
60 #define UART_2_STOP_BITS	0x04
61 
62 /* the switch of DLAB.  */
63 #define UART_DLAB	0x80
64 
65 /* Enable the FIFO.  */
66 #define UART_ENABLE_FIFO	0xC7
67 
68 /* Turn on DTR, RTS, and OUT2.  */
69 #define UART_ENABLE_MODEM	0x0B
70 
71 /* Arbitrary pattern to write during existence testing. */
72 #define	UART_SR_TEST	0x4F
73 
74 
75 /* Function prototypes.  */
76 
77 /* Fetch a key.  */
78 int serial_hw_fetch (void);
79 
80 /* Put a character.  */
81 void serial_hw_put (int c);
82 
83 /* Insert a delay.  */
84 void serial_hw_delay (void);
85 
86 /* Return the port number for the UNITth serial device.  */
87 unsigned short serial_hw_get_port (int unit);
88 
89 /* Initialize a serial device.  */
90 int serial_hw_init (unsigned short port, unsigned int speed,
91 		    int word_len, int parity, int stop_bit_len);
92 
93 #ifdef GRUB_UTIL
94 /* Set the file name of a serial device (or a pty device). This is a
95    function specific to the grub shell.  */
96 void serial_set_device (const char *device);
97 #endif /* GRUB_UTIL */
98 
99 #endif /* ! GRUB_SERIAL_HEADER */
100