Home | History | Annotate | Download | only in stage2
      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 offsets of UART registers.  */
     27 #define UART_TX		0
     28 #define UART_RX		0
     29 #define UART_DLL	0
     30 #define UART_IER	1
     31 #define UART_DLH	1
     32 #define UART_IIR	2
     33 #define UART_FCR	2
     34 #define UART_LCR	3
     35 #define UART_MCR	4
     36 #define UART_LSR	5
     37 #define UART_MSR	6
     38 #define UART_SR		7
     39 
     40 /* For LSR bits.  */
     41 #define UART_DATA_READY		0x01
     42 #define UART_EMPTY_TRANSMITTER	0x20
     43 
     44 /* The type of parity.  */
     45 #define UART_NO_PARITY		0x00
     46 #define UART_ODD_PARITY		0x08
     47 #define UART_EVEN_PARITY	0x18
     48 
     49 /* The type of word length.  */
     50 #define UART_5BITS_WORD	0x00
     51 #define UART_6BITS_WORD	0x01
     52 #define UART_7BITS_WORD	0x02
     53 #define UART_8BITS_WORD	0x03
     54 
     55 /* The type of the length of stop bit.  */
     56 #define UART_1_STOP_BIT		0x00
     57 #define UART_2_STOP_BITS	0x04
     58 
     59 /* the switch of DLAB.  */
     60 #define UART_DLAB	0x80
     61 
     62 /* Enable the FIFO.  */
     63 #define UART_ENABLE_FIFO	0xC7
     64 
     65 /* Turn on DTR, RTS, and OUT2.  */
     66 #define UART_ENABLE_MODEM	0x0B
     67 
     68 
     69 /* Function prototypes.  */
     71 
     72 /* Fetch a key.  */
     73 int serial_hw_fetch (void);
     74 
     75 /* Put a character.  */
     76 void serial_hw_put (int c);
     77 
     78 /* Insert a delay.  */
     79 void serial_hw_delay (void);
     80 
     81 /* Return the port number for the UNITth serial device.  */
     82 unsigned short serial_hw_get_port (int unit);
     83 
     84 /* Initialize a serial device.  */
     85 int serial_hw_init (unsigned short port, unsigned int speed,
     86 		    int word_len, int parity, int stop_bit_len);
     87 
     88 #ifdef GRUB_UTIL
     89 /* Set the file name of a serial device (or a pty device). This is a
     90    function specific to the grub shell.  */
     91 void serial_set_device (const char *device);
     92 #endif /* GRUB_UTIL */
     93 
     94 #endif /* ! GRUB_SERIAL_HEADER */
     95