Merge mainline into newreloc. For now without boot tests
This commit is contained in:
commit
16bd6cfab2
625 changed files with 45066 additions and 10823 deletions
|
@ -32,6 +32,12 @@ typedef enum
|
|||
GRUB_ATA_LBA48
|
||||
} grub_ata_addressing_t;
|
||||
|
||||
#define GRUB_ATA_CH0_PORT1 0x1f0
|
||||
#define GRUB_ATA_CH1_PORT1 0x170
|
||||
|
||||
#define GRUB_ATA_CH0_PORT2 0x3f6
|
||||
#define GRUB_ATA_CH1_PORT2 0x376
|
||||
|
||||
#define GRUB_ATA_REG_DATA 0
|
||||
#define GRUB_ATA_REG_ERROR 1
|
||||
#define GRUB_ATA_REG_FEATURES 1
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS 18
|
||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
|
||||
|
||||
#define GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION 2
|
||||
|
||||
/* The BSD partition entry. */
|
||||
struct grub_partition_bsd_entry
|
||||
{
|
||||
|
|
|
@ -117,5 +117,11 @@ grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
|||
|
||||
int grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
void
|
||||
grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
||||
grub_uint8_t *dest, grub_size_t destsize);
|
||||
grub_size_t grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1,8 +1,27 @@
|
|||
/*
|
||||
* 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_EMU_MISC_H
|
||||
#define GRUB_EMU_MISC_H 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/util/libzfs.h>
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
# include <sys/fcntl.h>
|
||||
|
@ -23,15 +42,20 @@
|
|||
extern int verbosity;
|
||||
extern const char *program_name;
|
||||
|
||||
void grub_emu_init (void);
|
||||
void grub_init_all (void);
|
||||
void grub_fini_all (void);
|
||||
|
||||
char *grub_make_system_path_relative_to_its_root (const char *path);
|
||||
void grub_find_zpool_from_dir (const char *dir,
|
||||
char **poolname, char **poolfs);
|
||||
|
||||
void * EXPORT_FUNC(xmalloc) (grub_size_t size);
|
||||
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size);
|
||||
char * EXPORT_FUNC(xstrdup) (const char *str);
|
||||
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||
char *grub_make_system_path_relative_to_its_root (const char *path)
|
||||
__attribute__ ((warn_unused_result));
|
||||
|
||||
void * EXPORT_FUNC(xmalloc) (grub_size_t size) __attribute__ ((warn_unused_result));
|
||||
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) __attribute__ ((warn_unused_result));
|
||||
char * EXPORT_FUNC(xstrdup) (const char *str) __attribute__ ((warn_unused_result));
|
||||
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((warn_unused_result));
|
||||
|
||||
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
|
||||
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);
|
||||
|
@ -45,11 +69,12 @@ int EXPORT_FUNC(vasprintf) (char **buf, const char *fmt, va_list ap);
|
|||
int EXPORT_FUNC(asprintf) (char **buf, const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...);
|
||||
extern char * canonicalize_file_name (const char *path);
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
int grub_device_mapper_supported (void);
|
||||
#endif
|
||||
|
||||
libzfs_handle_t *grub_get_libzfs_handle (void);
|
||||
|
||||
#endif /* GRUB_EMU_MISC_H */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/unicode.h>
|
||||
|
||||
/* Forward declaration of opaque structure grub_font.
|
||||
Users only pass struct grub_font pointers to the font module functions,
|
||||
|
@ -69,6 +70,11 @@ struct grub_font_glyph
|
|||
grub_uint8_t bitmap[0];
|
||||
};
|
||||
|
||||
/* Part of code field which is really used as such. */
|
||||
#define GRUB_FONT_CODE_CHAR_MASK 0x001fffff
|
||||
#define GRUB_FONT_CODE_RIGHT_JOINED 0x80000000
|
||||
#define GRUB_FONT_CODE_LEFT_JOINED 0x40000000
|
||||
|
||||
/* Initialize the font loader.
|
||||
Must be called before any fonts are loaded or used. */
|
||||
void grub_font_loader_init (void);
|
||||
|
@ -97,8 +103,7 @@ int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
|
|||
|
||||
int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
|
||||
|
||||
int EXPORT_FUNC (grub_font_get_string_width) (grub_font_t font,
|
||||
const char *str);
|
||||
int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
|
||||
|
||||
struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
|
||||
grub_uint32_t code);
|
||||
|
@ -110,9 +115,11 @@ grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
|
|||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
|
||||
grub_err_t EXPORT_FUNC (grub_font_draw_string) (const char *str,
|
||||
grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
int
|
||||
EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
|
||||
const struct grub_unicode_glyph *glyph_id);
|
||||
struct grub_font_glyph *
|
||||
EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
|
||||
const struct grub_unicode_glyph *glyph_id);
|
||||
|
||||
#endif /* ! GRUB_FONT_HEADER */
|
||||
|
|
|
@ -62,6 +62,14 @@ grub_gfxmenu_print_timeout (int timeout, void *data);
|
|||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data);
|
||||
|
||||
grub_err_t grub_font_draw_string (const char *str,
|
||||
grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
int grub_font_get_string_width (grub_font_t font,
|
||||
const char *str);
|
||||
|
||||
|
||||
/* Implementation details -- this should not be used outside of the
|
||||
view itself. */
|
||||
|
||||
|
|
|
@ -40,12 +40,15 @@
|
|||
#include <grub/i386/vga_common.h>
|
||||
|
||||
/* These are global to share code between C and asm. */
|
||||
int grub_console_checkkey (void);
|
||||
int grub_console_getkey (void);
|
||||
grub_uint16_t grub_console_getxy (void);
|
||||
void grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y);
|
||||
void grub_console_cls (void);
|
||||
void grub_console_setcursor (int on);
|
||||
int grub_console_checkkey (struct grub_term_input *term);
|
||||
int grub_console_getkey (struct grub_term_input *term);
|
||||
grub_uint16_t grub_console_getxy (struct grub_term_output *term);
|
||||
void grub_console_gotoxy (struct grub_term_output *term,
|
||||
grub_uint8_t x, grub_uint8_t y);
|
||||
void grub_console_cls (struct grub_term_output *term);
|
||||
void grub_console_setcursor (struct grub_term_output *term, int on);
|
||||
void grub_console_putchar (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
|
|
|
@ -25,16 +25,8 @@
|
|||
|
||||
extern grub_uint8_t grub_console_cur_color;
|
||||
|
||||
void grub_console_putchar (grub_uint32_t c);
|
||||
grub_ssize_t grub_console_getcharwidth (grub_uint32_t c);
|
||||
grub_uint16_t grub_console_getwh (void);
|
||||
void grub_console_setcolorstate (grub_term_color_state state);
|
||||
void grub_console_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color);
|
||||
void grub_console_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
|
||||
|
||||
/* Implemented in both kern/i386/pc/startup.S and vga_text.c; this symbol
|
||||
is not exported, so there's no collision, but vga_common.c expects this
|
||||
prototype to be the same. */
|
||||
void grub_console_real_putchar (int c);
|
||||
grub_uint16_t grub_console_getwh (struct grub_term_output *term);
|
||||
void grub_console_setcolorstate (struct grub_term_output *term,
|
||||
grub_term_color_state state);
|
||||
|
||||
#endif /* ! GRUB_VGA_COMMON_CPU_HEADER */
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include <grub/symbol.h>
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
void grub_console_init_early (void);
|
||||
void grub_console_init_lately (void);
|
||||
|
||||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
90
include/grub/mips/loongson.h
Normal file
90
include/grub/mips/loongson.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* 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_LOONGSON_CPU_HEADER
|
||||
#define GRUB_LOONGSON_CPU_HEADER 1
|
||||
|
||||
#ifdef ASM_FILE
|
||||
#define GRUB_CPU_REGISTER_WRAP(x) x
|
||||
#else
|
||||
#define GRUB_CPU_REGISTER_WRAP(x) #x
|
||||
#endif
|
||||
|
||||
#define GRUB_CPU_LOONGSON_FLASH_START 0xbfc00000
|
||||
#define GRUB_CPU_LOONGSON_FLASH_TLB_REFILL 0xbfc00200
|
||||
#define GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR 0xbfc00300
|
||||
#define GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION 0xbfc00380
|
||||
|
||||
#define GRUB_CPU_LOONGSON_DDR2_BASE 0xaffffe00
|
||||
#define GRUB_CPU_LOONGSON_DDR2_REG1_HI_8BANKS 0x00000001
|
||||
#define GRUB_CPU_LOONGSON_DDR2_REG_SIZE 0x8
|
||||
#define GRUB_CPU_LOONGSON_DDR2_REG_STEP 0x10
|
||||
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG GRUB_CPU_REGISTER_WRAP($16)
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_ILINESIZE 0x10
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_CONFIG_DLINESIZE 0x8
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_DSIZE_SHIFT 6
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_ISIZE_SHIFT 9
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_MASK 0x7
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_SIZE_OFFSET 12
|
||||
|
||||
#define GRUB_CPU_LOONGSON_COP0_I_INDEX_INVALIDATE 0
|
||||
#define GRUB_CPU_LOONGSON_COP0_D_INDEX_TAG_STORE 9
|
||||
#define GRUB_CPU_LOONGSON_COP0_S_INDEX_TAG_STORE 11
|
||||
|
||||
#define GRUB_CPU_LOONGSON_COP0_I_INDEX_BIT_OFFSET 5
|
||||
#define GRUB_CPU_LOONGSON_COP0_D_INDEX_BIT_OFFSET 5
|
||||
#define GRUB_CPU_LOONGSON_COP0_S_INDEX_BIT_OFFSET 5
|
||||
|
||||
#define GRUB_CPU_LOONGSON_CACHE_ACCELERATED 7
|
||||
#define GRUB_CPU_LOONGSON_CACHE_UNCACHED 2
|
||||
#define GRUB_CPU_LOONGSON_CACHE_CACHED 3
|
||||
#define GRUB_CPU_LOONGSON_CACHE_TYPE_MASK 7
|
||||
#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_SMALL 4
|
||||
#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_LOG_BIG 5
|
||||
#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_SMALL 16
|
||||
#define GRUB_CPU_LOONGSON_CACHE_LINE_SIZE_BIG 32
|
||||
|
||||
#define GRUB_CPU_LOONGSON_I_CACHE_LOG_WAYS 2
|
||||
#define GRUB_CPU_LOONGSON_D_CACHE_LOG_WAYS 2
|
||||
#define GRUB_CPU_LOONGSON_S_CACHE_LOG_WAYS 2
|
||||
|
||||
/* FIXME: determine dynamically. */
|
||||
#define GRUB_CPU_LOONGSON_SECONDARY_CACHE_LOG_SIZE 19
|
||||
|
||||
#define GRUB_CPU_LOONGSON_COP0_BADVADDR GRUB_CPU_REGISTER_WRAP($8)
|
||||
#define GRUB_CPU_LOONGSON_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9)
|
||||
#define GRUB_CPU_LOONGSON_COP0_CAUSE GRUB_CPU_REGISTER_WRAP($13)
|
||||
#define GRUB_CPU_LOONGSON_COP0_EPC GRUB_CPU_REGISTER_WRAP($14)
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_TAGLO GRUB_CPU_REGISTER_WRAP($28)
|
||||
#define GRUB_CPU_LOONGSON_COP0_CACHE_TAGHI GRUB_CPU_REGISTER_WRAP($29)
|
||||
|
||||
#define GRUB_CPU_LOONGSON_LIOCFG 0xbfe00108
|
||||
#define GRUB_CPU_LOONGSON_ROM_DELAY_OFFSET 2
|
||||
#define GRUB_CPU_LOONGSON_ROM_DELAY_MASK 0x1f
|
||||
#define GRUB_CPU_LOONGSON_CORECFG 0xbfe00180
|
||||
#define GRUB_CPU_LOONGSON_CORECFG_DISABLE_DDR2_SPACE 0x100
|
||||
#define GRUB_CPU_LOONGSON_CORECFG_BUFFER_CPU 0x200
|
||||
|
||||
#define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO 0xbfe00150
|
||||
#define GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI 0xbfe00154
|
||||
|
||||
#define GRUB_CPU_LOONGSON_GPIOCFG 0xbfe00120
|
||||
#define GRUB_CPU_LOONGSON_SHUTDOWN_GPIO 1
|
||||
|
||||
#endif
|
41
include/grub/mips/yeeloong/ec.h
Normal file
41
include/grub/mips/yeeloong/ec.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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_EC_MACHINE_HEADER
|
||||
#define GRUB_EC_MACHINE_HEADER 1
|
||||
|
||||
#define GRUB_MACHINE_EC_MAGIC_PORT1 0x381
|
||||
#define GRUB_MACHINE_EC_MAGIC_PORT2 0x382
|
||||
#define GRUB_MACHINE_EC_DATA_PORT 0x383
|
||||
|
||||
#define GRUB_MACHINE_EC_MAGIC_VAL1 0xf4
|
||||
#define GRUB_MACHINE_EC_MAGIC_VAL2 0xec
|
||||
|
||||
#define GRUB_MACHINE_EC_COMMAND_REBOOT 1
|
||||
|
||||
static inline void
|
||||
grub_write_ec (grub_uint8_t value)
|
||||
{
|
||||
grub_outb (GRUB_MACHINE_EC_MAGIC_VAL1,
|
||||
GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_MAGIC_PORT1);
|
||||
grub_outb (GRUB_MACHINE_EC_MAGIC_VAL2,
|
||||
GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_MAGIC_PORT2);
|
||||
grub_outb (value, GRUB_MACHINE_PCI_IO_BASE + GRUB_MACHINE_EC_DATA_PORT);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -19,6 +19,12 @@
|
|||
#ifndef GRUB_MACHINE_SERIAL_HEADER
|
||||
#define GRUB_MACHINE_SERIAL_HEADER 1
|
||||
|
||||
#define GRUB_MACHINE_SERIAL_PORTS { 0xbff003f8 }
|
||||
#define GRUB_MACHINE_SERIAL_DIVISOR_115200 2
|
||||
#define GRUB_MACHINE_SERIAL_PORT 0xbff003f8
|
||||
|
||||
#ifndef ASM_FILE
|
||||
#define GRUB_MACHINE_SERIAL_PORTS { GRUB_MACHINE_SERIAL_PORT }
|
||||
#else
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -233,13 +233,25 @@ grub_strtol (const char *str, char **end, int base)
|
|||
}
|
||||
}
|
||||
|
||||
char *EXPORT_FUNC(grub_strdup) (const char *s);
|
||||
char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n);
|
||||
char *EXPORT_FUNC(grub_strdup) (const char *s) __attribute__ ((warn_unused_result));
|
||||
char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n) __attribute__ ((warn_unused_result));
|
||||
void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
||||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
|
||||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) __attribute__ ((warn_unused_result));
|
||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
int EXPORT_FUNC(grub_puts) (const char *s);
|
||||
|
||||
extern void (*EXPORT_VAR (grub_xputs)) (const char *str);
|
||||
|
||||
static inline int
|
||||
grub_puts (const char *s)
|
||||
{
|
||||
const char nl[2] = "\n";
|
||||
grub_xputs (s);
|
||||
grub_xputs (nl);
|
||||
|
||||
return 1; /* Cannot fail. */
|
||||
}
|
||||
|
||||
int EXPORT_FUNC(grub_puts_) (const char *s);
|
||||
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||
const int line,
|
||||
|
@ -251,15 +263,10 @@ int EXPORT_FUNC(grub_snprintf) (char *str, grub_size_t n, const char *fmt, ...)
|
|||
int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt,
|
||||
va_list args);
|
||||
char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args);
|
||||
__attribute__ ((format (printf, 1, 2))) __attribute__ ((warn_unused_result));
|
||||
char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) __attribute__ ((warn_unused_result));
|
||||
void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
|
||||
void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
|
||||
grub_size_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest,
|
||||
grub_size_t destsize,
|
||||
const grub_uint8_t *src,
|
||||
grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend);
|
||||
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
|
||||
grub_uint32_t d, grub_uint32_t *r);
|
||||
|
||||
|
@ -283,6 +290,15 @@ grub_abs (int x)
|
|||
return (unsigned int) x;
|
||||
}
|
||||
|
||||
static inline long
|
||||
grub_min (long x, long y)
|
||||
{
|
||||
if (x < y)
|
||||
return x;
|
||||
else
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline long
|
||||
grub_max (long x, long y)
|
||||
{
|
||||
|
@ -300,14 +316,21 @@ grub_div_roundup (unsigned int x, unsigned int y)
|
|||
}
|
||||
|
||||
/* Reboot the machine. */
|
||||
void EXPORT_FUNC (grub_reboot) (void);
|
||||
void EXPORT_FUNC (grub_reboot) (void) __attribute__ ((noreturn));
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
/* Halt the system, using APM if possible. If NO_APM is true, don't
|
||||
* use APM even if it is available. */
|
||||
void EXPORT_FUNC (grub_halt) (int no_apm);
|
||||
void EXPORT_FUNC (grub_halt) (int no_apm) __attribute__ ((noreturn));
|
||||
#else
|
||||
void EXPORT_FUNC (grub_halt) (void);
|
||||
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 */
|
||||
|
|
|
@ -73,13 +73,15 @@ 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);
|
||||
void grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
void
|
||||
grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
int margin_left, int margin_right,
|
||||
struct grub_term_output *term);
|
||||
grub_ssize_t grub_getstringwidth (grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
|
@ -110,7 +112,9 @@ void read_terminal_list (const char *prefix);
|
|||
|
||||
void grub_set_more (int onoff);
|
||||
|
||||
int grub_normal_get_line_counter (void);
|
||||
void grub_install_newline_hook (void);
|
||||
int grub_normal_get_char_counter (void);
|
||||
void grub_normal_reset_more (void);
|
||||
|
||||
void grub_xputs_normal (const char *str);
|
||||
|
||||
#endif /* ! GRUB_NORMAL_HEADER */
|
||||
|
|
78
include/grub/ns8250.h
Normal file
78
include/grub/ns8250.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* 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
|
||||
|
||||
#include <grub/cpu/io.h>
|
||||
|
||||
grub_port_t
|
||||
grub_ns8250_hw_get_port (const unsigned int unit);
|
||||
|
||||
#endif /* ! GRUB_SERIAL_MACHINE_HEADER */
|
|
@ -83,7 +83,7 @@ struct grub_parser
|
|||
};
|
||||
typedef struct grub_parser *grub_parser_t;
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_parser_execute) (char *source);
|
||||
grub_err_t grub_parser_execute (char *source);
|
||||
|
||||
grub_err_t
|
||||
grub_rescue_parse_line (char *line, grub_reader_getline_t getline);
|
||||
|
|
|
@ -48,7 +48,7 @@ struct grub_partition
|
|||
/* The partition number. */
|
||||
int number;
|
||||
|
||||
/* The start sector. */
|
||||
/* The start sector (relative to parent). */
|
||||
grub_disk_addr_t start;
|
||||
|
||||
/* The length in sector units. */
|
||||
|
@ -60,7 +60,7 @@ struct grub_partition
|
|||
/* The index of this partition in the partition table. */
|
||||
int index;
|
||||
|
||||
/* Parent partition map. */
|
||||
/* Parent partition (physically contains this partition). */
|
||||
struct grub_partition *parent;
|
||||
|
||||
/* The type partition map. */
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
|
||||
#define GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT 9
|
||||
#define GRUB_PCI_STATUS_DEVSEL_TIMING_MASK 0x0600
|
||||
#define GRUB_PCI_CLASS_SUBCLASS_VGA 0x0300
|
||||
|
||||
#ifndef ASM_FILE
|
||||
typedef grub_uint32_t grub_pci_id_t;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* raid.h - On disk structures for RAID. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,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
|
||||
|
@ -51,6 +51,8 @@ struct grub_raid_array
|
|||
char *name; /* That will be "md<number>". */
|
||||
unsigned int nr_devs; /* The number of devices we've found so far. */
|
||||
grub_disk_t device[GRUB_RAID_MAX_DEVICES]; /* Array of total_devs devices. */
|
||||
grub_disk_addr_t start_sector[GRUB_RAID_MAX_DEVICES];
|
||||
/* Start of each device, in 512 byte sectors. */
|
||||
struct grub_raid_array *next;
|
||||
};
|
||||
|
||||
|
@ -58,7 +60,8 @@ struct grub_raid
|
|||
{
|
||||
const char *name;
|
||||
|
||||
grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array);
|
||||
grub_err_t (*detect) (grub_disk_t disk, struct grub_raid_array *array,
|
||||
grub_disk_addr_t *start_sector);
|
||||
|
||||
struct grub_raid *next;
|
||||
};
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/parser.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
struct grub_script_mem;
|
||||
|
||||
|
@ -63,6 +64,13 @@ struct grub_script_arg
|
|||
struct grub_script_arg *next;
|
||||
};
|
||||
|
||||
/* An argument vector. */
|
||||
struct grub_script_argv
|
||||
{
|
||||
unsigned argc;
|
||||
char **args;
|
||||
};
|
||||
|
||||
/* A complete argument. It consists of a list of one or more `struct
|
||||
grub_script_arg's. */
|
||||
struct grub_script_arglist
|
||||
|
@ -82,15 +90,6 @@ struct grub_script_cmdline
|
|||
struct grub_script_arglist *arglist;
|
||||
};
|
||||
|
||||
/* A block of commands, this can be used to group commands. */
|
||||
struct grub_script_cmdblock
|
||||
{
|
||||
struct grub_script_cmd cmd;
|
||||
|
||||
/* A chain of commands. */
|
||||
struct grub_script_cmd *cmdlist;
|
||||
};
|
||||
|
||||
/* An if statement. */
|
||||
struct grub_script_cmdif
|
||||
{
|
||||
|
@ -224,6 +223,14 @@ struct grub_parser_param
|
|||
struct grub_lexer_param *lexerstate;
|
||||
};
|
||||
|
||||
void grub_script_init (void);
|
||||
void grub_script_fini (void);
|
||||
|
||||
void grub_script_argv_free (struct grub_script_argv *argv);
|
||||
int grub_script_argv_next (struct grub_script_argv *argv);
|
||||
int grub_script_argv_append (struct grub_script_argv *argv, const char *s);
|
||||
int grub_script_argv_split_append (struct grub_script_argv *argv, char *s);
|
||||
|
||||
struct grub_script_arglist *
|
||||
grub_script_create_arglist (struct grub_parser_param *state);
|
||||
|
||||
|
@ -234,8 +241,6 @@ grub_script_add_arglist (struct grub_parser_param *state,
|
|||
struct grub_script_cmd *
|
||||
grub_script_create_cmdline (struct grub_parser_param *state,
|
||||
struct grub_script_arglist *arglist);
|
||||
struct grub_script_cmd *
|
||||
grub_script_create_cmdblock (struct grub_parser_param *state);
|
||||
|
||||
struct grub_script_cmd *
|
||||
grub_script_create_cmdif (struct grub_parser_param *state,
|
||||
|
@ -262,9 +267,9 @@ grub_script_create_cmdmenu (struct grub_parser_param *state,
|
|||
int options);
|
||||
|
||||
struct grub_script_cmd *
|
||||
grub_script_add_cmd (struct grub_parser_param *state,
|
||||
struct grub_script_cmdblock *cmdblock,
|
||||
struct grub_script_cmd *cmd);
|
||||
grub_script_append_cmd (struct grub_parser_param *state,
|
||||
struct grub_script_cmd *list,
|
||||
struct grub_script_cmd *last);
|
||||
struct grub_script_arg *
|
||||
grub_script_arg_add (struct grub_parser_param *state,
|
||||
struct grub_script_arg *arg,
|
||||
|
@ -301,7 +306,7 @@ void grub_script_yyerror (struct grub_parser_param *, char const *);
|
|||
|
||||
/* Commands to execute, don't use these directly. */
|
||||
grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdlist (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
||||
grub_err_t grub_script_execute_cmdwhile (struct grub_script_cmd *cmd);
|
||||
|
@ -310,6 +315,12 @@ grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
|
|||
/* Execute any GRUB pre-parsed command or script. */
|
||||
grub_err_t grub_script_execute (struct grub_script *script);
|
||||
|
||||
/* Break command for loops. */
|
||||
grub_err_t grub_script_break (grub_command_t cmd, int argc, char *argv[]);
|
||||
|
||||
/* SHIFT command for GRUB script. */
|
||||
grub_err_t grub_script_shift (grub_command_t cmd, int argc, char *argv[]);
|
||||
|
||||
/* This variable points to the parsed command. This is used to
|
||||
communicate with the bison code. */
|
||||
extern struct grub_script_cmd *grub_script_parsed;
|
||||
|
@ -344,8 +355,9 @@ grub_script_function_t grub_script_function_create (struct grub_script_arg *func
|
|||
struct grub_script *cmd);
|
||||
void grub_script_function_remove (const char *name);
|
||||
grub_script_function_t grub_script_function_find (char *functionname);
|
||||
int grub_script_function_call (grub_script_function_t func,
|
||||
int argc, char **args);
|
||||
|
||||
grub_err_t grub_script_function_call (grub_script_function_t func,
|
||||
int argc, char **args);
|
||||
|
||||
char **
|
||||
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count);
|
||||
|
|
|
@ -26,16 +26,35 @@ void grub_scsi_dev_unregister (grub_scsi_dev_t dev);
|
|||
|
||||
struct grub_scsi;
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_SCSI_SUBSYSTEM_USBMS,
|
||||
GRUB_SCSI_SUBSYSTEM_ATAPI
|
||||
};
|
||||
|
||||
#define GRUB_SCSI_ID_SUBSYSTEM_SHIFT 24
|
||||
#define GRUB_SCSI_ID_BUS_SHIFT 8
|
||||
#define GRUB_SCSI_ID_LUN_SHIFT 0
|
||||
|
||||
static inline grub_uint32_t
|
||||
grub_make_scsi_id (int subsystem, int bus, int lun)
|
||||
{
|
||||
return (subsystem << GRUB_SCSI_ID_SUBSYSTEM_SHIFT)
|
||||
| (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_BUS_SHIFT);
|
||||
}
|
||||
|
||||
struct grub_scsi_dev
|
||||
{
|
||||
/* The device name. */
|
||||
const char *name;
|
||||
|
||||
grub_uint8_t id;
|
||||
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int (*hook) (const char *name, int luns));
|
||||
int (*iterate) (int (*hook) (int bus, int luns));
|
||||
|
||||
/* Open the device named NAME, and set up SCSI. */
|
||||
grub_err_t (*open) (const char *name, struct grub_scsi *scsi);
|
||||
grub_err_t (*open) (int bus, struct grub_scsi *scsi);
|
||||
|
||||
/* Close the scsi device SCSI. */
|
||||
void (*close) (struct grub_scsi *scsi);
|
||||
|
@ -56,15 +75,14 @@ struct grub_scsi_dev
|
|||
|
||||
struct grub_scsi
|
||||
{
|
||||
/* The scsi device name. */
|
||||
char *name;
|
||||
|
||||
/* The underlying scsi device. */
|
||||
grub_scsi_dev_t dev;
|
||||
|
||||
/* Type of SCSI device. XXX: Make enum. */
|
||||
grub_uint8_t devtype;
|
||||
|
||||
int bus;
|
||||
|
||||
/* Number of LUNs. */
|
||||
int luns;
|
||||
|
||||
|
|
|
@ -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,53 +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 0xC7
|
||||
grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port);
|
||||
|
||||
/* Turn on DTR, RTS, and OUT2. */
|
||||
#define UART_ENABLE_MODEM 0x0B
|
||||
void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port);
|
||||
|
||||
#include <grub/cpu/io.h>
|
||||
/* 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
|
||||
};
|
||||
|
||||
grub_port_t
|
||||
grub_serial_hw_get_port (const unsigned int unit);
|
||||
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
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/unicode.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
/* These are used to represent the various color states we use. */
|
||||
|
@ -63,11 +64,25 @@ grub_term_color_state;
|
|||
to NULL. */
|
||||
|
||||
/* Set when input characters shouldn't be echoed back. */
|
||||
#define GRUB_TERM_NO_ECHO (1 << 0)
|
||||
#define GRUB_TERM_NO_ECHO (1 << 0)
|
||||
/* Set when the editing feature should be disabled. */
|
||||
#define GRUB_TERM_NO_EDIT (1 << 1)
|
||||
#define GRUB_TERM_NO_EDIT (1 << 1)
|
||||
/* Set when the terminal cannot do fancy things. */
|
||||
#define GRUB_TERM_DUMB (1 << 2)
|
||||
#define GRUB_TERM_DUMB (1 << 2)
|
||||
/* Which encoding does terminal expect stream to be. */
|
||||
#define GRUB_TERM_CODE_TYPE_SHIFT 3
|
||||
#define GRUB_TERM_CODE_TYPE_MASK (7 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* Only ASCII characters accepted. */
|
||||
#define GRUB_TERM_CODE_TYPE_ASCII (0 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* Expects CP-437 characters (ASCII + pseudographics). */
|
||||
#define GRUB_TERM_CODE_TYPE_CP437 (1 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* UTF-8 stream in logical order. Usually used for terminals
|
||||
which just forward the stream to another computer. */
|
||||
#define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL (2 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* UTF-8 in visual order. Like UTF-8 logical but for buggy endpoints. */
|
||||
#define GRUB_TERM_CODE_TYPE_UTF8_VISUAL (3 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* Glyph description in visual order. */
|
||||
#define GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS (4 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
|
||||
|
||||
/* Bitmasks for modifier keys returned by grub_getkeystatus. */
|
||||
|
@ -75,20 +90,6 @@ grub_term_color_state;
|
|||
#define GRUB_TERM_STATUS_CTRL (1 << 1)
|
||||
#define GRUB_TERM_STATUS_ALT (1 << 2)
|
||||
|
||||
|
||||
/* Unicode characters for fancy graphics. */
|
||||
#define GRUB_TERM_DISP_LEFT 0x2190
|
||||
#define GRUB_TERM_DISP_UP 0x2191
|
||||
#define GRUB_TERM_DISP_RIGHT 0x2192
|
||||
#define GRUB_TERM_DISP_DOWN 0x2193
|
||||
#define GRUB_TERM_DISP_HLINE 0x2501
|
||||
#define GRUB_TERM_DISP_VLINE 0x2503
|
||||
#define GRUB_TERM_DISP_UL 0x250F
|
||||
#define GRUB_TERM_DISP_UR 0x2513
|
||||
#define GRUB_TERM_DISP_LL 0x2517
|
||||
#define GRUB_TERM_DISP_LR 0x251B
|
||||
|
||||
|
||||
/* Menu-related geometrical constants. */
|
||||
|
||||
/* The number of lines of "GRUB version..." at the top. */
|
||||
|
@ -122,19 +123,21 @@ struct grub_term_input
|
|||
const char *name;
|
||||
|
||||
/* Initialize the terminal. */
|
||||
grub_err_t (*init) (void);
|
||||
grub_err_t (*init) (struct grub_term_input *term);
|
||||
|
||||
/* Clean up the terminal. */
|
||||
grub_err_t (*fini) (void);
|
||||
grub_err_t (*fini) (struct grub_term_input *term);
|
||||
|
||||
/* Check if any input character is available. */
|
||||
int (*checkkey) (void);
|
||||
int (*checkkey) (struct grub_term_input *term);
|
||||
|
||||
/* Get a character. */
|
||||
int (*getkey) (void);
|
||||
int (*getkey) (struct grub_term_input *term);
|
||||
|
||||
/* Get keyboard modifier status. */
|
||||
int (*getkeystatus) (void);
|
||||
int (*getkeystatus) (struct grub_term_input *term);
|
||||
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_term_input *grub_term_input_t;
|
||||
|
||||
|
@ -147,52 +150,58 @@ struct grub_term_output
|
|||
const char *name;
|
||||
|
||||
/* Initialize the terminal. */
|
||||
grub_err_t (*init) (void);
|
||||
grub_err_t (*init) (struct grub_term_output *term);
|
||||
|
||||
/* Clean up the terminal. */
|
||||
grub_err_t (*fini) (void);
|
||||
grub_err_t (*fini) (struct grub_term_output *term);
|
||||
|
||||
/* Put a character. C is encoded in Unicode. */
|
||||
void (*putchar) (grub_uint32_t c);
|
||||
void (*putchar) (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
/* Get the number of columns occupied by a given character C. C is
|
||||
encoded in Unicode. */
|
||||
grub_ssize_t (*getcharwidth) (grub_uint32_t c);
|
||||
grub_ssize_t (*getcharwidth) (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
/* Get the screen size. The return value is ((Width << 8) | Height). */
|
||||
grub_uint16_t (*getwh) (void);
|
||||
grub_uint16_t (*getwh) (struct grub_term_output *term);
|
||||
|
||||
/* Get the cursor position. The return value is ((X << 8) | Y). */
|
||||
grub_uint16_t (*getxy) (void);
|
||||
grub_uint16_t (*getxy) (struct grub_term_output *term);
|
||||
|
||||
/* Go to the position (X, Y). */
|
||||
void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
|
||||
void (*gotoxy) (struct grub_term_output *term,
|
||||
grub_uint8_t x, grub_uint8_t y);
|
||||
|
||||
/* Clear the screen. */
|
||||
void (*cls) (void);
|
||||
void (*cls) (struct grub_term_output *term);
|
||||
|
||||
/* Set the current color to be used */
|
||||
void (*setcolorstate) (grub_term_color_state state);
|
||||
|
||||
/* Set the normal color and the highlight color. The format of each
|
||||
color is VGA's. */
|
||||
void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
|
||||
|
||||
/* Get the normal color and the highlight color. The format of each
|
||||
color is VGA's. */
|
||||
void (*getcolor) (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
|
||||
void (*setcolorstate) (struct grub_term_output *term,
|
||||
grub_term_color_state state);
|
||||
|
||||
/* Turn on/off the cursor. */
|
||||
void (*setcursor) (int on);
|
||||
void (*setcursor) (struct grub_term_output *term, int on);
|
||||
|
||||
/* Update the screen. */
|
||||
void (*refresh) (void);
|
||||
void (*refresh) (struct grub_term_output *term);
|
||||
|
||||
/* The feature flags defined above. */
|
||||
grub_uint32_t flags;
|
||||
|
||||
/* Current color state. */
|
||||
grub_uint8_t normal_color;
|
||||
grub_uint8_t highlight_color;
|
||||
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_term_output *grub_term_output_t;
|
||||
|
||||
#define GRUB_TERM_DEFAULT_NORMAL_COLOR 0x07
|
||||
#define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70
|
||||
#define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07
|
||||
|
||||
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs_disabled);
|
||||
extern struct grub_term_input *EXPORT_VAR(grub_term_inputs_disabled);
|
||||
extern struct grub_term_output *EXPORT_VAR(grub_term_outputs);
|
||||
|
@ -208,11 +217,19 @@ grub_term_register_input (const char *name __attribute__ ((unused)),
|
|||
else
|
||||
{
|
||||
/* If this is the first terminal, enable automatically. */
|
||||
if (! term->init || term->init () == GRUB_ERR_NONE)
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_input_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
|
@ -223,12 +240,21 @@ grub_term_register_output (const char *name __attribute__ ((unused)),
|
|||
else
|
||||
{
|
||||
/* If this is the first terminal, enable automatically. */
|
||||
if (! term->init || term->init () == GRUB_ERR_NONE)
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_unregister_input (grub_term_input_t term)
|
||||
{
|
||||
|
@ -250,14 +276,11 @@ grub_term_unregister_output (grub_term_output_t term)
|
|||
#define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs))
|
||||
#define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled))
|
||||
|
||||
void EXPORT_FUNC(grub_putchar) (int c);
|
||||
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code,
|
||||
struct grub_term_output *term);
|
||||
void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
|
||||
int EXPORT_FUNC(grub_getkey) (void);
|
||||
int EXPORT_FUNC(grub_checkkey) (void);
|
||||
int EXPORT_FUNC(grub_getkeystatus) (void);
|
||||
void EXPORT_FUNC(grub_cls) (void);
|
||||
void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
|
||||
void grub_cls (void);
|
||||
void EXPORT_FUNC(grub_refresh) (void);
|
||||
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
||||
grub_uint16_t *grub_term_save_pos (void);
|
||||
|
@ -265,12 +288,12 @@ void grub_term_restore_pos (grub_uint16_t *pos);
|
|||
|
||||
static inline unsigned grub_term_width (struct grub_term_output *term)
|
||||
{
|
||||
return ((term->getwh()&0xFF00)>>8);
|
||||
return ((term->getwh(term)&0xFF00)>>8);
|
||||
}
|
||||
|
||||
static inline unsigned grub_term_height (struct grub_term_output *term)
|
||||
{
|
||||
return (term->getwh()&0xFF);
|
||||
return (term->getwh(term)&0xFF);
|
||||
}
|
||||
|
||||
/* The width of the border. */
|
||||
|
@ -314,20 +337,20 @@ grub_term_cursor_x (struct grub_term_output *term)
|
|||
static inline grub_uint16_t
|
||||
grub_term_getxy (struct grub_term_output *term)
|
||||
{
|
||||
return term->getxy ();
|
||||
return term->getxy (term);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_refresh (struct grub_term_output *term)
|
||||
{
|
||||
if (term->refresh)
|
||||
term->refresh ();
|
||||
term->refresh (term);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_gotoxy (struct grub_term_output *term, grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
term->gotoxy (x, y);
|
||||
term->gotoxy (term, x, y);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -335,17 +358,26 @@ grub_term_setcolorstate (struct grub_term_output *term,
|
|||
grub_term_color_state state)
|
||||
{
|
||||
if (term->setcolorstate)
|
||||
term->setcolorstate (state);
|
||||
term->setcolorstate (term, state);
|
||||
}
|
||||
|
||||
/* Set the normal color and the highlight color. The format of each
|
||||
color is VGA's. */
|
||||
static inline void
|
||||
grub_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
struct grub_term_output *term;
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
grub_term_setcolorstate (term, state);
|
||||
}
|
||||
|
||||
/* Set the normal color and the highlight color. The format of each
|
||||
color is VGA's. */
|
||||
static inline void
|
||||
grub_term_setcolor (struct grub_term_output *term,
|
||||
grub_uint8_t normal_color, grub_uint8_t highlight_color)
|
||||
{
|
||||
if (term->setcolor)
|
||||
term->setcolor (normal_color, highlight_color);
|
||||
term->normal_color = normal_color;
|
||||
term->highlight_color = highlight_color;
|
||||
}
|
||||
|
||||
/* Turn on/off the cursor. */
|
||||
|
@ -353,14 +385,14 @@ static inline void
|
|||
grub_term_setcursor (struct grub_term_output *term, int on)
|
||||
{
|
||||
if (term->setcursor)
|
||||
term->setcursor (on);
|
||||
term->setcursor (term, on);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_cls (struct grub_term_output *term)
|
||||
{
|
||||
if (term->cls)
|
||||
(term->cls) ();
|
||||
(term->cls) (term);
|
||||
else
|
||||
{
|
||||
grub_putcode ('\n', term);
|
||||
|
@ -368,11 +400,36 @@ grub_term_cls (struct grub_term_output *term)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_UNIFONT_WIDTHSPEC
|
||||
|
||||
grub_ssize_t
|
||||
grub_unicode_estimate_width (const struct grub_unicode_glyph *c);
|
||||
|
||||
#else
|
||||
|
||||
static inline grub_ssize_t
|
||||
grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((unused)))
|
||||
{
|
||||
if (grub_unicode_get_comb_type (c->base))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline grub_ssize_t
|
||||
grub_term_getcharwidth (struct grub_term_output *term, grub_uint32_t c)
|
||||
grub_term_getcharwidth (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c)
|
||||
{
|
||||
if (term->getcharwidth)
|
||||
return term->getcharwidth (c);
|
||||
return term->getcharwidth (term, c);
|
||||
else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||
== GRUB_TERM_CODE_TYPE_UTF8_LOGICAL)
|
||||
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||
== GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
|
||||
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||
== GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS))
|
||||
return grub_unicode_estimate_width (c);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
@ -381,17 +438,10 @@ static inline void
|
|||
grub_term_getcolor (struct grub_term_output *term,
|
||||
grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
|
||||
{
|
||||
if (term->getcolor)
|
||||
term->getcolor (normal_color, highlight_color);
|
||||
else
|
||||
{
|
||||
*normal_color = 0x07;
|
||||
*highlight_color = 0x07;
|
||||
}
|
||||
*normal_color = term->normal_color;
|
||||
*highlight_color = term->highlight_color;
|
||||
}
|
||||
|
||||
extern void (*EXPORT_VAR (grub_newline_hook)) (void);
|
||||
|
||||
struct grub_term_autoload
|
||||
{
|
||||
struct grub_term_autoload *next;
|
||||
|
@ -409,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)
|
||||
|
|
|
@ -23,15 +23,55 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
char *grub_terminfo_get_current (void);
|
||||
grub_err_t grub_terminfo_set_current (const char *);
|
||||
char *EXPORT_FUNC(grub_terminfo_get_current) (struct grub_term_output *term);
|
||||
grub_err_t EXPORT_FUNC(grub_terminfo_set_current) (struct grub_term_output *term,
|
||||
const char *);
|
||||
|
||||
void grub_terminfo_gotoxy (grub_uint8_t x, grub_uint8_t y,
|
||||
grub_term_output_t oterm);
|
||||
void grub_terminfo_cls (grub_term_output_t oterm);
|
||||
void grub_terminfo_reverse_video_on (grub_term_output_t oterm);
|
||||
void grub_terminfo_reverse_video_off (grub_term_output_t oterm);
|
||||
void grub_terminfo_cursor_on (grub_term_output_t oterm);
|
||||
void grub_terminfo_cursor_off (grub_term_output_t oterm);
|
||||
#define GRUB_TERMINFO_READKEY_MAX_LEN 4
|
||||
struct grub_terminfo_input_state
|
||||
{
|
||||
int input_buf[GRUB_TERMINFO_READKEY_MAX_LEN];
|
||||
int npending;
|
||||
int (*readkey) (struct grub_term_input *term);
|
||||
};
|
||||
|
||||
struct grub_terminfo_output_state
|
||||
{
|
||||
struct grub_term_output *next;
|
||||
|
||||
char *name;
|
||||
|
||||
char *gotoxy;
|
||||
char *cls;
|
||||
char *reverse_video_on;
|
||||
char *reverse_video_off;
|
||||
char *cursor_on;
|
||||
char *cursor_off;
|
||||
char *setcolor;
|
||||
|
||||
unsigned int xpos, ypos;
|
||||
|
||||
void (*put) (struct grub_term_output *term, const int c);
|
||||
};
|
||||
|
||||
void EXPORT_FUNC(grub_terminfo_gotoxy) (grub_term_output_t term,
|
||||
grub_uint8_t x, grub_uint8_t y);
|
||||
void EXPORT_FUNC(grub_terminfo_cls) (grub_term_output_t term);
|
||||
grub_uint16_t EXPORT_FUNC (grub_terminfo_getxy) (struct grub_term_output *term);
|
||||
void EXPORT_FUNC (grub_terminfo_setcursor) (struct grub_term_output *term,
|
||||
const int on);
|
||||
void EXPORT_FUNC (grub_terminfo_setcolorstate) (struct grub_term_output *term,
|
||||
const grub_term_color_state state);
|
||||
|
||||
|
||||
int EXPORT_FUNC (grub_terminfo_checkkey) (struct grub_term_input *term);
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_input_init) (struct grub_term_input *term);
|
||||
int EXPORT_FUNC (grub_terminfo_getkey) (struct grub_term_input *term);
|
||||
void EXPORT_FUNC (grub_terminfo_putchar) (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_output_register) (struct grub_term_output *term,
|
||||
const char *type);
|
||||
grub_err_t EXPORT_FUNC (grub_terminfo_output_unregister) (struct grub_term_output *term);
|
||||
|
||||
#endif /* ! GRUB_TERMINFO_HEADER */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -92,10 +92,18 @@ typedef grub_int32_t grub_target_ssize_t;
|
|||
typedef grub_uint64_t grub_addr_t;
|
||||
typedef grub_uint64_t grub_size_t;
|
||||
typedef grub_int64_t grub_ssize_t;
|
||||
|
||||
# if GRUB_CPU_SIZEOF_LONG == 8
|
||||
# define PRIxGRUB_SIZE "lx"
|
||||
# else
|
||||
# define PRIxGRUB_SIZE "llx"
|
||||
# endif
|
||||
#else
|
||||
typedef grub_uint32_t grub_addr_t;
|
||||
typedef grub_uint32_t grub_size_t;
|
||||
typedef grub_int32_t grub_ssize_t;
|
||||
|
||||
# define PRIxGRUB_SIZE "x"
|
||||
#endif
|
||||
|
||||
#if GRUB_CPU_SIZEOF_LONG == 8
|
||||
|
|
272
include/grub/unicode.h
Normal file
272
include/grub/unicode.h
Normal file
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
* 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_BIDI_HEADER
|
||||
#define GRUB_BIDI_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
struct grub_unicode_bidi_pair
|
||||
{
|
||||
grub_uint32_t key;
|
||||
grub_uint32_t replace;
|
||||
};
|
||||
|
||||
struct grub_unicode_compact_range
|
||||
{
|
||||
grub_uint32_t start:21;
|
||||
grub_uint32_t end:21;
|
||||
grub_uint8_t bidi_type:5;
|
||||
grub_uint8_t comb_type;
|
||||
grub_uint8_t bidi_mirror:1;
|
||||
grub_uint8_t join_type:3;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Old-style Arabic shaping. Used for "visual UTF-8" and
|
||||
in grub-mkfont to find variant glyphs in absence of GPOS tables. */
|
||||
struct grub_unicode_arabic_shape
|
||||
{
|
||||
grub_uint32_t code;
|
||||
grub_uint32_t isolated;
|
||||
grub_uint32_t right_linked;
|
||||
grub_uint32_t both_linked;
|
||||
grub_uint32_t left_linked;
|
||||
};
|
||||
|
||||
extern struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[];
|
||||
|
||||
enum grub_bidi_type
|
||||
{
|
||||
GRUB_BIDI_TYPE_L = 0,
|
||||
GRUB_BIDI_TYPE_LRE,
|
||||
GRUB_BIDI_TYPE_LRO,
|
||||
GRUB_BIDI_TYPE_R,
|
||||
GRUB_BIDI_TYPE_AL,
|
||||
GRUB_BIDI_TYPE_RLE,
|
||||
GRUB_BIDI_TYPE_RLO,
|
||||
GRUB_BIDI_TYPE_PDF,
|
||||
GRUB_BIDI_TYPE_EN,
|
||||
GRUB_BIDI_TYPE_ES,
|
||||
GRUB_BIDI_TYPE_ET,
|
||||
GRUB_BIDI_TYPE_AN,
|
||||
GRUB_BIDI_TYPE_CS,
|
||||
GRUB_BIDI_TYPE_NSM,
|
||||
GRUB_BIDI_TYPE_BN,
|
||||
GRUB_BIDI_TYPE_B,
|
||||
GRUB_BIDI_TYPE_S,
|
||||
GRUB_BIDI_TYPE_WS,
|
||||
GRUB_BIDI_TYPE_ON
|
||||
};
|
||||
|
||||
enum grub_join_type
|
||||
{
|
||||
GRUB_JOIN_TYPE_NONJOINING = 0,
|
||||
GRUB_JOIN_TYPE_LEFT = 1,
|
||||
GRUB_JOIN_TYPE_RIGHT = 2,
|
||||
GRUB_JOIN_TYPE_DUAL = 3,
|
||||
GRUB_JOIN_TYPE_CAUSING = 4,
|
||||
GRUB_JOIN_TYPE_TRANSPARENT = 5
|
||||
};
|
||||
|
||||
enum grub_comb_type
|
||||
{
|
||||
GRUB_UNICODE_COMB_NONE = 0,
|
||||
GRUB_UNICODE_COMB_OVERLAY = 1,
|
||||
GRUB_UNICODE_COMB_HEBREW_SHEVA = 10,
|
||||
GRUB_UNICODE_COMB_HEBREW_HATAF_SEGOL = 11,
|
||||
GRUB_UNICODE_COMB_HEBREW_HATAF_PATAH = 12,
|
||||
GRUB_UNICODE_COMB_HEBREW_HATAF_QAMATS = 13,
|
||||
GRUB_UNICODE_COMB_HEBREW_HIRIQ = 14,
|
||||
GRUB_UNICODE_COMB_HEBREW_TSERE = 15,
|
||||
GRUB_UNICODE_COMB_HEBREW_SEGOL = 16,
|
||||
GRUB_UNICODE_COMB_HEBREW_PATAH = 17,
|
||||
GRUB_UNICODE_COMB_HEBREW_QAMATS = 18,
|
||||
GRUB_UNICODE_COMB_HEBREW_HOLAM = 19,
|
||||
GRUB_UNICODE_COMB_HEBREW_QUBUTS = 20,
|
||||
GRUB_UNICODE_COMB_HEBREW_DAGESH = 21,
|
||||
GRUB_UNICODE_COMB_HEBREW_METEG = 22,
|
||||
GRUB_UNICODE_COMB_HEBREW_RAFE = 23,
|
||||
GRUB_UNICODE_COMB_HEBREW_SHIN_DOT = 24,
|
||||
GRUB_UNICODE_COMB_HEBREW_SIN_DOT = 25,
|
||||
GRUB_UNICODE_COMB_HEBREW_VARIKA = 26,
|
||||
GRUB_UNICODE_COMB_ARABIC_FATHATAN = 27,
|
||||
GRUB_UNICODE_COMB_ARABIC_DAMMATAN = 28,
|
||||
GRUB_UNICODE_COMB_ARABIC_KASRATAN = 29,
|
||||
GRUB_UNICODE_COMB_ARABIC_FATHAH = 30,
|
||||
GRUB_UNICODE_COMB_ARABIC_DAMMAH = 31,
|
||||
GRUB_UNICODE_COMB_ARABIC_KASRA = 32,
|
||||
GRUB_UNICODE_COMB_ARABIC_SHADDA = 33,
|
||||
GRUB_UNICODE_COMB_ARABIC_SUKUN = 34,
|
||||
GRUB_UNICODE_COMB_ARABIC_SUPERSCRIPT_ALIF = 35,
|
||||
GRUB_UNICODE_COMB_SYRIAC_SUPERSCRIPT_ALAPH = 36,
|
||||
GRUB_UNICODE_STACK_ATTACHED_BELOW = 202,
|
||||
GRUB_UNICODE_STACK_ATTACHED_ABOVE = 214,
|
||||
GRUB_UNICODE_COMB_ATTACHED_ABOVE_RIGHT = 216,
|
||||
GRUB_UNICODE_STACK_BELOW = 220,
|
||||
GRUB_UNICODE_COMB_BELOW_RIGHT = 222,
|
||||
GRUB_UNICODE_COMB_ABOVE_LEFT = 228,
|
||||
GRUB_UNICODE_STACK_ABOVE = 230,
|
||||
GRUB_UNICODE_COMB_ABOVE_RIGHT = 232,
|
||||
GRUB_UNICODE_COMB_YPOGEGRAMMENI = 240,
|
||||
/* If combining nature is indicated only by class and
|
||||
not "combining type". */
|
||||
GRUB_UNICODE_COMB_ME = 253,
|
||||
GRUB_UNICODE_COMB_MC = 254,
|
||||
GRUB_UNICODE_COMB_MN = 255,
|
||||
};
|
||||
|
||||
/* This structure describes a glyph as opposed to character. */
|
||||
struct grub_unicode_glyph
|
||||
{
|
||||
grub_uint32_t base;
|
||||
grub_uint16_t variant:9;
|
||||
grub_uint8_t attributes:5;
|
||||
grub_size_t ncomb;
|
||||
struct grub_unicode_combining {
|
||||
grub_uint32_t code;
|
||||
enum grub_comb_type type;
|
||||
} *combining;
|
||||
/* Hint by unicode subsystem how wide this character usually is.
|
||||
Real width is determined by font. Set only in UTF-8 stream. */
|
||||
int estimated_width;
|
||||
};
|
||||
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_MIRROR 0x1
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT 1
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED 0x2
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \
|
||||
(GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \
|
||||
<< GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT)
|
||||
/* Set iff the corresponding joining flags come from ZWJ or ZWNJ. */
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT 0x8
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT \
|
||||
(GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \
|
||||
<< GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN_LEFT_TO_RIGHT_SHIFT)
|
||||
#define GRUB_UNICODE_GLYPH_ATTRIBUTES_JOIN \
|
||||
(GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED \
|
||||
| GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED \
|
||||
| GRUB_UNICODE_GLYPH_ATTRIBUTE_LEFT_JOINED_EXPLICIT \
|
||||
| GRUB_UNICODE_GLYPH_ATTRIBUTE_RIGHT_JOINED_EXPLICIT)
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_UNICODE_COMBINING_GRAPHEME_JOINER = 0x034f,
|
||||
GRUB_UNICODE_HEBREW_WAW = 0x05d5,
|
||||
GRUB_UNICODE_ARABIC_START = 0x0600,
|
||||
GRUB_UNICODE_ARABIC_END = 0x0700,
|
||||
GRUB_UNICODE_THAANA_ABAFILI = 0x07a6,
|
||||
GRUB_UNICODE_THAANA_AABAAFILI = 0x07a7,
|
||||
GRUB_UNICODE_THAANA_IBIFILI = 0x07a8,
|
||||
GRUB_UNICODE_THAANA_EEBEEFILI = 0x07a9,
|
||||
GRUB_UNICODE_THAANA_UBUFILI = 0x07aa,
|
||||
GRUB_UNICODE_THAANA_OOBOOFILI = 0x07ab,
|
||||
GRUB_UNICODE_THAANA_EBEFILI = 0x07ac,
|
||||
GRUB_UNICODE_THAANA_EYBEYFILI = 0x07ad,
|
||||
GRUB_UNICODE_THAANA_OBOFILI = 0x07ae,
|
||||
GRUB_UNICODE_THAANA_OABOAFILI = 0x07af,
|
||||
GRUB_UNICODE_THAANA_SUKUN = 0x07b0,
|
||||
GRUB_UNICODE_ZWNJ = 0x200c,
|
||||
GRUB_UNICODE_ZWJ = 0x200d,
|
||||
GRUB_UNICODE_LEFTARROW = 0x2190,
|
||||
GRUB_UNICODE_UPARROW = 0x2191,
|
||||
GRUB_UNICODE_RIGHTARROW = 0x2192,
|
||||
GRUB_UNICODE_DOWNARROW = 0x2193,
|
||||
GRUB_UNICODE_LIGHT_HLINE = 0x2500,
|
||||
GRUB_UNICODE_HLINE = 0x2501,
|
||||
GRUB_UNICODE_LIGHT_VLINE = 0x2502,
|
||||
GRUB_UNICODE_VLINE = 0x2503,
|
||||
GRUB_UNICODE_LIGHT_CORNER_UL = 0x250c,
|
||||
GRUB_UNICODE_CORNER_UL = 0x250f,
|
||||
GRUB_UNICODE_LIGHT_CORNER_UR = 0x2510,
|
||||
GRUB_UNICODE_CORNER_UR = 0x2513,
|
||||
GRUB_UNICODE_LIGHT_CORNER_LL = 0x2514,
|
||||
GRUB_UNICODE_CORNER_LL = 0x2517,
|
||||
GRUB_UNICODE_LIGHT_CORNER_LR = 0x2518,
|
||||
GRUB_UNICODE_CORNER_LR = 0x251b,
|
||||
GRUB_UNICODE_BLACK_UP_TRIANGLE = 0x25b2,
|
||||
GRUB_UNICODE_BLACK_RIGHT_TRIANGLE = 0x25ba,
|
||||
GRUB_UNICODE_BLACK_DOWN_TRIANGLE = 0x25bc,
|
||||
GRUB_UNICODE_BLACK_LEFT_TRIANGLE = 0x25c4,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_1 = 0xfe00,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_16 = 0xfe0f,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_17 = 0xe0100,
|
||||
GRUB_UNICODE_VARIATION_SELECTOR_256 = 0xe01ef
|
||||
};
|
||||
|
||||
extern struct grub_unicode_compact_range grub_unicode_compact[];
|
||||
extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[];
|
||||
|
||||
#define GRUB_UNICODE_MAX_CACHED_CHAR 0x20000
|
||||
/* Unicode mandates an arbitrary limit. */
|
||||
#define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61
|
||||
|
||||
grub_ssize_t
|
||||
grub_bidi_logical_to_visual (const grub_uint32_t *logical,
|
||||
grub_size_t logical_len,
|
||||
struct grub_unicode_glyph **visual_out,
|
||||
grub_ssize_t (*getcharwidth) (const struct grub_unicode_glyph *visual),
|
||||
grub_size_t max_width,
|
||||
grub_size_t start_width);
|
||||
|
||||
enum grub_comb_type
|
||||
grub_unicode_get_comb_type (grub_uint32_t c);
|
||||
grub_size_t
|
||||
grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
|
||||
struct grub_unicode_glyph *out);
|
||||
|
||||
static inline struct grub_unicode_glyph *
|
||||
grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
|
||||
{
|
||||
struct grub_unicode_glyph *out = grub_malloc (sizeof (*out));
|
||||
if (!out)
|
||||
return NULL;
|
||||
grub_memcpy (out, in, sizeof (*in));
|
||||
if (in->combining)
|
||||
{
|
||||
out->combining = grub_malloc (in->ncomb * sizeof (*in));
|
||||
if (!out->combining)
|
||||
{
|
||||
grub_free (out);
|
||||
return NULL;
|
||||
}
|
||||
grub_memcpy (out->combining, in->combining, in->ncomb * sizeof (*in));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline struct grub_unicode_glyph *
|
||||
grub_unicode_glyph_from_code (grub_uint32_t code)
|
||||
{
|
||||
struct grub_unicode_glyph *ret;
|
||||
ret = grub_zalloc (sizeof (*ret));
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
ret->base = code;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
grub_uint32_t
|
||||
grub_unicode_mirror_code (grub_uint32_t in);
|
||||
grub_uint32_t
|
||||
grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr);
|
||||
|
||||
#endif
|
|
@ -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,14 +106,15 @@ 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);
|
||||
|
||||
grub_err_t (*portstatus) (grub_usb_controller_t dev, unsigned int port,
|
||||
unsigned int enable);
|
||||
|
||||
grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port);
|
||||
grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
|
||||
|
||||
/* The next host controller. */
|
||||
struct grub_usb_controller_dev *next;
|
||||
|
@ -125,6 +135,15 @@ struct grub_usb_interface
|
|||
struct grub_usb_desc_if *descif;
|
||||
|
||||
struct grub_usb_desc_endp *descendp;
|
||||
|
||||
/* A driver is handling this interface. Do we need to support multiple drivers
|
||||
for single interface?
|
||||
*/
|
||||
int attached;
|
||||
|
||||
void (*detach_hook) (struct grub_usb_device *dev, int config, int interface);
|
||||
|
||||
void *detach_data;
|
||||
};
|
||||
|
||||
struct grub_usb_configuration
|
||||
|
@ -159,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,
|
||||
|
@ -207,4 +246,25 @@ grub_usb_get_config_interface (struct grub_usb_desc_config *config)
|
|||
return interf;
|
||||
}
|
||||
|
||||
typedef int (*grub_usb_attach_hook_class) (grub_usb_device_t usbdev,
|
||||
int configno, int interfno);
|
||||
|
||||
struct grub_usb_attach_desc
|
||||
{
|
||||
struct grub_usb_attach_desc *next;
|
||||
int class;
|
||||
grub_usb_attach_hook_class hook;
|
||||
};
|
||||
|
||||
void grub_usb_register_attach_hook_class (struct grub_usb_attach_desc *desc);
|
||||
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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* serial.h - serial device interface */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,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
|
||||
|
@ -16,13 +17,18 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_CONSOLE_MACHINE_HEADER
|
||||
#define GRUB_CONSOLE_MACHINE_HEADER 1
|
||||
#ifndef GRUB_USBSERIAL_HEADER
|
||||
#define GRUB_USBSERIAL_HEADER 1
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
void grub_usbserial_fini (struct grub_serial_port *port);
|
||||
|
||||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
||||
void grub_usbserial_detach (grub_usb_device_t usbdev, int configno,
|
||||
int interfno);
|
||||
|
||||
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
|
||||
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
|
|
@ -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;
|
||||
|
||||
|
@ -87,15 +88,19 @@ typedef struct grub_usb_transfer *grub_usb_transfer_t;
|
|||
#define GRUB_USB_REQ_SET_INTERFACE 0x0B
|
||||
#define GRUB_USB_REQ_SYNC_FRAME 0x0C
|
||||
|
||||
#define GRUB_USB_REQ_HUB_GET_PORT_STATUS 0x00
|
||||
|
||||
#define GRUB_USB_FEATURE_ENDP_HALT 0x00
|
||||
#define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
|
||||
#define GRUB_USB_FEATURE_TEST_MODE 0x02
|
||||
|
||||
#define GRUB_USB_HUB_STATUS_CONNECTED (1 << 0)
|
||||
#define GRUB_USB_HUB_STATUS_LOWSPEED (1 << 9)
|
||||
#define GRUB_USB_HUB_STATUS_HIGHSPEED (1 << 10)
|
||||
#define GRUB_USB_HUB_FEATURE_PORT_RESET 0x04
|
||||
#define GRUB_USB_HUB_FEATURE_PORT_POWER 0x08
|
||||
#define GRUB_USB_HUB_FEATURE_C_CONNECTED 0x10
|
||||
|
||||
#define GRUB_USB_HUB_STATUS_CONNECTED (1 << 0)
|
||||
#define GRUB_USB_HUB_STATUS_LOWSPEED (1 << 9)
|
||||
#define GRUB_USB_HUB_STATUS_HIGHSPEED (1 << 10)
|
||||
#define GRUB_USB_HUB_STATUS_C_CONNECTED (1 << 16)
|
||||
#define GRUB_USB_HUB_STATUS_C_PORT_RESET (1 << 20)
|
||||
|
||||
struct grub_usb_packet_setup
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,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
|
||||
|
@ -16,13 +16,24 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_CONSOLE_MACHINE_HEADER
|
||||
#define GRUB_CONSOLE_MACHINE_HEADER 1
|
||||
#ifndef GRUB_LIBNVPAIR_UTIL_HEADER
|
||||
#define GRUB_LIBNVPAIR_UTIL_HEADER 1
|
||||
|
||||
/* Initialize the console system. */
|
||||
void grub_console_init (void);
|
||||
#include <config.h>
|
||||
|
||||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
||||
#ifdef HAVE_LIBNVPAIR_H
|
||||
#include <libnvpair.h>
|
||||
#else /* ! HAVE_LIBNVPAIR_H */
|
||||
|
||||
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
|
||||
#include <stdio.h> /* FILE */
|
||||
|
||||
typedef void nvlist_t;
|
||||
|
||||
int nvlist_lookup_string (nvlist_t *, const char *, char **);
|
||||
int nvlist_lookup_nvlist (nvlist_t *, const char *, nvlist_t **);
|
||||
int nvlist_lookup_nvlist_array (nvlist_t *, const char *, nvlist_t ***, unsigned int *);
|
||||
void nvlist_print (FILE *, nvlist_t *);
|
||||
|
||||
#endif /* ! HAVE_LIBNVPAIR_H */
|
||||
|
||||
#endif
|
45
include/grub/util/libzfs.h
Normal file
45
include/grub/util/libzfs.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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_LIBZFS_UTIL_HEADER
|
||||
#define GRUB_LIBZFS_UTIL_HEADER 1
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef HAVE_LIBZFS_H
|
||||
#include <libzfs.h>
|
||||
#else /* ! HAVE_LIBZFS_H */
|
||||
|
||||
#include <grub/util/libnvpair.h>
|
||||
|
||||
typedef void libzfs_handle_t;
|
||||
typedef void zpool_handle_t;
|
||||
|
||||
extern libzfs_handle_t *libzfs_init (void);
|
||||
extern void libzfs_fini (libzfs_handle_t *);
|
||||
|
||||
extern zpool_handle_t *zpool_open (libzfs_handle_t *, const char *);
|
||||
extern void zpool_close (zpool_handle_t *);
|
||||
|
||||
extern int zpool_get_physpath (zpool_handle_t *, const char *);
|
||||
|
||||
extern nvlist_t *zpool_get_config (zpool_handle_t *, nvlist_t **);
|
||||
|
||||
#endif /* ! HAVE_LIBZFS_H */
|
||||
|
||||
#endif
|
|
@ -19,9 +19,13 @@
|
|||
#ifndef GRUB_VGA_HEADER
|
||||
#define GRUB_VGA_HEADER 1
|
||||
|
||||
#include <grub/pci.h>
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_IO_ARX = 0x3c0,
|
||||
GRUB_VGA_IO_ARX_READ = 0x3c1,
|
||||
GRUB_VGA_IO_MISC_WRITE = 0x3c2,
|
||||
GRUB_VGA_IO_SR_INDEX = 0x3c4,
|
||||
GRUB_VGA_IO_SR_DATA = 0x3c5,
|
||||
GRUB_VGA_IO_PIXEL_MASK = 0x3c6,
|
||||
|
@ -39,8 +43,15 @@ enum
|
|||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_CR_WIDTH = 0x01,
|
||||
GRUB_VGA_CR_HTOTAL = 0x00,
|
||||
GRUB_VGA_CR_HORIZ_END = 0x01,
|
||||
GRUB_VGA_CR_HBLANK_START = 0x02,
|
||||
GRUB_VGA_CR_HBLANK_END = 0x03,
|
||||
GRUB_VGA_CR_HORIZ_SYNC_PULSE_START = 0x04,
|
||||
GRUB_VGA_CR_HORIZ_SYNC_PULSE_END = 0x05,
|
||||
GRUB_VGA_CR_VERT_TOTAL = 0x06,
|
||||
GRUB_VGA_CR_OVERFLOW = 0x07,
|
||||
GRUB_VGA_CR_BYTE_PANNING = 0x08,
|
||||
GRUB_VGA_CR_CELL_HEIGHT = 0x09,
|
||||
GRUB_VGA_CR_CURSOR_START = 0x0a,
|
||||
GRUB_VGA_CR_CURSOR_END = 0x0b,
|
||||
|
@ -48,14 +59,71 @@ enum
|
|||
GRUB_VGA_CR_START_ADDR_LOW_REGISTER = 0x0d,
|
||||
GRUB_VGA_CR_CURSOR_ADDR_HIGH = 0x0e,
|
||||
GRUB_VGA_CR_CURSOR_ADDR_LOW = 0x0f,
|
||||
GRUB_VGA_CR_VSYNC_START = 0x10,
|
||||
GRUB_VGA_CR_VSYNC_END = 0x11,
|
||||
GRUB_VGA_CR_HEIGHT = 0x12,
|
||||
GRUB_VGA_CR_VDISPLAY_END = 0x12,
|
||||
GRUB_VGA_CR_PITCH = 0x13,
|
||||
GRUB_VGA_CR_UNDERLINE_LOCATION = 0x14,
|
||||
GRUB_VGA_CR_VERTICAL_BLANK_START = 0x15,
|
||||
GRUB_VGA_CR_VERTICAL_BLANK_END = 0x16,
|
||||
GRUB_VGA_CR_MODE = 0x17,
|
||||
GRUB_VGA_CR_LINE_COMPARE = 0x18,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_CR_BYTE_PANNING_NORMAL = 0
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_CR_UNDERLINE_LOCATION_DWORD_MODE = 0x40
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_IO_MISC_COLOR = 0x01,
|
||||
GRUB_VGA_IO_MISC_ENABLE_VRAM_ACCESS = 0x02,
|
||||
GRUB_VGA_IO_MISC_EXTERNAL_CLOCK_0 = 0x08,
|
||||
GRUB_VGA_IO_MISC_28MHZ = 0x04,
|
||||
GRUB_VGA_IO_MISC_UPPER_64K = 0x20,
|
||||
GRUB_VGA_IO_MISC_NEGATIVE_HORIZ_POLARITY = 0x40,
|
||||
GRUB_VGA_IO_MISC_NEGATIVE_VERT_POLARITY = 0x80,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_ARX_MODE = 0x10,
|
||||
GRUB_VGA_ARX_OVERSCAN = 0x11,
|
||||
GRUB_VGA_ARX_COLOR_PLANE_ENABLE = 0x12,
|
||||
GRUB_VGA_ARX_HORIZONTAL_PANNING = 0x13,
|
||||
GRUB_VGA_ARX_COLOR_SELECT = 0x14
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_ARX_MODE_TEXT = 0x00,
|
||||
GRUB_VGA_ARX_MODE_GRAPHICS = 0x01,
|
||||
GRUB_VGA_ARX_MODE_ENABLE_256COLOR = 0x40
|
||||
};
|
||||
|
||||
#define GRUB_VGA_CR_WIDTH_DIVISOR 8
|
||||
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_SHIFT 7
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_MASK 0x02
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_SHIFT 3
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_MASK 0x40
|
||||
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_SHIFT 8
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_MASK 0x01
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_SHIFT 4
|
||||
#define GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_MASK 0x20
|
||||
|
||||
#define GRUB_VGA_CR_OVERFLOW_VSYNC_START1_SHIFT 6
|
||||
#define GRUB_VGA_CR_OVERFLOW_VSYNC_START1_MASK 0x04
|
||||
#define GRUB_VGA_CR_OVERFLOW_VSYNC_START2_SHIFT 2
|
||||
#define GRUB_VGA_CR_OVERFLOW_VSYNC_START2_MASK 0x80
|
||||
|
||||
#define GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT 7
|
||||
#define GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK 0x02
|
||||
#define GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT 3
|
||||
|
@ -65,7 +133,9 @@ enum
|
|||
|
||||
#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK 0x40
|
||||
#define GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT 3
|
||||
|
||||
#define GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_MASK 0x20
|
||||
#define GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_SHIFT 4
|
||||
#define GRUB_VGA_CR_CELL_HEIGHT_DOUBLE_SCAN 0x80
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_CR_CURSOR_START_DISABLE = (1 << 5)
|
||||
|
@ -77,17 +147,26 @@ enum
|
|||
{
|
||||
GRUB_VGA_CR_MODE_NO_CGA = 0x01,
|
||||
GRUB_VGA_CR_MODE_NO_HERCULES = 0x02,
|
||||
GRUB_VGA_CR_MODE_ADDRESS_WRAP = 0x20,
|
||||
GRUB_VGA_CR_MODE_BYTE_MODE = 0x40,
|
||||
GRUB_VGA_CR_MODE_TIMING_ENABLE = 0x80
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_SR_RESET = 0,
|
||||
GRUB_VGA_SR_CLOCKING_MODE = 1,
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER = 2,
|
||||
GRUB_VGA_SR_CHAR_MAP_SELECT = 3,
|
||||
GRUB_VGA_SR_MEMORY_MODE = 4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_SR_RESET_ASYNC = 1,
|
||||
GRUB_VGA_SR_RESET_SYNC = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK = 1
|
||||
|
@ -96,19 +175,33 @@ enum
|
|||
enum
|
||||
{
|
||||
GRUB_VGA_SR_MEMORY_MODE_NORMAL = 0,
|
||||
GRUB_VGA_SR_MEMORY_MODE_CHAIN4 = 8
|
||||
GRUB_VGA_SR_MEMORY_MODE_EXTERNAL_VIDEO_MEMORY = 2,
|
||||
GRUB_VGA_SR_MEMORY_MODE_SEQUENTIAL_ADDRESSING = 4,
|
||||
GRUB_VGA_SR_MEMORY_MODE_CHAIN4 = 8,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_GR_SET_RESET_PLANE = 0,
|
||||
GRUB_VGA_GR_SET_RESET_PLANE_ENABLE = 1,
|
||||
GRUB_VGA_GR_COLOR_COMPARE = 2,
|
||||
GRUB_VGA_GR_DATA_ROTATE = 3,
|
||||
GRUB_VGA_GR_READ_MAP_REGISTER = 4,
|
||||
GRUB_VGA_GR_MODE = 5,
|
||||
GRUB_VGA_GR_GR6 = 6,
|
||||
GRUB_VGA_GR_COLOR_COMPARE_DISABLE = 7,
|
||||
GRUB_VGA_GR_BITMASK = 8,
|
||||
GRUB_VGA_GR_MAX
|
||||
};
|
||||
|
||||
#define GRUB_VGA_ALL_PLANES 0xf
|
||||
#define GRUB_VGA_NO_PLANES 0x0
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_GR_DATA_ROTATE_NOP = 0
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GRUB_VGA_TEXT_TEXT_PLANE = 0,
|
||||
|
@ -119,6 +212,7 @@ enum
|
|||
enum
|
||||
{
|
||||
GRUB_VGA_GR_GR6_GRAPHICS_MODE = 1,
|
||||
GRUB_VGA_GR_GR6_MMAP_A0 = (1 << 2),
|
||||
GRUB_VGA_GR_GR6_MMAP_CGA = (3 << 2)
|
||||
};
|
||||
|
||||
|
@ -126,70 +220,152 @@ enum
|
|||
{
|
||||
GRUB_VGA_GR_MODE_READ_MODE1 = 0x08,
|
||||
GRUB_VGA_GR_MODE_ODD_EVEN = 0x10,
|
||||
GRUB_VGA_GR_MODE_ODD_EVEN_SHIFT = 0x20,
|
||||
GRUB_VGA_GR_MODE_256_COLOR = 0x40
|
||||
};
|
||||
|
||||
static inline void
|
||||
grub_vga_gr_write (grub_uint8_t val, grub_uint8_t addr)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_GR_INDEX);
|
||||
grub_outb (val, GRUB_VGA_IO_GR_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_INDEX);
|
||||
grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_DATA);
|
||||
}
|
||||
|
||||
static inline grub_uint8_t
|
||||
grub_vga_gr_read (grub_uint8_t addr)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_GR_INDEX);
|
||||
return grub_inb (GRUB_VGA_IO_GR_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_INDEX);
|
||||
return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_GR_DATA);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_vga_cr_write (grub_uint8_t val, grub_uint8_t addr)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_CR_INDEX);
|
||||
grub_outb (val, GRUB_VGA_IO_CR_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_INDEX);
|
||||
grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_DATA);
|
||||
}
|
||||
|
||||
static inline grub_uint8_t
|
||||
grub_vga_cr_read (grub_uint8_t addr)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_CR_INDEX);
|
||||
return grub_inb (GRUB_VGA_IO_CR_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_INDEX);
|
||||
return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_DATA);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_vga_sr_write (grub_uint8_t val, grub_uint8_t addr)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_SR_INDEX);
|
||||
grub_outb (val, GRUB_VGA_IO_SR_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_INDEX);
|
||||
grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_DATA);
|
||||
}
|
||||
|
||||
static inline grub_uint8_t
|
||||
grub_vga_sr_read (grub_uint8_t addr)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_SR_INDEX);
|
||||
return grub_inb (GRUB_VGA_IO_SR_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_INDEX);
|
||||
return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_DATA);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_vga_palette_read (grub_uint8_t addr, grub_uint8_t *r, grub_uint8_t *g,
|
||||
grub_uint8_t *b)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_PALLETTE_READ_INDEX);
|
||||
*r = grub_inb (GRUB_VGA_IO_PALLETTE_DATA);
|
||||
*g = grub_inb (GRUB_VGA_IO_PALLETTE_DATA);
|
||||
*b = grub_inb (GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_READ_INDEX);
|
||||
*r = grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
|
||||
*g = grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
|
||||
*b = grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_vga_palette_write (grub_uint8_t addr, grub_uint8_t r, grub_uint8_t g,
|
||||
grub_uint8_t b)
|
||||
{
|
||||
grub_outb (addr, GRUB_VGA_IO_PALLETTE_WRITE_INDEX);
|
||||
grub_outb (r, GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (g, GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (b, GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_WRITE_INDEX);
|
||||
grub_outb (r, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (g, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
|
||||
grub_outb (b, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_PALLETTE_DATA);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_vga_write_arx (grub_uint8_t val, grub_uint8_t addr)
|
||||
{
|
||||
grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_INPUT_STATUS1_REGISTER);
|
||||
grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX);
|
||||
grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX_READ);
|
||||
grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_ARX);
|
||||
}
|
||||
|
||||
struct grub_video_hw_config
|
||||
{
|
||||
unsigned vertical_total;
|
||||
unsigned vertical_blank_start;
|
||||
unsigned vertical_blank_end;
|
||||
unsigned vertical_sync_start;
|
||||
unsigned vertical_sync_end;
|
||||
unsigned line_compare;
|
||||
unsigned vdisplay_end;
|
||||
unsigned pitch;
|
||||
unsigned horizontal_total;
|
||||
unsigned horizontal_blank_start;
|
||||
unsigned horizontal_blank_end;
|
||||
unsigned horizontal_sync_pulse_start;
|
||||
unsigned horizontal_sync_pulse_end;
|
||||
unsigned horizontal_end;
|
||||
};
|
||||
|
||||
static inline void
|
||||
grub_vga_set_geometry (struct grub_video_hw_config *config,
|
||||
void (*cr_write) (grub_uint8_t val, grub_uint8_t addr))
|
||||
{
|
||||
unsigned vertical_total = config->vertical_total - 2;
|
||||
unsigned vertical_blank_start = config->vertical_blank_start - 1;
|
||||
unsigned vdisplay_end = config->vdisplay_end - 1;
|
||||
grub_uint8_t overflow, cell_height_reg;
|
||||
|
||||
/* Disable CR0-7 write protection. */
|
||||
cr_write (0, GRUB_VGA_CR_VSYNC_END);
|
||||
|
||||
overflow = ((vertical_total >> GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VERT_TOTAL1_MASK)
|
||||
| ((vertical_total >> GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VERT_TOTAL2_MASK)
|
||||
| ((config->vertical_sync_start >> GRUB_VGA_CR_OVERFLOW_VSYNC_START2_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VSYNC_START2_MASK)
|
||||
| ((config->vertical_sync_start >> GRUB_VGA_CR_OVERFLOW_VSYNC_START1_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VSYNC_START1_MASK)
|
||||
| ((vdisplay_end >> GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END1_MASK)
|
||||
| ((vdisplay_end >> GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VERT_DISPLAY_ENABLE_END2_MASK)
|
||||
| ((config->vertical_sync_start >> GRUB_VGA_CR_OVERFLOW_VSYNC_START1_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_VSYNC_START1_MASK)
|
||||
| ((config->line_compare >> GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_LINE_COMPARE_MASK);
|
||||
|
||||
cell_height_reg = ((vertical_blank_start
|
||||
>> GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_SHIFT)
|
||||
& GRUB_VGA_CR_CELL_HEIGHT_VERTICAL_BLANK_MASK)
|
||||
| ((config->line_compare >> GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_SHIFT)
|
||||
& GRUB_VGA_CR_CELL_HEIGHT_LINE_COMPARE_MASK);
|
||||
|
||||
cr_write (config->horizontal_total - 1, GRUB_VGA_CR_HTOTAL);
|
||||
cr_write (config->horizontal_end - 1, GRUB_VGA_CR_HORIZ_END);
|
||||
cr_write (config->horizontal_blank_start - 1, GRUB_VGA_CR_HBLANK_START);
|
||||
cr_write (config->horizontal_blank_end, GRUB_VGA_CR_HBLANK_END);
|
||||
cr_write (config->horizontal_sync_pulse_start,
|
||||
GRUB_VGA_CR_HORIZ_SYNC_PULSE_START);
|
||||
cr_write (config->horizontal_sync_pulse_end,
|
||||
GRUB_VGA_CR_HORIZ_SYNC_PULSE_END);
|
||||
cr_write (vertical_total & 0xff, GRUB_VGA_CR_VERT_TOTAL);
|
||||
cr_write (overflow, GRUB_VGA_CR_OVERFLOW);
|
||||
cr_write (cell_height_reg, GRUB_VGA_CR_CELL_HEIGHT);
|
||||
cr_write (config->vertical_sync_start & 0xff, GRUB_VGA_CR_VSYNC_START);
|
||||
cr_write (config->vertical_sync_end & 0x0f, GRUB_VGA_CR_VSYNC_END);
|
||||
cr_write (vdisplay_end & 0xff, GRUB_VGA_CR_VDISPLAY_END);
|
||||
cr_write (config->pitch & 0xff, GRUB_VGA_CR_PITCH);
|
||||
cr_write (vertical_blank_start & 0xff, GRUB_VGA_CR_VERTICAL_BLANK_START);
|
||||
cr_write (config->vertical_blank_end & 0xff, GRUB_VGA_CR_VERTICAL_BLANK_END);
|
||||
cr_write (config->line_compare & 0xff, GRUB_VGA_CR_LINE_COMPARE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -168,6 +168,15 @@ struct grub_video_rect
|
|||
};
|
||||
typedef struct grub_video_rect grub_video_rect_t;
|
||||
|
||||
struct grub_video_signed_rect
|
||||
{
|
||||
signed x;
|
||||
signed y;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
};
|
||||
typedef struct grub_video_signed_rect grub_video_signed_rect_t;
|
||||
|
||||
struct grub_video_palette_data
|
||||
{
|
||||
grub_uint8_t r; /* Red color value (0-255). */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue