Restructure serial in order to prepare for usbserial. As a byproduct simultaneous serial consoles are possible
This commit is contained in:
parent
03f286ea9f
commit
75eb7d1116
10 changed files with 733 additions and 295 deletions
|
@ -1,7 +1,7 @@
|
|||
/* serial.h - serial device interface */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2000,2001,2002,2005,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,30 +20,51 @@
|
|||
#ifndef GRUB_SERIAL_HEADER
|
||||
#define GRUB_SERIAL_HEADER 1
|
||||
|
||||
/* Macros. */
|
||||
#include <grub/types.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/usb.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
/* The offsets of UART registers. */
|
||||
#define UART_TX 0
|
||||
#define UART_RX 0
|
||||
#define UART_DLL 0
|
||||
#define UART_IER 1
|
||||
#define UART_DLH 1
|
||||
#define UART_IIR 2
|
||||
#define UART_FCR 2
|
||||
#define UART_LCR 3
|
||||
#define UART_MCR 4
|
||||
#define UART_LSR 5
|
||||
#define UART_MSR 6
|
||||
#define UART_SR 7
|
||||
struct grub_serial_port;
|
||||
|
||||
/* For LSR bits. */
|
||||
#define UART_DATA_READY 0x01
|
||||
#define UART_EMPTY_TRANSMITTER 0x20
|
||||
struct grub_serial_driver
|
||||
{
|
||||
grub_err_t (*configure) (struct grub_serial_port *port,
|
||||
unsigned speed,
|
||||
unsigned short word_len,
|
||||
unsigned int parity,
|
||||
unsigned short stop_bits);
|
||||
int (*fetch) (struct grub_serial_port *port);
|
||||
void (*put) (struct grub_serial_port *port, const int c);
|
||||
};
|
||||
|
||||
/* The type of parity. */
|
||||
#define UART_NO_PARITY 0x00
|
||||
#define UART_ODD_PARITY 0x08
|
||||
#define UART_EVEN_PARITY 0x18
|
||||
struct grub_serial_port
|
||||
{
|
||||
struct grub_serial_port *next;
|
||||
char *name;
|
||||
unsigned speed;
|
||||
unsigned short word_len;
|
||||
unsigned int parity;
|
||||
unsigned short stop_bits;
|
||||
struct grub_serial_driver *driver;
|
||||
/* This should be void *data but since serial is useful as an early console
|
||||
when malloc isn't available it's a union.
|
||||
*/
|
||||
union
|
||||
{
|
||||
grub_port_t port;
|
||||
struct
|
||||
{
|
||||
grub_usb_device_t dev;
|
||||
int in_endp;
|
||||
int out_endp;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
grub_err_t grub_serial_register (struct grub_serial_port *port);
|
||||
|
||||
void grub_serial_unregister (struct grub_serial_port *port);
|
||||
|
||||
/* The type of word length. */
|
||||
#define UART_5BITS_WORD 0x00
|
||||
|
@ -51,23 +72,30 @@
|
|||
#define UART_7BITS_WORD 0x02
|
||||
#define UART_8BITS_WORD 0x03
|
||||
|
||||
/* The type of parity. */
|
||||
#define UART_NO_PARITY 0x00
|
||||
#define UART_ODD_PARITY 0x08
|
||||
#define UART_EVEN_PARITY 0x18
|
||||
|
||||
/* The type of the length of stop bit. */
|
||||
#define UART_1_STOP_BIT 0x00
|
||||
#define UART_2_STOP_BITS 0x04
|
||||
|
||||
/* the switch of DLAB. */
|
||||
#define UART_DLAB 0x80
|
||||
static inline void
|
||||
grub_serial_fill_defaults (struct grub_serial_port *port)
|
||||
{
|
||||
/* Set default settings. */
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
port->speed = 115200;
|
||||
#else
|
||||
port->speed = 9600;
|
||||
#endif
|
||||
port->word_len = UART_8BITS_WORD;
|
||||
port->parity = UART_NO_PARITY;
|
||||
port->stop_bits = UART_1_STOP_BIT;
|
||||
}
|
||||
|
||||
/* Enable the FIFO. */
|
||||
#define UART_ENABLE_FIFO_TRIGGER14 0xC7
|
||||
void grub_ns8250_init (void);
|
||||
char *grub_serial_ns8250_add_port (grub_port_t port);
|
||||
|
||||
/* Enable the FIFO. */
|
||||
#define UART_ENABLE_FIFO_TRIGGER1 0x07
|
||||
|
||||
/* Turn on DTR, RTS, and OUT2. */
|
||||
#define UART_ENABLE_DTRRTS 0x03
|
||||
|
||||
/* Turn on DTR, RTS, and OUT2. */
|
||||
#define UART_ENABLE_OUT2 0x08
|
||||
|
||||
#endif /* ! GRUB_SERIAL_MACHINE_HEADER */
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue