merge mainline into net

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-15 20:51:35 +01:00
commit bd67ad0f70
335 changed files with 22289 additions and 5940 deletions

View file

@ -36,6 +36,8 @@
#define GRUB_UINT8_5_TRAILINGBITS 0x1f
#define GRUB_UINT8_6_TRAILINGBITS 0x3f
#define GRUB_MAX_UTF8_PER_UTF16 4
#define GRUB_UCS2_LIMIT 0x10000
#define GRUB_UTF16_UPPER_SURROGATE(code) \
(0xD800 + ((((code) - GRUB_UCS2_LIMIT) >> 12) & 0xfff))
@ -49,7 +51,7 @@ grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
/* Convert UTF-16 to UTF-8. */
static inline grub_uint8_t *
grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
grub_utf16_to_utf8 (grub_uint8_t *dest, const grub_uint16_t *src,
grub_size_t size)
{
grub_uint32_t code_high = 0;
@ -116,19 +118,52 @@ grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
return dest;
}
#define GRUB_MAX_UTF8_PER_LATIN1 2
/* Convert Latin1 to UTF-8. */
static inline grub_uint8_t *
grub_latin1_to_utf8 (grub_uint8_t *dest, const grub_uint8_t *src,
grub_size_t size)
{
while (size--)
{
if (!(*src & 0x80))
*dest++ = *src;
else
{
*dest++ = (*src >> 6) | 0xC0;
*dest++ = (*src & 0x3F) | 0x80;
}
src++;
}
return dest;
}
/* Convert UCS-4 to UTF-8. */
char *grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size);
char *grub_ucs4_to_utf8_alloc (const grub_uint32_t *src, grub_size_t size);
int
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);
/* Process one character from UTF8 sequence.
At beginning set *code = 0, *count = 0. Returns 0 on failure and
1 on success. *count holds the number of trailing bytes. */
int
grub_utf8_process (grub_uint8_t c, grub_uint32_t *code, int *count);
void
grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
grub_ucs4_to_utf8 (const 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);
/* Returns -2 if not enough space, -1 on invalid character. */
grub_ssize_t
grub_encode_utf8_character (grub_uint8_t *dest, grub_uint8_t *destend,
grub_uint32_t code);
#endif

View file

@ -26,6 +26,7 @@
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/err.h>
#include <grub/mm.h>
typedef enum
{
@ -191,11 +192,46 @@ grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher,
const unsigned char *key,
unsigned keylen);
void
grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher);
static inline void
grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher)
{
grub_free (cipher);
}
void
grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size);
static inline void
grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size)
{
const grub_uint8_t *in1ptr = in1, *in2ptr = in2;
grub_uint8_t *outptr = out;
while (size && (((grub_addr_t) in1ptr & (sizeof (grub_uint64_t) - 1))
|| ((grub_addr_t) in2ptr & (sizeof (grub_uint64_t) - 1))
|| ((grub_addr_t) outptr & (sizeof (grub_uint64_t) - 1))))
{
*outptr = *in1ptr ^ *in2ptr;
in1ptr++;
in2ptr++;
outptr++;
size--;
}
while (size >= sizeof (grub_uint64_t))
{
*(grub_uint64_t *) (void *) outptr
= (*(grub_uint64_t *) (void *) in1ptr
^ *(grub_uint64_t *) (void *) in2ptr);
in1ptr += sizeof (grub_uint64_t);
in2ptr += sizeof (grub_uint64_t);
outptr += sizeof (grub_uint64_t);
size -= sizeof (grub_uint64_t);
}
while (size)
{
*outptr = *in1ptr ^ *in2ptr;
in1ptr++;
in2ptr++;
outptr++;
size--;
}
}
gcry_err_code_t
grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher,
@ -203,7 +239,7 @@ grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher,
gcry_err_code_t
grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher,
void *out, void *in, grub_size_t size);
void *out, const void *in, grub_size_t size);
gcry_err_code_t
grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher,
void *out, void *in, grub_size_t size,
@ -251,11 +287,13 @@ extern gcry_md_spec_t _gcry_digest_spec_sha1;
extern gcry_md_spec_t _gcry_digest_spec_sha256;
extern gcry_md_spec_t _gcry_digest_spec_sha512;
extern gcry_md_spec_t _gcry_digest_spec_crc32;
extern gcry_cipher_spec_t _gcry_cipher_spec_aes;
#define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5)
#define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1)
#define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256)
#define GRUB_MD_SHA512 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha512)
#define GRUB_MD_CRC32 ((const gcry_md_spec_t *) &_gcry_digest_spec_crc32)
#define GRUB_CIPHER_AES ((const gcry_cipher_spec_t *) &_gcry_cipher_spec_aes)
/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant
of digest supplied by MD. Inputs are the password P of length PLEN,

View file

@ -46,7 +46,7 @@ grub_err_t grub_set_datetime (struct grub_datetime *datetime);
#endif
int grub_get_weekday (struct grub_datetime *datetime);
char *grub_get_weekday_name (struct grub_datetime *datetime);
const char *grub_get_weekday_name (struct grub_datetime *datetime);
void grub_unixtime2datetime (grub_int32_t nix,
struct grub_datetime *datetime);
@ -86,13 +86,13 @@ grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int32_t *nix)
are bissextile*/
/* Convenience: let's have 3 consecutive non-bissextile years
at the beginning of the epoch. So count from 1971 instead of 1970 */
ret = SECPERYEAR + SECPERDAY;
ret = 2 * SECPERYEAR + SECPERDAY;
/* Transform C divisions and modulos to mathematical ones */
y4 = (datetime->year - 1971) / 4;
if (datetime->year < 1971)
y4 = (datetime->year - 1972) / 4;
if (datetime->year < 1972)
y4--;
ay = datetime->year - 1971 - 4 * y4;
ay = datetime->year - 1972 - 4 * y4;
ret += y4 * SECPER4YEARS;
ret += ay * SECPERYEAR;

View file

@ -136,11 +136,12 @@ struct grub_dl
Elf_Sym *symtab;
void (*init) (struct grub_dl *mod);
void (*fini) (void);
#ifdef __ia64__
#if defined (__ia64__) || defined (__powerpc__)
void *got;
void *tramp;
#endif
void *base;
grub_size_t sz;
struct grub_dl *next;
};
typedef struct grub_dl *grub_dl_t;
@ -176,10 +177,21 @@ void
grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got);
#ifdef __ia64__
#define GRUB_ARCH_DL_TRAMP_ALIGN 16
#define GRUB_ARCH_DL_GOT_ALIGN 16
#if defined (__ia64__)
#define GRUB_ARCH_DL_TRAMP_ALIGN GRUB_IA64_DL_TRAMP_ALIGN
#define GRUB_ARCH_DL_GOT_ALIGN GRUB_IA64_DL_GOT_ALIGN
#define GRUB_ARCH_DL_TRAMP_SIZE GRUB_IA64_DL_TRAMP_SIZE
#define grub_arch_dl_get_tramp_got_size grub_ia64_dl_get_tramp_got_size
#else
void
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
grub_size_t *got);
#endif
#ifdef __powerpc__
#define GRUB_ARCH_DL_TRAMP_SIZE 16
#define GRUB_ARCH_DL_TRAMP_ALIGN 4
#define GRUB_ARCH_DL_GOT_ALIGN 4
#endif
#endif

View file

@ -371,7 +371,7 @@ struct grub_efi_memory_descriptor
grub_efi_virtual_address_t virtual_start;
grub_efi_uint64_t num_pages;
grub_efi_uint64_t attribute;
};
} __attribute__ ((packed));
typedef struct grub_efi_memory_descriptor grub_efi_memory_descriptor_t;
/* Device Path definitions. */
@ -416,7 +416,7 @@ struct grub_efi_pci_device_path
grub_efi_device_path_t header;
grub_efi_uint8_t function;
grub_efi_uint8_t device;
};
} __attribute__ ((packed));
typedef struct grub_efi_pci_device_path grub_efi_pci_device_path_t;
#define GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE 2
@ -425,7 +425,7 @@ struct grub_efi_pccard_device_path
{
grub_efi_device_path_t header;
grub_efi_uint8_t function;
};
} __attribute__ ((packed));
typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;
#define GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE 3
@ -433,10 +433,10 @@ typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;
struct grub_efi_memory_mapped_device_path
{
grub_efi_device_path_t header;
grub_efi_memory_type_t memory_type;
grub_efi_uint32_t memory_type;
grub_efi_physical_address_t start_address;
grub_efi_physical_address_t end_address;
};
} __attribute__ ((packed));
typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_path_t;
#define GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE 4
@ -446,7 +446,7 @@ struct grub_efi_vendor_device_path
grub_efi_device_path_t header;
grub_efi_guid_t vendor_guid;
grub_efi_uint8_t vendor_defined_data[0];
};
} __attribute__ ((packed));
typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;
#define GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE 5
@ -455,7 +455,7 @@ struct grub_efi_controller_device_path
{
grub_efi_device_path_t header;
grub_efi_uint32_t controller_number;
};
} __attribute__ ((packed));
typedef struct grub_efi_controller_device_path grub_efi_controller_device_path_t;
/* ACPI Device Path. */
@ -468,7 +468,7 @@ struct grub_efi_acpi_device_path
grub_efi_device_path_t header;
grub_efi_uint32_t hid;
grub_efi_uint32_t uid;
};
} __attribute__ ((packed));
typedef struct grub_efi_acpi_device_path grub_efi_acpi_device_path_t;
#define GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE 2
@ -479,8 +479,8 @@ struct grub_efi_expanded_acpi_device_path
grub_efi_uint32_t hid;
grub_efi_uint32_t uid;
grub_efi_uint32_t cid;
char hidstr[1];
};
char hidstr[0];
} __attribute__ ((packed));
typedef struct grub_efi_expanded_acpi_device_path grub_efi_expanded_acpi_device_path_t;
#define GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \
@ -503,7 +503,7 @@ struct grub_efi_atapi_device_path
grub_efi_uint8_t primary_secondary;
grub_efi_uint8_t slave_master;
grub_efi_uint16_t lun;
};
} __attribute__ ((packed));
typedef struct grub_efi_atapi_device_path grub_efi_atapi_device_path_t;
#define GRUB_EFI_SCSI_DEVICE_PATH_SUBTYPE 2
@ -513,7 +513,7 @@ struct grub_efi_scsi_device_path
grub_efi_device_path_t header;
grub_efi_uint16_t pun;
grub_efi_uint16_t lun;
};
} __attribute__ ((packed));
typedef struct grub_efi_scsi_device_path grub_efi_scsi_device_path_t;
#define GRUB_EFI_FIBRE_CHANNEL_DEVICE_PATH_SUBTYPE 3
@ -524,7 +524,7 @@ struct grub_efi_fibre_channel_device_path
grub_efi_uint32_t reserved;
grub_efi_uint64_t wwn;
grub_efi_uint64_t lun;
};
} __attribute__ ((packed));
typedef struct grub_efi_fibre_channel_device_path grub_efi_fibre_channel_device_path_t;
#define GRUB_EFI_1394_DEVICE_PATH_SUBTYPE 4
@ -534,7 +534,7 @@ struct grub_efi_1394_device_path
grub_efi_device_path_t header;
grub_efi_uint32_t reserved;
grub_efi_uint64_t guid;
};
} __attribute__ ((packed));
typedef struct grub_efi_1394_device_path grub_efi_1394_device_path_t;
#define GRUB_EFI_USB_DEVICE_PATH_SUBTYPE 5
@ -544,7 +544,7 @@ struct grub_efi_usb_device_path
grub_efi_device_path_t header;
grub_efi_uint8_t parent_port_number;
grub_efi_uint8_t interface;
};
} __attribute__ ((packed));
typedef struct grub_efi_usb_device_path grub_efi_usb_device_path_t;
#define GRUB_EFI_USB_CLASS_DEVICE_PATH_SUBTYPE 15
@ -557,7 +557,7 @@ struct grub_efi_usb_class_device_path
grub_efi_uint8_t device_class;
grub_efi_uint8_t device_subclass;
grub_efi_uint8_t device_protocol;
};
} __attribute__ ((packed));
typedef struct grub_efi_usb_class_device_path grub_efi_usb_class_device_path_t;
#define GRUB_EFI_I2O_DEVICE_PATH_SUBTYPE 6
@ -566,7 +566,7 @@ struct grub_efi_i2o_device_path
{
grub_efi_device_path_t header;
grub_efi_uint32_t tid;
};
} __attribute__ ((packed));
typedef struct grub_efi_i2o_device_path grub_efi_i2o_device_path_t;
#define GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE 11
@ -576,7 +576,7 @@ struct grub_efi_mac_address_device_path
grub_efi_device_path_t header;
grub_efi_mac_address_t mac_address;
grub_efi_uint8_t if_type;
};
} __attribute__ ((packed));
typedef struct grub_efi_mac_address_device_path grub_efi_mac_address_device_path_t;
#define GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE 12
@ -590,7 +590,7 @@ struct grub_efi_ipv4_device_path
grub_efi_uint16_t remote_port;
grub_efi_uint16_t protocol;
grub_efi_uint8_t static_ip_address;
};
} __attribute__ ((packed));
typedef struct grub_efi_ipv4_device_path grub_efi_ipv4_device_path_t;
#define GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE 13
@ -604,7 +604,7 @@ struct grub_efi_ipv6_device_path
grub_efi_uint16_t remote_port;
grub_efi_uint16_t protocol;
grub_efi_uint8_t static_ip_address;
};
} __attribute__ ((packed));
typedef struct grub_efi_ipv6_device_path grub_efi_ipv6_device_path_t;
#define GRUB_EFI_INFINIBAND_DEVICE_PATH_SUBTYPE 9
@ -617,7 +617,7 @@ struct grub_efi_infiniband_device_path
grub_efi_uint64_t remote_id;
grub_efi_uint64_t target_port_id;
grub_efi_uint64_t device_id;
};
} __attribute__ ((packed));
typedef struct grub_efi_infiniband_device_path grub_efi_infiniband_device_path_t;
#define GRUB_EFI_UART_DEVICE_PATH_SUBTYPE 14
@ -630,7 +630,7 @@ struct grub_efi_uart_device_path
grub_efi_uint8_t data_bits;
grub_efi_uint8_t parity;
grub_efi_uint8_t stop_bits;
};
} __attribute__ ((packed));
typedef struct grub_efi_uart_device_path grub_efi_uart_device_path_t;
#define GRUB_EFI_VENDOR_MESSAGING_DEVICE_PATH_SUBTYPE 10
@ -640,7 +640,7 @@ struct grub_efi_vendor_messaging_device_path
grub_efi_device_path_t header;
grub_efi_guid_t vendor_guid;
grub_efi_uint8_t vendor_defined_data[0];
};
} __attribute__ ((packed));
typedef struct grub_efi_vendor_messaging_device_path grub_efi_vendor_messaging_device_path_t;
/* Media Device Path. */
@ -657,7 +657,7 @@ struct grub_efi_hard_drive_device_path
grub_efi_uint8_t partition_signature[8];
grub_efi_uint8_t mbr_type;
grub_efi_uint8_t signature_type;
};
} __attribute__ ((packed));
typedef struct grub_efi_hard_drive_device_path grub_efi_hard_drive_device_path_t;
#define GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE 2
@ -668,7 +668,7 @@ struct grub_efi_cdrom_device_path
grub_efi_uint32_t boot_entry;
grub_efi_lba_t partition_start;
grub_efi_lba_t partition_size;
};
} __attribute__ ((packed));
typedef struct grub_efi_cdrom_device_path grub_efi_cdrom_device_path_t;
#define GRUB_EFI_VENDOR_MEDIA_DEVICE_PATH_SUBTYPE 3
@ -678,7 +678,7 @@ struct grub_efi_vendor_media_device_path
grub_efi_device_path_t header;
grub_efi_guid_t vendor_guid;
grub_efi_uint8_t vendor_defined_data[0];
};
} __attribute__ ((packed));
typedef struct grub_efi_vendor_media_device_path grub_efi_vendor_media_device_path_t;
#define GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE 4
@ -687,7 +687,7 @@ struct grub_efi_file_path_device_path
{
grub_efi_device_path_t header;
grub_efi_char16_t path_name[0];
};
} __attribute__ ((packed));
typedef struct grub_efi_file_path_device_path grub_efi_file_path_device_path_t;
#define GRUB_EFI_PROTOCOL_DEVICE_PATH_SUBTYPE 5
@ -696,7 +696,7 @@ struct grub_efi_protocol_device_path
{
grub_efi_device_path_t header;
grub_efi_guid_t guid;
};
} __attribute__ ((packed));
typedef struct grub_efi_protocol_device_path grub_efi_protocol_device_path_t;
#define GRUB_EFI_PIWG_DEVICE_PATH_SUBTYPE 6
@ -705,7 +705,7 @@ struct grub_efi_piwg_device_path
{
grub_efi_device_path_t header;
grub_efi_guid_t guid __attribute__ ((packed));
};
} __attribute__ ((packed));
typedef struct grub_efi_piwg_device_path grub_efi_piwg_device_path_t;
@ -720,7 +720,7 @@ struct grub_efi_bios_device_path
grub_efi_uint16_t device_type;
grub_efi_uint16_t status_flags;
char description[0];
};
} __attribute__ ((packed));
typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
struct grub_efi_open_protocol_information_entry

View file

@ -70,6 +70,8 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
char **device,
char **path);
grub_addr_t grub_efi_modules_addr (void);
void grub_efi_mm_init (void);
void grub_efi_mm_fini (void);
void grub_efi_init (void);

View file

@ -24,15 +24,8 @@
#define GRUB_MMAP_REGISTER_BY_FIRMWARE 1
grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
grub_uint64_t,
grub_uint32_t));
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
int type, int handle);
grub_err_t grub_machine_mmap_unregister (int handle);
grub_uint64_t grub_mmap_get_post64 (void);
grub_uint64_t grub_mmap_get_upper (void);
grub_uint64_t grub_mmap_get_lower (void);
#endif /* ! GRUB_MEMORY_MACHINE_HEADER */

View file

@ -114,9 +114,9 @@ extern grub_efi_system_table64_t *grub_efiemu_system_table64;
: (grub_efiemu_system_table32->x \
= (y)))
#define GRUB_EFIEMU_SYSTEM_TABLE_PTR(x) ((grub_efiemu_sizeof_uintn_t () == 8)\
? UINT_TO_PTR \
? (void *) (grub_addr_t) \
(grub_efiemu_system_table64->x) \
: UINT_TO_PTR \
: (void *) (grub_addr_t) \
(grub_efiemu_system_table32->x))
#define GRUB_EFIEMU_SYSTEM_TABLE_VAR(x) ((grub_efiemu_sizeof_uintn_t () == 8) \
? (void *) \
@ -200,15 +200,9 @@ grub_efiemu_register_configuration_table (grub_efi_guid_t guid,
int grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_efi_memory_type_t type);
void *grub_efiemu_mm_obtain_request (int handle);
int grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
grub_efi_memory_descriptor_t *memory_map,
grub_efi_uintn_t *map_key,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
grub_err_t grub_efiemu_mm_unload (void);
grub_err_t grub_efiemu_mm_do_alloc (void);
grub_err_t grub_efiemu_mm_init (void);
void *grub_efiemu_mm_obtain_request (int handle);
void grub_efiemu_mm_return_request (int handle);
grub_efi_memory_type_t grub_efiemu_mm_get_type (int handle);
@ -271,8 +265,7 @@ grub_err_t grub_efiemu_write_value (void * addr, grub_uint32_t value,
int minus_handle, int ptv_needed, int size);
grub_err_t grub_efiemu_write_sym_markers (void);
grub_err_t grub_efiemu_pnvram (void);
grub_err_t grub_efiemu_prepare (void);
char *grub_efiemu_get_default_core_name (void);
const char *grub_efiemu_get_default_core_name (void);
void grub_efiemu_pnvram_cmd_unregister (void);
grub_err_t grub_efiemu_autocore (void);
grub_err_t grub_efiemu_crc32 (void);

View file

@ -60,7 +60,7 @@ grub_util_device_is_mapped (const char *dev);
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));
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((warn_unused_result));
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...);
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...);

View file

@ -26,8 +26,8 @@
struct grub_env_var;
typedef char *(*grub_env_read_hook_t) (struct grub_env_var *var,
const char *val);
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
const char *val);
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
const char *val);
@ -43,7 +43,7 @@ struct grub_env_var
};
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
char *EXPORT_FUNC(grub_env_get) (const char *name);
const char *EXPORT_FUNC(grub_env_get) (const char *name);
void EXPORT_FUNC(grub_env_unset) (const char *name);
void EXPORT_FUNC(grub_env_iterate) (int (*func) (struct grub_env_var *var));
struct grub_env_var *EXPORT_FUNC(grub_env_find) (const char *name);

View file

@ -31,8 +31,17 @@ struct grub_video_fbblit_info
grub_uint8_t *data;
};
grub_uint8_t *grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
unsigned int x, unsigned int y);
void *grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
unsigned int x, unsigned int y);
/* Advance pointer by VAL bytes. If there is no unaligned access available,
VAL has to be divisible by size of pointed type.
*/
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
#define GRUB_VIDEO_FB_ADVANCE_POINTER(ptr, val) ((ptr) = (typeof (ptr)) ((char *) ptr + val))
#else
#define GRUB_VIDEO_FB_ADVANCE_POINTER(ptr, val) ((ptr) += (val) / sizeof (*(ptr)))
#endif
grub_video_color_t get_pixel (struct grub_video_fbblit_info *source,
unsigned int x, unsigned int y);

View file

@ -56,9 +56,10 @@ typedef enum grub_file_filter_id
{
GRUB_FILE_FILTER_GZIO,
GRUB_FILE_FILTER_XZIO,
GRUB_FILE_FILTER_LZOPIO,
GRUB_FILE_FILTER_MAX,
GRUB_FILE_FILTER_COMPRESSION_FIRST = GRUB_FILE_FILTER_GZIO,
GRUB_FILE_FILTER_COMPRESSION_LAST = GRUB_FILE_FILTER_XZIO,
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);

View file

@ -25,6 +25,10 @@
#include <grub/types.h>
#include <grub/list.h>
/* For embedding types. */
#ifdef GRUB_UTIL
#include <grub/partition.h>
#endif
/* Forward declaration is required, because of mutual reference. */
struct grub_file;
@ -74,6 +78,11 @@ struct grub_fs
grub_err_t (*mtime) (grub_device_t device, grub_int32_t *timebuf);
#ifdef GRUB_UTIL
/* Determine sectors available for embedding. */
grub_err_t (*embed) (grub_device_t device, unsigned int *nsectors,
grub_embed_type_t embed_type,
grub_disk_addr_t **sectors);
/* Whether this filesystem reserves first sector for DOS-style boot. */
int reserved_first_sector;
#endif

View file

@ -94,8 +94,8 @@ grub_err_t grub_netbsd_load_elf_meta64 (struct grub_relocator *relocator,
grub_addr_t *kern_end);
grub_err_t grub_bsd_add_meta (grub_uint32_t type,
void *data, grub_uint32_t len);
grub_err_t grub_freebsd_add_meta_module (char *filename, char *type,
const void *data, grub_uint32_t len);
grub_err_t grub_freebsd_add_meta_module (const char *filename, const char *type,
int argc, char **argv,
grub_addr_t addr, grub_uint32_t size);

View file

@ -92,7 +92,7 @@ struct grub_netbsd_btinfo_bootwedge {
grub_disk_addr_t matchblk;
grub_uint64_t matchnblks;
grub_uint8_t matchhash[16]; /* MD5 hash */
} __packed;
} __attribute__ ((packed));
struct grub_netbsd_btinfo_symtab
{

View file

@ -26,16 +26,6 @@
#include <grub/term.h>
#include <grub/i386/vga_common.h>
/* These are global to share code between C and asm. */
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);

View file

@ -29,20 +29,10 @@
#include <grub/symbol.h>
#include <grub/types.h>
/* The size of kernel image. */
extern grub_int32_t grub_kernel_image_size;
/* The total size of module images following the kernel. */
extern grub_int32_t grub_total_module_size;
/* The DOS partition number of the installed partition. */
extern grub_int32_t grub_install_dos_part;
/* The BSD partition number of the installed partition. */
extern grub_int32_t grub_install_bsd_part;
/* The boot BIOS drive number. */
extern grub_uint8_t EXPORT_VAR(grub_boot_drive);
extern grub_uint32_t EXPORT_VAR(grub_boot_device);
extern void (*EXPORT_VAR(grub_pc_net_config)) (char **device, char **path);

View file

@ -1,27 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,2004,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_LOADER_MACHINE_HEADER
#define GRUB_LOADER_MACHINE_HEADER 1
#include <grub/symbol.h>
/* This is an asm part of the chainloader. */
void EXPORT_FUNC(grub_chainloader_real_boot) (int drive, void *part_addr) __attribute__ ((noreturn));
#endif /* ! GRUB_LOADER_MACHINE_HEADER */

View file

@ -28,12 +28,6 @@
extern grub_addr_t grub_core_entry_addr;
/* The size of kernel image. */
extern grub_int32_t grub_kernel_image_size;
/* The total size of module images following the kernel. */
extern grub_int32_t grub_total_module_size;
void grub_qemu_init_cirrus (void);
#endif /* ! ASM_FILE */

View file

@ -33,10 +33,4 @@
#define GRUB_MEMORY_MACHINE_UPPER_START 0x100000 /* 1 MiB */
#define GRUB_MEMORY_MACHINE_LOWER_SIZE GRUB_MEMORY_MACHINE_UPPER_START
#ifndef ASM_FILE
void grub_machine_mmap_init (void);
#endif
#endif /* ! _GRUB_MEMORY_MACHINE_HEADER */

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2007 Free Software Foundation, Inc.
* Copyright (C) 2011 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,12 +16,13 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_BOOT_HEADER
#define GRUB_BOOT_HEADER 1
#ifndef GRUB_REBOOT_H
#define GRUB_REBOOT_H 1
#define GRUB_BOOT_VERSION_MAJOR 4
#define GRUB_BOOT_VERSION_MINOR 0
#define GRUB_BOOT_VERSION ((GRUB_BOOT_VERSION_MINOR << 8) \
| GRUB_BOOT_VERSION_MAJOR)
#ifndef ASM_FILE
#endif /* ! GRUB_BOOT_HEADER */
extern grub_uint8_t grub_reboot_end[], grub_reboot_start[];
#endif
#endif

View file

@ -48,6 +48,8 @@ struct grub_relocator16_state
grub_uint16_t ip;
grub_uint32_t ebx;
grub_uint32_t edx;
grub_uint32_t esi;
int a20;
};
struct grub_relocator64_state

View file

@ -28,4 +28,6 @@
/* i386 is little-endian. */
#undef GRUB_TARGET_WORDS_BIGENDIAN
#define GRUB_HAVE_UNALIGNED_ACCESS 1
#endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -1,34 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,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
* 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_MACHINE_KERNEL_HEADER
#define GRUB_MACHINE_KERNEL_HEADER 1
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_MACHINE_PREFIX 0x8
/* End of the data section. */
#define GRUB_KERNEL_MACHINE_DATA_END 0x50
#ifndef ASM_FILE
/* The prefix which points to the directory where GRUB modules and its
configuration file are located. */
extern char grub_prefix[];
#endif
#endif /* ! GRUB_MACHINE_KERNEL_HEADER */

View file

@ -125,7 +125,7 @@ extern void EXPORT_FUNC(grub_ieee1275_set_flag) (enum grub_ieee1275_flag flag);
void EXPORT_FUNC(grub_ieee1275_init) (void);
int EXPORT_FUNC(grub_ieee1275_finddevice) (char *name,
int EXPORT_FUNC(grub_ieee1275_finddevice) (const char *name,
grub_ieee1275_phandle_t *phandlep);
int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t phandle,
const char *property, void *buf,
@ -173,7 +173,8 @@ int EXPORT_FUNC(grub_ieee1275_claim) (grub_addr_t addr, grub_size_t size,
unsigned int align, grub_addr_t *result);
int EXPORT_FUNC(grub_ieee1275_release) (grub_addr_t addr, grub_size_t size);
int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle,
const char *propname, void *buf,
const char *propname,
const void *buf,
grub_size_t size,
grub_ssize_t *actual);
int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
@ -183,10 +184,8 @@ int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
int EXPORT_FUNC(grub_devalias_iterate)
(int (*hook) (struct grub_ieee1275_devalias *alias));
int EXPORT_FUNC(grub_children_iterate) (char *devpath,
int EXPORT_FUNC(grub_children_iterate) (const char *devpath,
int (*hook) (struct grub_ieee1275_devalias *alias));
grub_err_t EXPORT_FUNC(grub_machine_mmap_iterate)
(int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t));
int EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
int

View file

@ -26,14 +26,15 @@ enum
{
OBJ_TYPE_ELF,
OBJ_TYPE_MEMDISK,
OBJ_TYPE_CONFIG
OBJ_TYPE_CONFIG,
OBJ_TYPE_PREFIX
};
/* The module header. */
struct grub_module_header
{
/* The type of object. */
grub_uint8_t type;
grub_uint32_t type;
/* The size of object (including this header). */
grub_uint32_t size;
};
@ -68,14 +69,20 @@ struct grub_module_info64
#define grub_module_info grub_module_info32
#endif
extern grub_addr_t grub_arch_modules_addr (void);
extern grub_addr_t EXPORT_VAR (grub_modbase);
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
#define FOR_MODULES(var) for (\
var = grub_modbase ? (struct grub_module_header *) \
(grub_modbase + (((struct grub_module_info *) grub_modbase)->offset)) : 0;\
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_addr_t grub_modules_get_end (void);
/* The start point of the C code. */
void grub_main (void);
void grub_main (void) __attribute__ ((noreturn));
/* The machine-specific initialization. This must initialize memory. */
void grub_machine_init (void);
@ -92,9 +99,4 @@ void grub_register_exported_symbols (void);
extern void (*EXPORT_VAR(grub_net_poll_cards_idle)) (void);
#if ! defined (ASM_FILE)
extern char grub_prefix[];
#endif
#endif /* ! GRUB_KERNEL_HEADER */

View file

@ -53,8 +53,8 @@ struct grub_arg_option
const char *longarg;
int shortarg;
int flags;
char *doc;
char *arg;
const char *doc;
const char *arg;
grub_arg_type_t type;
};

View file

@ -63,6 +63,12 @@ void EXPORT_FUNC (__divsi3) (void);
# ifdef HAVE___MODSI3
void EXPORT_FUNC (__modsi3) (void);
# endif
# ifdef HAVE___CTZDI2
void EXPORT_FUNC (__ctzdi2) (void);
# endif
# ifdef HAVE___CTZSI2
void EXPORT_FUNC (__ctzsi2) (void);
# endif
#endif
# ifdef HAVE___IA64_TRAMPOLINE

View file

@ -54,11 +54,11 @@ grub_bad_type_cast_real (int line, const char *file)
#define GRUB_AS_LIST(ptr) \
(GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \
(grub_list_t) ptr : grub_bad_type_cast ())
(grub_list_t) ptr : (grub_list_t) grub_bad_type_cast ())
#define GRUB_AS_LIST_P(pptr) \
(GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \
(grub_list_t *) (void *) pptr : grub_bad_type_cast ())
(grub_list_t *) (void *) pptr : (grub_list_t *) grub_bad_type_cast ())
struct grub_named_list
{
@ -73,12 +73,12 @@ void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head,
#define GRUB_AS_NAMED_LIST(ptr) \
((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \
GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
(grub_named_list_t) ptr : grub_bad_type_cast ())
(grub_named_list_t) ptr : (grub_named_list_t) grub_bad_type_cast ())
#define GRUB_AS_NAMED_LIST_P(pptr) \
((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \
GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
(grub_named_list_t *) (void *) pptr : grub_bad_type_cast ())
(grub_named_list_t *) (void *) pptr : (grub_named_list_t *) grub_bad_type_cast ())
#define GRUB_PRIO_LIST_PRIO_MASK 0xff
#define GRUB_PRIO_LIST_FLAG_ACTIVE 0x100
@ -106,12 +106,14 @@ grub_prio_list_remove (grub_prio_list_t *head, grub_prio_list_t item)
((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
(grub_prio_list_t) ptr : grub_bad_type_cast ())
(grub_prio_list_t) ptr \
: (grub_prio_list_t) grub_bad_type_cast ())
#define GRUB_AS_PRIO_LIST_P(pptr) \
((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio))? \
(grub_prio_list_t *) (void *) pptr : grub_bad_type_cast ())
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio)) ? \
(grub_prio_list_t *) (void *) pptr \
: (grub_prio_list_t *) grub_bad_type_cast ())
#endif /* ! GRUB_LIST_HEADER */

View file

@ -56,11 +56,13 @@ typedef enum {
} grub_loader_preboot_hook_prio_t;
/* Register a preboot hook. */
void *EXPORT_FUNC(grub_loader_register_preboot_hook) (grub_err_t (*preboot_func) (int noret),
grub_err_t (*preboot_rest_func) (void),
grub_loader_preboot_hook_prio_t prio);
struct grub_preboot;
struct grub_preboot *EXPORT_FUNC(grub_loader_register_preboot_hook) (grub_err_t (*preboot_func) (int noret),
grub_err_t (*preboot_rest_func) (void),
grub_loader_preboot_hook_prio_t prio);
/* Unregister given preboot hook. */
void EXPORT_FUNC (grub_loader_unregister_preboot_hook) (void *hnd);
void EXPORT_FUNC (grub_loader_unregister_preboot_hook) (struct grub_preboot *hnd);
#endif /* ! GRUB_LOADER_HEADER */

View file

@ -38,7 +38,7 @@ struct grub_lvm_pv {
char id[GRUB_LVM_ID_STRLEN+1];
char *name;
grub_disk_t disk;
int start; /* Sector number where the data area starts. */
grub_disk_addr_t start; /* Sector number where the data area starts. */
struct grub_lvm_pv *next;
};

View file

@ -21,10 +21,4 @@
#include <grub/symbol.h>
#ifndef ASM_FILE
void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
#endif
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */

View file

@ -19,6 +19,10 @@
#ifndef GRUB_EC_MACHINE_HEADER
#define GRUB_EC_MACHINE_HEADER 1
#include <grub/types.h>
#include <grub/cpu/io.h>
#include <grub/pci.h>
#define GRUB_MACHINE_EC_MAGIC_PORT1 0x381
#define GRUB_MACHINE_EC_MAGIC_PORT2 0x382
#define GRUB_MACHINE_EC_DATA_PORT 0x383

View file

@ -23,8 +23,6 @@
#ifndef ASM_FILE
void EXPORT_FUNC (grub_reboot) (void);
void EXPORT_FUNC (grub_halt) (void);
void grub_qemu_init_cirrus (void);
#endif

View file

@ -49,14 +49,19 @@
#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args)
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
char *EXPORT_FUNC(grub_stpcpy) (char *dest, const char *src);
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
static inline void *
grub_memcpy (void *dest, const void *src, grub_size_t n)
{
return grub_memmove (dest, src, n);
}
static inline char *
grub_strcat (char *dest, const char *src)
{
@ -82,7 +87,7 @@ grub_strncat (char *dest, const char *src, int c)
while (*p)
p++;
while ((*p = *src) != '\0' && c--)
while (c-- && (*p = *src) != '\0')
{
p++;
src++;
@ -108,7 +113,53 @@ int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
char *EXPORT_FUNC(grub_strstr) (const char *haystack, const char *needle);
/* Copied from gnulib.
Written by Bruno Haible <bruno@clisp.org>, 2005. */
static inline char *
grub_strstr (const char *haystack, const char *needle)
{
/* Be careful not to look at the entire extent of haystack or needle
until needed. This is useful because of these two cases:
- haystack may be very long, and a match of needle found early,
- needle may be very long, and not even a short initial segment of
needle may be found in haystack. */
if (*needle != '\0')
{
/* Speed up the following searches of needle by caching its first
character. */
char b = *needle++;
for (;; haystack++)
{
if (*haystack == '\0')
/* No match. */
return 0;
if (*haystack == b)
/* The first character matches. */
{
const char *rhaystack = haystack + 1;
const char *rneedle = needle;
for (;; rhaystack++, rneedle++)
{
if (*rneedle == '\0')
/* Found a match. */
return (char *) haystack;
if (*rhaystack == '\0')
/* No match. */
return 0;
if (*rhaystack != *rneedle)
/* Nothing in this round. */
break;
}
}
}
}
else
return (char *) haystack;
}
int EXPORT_FUNC(grub_isspace) (int c);
int EXPORT_FUNC(grub_isprint) (int c);
@ -124,6 +175,18 @@ grub_isalpha (int c)
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
static inline int
grub_islower (int c)
{
return (c >= 'a' && c <= 'z');
}
static inline int
grub_isupper (int c)
{
return (c >= 'A' && c <= 'Z');
}
static inline int
grub_isgraph (int c)
{
@ -136,6 +199,12 @@ grub_isdigit (int c)
return (c >= '0' && c <= '9');
}
static inline int
grub_isxdigit (int c)
{
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
static inline int
grub_isalnum (int c)
{
@ -193,27 +262,6 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
}
/* Replace all `ch' characters of `input' with `with' and copy the
result into `output'; return EOS address of `output'. */
static inline char *
grub_strchrsub (char *output, const char *input, char ch, const char *with)
{
grub_size_t grub_strlen (const char *s);
while (*input)
{
if (*input == ch)
{
grub_strcpy (output, with);
output += grub_strlen (with);
input++;
continue;
}
*output++ = *input++;
}
*output = '\0';
return output;
}
unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base);
@ -260,6 +308,26 @@ grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) __attribute__ ((warn_unused
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)));
/* Replace all `ch' characters of `input' with `with' and copy the
result into `output'; return EOS address of `output'. */
static inline char *
grub_strchrsub (char *output, const char *input, char ch, const char *with)
{
while (*input)
{
if (*input == ch)
{
grub_strcpy (output, with);
output += grub_strlen (with);
input++;
continue;
}
*output++ = *input++;
}
*output = '\0';
return output;
}
extern void (*EXPORT_VAR (grub_xputs)) (const char *str);
static inline int
@ -351,12 +419,18 @@ grub_div_roundup (unsigned int x, unsigned int y)
}
/* Reboot the machine. */
void EXPORT_FUNC (grub_reboot) (void) __attribute__ ((noreturn));
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS)
void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn));
#else
void grub_reboot (void) __attribute__ ((noreturn));
#endif
#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 grub_halt (int no_apm) __attribute__ ((noreturn));
#elif defined (__mips__)
void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
#else
void grub_halt (void) __attribute__ ((noreturn));
#endif

View file

@ -72,4 +72,21 @@ void *EXPORT_FUNC(grub_debug_memalign) (const char *file, int line,
grub_size_t align, grub_size_t size);
#endif /* MM_DEBUG && ! GRUB_UTIL */
#include <grub/err.h>
static inline grub_err_t
grub_extend_alloc (grub_size_t sz, grub_size_t *allocated, void **ptr)
{
void *n;
if (sz < *allocated)
return GRUB_ERR_NONE;
*allocated = 2 * sz;
n = grub_realloc (*ptr, *allocated);
if (!n)
return grub_errno;
*ptr = n;
return GRUB_ERR_NONE;
}
#endif /* ! GRUB_MM_H */

View file

@ -42,9 +42,11 @@
#define GRUB_PC_PARTITION_TYPE_FAT32_LBA 0xc
#define GRUB_PC_PARTITION_TYPE_FAT16_LBA 0xe
#define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED 0xf
#define GRUB_PC_PARTITION_TYPE_PLAN9 0x39
#define GRUB_PC_PARTITION_TYPE_EZD 0x55
#define GRUB_PC_PARTITION_TYPE_MINIX 0x80
#define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81
#define GRUB_PC_PARTITION_TYPE_LINUX_SWAP 0x82
#define GRUB_PC_PARTITION_TYPE_EXT2FS 0x83
#define GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED 0x85
#define GRUB_PC_PARTITION_TYPE_VSTAFS 0x9e

View file

@ -72,7 +72,7 @@ struct grub_net_card;
struct grub_net_card_driver
{
struct grub_net_card_driver *next;
char *name;
const char *name;
grub_err_t (*open) (const struct grub_net_card *dev);
void (*close) (const struct grub_net_card *dev);
grub_err_t (*send) (const struct grub_net_card *dev,
@ -111,7 +111,7 @@ struct grub_net_link_layer_entry;
struct grub_net_card
{
struct grub_net_card *next;
char *name;
const char *name;
struct grub_net_card_driver *driver;
grub_net_link_level_address_t default_address;
grub_net_card_flags_t flags;
@ -220,7 +220,7 @@ typedef struct grub_net_socket *grub_net_socket_t;
struct grub_net_app_protocol
{
struct grub_net_app_protocol *next;
char *name;
const char *name;
grub_err_t (*dir) (grub_device_t device, const char *path,
int (*hook) (const char *filename,
const struct grub_dirhook_info *info));
@ -301,6 +301,7 @@ grub_net_add_addr (const char *name,
grub_net_interface_flags_t flags);
extern struct grub_net_network_level_interface *grub_net_network_level_interfaces;
#define FOR_NET_NETWORK_LEVEL_INTERFACES(var) for (var = grub_net_network_level_interfaces; var; var = var->next)
extern grub_net_app_level_t grub_net_app_level_list;

View file

@ -20,79 +20,87 @@
#ifndef GRUB_NTFS_H
#define GRUB_NTFS_H 1
#define FILE_MFT 0
#define FILE_MFTMIRR 1
#define FILE_LOGFILE 2
#define FILE_VOLUME 3
#define FILE_ATTRDEF 4
#define FILE_ROOT 5
#define FILE_BITMAP 6
#define FILE_BOOT 7
#define FILE_BADCLUS 8
#define FILE_QUOTA 9
#define FILE_UPCASE 10
enum
{
GRUB_NTFS_FILE_MFT = 0,
GRUB_NTFS_FILE_MFTMIRR = 1,
GRUB_NTFS_FILE_LOGFILE = 2,
GRUB_NTFS_FILE_VOLUME = 3,
GRUB_NTFS_FILE_ATTRDEF = 4,
GRUB_NTFS_FILE_ROOT = 5,
GRUB_NTFS_FILE_BITMAP = 6,
GRUB_NTFS_FILE_BOOT = 7,
GRUB_NTFS_FILE_BADCLUS = 8,
GRUB_NTFS_FILE_QUOTA = 9,
GRUB_NTFS_FILE_UPCASE = 10,
};
#define AT_STANDARD_INFORMATION 0x10
#define AT_ATTRIBUTE_LIST 0x20
#define AT_FILENAME 0x30
#define AT_OBJECT_ID 0x40
#define AT_SECURITY_DESCRIPTOR 0x50
#define AT_VOLUME_NAME 0x60
#define AT_VOLUME_INFORMATION 0x70
#define AT_DATA 0x80
#define AT_INDEX_ROOT 0x90
#define AT_INDEX_ALLOCATION 0xA0
#define AT_BITMAP 0xB0
#define AT_SYMLINK 0xC0
#define AT_EA_INFORMATION 0xD0
#define AT_EA 0xE0
enum
{
GRUB_NTFS_AT_STANDARD_INFORMATION = 0x10,
GRUB_NTFS_AT_ATTRIBUTE_LIST = 0x20,
GRUB_NTFS_AT_FILENAME = 0x30,
GRUB_NTFS_AT_OBJECT_ID = 0x40,
GRUB_NTFS_AT_SECURITY_DESCRIPTOR = 0x50,
GRUB_NTFS_AT_VOLUME_NAME = 0x60,
GRUB_NTFS_AT_VOLUME_INFORMATION = 0x70,
GRUB_NTFS_AT_DATA = 0x80,
GRUB_NTFS_AT_INDEX_ROOT = 0x90,
GRUB_NTFS_AT_INDEX_ALLOCATION = 0xA0,
GRUB_NTFS_AT_BITMAP = 0xB0,
GRUB_NTFS_AT_SYMLINK = 0xC0,
GRUB_NTFS_AT_EA_INFORMATION = 0xD0,
GRUB_NTFS_AT_EA = 0xE0,
};
#define ATTR_READ_ONLY 0x1
#define ATTR_HIDDEN 0x2
#define ATTR_SYSTEM 0x4
#define ATTR_ARCHIVE 0x20
#define ATTR_DEVICE 0x40
#define ATTR_NORMAL 0x80
#define ATTR_TEMPORARY 0x100
#define ATTR_SPARSE 0x200
#define ATTR_REPARSE 0x400
#define ATTR_COMPRESSED 0x800
#define ATTR_OFFLINE 0x1000
#define ATTR_NOT_INDEXED 0x2000
#define ATTR_ENCRYPTED 0x4000
#define ATTR_DIRECTORY 0x10000000
#define ATTR_INDEX_VIEW 0x20000000
enum
{
GRUB_NTFS_ATTR_READ_ONLY = 0x1,
GRUB_NTFS_ATTR_HIDDEN = 0x2,
GRUB_NTFS_ATTR_SYSTEM = 0x4,
GRUB_NTFS_ATTR_ARCHIVE = 0x20,
GRUB_NTFS_ATTR_DEVICE = 0x40,
GRUB_NTFS_ATTR_NORMAL = 0x80,
GRUB_NTFS_ATTR_TEMPORARY = 0x100,
GRUB_NTFS_ATTR_SPARSE = 0x200,
GRUB_NTFS_ATTR_REPARSE = 0x400,
GRUB_NTFS_ATTR_COMPRESSED = 0x800,
GRUB_NTFS_ATTR_OFFLINE = 0x1000,
GRUB_NTFS_ATTR_NOT_INDEXED = 0x2000,
GRUB_NTFS_ATTR_ENCRYPTED = 0x4000,
GRUB_NTFS_ATTR_DIRECTORY = 0x10000000,
GRUB_NTFS_ATTR_INDEX_VIEW = 0x20000000
};
#define FLAG_COMPRESSED 1
#define FLAG_ENCRYPTED 0x4000
#define FLAG_SPARSE 0x8000
enum
{
GRUB_NTFS_FLAG_COMPRESSED = 1,
GRUB_NTFS_FLAG_ENCRYPTED = 0x4000,
GRUB_NTFS_FLAG_SPARSE = 0x8000
};
#define BLK_SHR GRUB_DISK_SECTOR_BITS
#define GRUB_NTFS_BLK_SHR GRUB_DISK_SECTOR_BITS
#define MAX_MFT (1024 >> BLK_SHR)
#define MAX_IDX (16384 >> BLK_SHR)
#define GRUB_NTFS_MAX_MFT (1024 >> GRUB_NTFS_BLK_SHR)
#define GRUB_NTFS_MAX_IDX (16384 >> GRUB_NTFS_BLK_SHR)
#define COM_LEN 4096
#define COM_LOG_LEN 12
#define COM_SEC (COM_LEN >> BLK_SHR)
#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 AF_ALST 1
#define AF_MMFT 2
#define AF_GPOS 4
enum
{
GRUB_NTFS_AF_ALST = 1,
GRUB_NTFS_AF_MMFT = 2,
GRUB_NTFS_AF_GPOS = 4,
};
#define RF_COMP 1
#define RF_CBLK 2
#define RF_BLNK 4
#define valueat(buf,ofs,type) *((type*)(((char*)buf)+ofs))
#define u16at(buf,ofs) grub_le_to_cpu16(valueat(buf,ofs,grub_uint16_t))
#define u32at(buf,ofs) grub_le_to_cpu32(valueat(buf,ofs,grub_uint32_t))
#define u64at(buf,ofs) grub_le_to_cpu64(valueat(buf,ofs,grub_uint64_t))
#define v16at(buf,ofs) valueat(buf,ofs,grub_uint16_t)
#define v32at(buf,ofs) valueat(buf,ofs,grub_uint32_t)
#define v64at(buf,ofs) valueat(buf,ofs,grub_uint64_t)
enum
{
GRUB_NTFS_RF_COMP = 1,
GRUB_NTFS_RF_CBLK = 2,
GRUB_NTFS_RF_BLNK = 4
};
struct grub_ntfs_bpb
{
@ -120,8 +128,6 @@ struct grub_ntfs_bpb
grub_uint32_t checksum;
} __attribute__ ((packed));
#define grub_ntfs_file grub_fshelp_node
struct grub_ntfs_attr
{
int flags;
@ -132,7 +138,7 @@ struct grub_ntfs_attr
struct grub_ntfs_file *mft;
};
struct grub_fshelp_node
struct grub_ntfs_file
{
struct grub_ntfs_data *data;
char *buf;
@ -174,13 +180,15 @@ struct grub_ntfs_rlst
struct grub_ntfs_comp comp;
};
typedef grub_err_t (*ntfscomp_func_t) (struct grub_ntfs_attr * at, char *dest,
grub_uint32_t ofs, grub_uint32_t len,
struct grub_ntfs_rlst * ctx,
grub_uint32_t vcn);
typedef grub_err_t (*grub_ntfscomp_func_t) (struct grub_ntfs_attr * at,
char *dest,
grub_uint32_t ofs,
grub_uint32_t len,
struct grub_ntfs_rlst * ctx,
grub_uint32_t vcn);
extern ntfscomp_func_t EXPORT_VAR (grub_ntfscomp_func);
extern grub_ntfscomp_func_t grub_ntfscomp_func;
grub_err_t EXPORT_FUNC(grub_ntfs_read_run_list) (struct grub_ntfs_rlst *ctx);
grub_err_t grub_ntfs_read_run_list (struct grub_ntfs_rlst *ctx);
#endif /* ! GRUB_NTFS_H */

View file

@ -19,39 +19,21 @@
#ifndef OFFSETS_HEADER
#define OFFSETS_HEADER 1
/* The offset of GRUB_TOTAL_MODULE_SIZE. */
#define GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE 0x8
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
#define GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE 0xc
/* The offset of GRUB_COMPRESSED_SIZE. */
#define GRUB_DECOMPRESSOR_I386_PC_COMPRESSED_SIZE 0x08
/* The offset of GRUB_COMPRESSED_SIZE. */
#define GRUB_KERNEL_I386_PC_COMPRESSED_SIZE 0x10
/* The offset of GRUB_INSTALL_DOS_PART. */
#define GRUB_KERNEL_I386_PC_INSTALL_DOS_PART 0x14
/* The offset of GRUB_INSTALL_BSD_PART. */
#define GRUB_KERNEL_I386_PC_INSTALL_BSD_PART 0x18
#define GRUB_DECOMPRESSOR_I386_PC_UNCOMPRESSED_SIZE 0x0c
/* Offset of reed_solomon_redundancy. */
#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x1c
#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x10
/* The size of the first region which won't be compressed. */
#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xcd0
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x730
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE
/* End of the data section. */
#define GRUB_KERNEL_I386_PC_PREFIX_END (GRUB_KERNEL_I386_PC_PREFIX + 0x40)
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x7e0
/* The segment where the kernel is loaded. */
#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800
#define GRUB_KERNEL_I386_PC_LINK_ADDR 0x8200
#define GRUB_KERNEL_I386_PC_LINK_ADDR 0x9000
/* The upper memory area (starting at 640 kiB). */
#define GRUB_MEMORY_I386_PC_UPPER 0xa0000
@ -63,40 +45,16 @@
/* The offset of GRUB_CORE_ENTRY_ADDR. */
#define GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR 0x8
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
#define GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE 0xc
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_QEMU_PREFIX 0x10
/* End of the data section. */
#define GRUB_KERNEL_I386_QEMU_PREFIX_END 0x50
#define GRUB_KERNEL_I386_QEMU_LINK_ADDR 0x8200
/* The offset of GRUB_TOTAL_MODULE_SIZE. */
#define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8
/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
#define GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE 0xc
/* The offset of GRUB_COMPRESSED_SIZE. */
#define GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE 0x10
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX 0x14
/* End of the data section. */
#define GRUB_KERNEL_SPARC64_IEEE1275_PREFIX_END 0x114
#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
#define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS 0x4400
#define GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE 0
#define GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR 0x4400
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX_END 0x44
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
@ -104,62 +62,31 @@
#define GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN 32
#define GRUB_KERNEL_MIPS_LOONGSON_COMPRESSED_SIZE 0x8
#define GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_SIZE 0xc
#define GRUB_KERNEL_MIPS_LOONGSON_UNCOMPRESSED_ADDR 0x10
#define GRUB_DECOMPRESSOR_MIPS_LOONGSON_COMPRESSED_SIZE 0x8
#define GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_SIZE 0xc
#define GRUB_DECOMPRESSOR_MIPS_LOONGSON_UNCOMPRESSED_ADDR 0x10
#define GRUB_KERNEL_MIPS_LOONGSON_TOTAL_MODULE_SIZE 0x08
#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_LOONGSON_PREFIX_END 0x54
#define GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ADDR 0x80200000
#define GRUB_KERNEL_MIPS_QEMU_MIPS_LINK_ALIGN 32
#define GRUB_KERNEL_MIPS_QEMU_MIPS_COMPRESSED_SIZE 0x8
#define GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE 0xc
#define GRUB_KERNEL_MIPS_QEMU_MIPS_UNCOMPRESSED_ADDR 0x10
#define GRUB_DECOMPRESSOR_MIPS_QEMU_MIPS_COMPRESSED_SIZE 0x8
#define GRUB_DECOMPRESSOR_MIPS_QEMU_MIPS_UNCOMPRESSED_SIZE 0xc
#define GRUB_DECOMPRESSOR_MIPS_QEMU_MIPS_UNCOMPRESSED_ADDR 0x10
#define GRUB_KERNEL_MIPS_QEMU_MIPS_TOTAL_MODULE_SIZE 0x08
#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_QEMU_MIPS_PREFIX_END 0x54
#define GRUB_KERNEL_MIPS_ARC_LINK_ADDR 0x8bd00000
#define GRUB_KERNEL_MIPS_ARC_LINK_ALIGN 32
#define GRUB_KERNEL_MIPS_ARC_COMPRESSED_SIZE 0x8
#define GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_SIZE 0xc
#define GRUB_KERNEL_MIPS_ARC_UNCOMPRESSED_ADDR 0x10
#define GRUB_DECOMPRESSOR_MIPS_ARC_COMPRESSED_SIZE 0x8
#define GRUB_DECOMPRESSOR_MIPS_ARC_UNCOMPRESSED_SIZE 0xc
#define GRUB_DECOMPRESSOR_MIPS_ARC_UNCOMPRESSED_ADDR 0x10
#define GRUB_KERNEL_MIPS_ARC_TOTAL_MODULE_SIZE 0x08
#define GRUB_KERNEL_MIPS_ARC_PREFIX 0x0c
#define GRUB_KERNEL_MIPS_ARC_PREFIX_END 0x54
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_I386_EFI_PREFIX 0x8
/* End of the data section. */
#define GRUB_KERNEL_I386_EFI_PREFIX_END 0x50
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_IA64_EFI_PREFIX 0x50
/* End of the data section. */
#define GRUB_KERNEL_IA64_EFI_PREFIX_END 0xa0
/* The offset of GRUB_PREFIX. */
#define GRUB_KERNEL_X86_64_EFI_PREFIX 0x8
/* End of the data section. */
#define GRUB_KERNEL_X86_64_EFI_PREFIX_END 0x50
#define GRUB_KERNEL_I386_COREBOOT_PREFIX 0x2
#define GRUB_KERNEL_I386_COREBOOT_PREFIX_END 0x42
#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x8200
#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX GRUB_KERNEL_I386_COREBOOT_PREFIX
#define GRUB_KERNEL_I386_MULTIBOOT_PREFIX_END GRUB_KERNEL_I386_COREBOOT_PREFIX_END
#define GRUB_KERNEL_I386_IEEE1275_PREFIX 0x2
#define GRUB_KERNEL_I386_IEEE1275_PREFIX_END 0x42
#define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR 0x10000
#define GRUB_KERNEL_I386_IEEE1275_MOD_ALIGN 0x1000
@ -189,19 +116,14 @@
#define GRUB_KERNEL_MACHINE_MOD_ALIGN GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _MOD_ALIGN)
#define GRUB_KERNEL_MACHINE_MOD_GAP GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _MOD_GAP)
#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _TOTAL_MODULE_SIZE)
#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _KERNEL_IMAGE_SIZE)
#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _COMPRESSED_SIZE)
#define GRUB_KERNEL_MACHINE_UNCOMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _UNCOMPRESSED_SIZE)
#define GRUB_KERNEL_MACHINE_UNCOMPRESSED_ADDR GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _UNCOMPRESSED_ADDR)
#define GRUB_KERNEL_MACHINE_PREFIX GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _PREFIX)
#define GRUB_KERNEL_MACHINE_PREFIX_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _PREFIX_END)
#define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, GRUB_MACHINE, _KERNEL_SEG)
#define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, GRUB_MACHINE, _UPPER)
#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _RAW_SIZE)
#define GRUB_KERNEL_MACHINE_INSTALL_BSD_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _INSTALL_BSD_PART)
#define GRUB_KERNEL_MACHINE_INSTALL_DOS_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _INSTALL_DOS_PART)
#define GRUB_MACHINE_LINK_ADDR GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, GRUB_MACHINE, _LINK_ADDR)
#define GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_DECOMPRESSOR_, GRUB_MACHINE, _COMPRESSED_SIZE)
#define GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_DECOMPRESSOR_, GRUB_MACHINE, _UNCOMPRESSED_SIZE)
#define GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR GRUB_OFFSETS_CONCAT (GRUB_DECOMPRESSOR_, GRUB_MACHINE, _UNCOMPRESSED_ADDR)
#endif
#ifndef ASM_FILE

View file

@ -21,8 +21,8 @@
struct grub_parttool_argdesc
{
char *name;
char *desc;
const char *name;
const char *desc;
enum {GRUB_PARTTOOL_ARG_END, GRUB_PARTTOOL_ARG_BOOL, GRUB_PARTTOOL_ARG_VAL}
type;
};

View file

@ -24,6 +24,6 @@
typedef grub_err_t (*grub_reader_getline_t) (char **, int);
void grub_rescue_run (void);
void grub_rescue_run (void) __attribute__ ((noreturn));
#endif /* ! GRUB_READER_HEADER */

View file

@ -245,8 +245,9 @@ void grub_script_mem_free (struct grub_script_mem *mem);
void grub_script_argv_free (struct grub_script_argv *argv);
int grub_script_argv_make (struct grub_script_argv *argv, int argc, char **args);
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);
int grub_script_argv_append (struct grub_script_argv *argv, const char *s,
grub_size_t slen);
int grub_script_argv_split_append (struct grub_script_argv *argv, const char *s);
struct grub_script_arglist *
grub_script_create_arglist (struct grub_parser_param *state);

View file

@ -96,6 +96,32 @@ grub_err_t EXPORT_FUNC(grub_serial_register) (struct grub_serial_port *port);
void EXPORT_FUNC(grub_serial_unregister) (struct grub_serial_port *port);
/* Convenience functions to perform primitive operations on a port. */
static inline grub_err_t
grub_serial_port_configure (struct grub_serial_port *port,
struct grub_serial_config *config)
{
return port->driver->configure (port, config);
}
static inline int
grub_serial_port_fetch (struct grub_serial_port *port)
{
return port->driver->fetch (port);
}
static inline void
grub_serial_port_put (struct grub_serial_port *port, const int c)
{
port->driver->put (port, c);
}
static inline void
grub_serial_port_fini (struct grub_serial_port *port)
{
port->driver->fini (port);
}
/* Set default settings. */
static inline grub_err_t
grub_serial_config_defaults (struct grub_serial_port *port)
@ -117,6 +143,7 @@ grub_serial_config_defaults (struct grub_serial_port *port)
void grub_ns8250_init (void);
char *grub_serial_ns8250_add_port (grub_port_t port);
struct grub_serial_port *grub_serial_find (const char *name);
extern struct grub_serial_driver grub_ns8250_driver;
void EXPORT_FUNC(grub_serial_unregister_driver) (struct grub_serial_driver *driver);

View file

@ -39,9 +39,7 @@
#define GRUB_BOOT_MACHINE_SIGNATURE 0xbb44aa55
#define GRUB_BOOT_MACHINE_VER_MAJ 0x08
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH 0x0a
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH 0x08
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH_END 0x80

View file

@ -26,12 +26,6 @@
#include <grub/symbol.h>
#include <grub/types.h>
/* The size of kernel image. */
extern grub_int32_t grub_kernel_image_size;
/* The total size of module images following the kernel. */
extern grub_int32_t grub_total_module_size;
#endif /* ! ASM_FILE */
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */

View file

@ -21,6 +21,6 @@
#define GRUB_TPARM_HEADER 1
/* Function prototypes. */
char *grub_terminfo_tparm (const char *string, ...);
const char *grub_terminfo_tparm (const char *string, ...);
#endif /* ! GRUB_TPARM_HEADER */

View file

@ -119,6 +119,10 @@ typedef grub_int32_t grub_ssize_t;
# define PRIdGRUB_SSIZE "d"
#endif
#define GRUB_UCHAR_MAX 0xFF
#define GRUB_USHRT_MAX 65535
#define GRUB_UINT_MAX 4294967295U
#if GRUB_CPU_SIZEOF_LONG == 8
# define GRUB_ULONG_MAX 18446744073709551615UL
# define GRUB_LONG_MAX 9223372036854775807L
@ -129,15 +133,9 @@ typedef grub_int32_t grub_ssize_t;
# define GRUB_LONG_MIN (-2147483647L - 1)
#endif
#if GRUB_CPU_SIZEOF_VOID_P == 4
#define UINT_TO_PTR(x) ((void*)(grub_uint32_t)(x))
#define PTR_TO_UINT64(x) ((grub_uint64_t)(grub_uint32_t)(x))
#define PTR_TO_UINT32(x) ((grub_uint32_t)(x))
#else
#define UINT_TO_PTR(x) ((void*)(grub_uint64_t)(x))
#define PTR_TO_UINT64(x) ((grub_uint64_t)(x))
#define PTR_TO_UINT32(x) ((grub_uint32_t)(grub_uint64_t)(x))
#endif
typedef grub_uint64_t grub_properly_aligned_t;
#define GRUB_PROPERLY_ALIGNED_ARRAY(name, size) grub_properly_aligned_t name[((size) + sizeof (grub_properly_aligned_t) - 1) / sizeof (grub_properly_aligned_t)]
/* The type for representing a file offset. */
typedef grub_uint64_t grub_off_t;
@ -242,4 +240,57 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
#endif /* ! WORDS_BIGENDIAN */
static inline grub_uint16_t grub_get_unaligned16 (const void *ptr)
{
struct grub_unaligned_uint16_t
{
grub_uint16_t d;
} __attribute__ ((packed));
const struct grub_unaligned_uint16_t *dd
= (const struct grub_unaligned_uint16_t *) ptr;
return dd->d;
}
static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val)
{
struct grub_unaligned_uint16_t
{
grub_uint16_t d;
} __attribute__ ((packed));
struct grub_unaligned_uint16_t *dd = (struct grub_unaligned_uint16_t *) ptr;
dd->d = val;
}
static inline grub_uint32_t grub_get_unaligned32 (const void *ptr)
{
struct grub_unaligned_uint32_t
{
grub_uint32_t d;
} __attribute__ ((packed));
const struct grub_unaligned_uint32_t *dd
= (const struct grub_unaligned_uint32_t *) ptr;
return dd->d;
}
static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val)
{
struct grub_unaligned_uint32_t
{
grub_uint32_t d;
} __attribute__ ((packed));
struct grub_unaligned_uint32_t *dd = (struct grub_unaligned_uint32_t *) ptr;
dd->d = val;
}
static inline grub_uint64_t grub_get_unaligned64 (const void *ptr)
{
struct grub_unaligned_uint64_t
{
grub_uint64_t d;
} __attribute__ ((packed));
const struct grub_unaligned_uint64_t *dd
= (const struct grub_unaligned_uint64_t *)ptr;
return dd->d;
}
#endif /* ! GRUB_TYPES_HEADER */

View file

@ -1,7 +1,7 @@
/* lvm.h - LVM support for GRUB utils. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
* Copyright (C) 2006,2007,2011 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,7 +20,14 @@
#ifndef GRUB_LVM_UTIL_HEADER
#define GRUB_LVM_UTIL_HEADER 1
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#ifdef __linux__
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
#else
#define LVM_DEV_MAPPER_STRING "/dev/linux_lvm/"
#endif
int grub_util_lvm_isvolume (char *name);
#endif

View file

@ -28,4 +28,6 @@
/* x86_64 is little-endian. */
#undef GRUB_TARGET_WORDS_BIGENDIAN
#define GRUB_HAVE_UNALIGNED_ACCESS 1
#endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -81,7 +81,7 @@ struct grub_xnu_extheader
} __attribute__ ((packed));
struct grub_xnu_devtree_key *grub_xnu_create_key (struct grub_xnu_devtree_key **parent,
char *name);
const char *name);
extern struct grub_xnu_devtree_key *grub_xnu_devtree_root;
@ -89,18 +89,20 @@ void grub_xnu_free_devtree (struct grub_xnu_devtree_key *cur);
grub_err_t grub_xnu_writetree_toheap (grub_addr_t *target, grub_size_t *size);
struct grub_xnu_devtree_key *grub_xnu_create_value (struct grub_xnu_devtree_key **parent,
char *name);
const char *name);
void grub_xnu_lock (void);
void grub_xnu_unlock (void);
grub_err_t grub_xnu_resume (char *imagename);
grub_err_t grub_xnu_boot_resume (void);
struct grub_xnu_devtree_key *grub_xnu_find_key (struct grub_xnu_devtree_key *parent,
char *name);
const char *name);
grub_err_t grub_xnu_align_heap (int align);
grub_err_t grub_xnu_scan_dir_for_kexts (char *dirname, char *osbundlerequired,
grub_err_t grub_xnu_scan_dir_for_kexts (char *dirname,
const char *osbundlerequired,
int maxrecursion);
grub_err_t grub_xnu_load_kext_from_dir (char *dirname, char *osbundlerequired,
grub_err_t grub_xnu_load_kext_from_dir (char *dirname,
const char *osbundlerequired,
int maxrecursion);
grub_err_t grub_xnu_heap_malloc (int size, void **src, grub_addr_t *target);
grub_err_t grub_xnu_fill_devicetree (void);

View file

@ -88,6 +88,7 @@ typedef enum dmu_object_type {
DMU_OT_SA_MASTER_NODE, /* ZAP */
DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */
DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */
DMU_OT_DSL_KEYCHAIN = 54,
DMU_OT_NUMTYPES
} dmu_object_type_t;

View file

@ -42,7 +42,9 @@ typedef struct dsl_dir_phys {
grub_uint64_t dd_reserved;
grub_uint64_t dd_props_zapobj;
grub_uint64_t dd_deleg_zapobj; /* dataset permissions */
grub_uint64_t dd_pad[20]; /* pad out to 256 bytes for good measure */
grub_uint64_t unused[7];
grub_uint64_t keychain;
grub_uint64_t unused2[12];
} dsl_dir_phys_t;
#endif /* _SYS_DSL_DIR_H */

View file

@ -29,6 +29,9 @@ typedef struct sa_hdr_phys {
} sa_hdr_phys_t;
#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0)
#define SA_TYPE_OFFSET 0x0
#define SA_SIZE_OFFSET 0x8
#define SA_MTIME_OFFSET 0x38
#define SA_SYMLINK_OFFSET 0xa0
#endif /* _SYS_SA_IMPL_H */

View file

@ -20,26 +20,24 @@
#ifndef GRUB_ZFS_SPA_HEADER
#define GRUB_ZFS_SPA_HEADER 1
typedef enum grub_zfs_endian
{
UNKNOWN_ENDIAN = -2,
LITTLE_ENDIAN = -1,
BIG_ENDIAN = 0
} grub_zfs_endian_t;
#define grub_zfs_to_cpu16(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu16(x) \
#define grub_zfs_to_cpu16(x,a) (((a) == GRUB_ZFS_BIG_ENDIAN) ? \
grub_be_to_cpu16(x) \
: grub_le_to_cpu16(x))
#define grub_cpu_to_zfs16(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be16(x) \
#define grub_cpu_to_zfs16(x,a) (((a) == GRUB_ZFS_BIG_ENDIAN) ? \
grub_cpu_to_be16(x) \
: grub_cpu_to_le16(x))
#define grub_zfs_to_cpu32(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu32(x) \
#define grub_zfs_to_cpu32(x,a) (((a) == GRUB_ZFS_BIG_ENDIAN) ? \
grub_be_to_cpu32(x) \
: grub_le_to_cpu32(x))
#define grub_cpu_to_zfs32(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be32(x) \
#define grub_cpu_to_zfs32(x,a) (((a) == GRUB_ZFS_BIG_ENDIAN) ? \
grub_cpu_to_be32(x) \
: grub_cpu_to_le32(x))
#define grub_zfs_to_cpu64(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu64(x) \
#define grub_zfs_to_cpu64(x,a) (((a) == GRUB_ZFS_BIG_ENDIAN) \
? grub_be_to_cpu64(x) \
: grub_le_to_cpu64(x))
#define grub_cpu_to_zfs64(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be64(x) \
#define grub_cpu_to_zfs64(x,a) (((a) == GRUB_ZFS_BIG_ENDIAN) ? grub_cpu_to_be64(x) \
: grub_cpu_to_le64(x))
/*

View file

@ -69,7 +69,8 @@ typedef struct zap_leaf_phys {
* with the ZAP_LEAF_CHUNK() macro.
*/
grub_uint16_t l_hash[1];
grub_uint16_t l_hash[0];
grub_properly_aligned_t l_entries[0];
} zap_leaf_phys_t;
typedef union zap_leaf_chunk {

View file

@ -24,11 +24,19 @@
#include <grub/err.h>
#include <grub/disk.h>
#include <grub/crypto.h>
typedef enum grub_zfs_endian
{
GRUB_ZFS_UNKNOWN_ENDIAN = -2,
GRUB_ZFS_LITTLE_ENDIAN = -1,
GRUB_ZFS_BIG_ENDIAN = 0
} grub_zfs_endian_t;
/*
* On-disk version number.
*/
#define SPA_VERSION 28ULL
#define SPA_VERSION 33ULL
/*
* The following are configuration names used in the nvlist describing a pool's
@ -112,12 +120,34 @@ grub_err_t grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist);
grub_err_t grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename,
grub_uint64_t *mdnobj);
char *grub_zfs_nvlist_lookup_string (char *nvlist, char *name);
char *grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name);
int grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name,
char *grub_zfs_nvlist_lookup_string (const char *nvlist, const char *name);
char *grub_zfs_nvlist_lookup_nvlist (const char *nvlist, const char *name);
int grub_zfs_nvlist_lookup_uint64 (const char *nvlist, const char *name,
grub_uint64_t *out);
char *grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name,
char *grub_zfs_nvlist_lookup_nvlist_array (const char *nvlist,
const char *name,
grub_size_t index);
int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name);
int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (const char *nvlist,
const char *name);
grub_err_t
grub_zfs_add_key (grub_uint8_t *key_in,
grub_size_t keylen,
int passphrase);
extern grub_err_t (*grub_zfs_decrypt) (grub_crypto_cipher_handle_t cipher,
grub_uint64_t algo,
void *nonce,
char *buf, grub_size_t size,
const grub_uint32_t *expected_mac,
grub_zfs_endian_t endian);
struct grub_zfs_key;
extern grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key,
grub_size_t keysize,
grub_uint64_t salt,
grub_uint64_t algo);
#endif /* ! GRUB_ZFS_HEADER */

View file

@ -30,7 +30,7 @@
typedef struct zio_eck {
grub_uint64_t zec_magic; /* for validation, endianness */
zio_cksum_t zec_cksum; /* 256-bit checksum */
} zio_eck_t;
} __attribute__ ((packed)) zio_eck_t;
/*
* Gang block headers are self-checksumming and contain an array
@ -65,6 +65,7 @@ enum zio_checksum {
ZIO_CHECKSUM_FLETCHER_4,
ZIO_CHECKSUM_SHA256,
ZIO_CHECKSUM_ZILOG2,
ZIO_CHECKSUM_SHA256_MAC,
ZIO_CHECKSUM_FUNCTIONS
};
@ -86,6 +87,7 @@ enum zio_compress {
ZIO_COMPRESS_GZIP7,
ZIO_COMPRESS_GZIP8,
ZIO_COMPRESS_GZIP9,
ZIO_COMPRESS_ZLE,
ZIO_COMPRESS_FUNCTIONS
};

View file

@ -23,22 +23,6 @@
#ifndef _SYS_ZIO_CHECKSUM_H
#define _SYS_ZIO_CHECKSUM_H
/*
* Signature for checksum functions.
*/
typedef void zio_checksum_t(const void *data, grub_uint64_t size,
grub_zfs_endian_t endian, zio_cksum_t *zcp);
/*
* Information about each checksum function.
*/
typedef struct zio_checksum_info {
zio_checksum_t *ci_func; /* checksum function for each byteorder */
int ci_correctable; /* number of correctable bits */
int ci_eck; /* uses zio embedded checksum? */
char *ci_name; /* descriptive name */
} zio_checksum_info_t;
extern void zio_checksum_SHA256 (const void *, grub_uint64_t,
grub_zfs_endian_t endian, zio_cksum_t *);
extern void fletcher_2 (const void *, grub_uint64_t, grub_zfs_endian_t endian,