diff options
Diffstat (limited to 'include')
37 files changed, 518 insertions, 115 deletions
diff --git a/include/grub/arc/arc.h b/include/grub/arc/arc.h index a825a98..739926f 100644 --- a/include/grub/arc/arc.h +++ b/include/grub/arc/arc.h @@ -255,7 +255,12 @@ struct grub_arc_system_parameter_block #define GRUB_ARC_STDIN 0 #define GRUB_ARC_STDOUT 1 -int EXPORT_FUNC (grub_arc_iterate_devs) (int (*hook) (const char *name, const struct grub_arc_component *comp), int alt_names); +typedef int (*grub_arc_iterate_devs_hook_t) + (const char *name, const struct grub_arc_component *comp, void *data); + +int EXPORT_FUNC (grub_arc_iterate_devs) (grub_arc_iterate_devs_hook_t hook, + void *hook_data, + int alt_names); #define FOR_ARC_CHILDREN(comp, parent) for (comp = GRUB_ARC_FIRMWARE_VECTOR->getchild (parent); comp; comp = GRUB_ARC_FIRMWARE_VECTOR->getpeer (comp)) diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h index 043994b..de4b4fe 100644 --- a/include/grub/arm/linux.h +++ b/include/grub/arm/linux.h @@ -24,12 +24,12 @@ #define LINUX_ZIMAGE_MAGIC 0x016f2818 #if defined GRUB_MACHINE_UBOOT -# include <grub/uboot/uboot.h> -# define LINUX_ADDRESS (start_of_ram + 0x8000) -# define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) -# define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) -# define firmware_get_boot_data uboot_get_boot_data -# define firmware_get_machine_type uboot_get_machine_type +#include <grub/uboot/uboot.h> +#define LINUX_ADDRESS (start_of_ram + 0x8000) +#define LINUX_INITRD_ADDRESS (start_of_ram + 0x02000000) +#define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000) +#define firmware_get_boot_data uboot_get_boot_data +#define firmware_get_machine_type uboot_get_machine_type #endif #define FDT_ADDITIONAL_ENTRIES_SIZE 0x300 diff --git a/include/grub/ata.h b/include/grub/ata.h index efba7b7..e8a84b8 100644 --- a/include/grub/ata.h +++ b/include/grub/ata.h @@ -193,10 +193,12 @@ struct grub_ata typedef struct grub_ata *grub_ata_t; +typedef int (*grub_ata_dev_iterate_hook_t) (int id, int bus, void *data); + struct grub_ata_dev { /* Call HOOK with each device name, until HOOK returns non-zero. */ - int (*iterate) (int (*hook) (int id, int bus), + int (*iterate) (grub_ata_dev_iterate_hook_t hook, void *hook_data, grub_disk_pull_t pull); /* Open the device named NAME, and set up SCSI. */ diff --git a/include/grub/crypto.h b/include/grub/crypto.h index 67e0a1b..ea2f13e 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -64,11 +64,14 @@ typedef enum GPG_ERR_WEAK_KEY, GPG_ERR_WRONG_KEY_USAGE, GPG_ERR_WRONG_PUBKEY_ALGO, - GPG_ERR_OUT_OF_MEMORY - } gcry_err_code_t; -#define gpg_err_code_t gcry_err_code_t -#define gpg_error_t gcry_err_code_t - + GPG_ERR_OUT_OF_MEMORY, + GPG_ERR_TOO_LARGE + } gpg_err_code_t; +typedef gpg_err_code_t gpg_error_t; +typedef gpg_error_t gcry_error_t; +typedef gpg_err_code_t gcry_err_code_t; +#define gcry_error_t gcry_err_code_t +#if 0 enum gcry_cipher_modes { GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */ @@ -79,6 +82,7 @@ enum gcry_cipher_modes GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */ GCRY_CIPHER_MODE_CTR = 6 /* Counter. */ }; +#endif /* Type for the cipher_setkey function. */ typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c, @@ -171,6 +175,74 @@ typedef struct gcry_md_spec struct gcry_md_spec *next; } gcry_md_spec_t; +struct gcry_mpi; +typedef struct gcry_mpi *gcry_mpi_t; + +/* Type for the pk_generate function. */ +typedef gcry_err_code_t (*gcry_pk_generate_t) (int algo, + unsigned int nbits, + unsigned long use_e, + gcry_mpi_t *skey, + gcry_mpi_t **retfactors); + +/* Type for the pk_check_secret_key function. */ +typedef gcry_err_code_t (*gcry_pk_check_secret_key_t) (int algo, + gcry_mpi_t *skey); + +/* Type for the pk_encrypt function. */ +typedef gcry_err_code_t (*gcry_pk_encrypt_t) (int algo, + gcry_mpi_t *resarr, + gcry_mpi_t data, + gcry_mpi_t *pkey, + int flags); + +/* Type for the pk_decrypt function. */ +typedef gcry_err_code_t (*gcry_pk_decrypt_t) (int algo, + gcry_mpi_t *result, + gcry_mpi_t *data, + gcry_mpi_t *skey, + int flags); + +/* Type for the pk_sign function. */ +typedef gcry_err_code_t (*gcry_pk_sign_t) (int algo, + gcry_mpi_t *resarr, + gcry_mpi_t data, + gcry_mpi_t *skey); + +/* Type for the pk_verify function. */ +typedef gcry_err_code_t (*gcry_pk_verify_t) (int algo, + gcry_mpi_t hash, + gcry_mpi_t *data, + gcry_mpi_t *pkey, + int (*cmp) (void *, gcry_mpi_t), + void *opaquev); + +/* Type for the pk_get_nbits function. */ +typedef unsigned (*gcry_pk_get_nbits_t) (int algo, gcry_mpi_t *pkey); + +/* Module specification structure for message digests. */ +typedef struct gcry_pk_spec +{ + const char *name; + const char **aliases; + const char *elements_pkey; + const char *elements_skey; + const char *elements_enc; + const char *elements_sig; + const char *elements_grip; + int use; + gcry_pk_generate_t generate; + gcry_pk_check_secret_key_t check_secret_key; + gcry_pk_encrypt_t encrypt; + gcry_pk_decrypt_t decrypt; + gcry_pk_sign_t sign; + gcry_pk_verify_t verify; + gcry_pk_get_nbits_t get_nbits; +#ifdef GRUB_UTIL + const char *modname; +#endif +} gcry_pk_spec_t; + struct grub_crypto_cipher_handle { const struct gcry_cipher_spec *cipher; @@ -256,6 +328,11 @@ void grub_md_register (gcry_md_spec_t *digest); void grub_md_unregister (gcry_md_spec_t *cipher); + +extern struct gcry_pk_spec *grub_crypto_pk_dsa; +extern struct gcry_pk_spec *grub_crypto_pk_ecdsa; +extern struct gcry_pk_spec *grub_crypto_pk_rsa; + void grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in, grub_size_t inlen); @@ -319,10 +396,20 @@ grub_password_get (char buf[], unsigned buf_size); extern void (*grub_crypto_autoload_hook) (const char *name); +void _gcry_assert_failed (const char *expr, const char *file, int line, + const char *func) __attribute__ ((noreturn)); + +void _gcry_burn_stack (int bytes); +void _gcry_log_error( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); +void _gcry_log_bug( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); +void _gcry_log_printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); +void +_gcry_check_heap (const void *a __attribute__ ((unused))); + + #ifdef GRUB_UTIL void grub_gcry_init_all (void); void grub_gcry_fini_all (void); #endif - #endif diff --git a/include/grub/device.h b/include/grub/device.h index f3e43bf..1d1a239 100644 --- a/include/grub/device.h +++ b/include/grub/device.h @@ -33,8 +33,11 @@ struct grub_device }; typedef struct grub_device *grub_device_t; +typedef int (*grub_device_iterate_hook_t) (const char *name, void *data); + grub_device_t EXPORT_FUNC(grub_device_open) (const char *name); grub_err_t EXPORT_FUNC(grub_device_close) (grub_device_t device); -int EXPORT_FUNC(grub_device_iterate) (int (*hook) (const char *name)); +int EXPORT_FUNC(grub_device_iterate) (grub_device_iterate_hook_t hook, + void *hook_data); #endif /* ! GRUB_DEVICE_HEADER */ diff --git a/include/grub/disk.h b/include/grub/disk.h index 6979a9c..89b4d08 100644 --- a/include/grub/disk.h +++ b/include/grub/disk.h @@ -57,6 +57,8 @@ typedef enum GRUB_DISK_PULL_MAX } grub_disk_pull_t; +typedef int (*grub_disk_dev_iterate_hook_t) (const char *name, void *data); + /* Disk device. */ struct grub_disk_dev { @@ -67,7 +69,7 @@ struct grub_disk_dev enum grub_disk_dev_id id; /* Call HOOK with each device name, until HOOK returns non-zero. */ - int (*iterate) (int (*hook) (const char *name), + int (*iterate) (grub_disk_dev_iterate_hook_t hook, void *hook_data, grub_disk_pull_t pull); /* Open the device named NAME, and set up DISK. */ @@ -159,14 +161,14 @@ void grub_disk_cache_invalidate_all (void); void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev); void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev); static inline int -grub_disk_dev_iterate (int (*hook) (const char *name)) +grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data) { grub_disk_dev_t p; grub_disk_pull_t pull; for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++) for (p = grub_disk_dev_list; p; p = p->next) - if (p->iterate && (p->iterate) (hook, pull)) + if (p->iterate && (p->iterate) (hook, hook_data, pull)) return 1; return 0; diff --git a/include/grub/efiemu/efiemu.h b/include/grub/efiemu/efiemu.h index 4ce3fc9..f241e75 100644 --- a/include/grub/efiemu/efiemu.h +++ b/include/grub/efiemu/efiemu.h @@ -226,7 +226,7 @@ grub_efiemu_finish_boot_services (grub_efi_uintn_t *memory_map_size, grub_efi_uint32_t *descriptor_version); grub_err_t -grub_efiemu_mmap_iterate (grub_memory_hook_t hook); +grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data); int grub_efiemu_sizeof_uintn_t (void); grub_err_t grub_efiemu_get_lower_upper_memory (grub_uint64_t *lower, grub_uint64_t *upper); diff --git a/include/grub/elfload.h b/include/grub/elfload.h index aae95f5..d1a8d54 100644 --- a/include/grub/elfload.h +++ b/include/grub/elfload.h @@ -41,6 +41,11 @@ typedef grub_err_t (*grub_elf32_load_hook_t) typedef grub_err_t (*grub_elf64_load_hook_t) (Elf64_Phdr *phdr, grub_addr_t *addr, int *load); +typedef int (*grub_elf32_phdr_iterate_hook_t) + (grub_elf_t elf, Elf32_Phdr *phdr, void *arg); +typedef int (*grub_elf64_phdr_iterate_hook_t) + (grub_elf_t elf, Elf64_Phdr *phdr, void *arg); + grub_elf_t grub_elf_open (const char *); grub_elf_t grub_elf_file (grub_file_t file, const char *filename); grub_err_t grub_elf_close (grub_elf_t); @@ -63,12 +68,10 @@ grub_err_t grub_elf64_load (grub_elf_t, const char *filename, grub_err_t grub_elf32_phdr_iterate (grub_elf_t elf, const char *filename, - int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf32_Phdr *, void *), - void *hook_arg); + grub_elf32_phdr_iterate_hook_t hook, void *hook_arg); grub_err_t grub_elf64_phdr_iterate (grub_elf_t elf, const char *filename, - int NESTED_FUNC_ATTR (*hook) (grub_elf_t, Elf64_Phdr *, void *), - void *hook_arg); + grub_elf64_phdr_iterate_hook_t hook, void *hook_arg); #endif /* ! GRUB_ELFLOAD_HEADER */ diff --git a/include/grub/err.h b/include/grub/err.h index 2edc514..0f9b208 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -69,7 +69,8 @@ typedef enum GRUB_ERR_NET_UNKNOWN_ERROR, GRUB_ERR_NET_PACKET_TOO_BIG, GRUB_ERR_NET_NO_DOMAIN, - GRUB_ERR_EOF + GRUB_ERR_EOF, + GRUB_ERR_BAD_SIGNATURE } grub_err_t; diff --git a/include/grub/file.h b/include/grub/file.h index e08ac2e..ae86401 100644 --- a/include/grub/file.h +++ b/include/grub/file.h @@ -54,6 +54,7 @@ typedef struct grub_file *grub_file_t; /* Filters with lower ID are executed first. */ typedef enum grub_file_filter_id { + GRUB_FILE_FILTER_PUBKEY, GRUB_FILE_FILTER_GZIO, GRUB_FILE_FILTER_XZIO, GRUB_FILE_FILTER_LZOPIO, @@ -62,7 +63,7 @@ typedef enum grub_file_filter_id GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_LZOPIO, } grub_file_filter_id_t; -typedef grub_file_t (*grub_file_filter_t) (grub_file_t in); +typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, const char *filename); extern grub_file_filter_t EXPORT_VAR(grub_file_filters_all)[GRUB_FILE_FILTER_MAX]; extern grub_file_filter_t EXPORT_VAR(grub_file_filters_enabled)[GRUB_FILE_FILTER_MAX]; @@ -72,20 +73,20 @@ grub_file_filter_register (grub_file_filter_id_t id, grub_file_filter_t filter) { grub_file_filters_all[id] = filter; grub_file_filters_enabled[id] = filter; -}; +} static inline void grub_file_filter_unregister (grub_file_filter_id_t id) { grub_file_filters_all[id] = 0; grub_file_filters_enabled[id] = 0; -}; +} static inline void grub_file_filter_disable (grub_file_filter_id_t id) { grub_file_filters_enabled[id] = 0; -}; +} static inline void grub_file_filter_disable_compression (void) @@ -95,7 +96,23 @@ grub_file_filter_disable_compression (void) for (id = GRUB_FILE_FILTER_COMPRESSION_FIRST; id <= GRUB_FILE_FILTER_COMPRESSION_LAST; id++) grub_file_filters_enabled[id] = 0; -}; +} + +static inline void +grub_file_filter_disable_all (void) +{ + grub_file_filter_id_t id; + + for (id = 0; + id < GRUB_FILE_FILTER_MAX; id++) + grub_file_filters_enabled[id] = 0; +} + +static inline void +grub_file_filter_disable_pubkey (void) +{ + grub_file_filters_enabled[GRUB_FILE_FILTER_PUBKEY] = 0; +} /* Get a device name from NAME. */ char *EXPORT_FUNC(grub_file_get_device_name) (const char *name); diff --git a/include/grub/fs.h b/include/grub/fs.h index 503d1a9..e451797 100644 --- a/include/grub/fs.h +++ b/include/grub/fs.h @@ -41,6 +41,10 @@ struct grub_dirhook_info grub_int32_t mtime; }; +typedef int (*grub_fs_dir_hook_t) (const char *filename, + const struct grub_dirhook_info *info, + void *data); + /* Filesystem descriptor. */ struct grub_fs { @@ -53,8 +57,7 @@ struct grub_fs /* Call HOOK with each file under DIR. */ grub_err_t (*dir) (grub_device_t device, const char *path, - int (*hook) (const char *filename, - const struct grub_dirhook_info *info)); + grub_fs_dir_hook_t hook, void *hook_data); /* Open a file named NAME and initialize FILE. */ grub_err_t (*open) (struct grub_file *file, const char *name); diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h index 4838fca..e437d4c 100644 --- a/include/grub/fshelp.h +++ b/include/grub/fshelp.h @@ -38,24 +38,25 @@ enum grub_fshelp_filetype GRUB_FSHELP_SYMLINK }; +typedef int (*grub_fshelp_iterate_dir_hook_t) (const char *filename, + enum grub_fshelp_filetype filetype, + grub_fshelp_node_t node, + void *data); + /* Lookup the node PATH. The node ROOTNODE describes the root of the directory tree. The node found is returned in FOUNDNODE, which is either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to iterate over all directory entries in the current node. READ_SYMLINK is used to read the symlink if a node is a symlink. EXPECTTYPE is the type node that is expected by the called, an - error is generated if the node is not of the expected type. Make - sure you use the NESTED_FUNC_ATTR macro for HOOK, this is required - because GCC has a nasty bug when using regparm=3. */ + error is generated if the node is not of the expected type. */ grub_err_t EXPORT_FUNC(grub_fshelp_find_file) (const char *path, grub_fshelp_node_t rootnode, grub_fshelp_node_t *foundnode, int (*iterate_dir) (grub_fshelp_node_t dir, - int NESTED_FUNC_ATTR - (*hook) (const char *filename, - enum grub_fshelp_filetype filetype, - grub_fshelp_node_t node)), + grub_fshelp_iterate_dir_hook_t hook, + void *hook_data), char *(*read_symlink) (grub_fshelp_node_t node), enum grub_fshelp_filetype expect); diff --git a/include/grub/gcry/types.h b/include/grub/gcry/types.h new file mode 100644 index 0000000..892a204 --- /dev/null +++ b/include/grub/gcry/types.h @@ -0,0 +1,37 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 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_GCRY_TYPES_HEADER +#define GRUB_GCRY_TYPES_HEADER 1 + +#include <grub/types.h> +#include <grub/misc.h> + +#ifdef GRUB_CPU_WORDS_BIGENDIAN +#define WORDS_BIGENDIAN +#else +#undef WORDS_BIGENDIAN +#endif + +typedef grub_uint64_t u64; +typedef grub_uint32_t u32; +typedef grub_uint16_t u16; +typedef grub_uint8_t byte; +typedef grub_size_t size_t; + +#endif diff --git a/include/grub/gcrypt/gpg-error.h b/include/grub/gcrypt/gpg-error.h new file mode 100644 index 0000000..1e42502 --- /dev/null +++ b/include/grub/gcrypt/gpg-error.h @@ -0,0 +1,32 @@ +#ifndef GRUB_GPG_ERROR_H +#define GRUB_GPG_ERROR_H 1 + +#include <grub/crypto.h> +typedef enum + { + GPG_ERR_SOURCE_USER_1 + } + gpg_err_source_t; +#define GPG_ERR_INLINE inline +static inline int +gpg_err_make (gpg_err_source_t source __attribute__ ((unused)), gpg_err_code_t code) +{ + return code; +} + +static inline gpg_err_code_t +gpg_err_code (gpg_error_t err) +{ + return err; +} + +static inline gpg_err_source_t +gpg_err_source (gpg_error_t err __attribute__ ((unused))) +{ + return GPG_ERR_SOURCE_USER_1; +} + +gcry_err_code_t +gpg_error_from_syserror (void); + +#endif diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index 83e3b31..4aaf1c4 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -80,8 +80,8 @@ struct grub_gpt_partentry grub_err_t grub_gpt_partition_map_iterate (grub_disk_t disk, - int (*hook) (grub_disk_t disk, - const grub_partition_t partition)); + grub_partition_iterate_hook_t hook, + void *hook_data); #endif /* ! GRUB_GPT_PARTITION_HEADER */ diff --git a/include/grub/i386/macho.h b/include/grub/i386/macho.h index f22c211..5ee9f9e 100644 --- a/include/grub/i386/macho.h +++ b/include/grub/i386/macho.h @@ -23,6 +23,11 @@ #define GRUB_MACHO_CPUTYPE_IS_HOST32(x) ((x)==0x00000007) #define GRUB_MACHO_CPUTYPE_IS_HOST64(x) ((x)==0x01000007) +#ifdef __x86_64__ +#define GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT(x) ((x)==0x01000007) +#else +#define GRUB_MACHO_CPUTYPE_IS_HOST_CURRENT(x) ((x)==0x00000007) +#endif struct grub_macho_thread32 { diff --git a/include/grub/i386/pit.h b/include/grub/i386/pit.h index ff9b9a6..e1c92cd 100644 --- a/include/grub/i386/pit.h +++ b/include/grub/i386/pit.h @@ -22,6 +22,84 @@ #include <grub/types.h> #include <grub/err.h> +enum + { + /* The PIT channel value ports. You can write to and read from them. + Do not mess with timer 0 or 1. */ + GRUB_PIT_COUNTER_0 = 0x40, + GRUB_PIT_COUNTER_1 = 0x41, + GRUB_PIT_COUNTER_2 = 0x42, + /* The PIT control port. You can only write to it. Do not mess with + timer 0 or 1. */ + GRUB_PIT_CTRL = 0x43, + /* The speaker port. */ + GRUB_PIT_SPEAKER_PORT = 0x61, + }; + + +/* The speaker port. */ +enum + { + /* If 0, follow state of SPEAKER_DATA bit, otherwise enable output + from timer 2. */ + GRUB_PIT_SPK_TMR2 = 0x01, + /* If SPEAKER_TMR2 is not set, this provides direct input into the + speaker. Otherwise, this enables or disables the output from the + timer. */ + GRUB_PIT_SPK_DATA = 0x02, + + GRUB_PIT_SPK_TMR2_LATCH = 0x20 + }; + +/* The PIT control port. You can only write to it. Do not mess with + timer 0 or 1. */ +enum + { + GRUB_PIT_CTRL_SELECT_MASK = 0xc0, + GRUB_PIT_CTRL_SELECT_0 = 0x00, + GRUB_PIT_CTRL_SELECT_1 = 0x40, + GRUB_PIT_CTRL_SELECT_2 = 0x80, + + /* Read and load control. */ + GRUB_PIT_CTRL_READLOAD_MASK= 0x30, + GRUB_PIT_CTRL_COUNTER_LATCH = 0x00, /* Hold timer value until read. */ + GRUB_PIT_CTRL_READLOAD_LSB = 0x10, /* Read/load the LSB. */ + GRUB_PIT_CTRL_READLOAD_MSB = 0x20, /* Read/load the MSB. */ + GRUB_PIT_CTRL_READLOAD_WORD = 0x30, /* Read/load the LSB then the MSB. */ + + /* Mode control. */ + GRUB_PIT_CTRL_MODE_MASK = 0x0e, + /* Interrupt on terminal count. Setting the mode sets output to low. + When counter is set and terminated, output is set to high. */ + GRUB_PIT_CTRL_INTR_ON_TERM = 0x00, + /* Programmable one-shot. When loading counter, output is set to + high. When counter terminated, output is set to low. Can be + triggered again from that point on by setting the gate pin to + high. */ + GRUB_PIT_CTRL_PROGR_ONE_SHOT = 0x02, + + /* Rate generator. Output is low for one period of the counter, and + high for the other. */ + GRUB_PIT_CTRL_RATE_GEN = 0x04, + + /* Square wave generator. Output is low for one half of the period, + and high for the other half. */ + GRUB_PIT_CTRL_SQUAREWAVE_GEN = 0x06, + /* Software triggered strobe. Setting the mode sets output to high. + When counter is set and terminated, output is set to low. */ + GRUB_PIT_CTRL_SOFTSTROBE = 0x08, + + /* Hardware triggered strobe. Like software triggered strobe, but + only starts the counter when the gate pin is set to high. */ + GRUB_PIT_CTRL_HARDSTROBE = 0x0a, + + + /* Count mode. */ + GRUB_PIT_CTRL_COUNT_MASK = 0x01, + GRUB_PIT_CTRL_COUNT_BINARY = 0x00, /* 16-bit binary counter. */ + GRUB_PIT_CTRL_COUNT_BCD = 0x01 /* 4-decade BCD counter. */ + }; + void EXPORT_FUNC(grub_pit_wait) (grub_uint16_t tics); #endif /* ! KERNEL_CPU_PIT_HEADER */ diff --git a/include/grub/i386/relocator.h b/include/grub/i386/relocator.h index 46becb8..5f89a7e 100644 --- a/include/grub/i386/relocator.h +++ b/include/grub/i386/relocator.h @@ -49,6 +49,7 @@ struct grub_relocator16_state grub_uint32_t ebx; grub_uint32_t edx; grub_uint32_t esi; + grub_uint32_t ebp; int a20; }; diff --git a/include/grub/kernel.h b/include/grub/kernel.h index eef4c3f..23e4f02 100644 --- a/include/grub/kernel.h +++ b/include/grub/kernel.h @@ -27,7 +27,8 @@ enum OBJ_TYPE_ELF, OBJ_TYPE_MEMDISK, OBJ_TYPE_CONFIG, - OBJ_TYPE_PREFIX + OBJ_TYPE_PREFIX, + OBJ_TYPE_PUBKEY }; /* The module header. */ @@ -77,7 +78,7 @@ extern grub_addr_t EXPORT_VAR (grub_modbase); var && (grub_addr_t) var \ < (grub_modbase + (((struct grub_module_info *) grub_modbase)->size)); \ var = (struct grub_module_header *) \ - ((grub_uint32_t *) var + ((struct grub_module_header *) var)->size / 4)) + (((grub_uint32_t *) var) + ((((struct grub_module_header *) var)->size + sizeof (grub_addr_t) - 1) / sizeof (grub_addr_t)) * (sizeof (grub_addr_t) / sizeof (grub_uint32_t)))) grub_addr_t grub_modules_get_end (void); diff --git a/include/grub/macho.h b/include/grub/macho.h index 6a98b6e..21f0714 100644 --- a/include/grub/macho.h +++ b/include/grub/macho.h @@ -27,6 +27,7 @@ struct grub_macho_fat_header grub_uint32_t nfat_arch; } __attribute__ ((packed)); #define GRUB_MACHO_FAT_MAGIC 0xcafebabe +#define GRUB_MACHO_FAT_EFI_MAGIC 0x0ef1fab9 typedef grub_uint32_t grub_macho_cpu_type_t; typedef grub_uint32_t grub_macho_cpu_subtype_t; diff --git a/include/grub/memory.h b/include/grub/memory.h index 61470d7..3311fcb 100644 --- a/include/grub/memory.h +++ b/include/grub/memory.h @@ -36,21 +36,25 @@ typedef enum grub_memory_type GRUB_MEMORY_HOLE = 21 } grub_memory_type_t; -typedef int NESTED_FUNC_ATTR (*grub_memory_hook_t) (grub_uint64_t, - grub_uint64_t, - grub_memory_type_t); +typedef int (*grub_memory_hook_t) (grub_uint64_t, + grub_uint64_t, + grub_memory_type_t, + void *); -grub_err_t grub_mmap_iterate (grub_memory_hook_t hook); +grub_err_t grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data); #ifdef GRUB_MACHINE_EFI grub_err_t -grub_efi_mmap_iterate (grub_memory_hook_t hook, int avoid_efi_boot_services); +grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, + int avoid_efi_boot_services); #endif #if !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_EFI) -grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) (grub_memory_hook_t hook); +grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate) (grub_memory_hook_t hook, + void *hook_data); #else -grub_err_t grub_machine_mmap_iterate (grub_memory_hook_t hook); +grub_err_t grub_machine_mmap_iterate (grub_memory_hook_t hook, + void *hook_data); #endif int grub_mmap_register (grub_uint64_t start, grub_uint64_t size, int type); diff --git a/include/grub/msdos_partition.h b/include/grub/msdos_partition.h index 9c8ac3e..1e9b65e 100644 --- a/include/grub/msdos_partition.h +++ b/include/grub/msdos_partition.h @@ -120,7 +120,7 @@ grub_msdos_partition_is_extended (int type) grub_err_t grub_partition_msdos_iterate (grub_disk_t disk, - int (*hook) (grub_disk_t disk, - const grub_partition_t partition)); + grub_partition_iterate_hook_t hook, + void *hook_data); #endif /* ! GRUB_PC_PARTITION_HEADER */ diff --git a/include/grub/normal.h b/include/grub/normal.h index e88cd26..416faa4 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -77,6 +77,14 @@ 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); + +void +grub_print_ucs4_menu (const grub_uint32_t * str, + const grub_uint32_t * last_position, + int margin_left, int margin_right, + struct grub_term_output *term, + int skip_lines, int max_lines, grub_uint32_t contchar, + struct grub_term_pos *pos); int grub_ucs4_count_lines (const grub_uint32_t * str, const grub_uint32_t * last_position, diff --git a/include/grub/ntfs.h b/include/grub/ntfs.h index 0935342..37983c4 100644 --- a/include/grub/ntfs.h +++ b/include/grub/ntfs.h @@ -87,6 +87,7 @@ enum #define GRUB_NTFS_COM_LEN 4096 #define GRUB_NTFS_COM_LOG_LEN 12 #define GRUB_NTFS_COM_SEC (GRUB_NTFS_COM_LEN >> GRUB_NTFS_BLK_SHR) +#define GRUB_NTFS_LOG_COM_SEC (GRUB_NTFS_COM_LOG_LEN - GRUB_NTFS_BLK_SHR) enum { @@ -131,17 +132,17 @@ struct grub_ntfs_bpb struct grub_ntfs_attr { int flags; - char *emft_buf, *edat_buf; - char *attr_cur, *attr_nxt, *attr_end; + grub_uint8_t *emft_buf, *edat_buf; + grub_uint8_t *attr_cur, *attr_nxt, *attr_end; grub_uint32_t save_pos; - char *sbuf; + grub_uint8_t *sbuf; struct grub_ntfs_file *mft; }; struct grub_ntfs_file { struct grub_ntfs_data *data; - char *buf; + grub_uint8_t *buf; grub_uint64_t size; grub_uint64_t mtime; grub_uint32_t ino; @@ -154,10 +155,10 @@ struct grub_ntfs_data struct grub_ntfs_file cmft; struct grub_ntfs_file mmft; grub_disk_t disk; - grub_uint32_t mft_size; - grub_uint32_t idx_size; - grub_uint32_t spc; - grub_uint32_t mft_start; + grub_uint64_t mft_size; + grub_uint64_t idx_size; + int log_spc; + grub_uint64_t mft_start; grub_uint64_t uuid; }; @@ -172,21 +173,22 @@ struct grub_ntfs_comp grub_disk_t disk; int comp_head, comp_tail; struct grub_ntfs_comp_table_element comp_table[16]; - grub_uint32_t cbuf_ofs, cbuf_vcn, spc; - char *cbuf; + grub_uint32_t cbuf_ofs, cbuf_vcn; + int log_spc; + grub_uint8_t *cbuf; }; struct grub_ntfs_rlst { int flags; grub_disk_addr_t target_vcn, curr_vcn, next_vcn, curr_lcn; - char *cur_run; + grub_uint8_t *cur_run; struct grub_ntfs_attr *attr; struct grub_ntfs_comp comp; }; typedef grub_err_t (*grub_ntfscomp_func_t) (struct grub_ntfs_attr * at, - char *dest, + grub_uint8_t *dest, grub_disk_addr_t ofs, grub_size_t len, struct grub_ntfs_rlst * ctx, diff --git a/include/grub/parser.h b/include/grub/parser.h index de4da05..bf9c7c6 100644 --- a/include/grub/parser.h +++ b/include/grub/parser.h @@ -63,6 +63,7 @@ EXPORT_FUNC (grub_parser_cmdline_state) (grub_parser_state_t state, grub_err_t EXPORT_FUNC (grub_parser_split_cmdline) (const char *cmdline, grub_reader_getline_t getline, + void *getline_data, int *argc, char ***argv); struct grub_parser @@ -79,13 +80,15 @@ struct grub_parser /* Clean up the parser. */ grub_err_t (*fini) (void); - grub_err_t (*parse_line) (char *line, grub_reader_getline_t getline); + grub_err_t (*parse_line) (char *line, + grub_reader_getline_t getline, void *getline_data); }; typedef struct grub_parser *grub_parser_t; grub_err_t grub_parser_execute (char *source); grub_err_t -grub_rescue_parse_line (char *line, grub_reader_getline_t getline); +grub_rescue_parse_line (char *line, + grub_reader_getline_t getline, void *getline_data); #endif /* ! GRUB_PARSER_HEADER */ diff --git a/include/grub/partition.h b/include/grub/partition.h index ec0a667..7adb7ec 100644 --- a/include/grub/partition.h +++ b/include/grub/partition.h @@ -33,6 +33,10 @@ typedef enum } grub_embed_type_t; #endif +typedef int (*grub_partition_iterate_hook_t) (struct grub_disk *disk, + const grub_partition_t partition, + void *data); + /* Partition map type. */ struct grub_partition_map { @@ -45,8 +49,7 @@ struct grub_partition_map /* Call HOOK with each partition, until HOOK returns non-zero. */ grub_err_t (*iterate) (struct grub_disk *disk, - int (*hook) (struct grub_disk *disk, - const grub_partition_t partition)); + grub_partition_iterate_hook_t hook, void *hook_data); #ifdef GRUB_UTIL /* Determine sectors available for embedding. */ grub_err_t (*embed) (struct grub_disk *disk, unsigned int *nsectors, @@ -89,8 +92,8 @@ struct grub_partition grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk, const char *str); int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk, - int (*hook) (struct grub_disk *disk, - const grub_partition_t partition)); + grub_partition_iterate_hook_t hook, + void *hook_data); char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition); diff --git a/include/grub/pci.h b/include/grub/pci.h index aaf0101..e163d47 100644 --- a/include/grub/pci.h +++ b/include/grub/pci.h @@ -132,13 +132,14 @@ grub_pci_get_function (grub_pci_device_t dev) #include <grub/cpu/pci.h> #endif -typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t) - (grub_pci_device_t dev, grub_pci_id_t pciid); +typedef int (*grub_pci_iteratefunc_t) + (grub_pci_device_t dev, grub_pci_id_t pciid, void *data); grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev, int reg); -void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook); +void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook, + void *hook_data); struct grub_pci_dma_chunk; diff --git a/include/grub/pubkey.h b/include/grub/pubkey.h new file mode 100644 index 0000000..4a9d04b --- /dev/null +++ b/include/grub/pubkey.h @@ -0,0 +1,38 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 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_PUBKEY_HEADER +#define GRUB_PUBKEY_HEADER 1 + +#include <grub/crypto.h> + +struct grub_public_key * +grub_load_public_key (grub_file_t f); + +grub_err_t +grub_verify_signature (grub_file_t f, grub_file_t sig, + struct grub_public_key *pk); + + +struct grub_public_subkey * +grub_crypto_pk_locate_subkey (grub_uint64_t keyid, struct grub_public_key *pkey); + +struct grub_public_subkey * +grub_crypto_pk_locate_subkey_in_trustdb (grub_uint64_t keyid); + +#endif diff --git a/include/grub/reader.h b/include/grub/reader.h index cd92df8..fd86b20 100644 --- a/include/grub/reader.h +++ b/include/grub/reader.h @@ -22,7 +22,7 @@ #include <grub/err.h> -typedef grub_err_t (*grub_reader_getline_t) (char **, int); +typedef grub_err_t (*grub_reader_getline_t) (char **, int, void *); void grub_rescue_run (void) __attribute__ ((noreturn)); diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index d99cbf7..78602e4 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -161,6 +161,9 @@ struct grub_lexer_param expected, but not available. */ grub_reader_getline_t getline; + /* Caller-supplied data passed to `getline'. */ + void *getline_data; + /* A reference counter. If this is >0 it means that the parser expects more tokens and `getline' should be called to fetch more. Otherwise the lexer can stop processing if the current buffer is @@ -287,14 +290,16 @@ grub_script_arg_add (struct grub_parser_param *state, grub_script_arg_type_t type, char *str); struct grub_script *grub_script_parse (char *script, - grub_reader_getline_t getline); + grub_reader_getline_t getline, + void *getline_data); void grub_script_free (struct grub_script *script); struct grub_script *grub_script_create (struct grub_script_cmd *cmd, struct grub_script_mem *mem); struct grub_lexer_param *grub_script_lexer_init (struct grub_parser_param *parser, char *script, - grub_reader_getline_t getline); + grub_reader_getline_t getline, + void *getline_data); void grub_script_lexer_fini (struct grub_lexer_param *); void grub_script_lexer_ref (struct grub_lexer_param *); void grub_script_lexer_deref (struct grub_lexer_param *); @@ -380,7 +385,8 @@ char ** grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count); grub_err_t -grub_normal_parse_line (char *line, grub_reader_getline_t getline); +grub_normal_parse_line (char *line, + grub_reader_getline_t getline, void *getline_data); static inline struct grub_script * grub_script_ref (struct grub_script *script) diff --git a/include/grub/scsi.h b/include/grub/scsi.h index 13300ca..a919a7c 100644 --- a/include/grub/scsi.h +++ b/include/grub/scsi.h @@ -49,10 +49,13 @@ grub_make_scsi_id (int subsystem, int bus, int lun) | (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_LUN_SHIFT); } +typedef int (*grub_scsi_dev_iterate_hook_t) (int id, int bus, int luns, + void *data); + struct grub_scsi_dev { /* Call HOOK with each device name, until HOOK returns non-zero. */ - int (*iterate) (int NESTED_FUNC_ATTR (*hook) (int id, int bus, int luns), + int (*iterate) (grub_scsi_dev_iterate_hook_t hook, void *hook_data, grub_disk_pull_t pull); /* Open the device named NAME, and set up SCSI. */ diff --git a/include/grub/speaker.h b/include/grub/speaker.h new file mode 100644 index 0000000..a076fcf --- /dev/null +++ b/include/grub/speaker.h @@ -0,0 +1,47 @@ +#ifndef GRUB_SPEAKER_HEADER +#define GRUB_SPEAKER_HEADER 1 + +#include <grub/cpu/io.h> +#include <grub/i386/pit.h> + +/* The frequency of the PIT clock. */ +#define GRUB_SPEAKER_PIT_FREQUENCY 0x1234dd + +static inline void +grub_speaker_beep_off (void) +{ + unsigned char status; + + status = grub_inb (GRUB_PIT_SPEAKER_PORT); + grub_outb (status & ~(GRUB_PIT_SPK_TMR2 | GRUB_PIT_SPK_DATA), + GRUB_PIT_SPEAKER_PORT); +} + +static inline void +grub_speaker_beep_on (grub_uint16_t pitch) +{ + unsigned char status; + unsigned int counter; + + if (pitch < 20) + pitch = 20; + else if (pitch > 20000) + pitch = 20000; + + counter = GRUB_SPEAKER_PIT_FREQUENCY / pitch; + + /* Program timer 2. */ + grub_outb (GRUB_PIT_CTRL_SELECT_2 + | GRUB_PIT_CTRL_READLOAD_WORD + | GRUB_PIT_CTRL_SQUAREWAVE_GEN + | GRUB_PIT_CTRL_COUNT_BINARY, GRUB_PIT_CTRL); + grub_outb (counter & 0xff, GRUB_PIT_COUNTER_2); /* LSB */ + grub_outb ((counter >> 8) & 0xff, GRUB_PIT_COUNTER_2); /* MSB */ + + /* Start speaker. */ + status = grub_inb (GRUB_PIT_SPEAKER_PORT); + grub_outb (status | GRUB_PIT_SPK_TMR2 | GRUB_PIT_SPK_DATA, + GRUB_PIT_SPEAKER_PORT); +} + +#endif diff --git a/include/grub/symbol.h b/include/grub/symbol.h index a2ba9b2..e2119bf 100644 --- a/include/grub/symbol.h +++ b/include/grub/symbol.h @@ -29,16 +29,16 @@ #if HAVE_ASM_USCORE #ifdef ASM_FILE -#ifndef (__arm__) -#define EXT_C(sym) _ ## sym +# ifndef (__arm__) +# define EXT_C(sym) _ ## sym +# else +# define EXT_C(sym) % ## sym +# endif #else -#define EXT_C(sym) % ## sym +# define EXT_C(sym) "_" sym #endif #else -#define EXT_C(sym) "_" sym -#endif -#else -#define EXT_C(sym) sym +# define EXT_C(sym) sym #endif #if defined (__APPLE__) @@ -56,8 +56,8 @@ /* Mark an exported symbol. */ #ifndef GRUB_SYMBOL_GENERATOR -#define EXPORT_FUNC(x) x -#define EXPORT_VAR(x) x +# define EXPORT_FUNC(x) x +# define EXPORT_VAR(x) x #endif /* ! GRUB_SYMBOL_GENERATOR */ #endif /* ! GRUB_SYMBOL_HEADER */ diff --git a/include/grub/term.h b/include/grub/term.h index bf4dcb4..84f5766 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -104,7 +104,7 @@ grub_term_color_state; #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) +#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. */ @@ -221,10 +221,6 @@ struct grub_term_output /* 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; @@ -233,6 +229,10 @@ typedef struct grub_term_output *grub_term_output_t; #define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70 #define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07 +/* Current color state. */ +extern grub_uint8_t EXPORT_VAR(grub_term_normal_color); +extern grub_uint8_t EXPORT_VAR(grub_term_highlight_color); + 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); @@ -344,7 +344,7 @@ static inline unsigned grub_term_height (struct grub_term_output *term) static inline unsigned grub_term_border_width (struct grub_term_output *term) { - return grub_term_width (term) - GRUB_TERM_MARGIN * 3 - GRUB_TERM_SCROLL_WIDTH; + return grub_term_width (term) - GRUB_TERM_MARGIN * 2; } /* The max column number of an entry. The last "-1" is for a @@ -352,7 +352,7 @@ grub_term_border_width (struct grub_term_output *term) static inline int grub_term_entry_width (struct grub_term_output *term) { - return grub_term_border_width (term) - 2 - GRUB_TERM_MARGIN * 2 - 1; + return grub_term_border_width (term) - GRUB_TERM_MARGIN * 2 - 1; } static inline grub_uint16_t @@ -391,16 +391,6 @@ grub_setcolorstate (grub_term_color_state state) 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) -{ - term->normal_color = normal_color; - term->highlight_color = highlight_color; -} - /* Turn on/off the cursor. */ static inline void grub_term_setcursor (struct grub_term_output *term, int on) @@ -460,14 +450,6 @@ grub_term_getcharwidth (struct grub_term_output *term, return 1; } -static inline void -grub_term_getcolor (struct grub_term_output *term, - grub_uint8_t *normal_color, grub_uint8_t *highlight_color) -{ - *normal_color = term->normal_color; - *highlight_color = term->highlight_color; -} - struct grub_term_autoload { struct grub_term_autoload *next; diff --git a/include/grub/unicode.h b/include/grub/unicode.h index 763e25e..eb5051a 100644 --- a/include/grub/unicode.h +++ b/include/grub/unicode.h @@ -139,6 +139,7 @@ struct grub_unicode_glyph grub_uint16_t variant:9; grub_uint8_t attributes:5; grub_size_t ncomb; + grub_size_t orig_pos; struct grub_unicode_combining { grub_uint32_t code; enum grub_comb_type type; @@ -186,6 +187,13 @@ enum GRUB_UNICODE_THAANA_SUKUN = 0x07b0, GRUB_UNICODE_ZWNJ = 0x200c, GRUB_UNICODE_ZWJ = 0x200d, + GRUB_UNICODE_LRM = 0x200e, + GRUB_UNICODE_RLM = 0x200f, + GRUB_UNICODE_LRE = 0x202a, + GRUB_UNICODE_RLE = 0x202b, + GRUB_UNICODE_PDF = 0x202c, + GRUB_UNICODE_LRO = 0x202d, + GRUB_UNICODE_RLO = 0x202e, GRUB_UNICODE_LEFTARROW = 0x2190, GRUB_UNICODE_UPARROW = 0x2191, GRUB_UNICODE_RIGHTARROW = 0x2192, @@ -222,13 +230,21 @@ extern struct grub_unicode_bidi_pair grub_unicode_bidi_pairs[]; /* Unicode mandates an arbitrary limit. */ #define GRUB_BIDI_MAX_EXPLICIT_LEVEL 61 +struct grub_term_pos +{ + unsigned valid:1; + unsigned x:15, y:16; +}; + 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); + grub_size_t start_width, grub_uint32_t codechar, + struct grub_term_pos *pos, + int primitive_wrap); enum grub_comb_type grub_unicode_get_comb_type (grub_uint32_t c); @@ -275,4 +291,8 @@ grub_unicode_mirror_code (grub_uint32_t in); grub_uint32_t grub_unicode_shape_code (grub_uint32_t in, grub_uint8_t attr); +const grub_uint32_t * +grub_unicode_get_comb_end (const grub_uint32_t *end, + const grub_uint32_t *cur); + #endif diff --git a/include/grub/usb.h b/include/grub/usb.h index 08d57b2..cefa8b6 100644 --- a/include/grub/usb.h +++ b/include/grub/usb.h @@ -50,8 +50,12 @@ typedef enum GRUB_USB_SPEED_HIGH } grub_usb_speed_t; +typedef int (*grub_usb_iterate_hook_t) (grub_usb_device_t dev, void *data); +typedef int (*grub_usb_controller_iterate_hook_t) (grub_usb_controller_t dev, + void *data); + /* Call HOOK with each device, until HOOK returns non-zero. */ -int grub_usb_iterate (int (*hook) (grub_usb_device_t dev)); +int grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data); grub_usb_err_t grub_usb_device_initialize (grub_usb_device_t dev); @@ -72,7 +76,8 @@ void grub_usb_controller_dev_register (grub_usb_controller_dev_t usb); void grub_usb_controller_dev_unregister (grub_usb_controller_dev_t usb); -int grub_usb_controller_iterate (int (*hook) (grub_usb_controller_t dev)); +int grub_usb_controller_iterate (grub_usb_controller_iterate_hook_t hook, + void *hook_data); grub_usb_err_t grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype, @@ -98,7 +103,7 @@ struct grub_usb_controller_dev /* The device name. */ const char *name; - int (*iterate) (int (*hook) (grub_usb_controller_t dev)); + int (*iterate) (grub_usb_controller_iterate_hook_t hook, void *hook_data); grub_usb_err_t (*setup_transfer) (grub_usb_controller_t dev, grub_usb_transfer_t transfer); diff --git a/include/grub/usbtrans.h b/include/grub/usbtrans.h index 5ee276d..5429007 100644 --- a/include/grub/usbtrans.h +++ b/include/grub/usbtrans.h @@ -19,6 +19,8 @@ #ifndef GRUB_USBTRANS_H #define GRUB_USBTRANS_H 1 +#define MAX_USB_TRANSFER_LEN 0x0800 + typedef enum { GRUB_USB_TRANSFER_TYPE_IN, |