Implement serial on IEEE1275 and EFI.

* docs/grub.texi (Platform-specific limitations): Fix the columen video
	on emu. Mention arc and emu as the only platforms without serial
	support.
	* grub-core/Makefile.core.def (serial): Enable on all terminfomodule and
	ieee1275 platforms.
	* grub-core/term/efi/serial.c: New file.
	* grub-core/term/ieee1275/serial.c: Likewise.
	* grub-core/term/serial.c (grub_serial_find): Disable direct port
	specification if no ns8250 driver is available.
	(grub_cmd_serial): Likewise.
	(GRUB_MOD_INIT) [GRUB_MACHINE_IEEE1275]: Init ofserial.
	(GRUB_MOD_INIT) [GRUB_MACHINE_EFI]: Init efiserial.
	* include/grub/efi/api.h (GRUB_EFI_SERIAL_IO_GUID): New define.
	(grub_efi_parity_type_t): New type.
	(grub_efi_stop_bits_t): Likewise.
	(grub_efi_serial_io_interface): New struct.
	* include/grub/serial.h (grub_serial_port): Make 'broken' field
	available for all interfaces.
	Add EFI and IEEE1275 fields.
	(grub_ofserial_init): New proto.
	(grub_efiserial_init): Likeiwse.
	* util/grub.d/00_header.in: Don't check for the presence of serial
	module.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-26 17:08:11 +01:00
parent 0ec820904e
commit a9c7fd1c6c
9 changed files with 566 additions and 19 deletions

View file

@ -84,6 +84,11 @@
{ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
}
#define GRUB_EFI_SERIAL_IO_GUID \
{ 0xbb25cf6f, 0xf1d4, 0x11d2, \
{ 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0xfd } \
}
#define GRUB_EFI_SIMPLE_NETWORK_GUID \
{ 0xa19832b9, 0xac25, 0x11d3, \
{ 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
@ -222,6 +227,24 @@ enum
GRUB_EFI_SAL_SYSTEM_TABLE_PLATFORM_FEATURE_ITCDRIFT = 8,
};
typedef enum grub_efi_parity_type
{
GRUB_EFI_SERIAL_DEFAULT_PARITY,
GRUB_EFI_SERIAL_NO_PARITY,
GRUB_EFI_SERIAL_EVEN_PARITY,
GRUB_EFI_SERIAL_ODD_PARITY
}
grub_efi_parity_type_t;
typedef enum grub_efi_stop_bits
{
GRUB_EFI_SERIAL_DEFAULT_STOP_BITS,
GRUB_EFI_SERIAL_1_STOP_BIT,
GRUB_EFI_SERIAL_1_5_STOP_BITS,
GRUB_EFI_SERIAL_2_STOP_BITS
}
grub_efi_stop_bits_t;
/* Enumerations. */
enum grub_efi_timer_delay
{
@ -1065,6 +1088,27 @@ typedef struct grub_efi_configuration_table grub_efi_configuration_table_t;
#define GRUB_EFIEMU_SYSTEM_TABLE_SIGNATURE 0x5453595320494249LL
#define GRUB_EFIEMU_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552LL
struct grub_efi_serial_io_interface
{
grub_efi_uint32_t revision;
void (*reset) (void);
grub_efi_status_t (*set_attributes) (struct grub_efi_serial_io_interface *this,
grub_efi_uint64_t speed,
grub_efi_uint32_t fifo_depth,
grub_efi_uint32_t timeout,
grub_efi_parity_type_t parity,
grub_uint8_t word_len,
grub_efi_stop_bits_t stop_bits);
void (*set_control_bits) (void);
void (*get_control_bits) (void);
grub_efi_status_t (*write) (struct grub_efi_serial_io_interface *this,
grub_efi_uintn_t *buf_size,
void *buffer);
grub_efi_status_t (*read) (struct grub_efi_serial_io_interface *this,
grub_efi_uintn_t *buf_size,
void *buffer);
};
struct grub_efi_simple_input_interface
{
grub_efi_status_t

View file

@ -21,10 +21,15 @@
#define GRUB_SERIAL_HEADER 1
#include <grub/types.h>
#if defined(__mips__) || defined (__i386__) || defined (__x86_64__)
#include <grub/cpu/io.h>
#endif
#include <grub/usb.h>
#include <grub/list.h>
#include <grub/term.h>
#ifdef GRUB_MACHINE_IEEE1275
#include <grub/ieee1275/ieee1275.h>
#endif
struct grub_serial_port;
struct grub_serial_config;
@ -68,16 +73,16 @@ struct grub_serial_port
struct grub_serial_driver *driver;
struct grub_serial_config config;
int configured;
int broken;
/* This should be void *data but since serial is useful as an early console
when malloc isn't available it's a union.
*/
union
{
struct
{
grub_port_t port;
int broken;
};
#if defined(__mips__) || defined (__i386__) || defined (__x86_64__)
grub_port_t port;
#endif
struct
{
grub_usb_device_t usbdev;
@ -88,6 +93,16 @@ struct grub_serial_port
struct grub_usb_desc_endp *in_endp;
struct grub_usb_desc_endp *out_endp;
};
#ifdef GRUB_MACHINE_IEEE1275
struct
{
grub_ieee1275_ihandle_t handle;
struct ofserial_hash_ent *elem;
};
#endif
#ifdef GRUB_MACHINE_EFI
struct grub_efi_serial_io_interface *interface;
#endif
};
grub_term_output_t term_out;
grub_term_input_t term_in;
@ -142,8 +157,18 @@ grub_serial_config_defaults (struct grub_serial_port *port)
return port->driver->configure (port, &config);
}
#if defined(__mips__) || defined (__i386__) || defined (__x86_64__)
void grub_ns8250_init (void);
char *grub_serial_ns8250_add_port (grub_port_t port);
#endif
#ifdef GRUB_MACHINE_IEEE1275
void grub_ofserial_init (void);
#endif
#ifdef GRUB_MACHINE_EFI
void
grub_efiserial_init (void);
#endif
struct grub_serial_port *grub_serial_find (const char *name);
extern struct grub_serial_driver grub_ns8250_driver;
void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver);