merge with mainline

This commit is contained in:
BVK Chaitanya 2010-08-26 11:45:29 +05:30
commit b899201c69
556 changed files with 6811 additions and 5037 deletions

View file

@ -25,6 +25,13 @@
#include <grub/types.h>
#include <grub/elf.h>
/*
* Macros GRUB_MOD_INIT and GRUB_MOD_FINI are also used by build rules
* to collect module names, so we define them only when they are not
* defined already.
*/
#ifndef GRUB_MOD_INIT
#define GRUB_MOD_INIT(name) \
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
void grub_##name##_init (void); \
@ -32,7 +39,9 @@ void \
grub_##name##_init (void) { grub_mod_init (0); } \
static void \
grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
#endif
#ifndef GRUB_MOD_FINI
#define GRUB_MOD_FINI(name) \
static void grub_mod_fini (void) __attribute__ ((used)); \
void grub_##name##_fini (void); \
@ -40,6 +49,7 @@ void \
grub_##name##_fini (void) { grub_mod_fini (); } \
static void \
grub_mod_fini (void)
#endif
#ifdef APPLE_CC
#define GRUB_MOD_NAME(name) \
@ -92,11 +102,6 @@ grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
void grub_dl_unload_unneeded (void);
void grub_dl_unload_all (void);
#if defined (GRUB_UTIL) || defined (GRUB_TARGET_NO_MODULES)
#define GRUB_NO_MODULES 1
#else
#define GRUB_NO_MODULES 0
#endif
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
extern grub_dl_t EXPORT_VAR(grub_dl_head);
@ -110,7 +115,7 @@ grub_err_t grub_dl_register_symbol (const char *name, void *addr,
grub_err_t grub_arch_dl_check_header (void *ehdr);
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
#if defined (_mips) && ! GRUB_NO_MODULES
#if defined (_mips)
#define GRUB_LINKER_HAVE_INIT 1
void grub_arch_dl_init_linker (void);
#endif

View file

@ -28,6 +28,7 @@ enum grub_dev_abstraction_types {
char *grub_guess_root_device (const char *dir);
int grub_util_get_dev_abstraction (const char *os_dev);
char *grub_util_get_grub_dev (const char *os_dev);
char *grub_make_system_path_relative_to_its_root (const char *path);
const char *grub_util_check_block_device (const char *blk_dev);
const char *grub_util_check_char_device (const char *blk_dev);

View file

@ -42,6 +42,7 @@
extern int verbosity;
extern const char *program_name;
void grub_emu_init (void);
void grub_init_all (void);
void grub_fini_all (void);

View file

@ -324,4 +324,11 @@ void EXPORT_FUNC (grub_halt) (int no_apm) __attribute__ ((noreturn));
void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
#endif
#ifdef GRUB_MACHINE_EMU
/* Flag to control module autoloading in normal mode. */
extern int EXPORT_VAR(grub_no_autoload);
#else
#define grub_no_autoload 0
#endif
#endif /* ! GRUB_MISC_HEADER */

View file

@ -73,7 +73,7 @@ grub_err_t grub_normal_print_device_info (const char *name);
/* Defined in `color.c'. */
char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
char *grub_env_write_color_highlight (struct grub_env_var *var, const char *val);
void grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
int grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
/* Defined in `menu_text.c'. */
void grub_wait_after_message (void);

73
include/grub/ns8250.h Normal file
View file

@ -0,0 +1,73 @@
/* serial.h - serial device interface */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2005,2007 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_NS8250_HEADER
#define GRUB_NS8250_HEADER 1
/* Macros. */
/* 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
/* For LSR bits. */
#define UART_DATA_READY 0x01
#define UART_EMPTY_TRANSMITTER 0x20
/* The type of parity. */
#define UART_NO_PARITY 0x00
#define UART_ODD_PARITY 0x08
#define UART_EVEN_PARITY 0x18
/* The type of word length. */
#define UART_5BITS_WORD 0x00
#define UART_6BITS_WORD 0x01
#define UART_7BITS_WORD 0x02
#define UART_8BITS_WORD 0x03
/* 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
/* Enable the FIFO. */
#define UART_ENABLE_FIFO_TRIGGER14 0xC7
/* 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 */

View file

@ -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,54 +20,100 @@
#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>
#include <grub/term.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;
struct grub_serial_config;
/* 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,
struct grub_serial_config *config);
int (*fetch) (struct grub_serial_port *port);
void (*put) (struct grub_serial_port *port, const int c);
void (*fini) (struct grub_serial_port *port);
};
/* The type of parity. */
#define UART_NO_PARITY 0x00
#define UART_ODD_PARITY 0x08
#define UART_EVEN_PARITY 0x18
typedef enum
{
GRUB_SERIAL_PARITY_NONE,
GRUB_SERIAL_PARITY_ODD,
GRUB_SERIAL_PARITY_EVEN,
} grub_serial_parity_t;
/* The type of word length. */
#define UART_5BITS_WORD 0x00
#define UART_6BITS_WORD 0x01
#define UART_7BITS_WORD 0x02
#define UART_8BITS_WORD 0x03
typedef enum
{
GRUB_SERIAL_STOP_BITS_1,
GRUB_SERIAL_STOP_BITS_2,
} grub_serial_stop_bits_t;
/* The type of the length of stop bit. */
#define UART_1_STOP_BIT 0x00
#define UART_2_STOP_BITS 0x04
struct grub_serial_config
{
unsigned speed;
int word_len;
grub_serial_parity_t parity;
grub_serial_stop_bits_t stop_bits;
};
/* the switch of DLAB. */
#define UART_DLAB 0x80
struct grub_serial_port
{
struct grub_serial_port *next;
char *name;
struct grub_serial_driver *driver;
struct grub_serial_config config;
int configured;
/* 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 usbdev;
int configno;
int interfno;
char buf[64];
int bufstart, bufend;
struct grub_usb_desc_endp *in_endp;
struct grub_usb_desc_endp *out_endp;
};
};
grub_term_output_t term_out;
grub_term_input_t term_in;
};
/* Enable the FIFO. */
#define UART_ENABLE_FIFO_TRIGGER14 0xC7
grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port);
/* Enable the FIFO. */
#define UART_ENABLE_FIFO_TRIGGER1 0x07
void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port);
/* Turn on DTR, RTS, and OUT2. */
#define UART_ENABLE_DTRRTS 0x03
/* Set default settings. */
static inline grub_err_t
grub_serial_config_defaults (struct grub_serial_port *port)
{
struct grub_serial_config config =
{
#ifdef GRUB_MACHINE_MIPS_YEELOONG
.speed = 115200,
#else
.speed = 9600,
#endif
.word_len = 8,
.parity = GRUB_SERIAL_PARITY_NONE,
.stop_bits = GRUB_SERIAL_STOP_BITS_1
};
/* Turn on DTR, RTS, and OUT2. */
#define UART_ENABLE_OUT2 0x08
return port->driver->configure (port, &config);
}
#endif /* ! GRUB_SERIAL_MACHINE_HEADER */
void grub_ns8250_init (void);
char *grub_serial_ns8250_add_port (grub_port_t port);
extern struct grub_serial_driver grub_ns8250_driver;
void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver);
#endif

View file

@ -459,6 +459,7 @@ grub_print_spaces (struct grub_term_output *term, int number_spaces)
grub_putcode (' ', term);
}
extern void (*EXPORT_VAR (grub_term_poll_usb)) (void);
/* For convenience. */
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)

View file

@ -32,7 +32,7 @@ struct grub_terminfo_input_state
{
int input_buf[GRUB_TERMINFO_READKEY_MAX_LEN];
int npending;
int (*readkey) (void);
int (*readkey) (struct grub_term_input *term);
};
struct grub_terminfo_output_state
@ -51,7 +51,7 @@ struct grub_terminfo_output_state
unsigned int xpos, ypos;
void (*put) (const int c);
void (*put) (struct grub_term_output *term, const int c);
};
void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term,

View file

@ -72,14 +72,14 @@ void grub_test_nonzero (int cond, const char *file,
/* Macro to define a functional test. */
#define GRUB_FUNCTIONAL_TEST(name, funp) \
GRUB_MOD_INIT(functional_test_##funp) \
GRUB_MOD_INIT(name) \
{ \
grub_test_register (name, funp); \
grub_test_register (#name, funp); \
} \
\
GRUB_MOD_FINI(functional_test_##funp) \
GRUB_MOD_FINI(name) \
{ \
grub_test_unregister (name); \
grub_test_unregister (#name); \
}
#endif /* ! GRUB_TEST_HEADER */

View file

@ -19,6 +19,7 @@
#ifndef GRUB_USB_H
#define GRUB_USB_H 1
#include <grub/err.h>
#include <grub/usbdesc.h>
#include <grub/usbtrans.h>
@ -47,6 +48,14 @@ typedef enum
GRUB_USB_SPEED_HIGH
} grub_usb_speed_t;
enum
{
GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT = 0x21,
GRUB_USB_REQTYPE_VENDOR_OUT = 0x40,
GRUB_USB_REQTYPE_CLASS_INTERFACE_IN = 0xa1,
GRUB_USB_REQTYPE_VENDOR_IN = 0xc0
};
/* Call HOOK with each device, until HOOK returns non-zero. */
int grub_usb_iterate (int (*hook) (grub_usb_device_t dev));
@ -97,7 +106,8 @@ struct grub_usb_controller_dev
int (*iterate) (int (*hook) (grub_usb_controller_t dev));
grub_usb_err_t (*transfer) (grub_usb_controller_t dev,
grub_usb_transfer_t transfer);
grub_usb_transfer_t transfer,
int timeout, grub_size_t *actual);
int (*hubports) (grub_usb_controller_t dev);
@ -132,6 +142,8 @@ struct grub_usb_interface
int attached;
void (*detach_hook) (struct grub_usb_device *dev, int config, int interface);
void *detach_data;
};
struct grub_usb_configuration
@ -166,12 +178,32 @@ struct grub_usb_device
/* Data toggle values (used for bulk transfers only). */
int toggle[256];
/* Device-specific data. */
/* Used by libusb wrapper. Schedulded for removal. */
void *data;
/* Array of children for a hub. */
grub_usb_device_t *children;
/* Number of hub ports. */
unsigned nports;
};
typedef enum grub_usb_ep_type
{
GRUB_USB_EP_CONTROL,
GRUB_USB_EP_ISOCHRONOUS,
GRUB_USB_EP_BULK,
GRUB_USB_EP_INTERRUPT
} grub_usb_ep_type_t;
static inline enum grub_usb_ep_type
grub_usb_get_ep_type (struct grub_usb_desc_endp *ep)
{
return ep->attrib & 3;
}
typedef enum
{
GRUB_USB_CLASS_NOTHERE,
@ -230,5 +262,9 @@ void grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc);
void grub_usb_poll_devices (void);
void grub_usb_device_attach (grub_usb_device_t dev);
grub_usb_err_t
grub_usb_bulk_read_extended (grub_usb_device_t dev,
int endpoint, grub_size_t size, char *data,
int timeout, grub_size_t *actual);
#endif /* GRUB_USB_H */

View file

@ -31,6 +31,12 @@ typedef enum {
GRUB_USB_DESCRIPTOR_HUB = 0x29
} grub_usb_descriptor_t;
struct grub_usb_desc
{
grub_uint8_t length;
grub_uint8_t type;
} __attribute__ ((packed));
struct grub_usb_desc_device
{
grub_uint8_t length;

34
include/grub/usbserial.h Normal file
View file

@ -0,0 +1,34 @@
/* serial.h - serial device interface */
/*
* GRUB -- GRand Unified Bootloader
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_USBSERIAL_HEADER
#define GRUB_USBSERIAL_HEADER 1
void grub_usbserial_fini (struct grub_serial_port *port);
void grub_usbserial_detach (grub_usb_device_t usbdev, int configno,
int interfno);
int
grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno,
struct grub_serial_driver *driver);
int
grub_usbserial_fetch (struct grub_serial_port *port, grub_size_t header_size);
#endif

View file

@ -38,6 +38,7 @@ struct grub_usb_transaction
int toggle;
grub_transfer_type_t pid;
grub_uint32_t data;
grub_size_t preceding;
};
typedef struct grub_usb_transaction *grub_usb_transaction_t;