17c478bd9Sstevel@tonic-gate /* serial.h - serial device interface */ 27c478bd9Sstevel@tonic-gate /* 37c478bd9Sstevel@tonic-gate * GRUB -- GRand Unified Bootloader 47c478bd9Sstevel@tonic-gate * Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 57c478bd9Sstevel@tonic-gate * 67c478bd9Sstevel@tonic-gate * This program is free software; you can redistribute it and/or modify 77c478bd9Sstevel@tonic-gate * it under the terms of the GNU General Public License as published by 87c478bd9Sstevel@tonic-gate * the Free Software Foundation; either version 2 of the License, or 97c478bd9Sstevel@tonic-gate * (at your option) any later version. 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * This program is distributed in the hope that it will be useful, 127c478bd9Sstevel@tonic-gate * but WITHOUT ANY WARRANTY; without even the implied warranty of 137c478bd9Sstevel@tonic-gate * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 147c478bd9Sstevel@tonic-gate * GNU General Public License for more details. 157c478bd9Sstevel@tonic-gate * 167c478bd9Sstevel@tonic-gate * You should have received a copy of the GNU General Public License 177c478bd9Sstevel@tonic-gate * along with this program; if not, write to the Free Software 187c478bd9Sstevel@tonic-gate * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 197c478bd9Sstevel@tonic-gate */ 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate #ifndef GRUB_SERIAL_HEADER 227c478bd9Sstevel@tonic-gate #define GRUB_SERIAL_HEADER 1 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate /* Macros. */ 257c478bd9Sstevel@tonic-gate 26*5626beecSKeith M Wesolowski /* The maximum number of ports we ever try to use. */ 27*5626beecSKeith M Wesolowski #define SERIAL_MAX_PORTS 4 28*5626beecSKeith M Wesolowski 297c478bd9Sstevel@tonic-gate /* The offsets of UART registers. */ 307c478bd9Sstevel@tonic-gate #define UART_TX 0 317c478bd9Sstevel@tonic-gate #define UART_RX 0 327c478bd9Sstevel@tonic-gate #define UART_DLL 0 337c478bd9Sstevel@tonic-gate #define UART_IER 1 347c478bd9Sstevel@tonic-gate #define UART_DLH 1 357c478bd9Sstevel@tonic-gate #define UART_IIR 2 367c478bd9Sstevel@tonic-gate #define UART_FCR 2 377c478bd9Sstevel@tonic-gate #define UART_LCR 3 387c478bd9Sstevel@tonic-gate #define UART_MCR 4 397c478bd9Sstevel@tonic-gate #define UART_LSR 5 407c478bd9Sstevel@tonic-gate #define UART_MSR 6 417c478bd9Sstevel@tonic-gate #define UART_SR 7 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* For LSR bits. */ 447c478bd9Sstevel@tonic-gate #define UART_DATA_READY 0x01 457c478bd9Sstevel@tonic-gate #define UART_EMPTY_TRANSMITTER 0x20 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* The type of parity. */ 487c478bd9Sstevel@tonic-gate #define UART_NO_PARITY 0x00 497c478bd9Sstevel@tonic-gate #define UART_ODD_PARITY 0x08 507c478bd9Sstevel@tonic-gate #define UART_EVEN_PARITY 0x18 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* The type of word length. */ 537c478bd9Sstevel@tonic-gate #define UART_5BITS_WORD 0x00 547c478bd9Sstevel@tonic-gate #define UART_6BITS_WORD 0x01 557c478bd9Sstevel@tonic-gate #define UART_7BITS_WORD 0x02 567c478bd9Sstevel@tonic-gate #define UART_8BITS_WORD 0x03 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* The type of the length of stop bit. */ 597c478bd9Sstevel@tonic-gate #define UART_1_STOP_BIT 0x00 607c478bd9Sstevel@tonic-gate #define UART_2_STOP_BITS 0x04 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* the switch of DLAB. */ 637c478bd9Sstevel@tonic-gate #define UART_DLAB 0x80 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate /* Enable the FIFO. */ 667c478bd9Sstevel@tonic-gate #define UART_ENABLE_FIFO 0xC7 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* Turn on DTR, RTS, and OUT2. */ 697c478bd9Sstevel@tonic-gate #define UART_ENABLE_MODEM 0x0B 707c478bd9Sstevel@tonic-gate 71*5626beecSKeith M Wesolowski /* Arbitrary pattern to write during existence testing. */ 72*5626beecSKeith M Wesolowski #define UART_SR_TEST 0x4F 73*5626beecSKeith M Wesolowski 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* Function prototypes. */ 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* Fetch a key. */ 787c478bd9Sstevel@tonic-gate int serial_hw_fetch (void); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* Put a character. */ 817c478bd9Sstevel@tonic-gate void serial_hw_put (int c); 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* Insert a delay. */ 847c478bd9Sstevel@tonic-gate void serial_hw_delay (void); 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* Return the port number for the UNITth serial device. */ 877c478bd9Sstevel@tonic-gate unsigned short serial_hw_get_port (int unit); 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* Initialize a serial device. */ 907c478bd9Sstevel@tonic-gate int serial_hw_init (unsigned short port, unsigned int speed, 917c478bd9Sstevel@tonic-gate int word_len, int parity, int stop_bit_len); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #ifdef GRUB_UTIL 947c478bd9Sstevel@tonic-gate /* Set the file name of a serial device (or a pty device). This is a 957c478bd9Sstevel@tonic-gate function specific to the grub shell. */ 967c478bd9Sstevel@tonic-gate void serial_set_device (const char *device); 977c478bd9Sstevel@tonic-gate #endif /* GRUB_UTIL */ 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #endif /* ! GRUB_SERIAL_HEADER */ 100