Merge branch 'mainline' into relocator

This commit is contained in:
phcoder 2009-09-20 19:38:16 +02:00
commit 8f2e29a2a3
99 changed files with 3333 additions and 732 deletions

45
include/grub/auth.h Normal file
View file

@ -0,0 +1,45 @@
/*
* 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_AURH_HEADER
#define GRUB_AUTH_HEADER 1
#include <grub/err.h>
/* Macros for indistinguishibility. */
#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, "Access denied.")
#define GRUB_GET_PASSWORD(string, len) grub_cmdline_get ("Enter password: ", \
string, len, \
'*', 0, 0)
/* Like strcmp but untimeable. Accepts NULL as second argument. */
int grub_auth_strcmp (const char *user_input, const char *template);
/* Like strcmp but untimeable and ignores commas in needle. */
int grub_auth_strword (const char *haystack, const char *needle);
typedef grub_err_t (*grub_auth_callback_t) (const char*, void *);
grub_err_t grub_auth_register_authentication (const char *user,
grub_auth_callback_t callback,
void *arg);
grub_err_t grub_auth_unregister_authentication (const char *user);
grub_err_t grub_auth_authenticate (const char *user);
grub_err_t grub_auth_deauthenticate (const char *user);
grub_err_t grub_auth_check_authentication (const char *userlist);
#endif /* ! GRUB_AUTH_HEADER */

View file

@ -53,7 +53,8 @@ typedef enum
GRUB_ERR_BAD_GZIP_DATA,
GRUB_ERR_MENU,
GRUB_ERR_TIMEOUT,
GRUB_ERR_IO
GRUB_ERR_IO,
GRUB_ERR_ACCESS_DENIED
}
grub_err_t;

View file

@ -131,4 +131,52 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_32bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_24bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_16bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_replace_8bit_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
void
grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst,
struct grub_video_fbblit_info *src,
int x, int y,
int width, int height,
int offset_x, int offset_y);
#endif /* ! GRUB_FBBLIT_HEADER */

View file

@ -29,7 +29,7 @@ enum bsd_kernel_types
KERNEL_TYPE_NETBSD,
};
#define GRUB_BSD_TEMP_BUFFER 0x68000
#define GRUB_BSD_TEMP_BUFFER 0x80000
#define FREEBSD_RB_ASKNAME (1 << 0) /* ask for file name to reboot from */
#define FREEBSD_RB_SINGLE (1 << 1) /* reboot to single user only */
@ -157,6 +157,8 @@ struct grub_openbsd_bios_mmap
grub_uint64_t len;
#define OPENBSD_MMAP_AVAILABLE 1
#define OPENBSD_MMAP_RESERVED 2
#define OPENBSD_MMAP_ACPI 3
#define OPENBSD_MMAP_NVS 4
grub_uint32_t type;
};
@ -189,6 +191,8 @@ struct grub_openbsd_bootargs
#define NETBSD_AB_VERBOSE (1 << 17) /* boot verbosely */
#define NETBSD_AB_SILENT (1 << 18) /* boot silently */
#define NETBSD_AB_DEBUG (1 << 19) /* boot with debug messages */
#define NETBSD_AB_NOSMP (1 << 28) /* Boot without SMP support. */
#define NETBSD_AB_NOACPI (1 << 29) /* Boot without ACPI support. */
struct grub_netbsd_bootinfo
{
@ -199,6 +203,7 @@ struct grub_netbsd_bootinfo
#define NETBSD_BTINFO_BOOTPATH 0
#define NETBSD_BTINFO_ROOTDEVICE 1
#define NETBSD_BTINFO_BOOTDISK 3
#define NETBSD_BTINFO_MEMMAP 9
struct grub_netbsd_btinfo_common
{
@ -206,6 +211,23 @@ struct grub_netbsd_btinfo_common
int type;
};
struct grub_netbsd_btinfo_mmap_header
{
struct grub_netbsd_btinfo_common common;
grub_uint32_t count;
};
struct grub_netbsd_btinfo_mmap_entry
{
grub_uint64_t addr;
grub_uint64_t len;
#define NETBSD_MMAP_AVAILABLE 1
#define NETBSD_MMAP_RESERVED 2
#define NETBSD_MMAP_ACPI 3
#define NETBSD_MMAP_NVS 4
grub_uint32_t type;
};
struct grub_netbsd_btinfo_bootpath
{
struct grub_netbsd_btinfo_common common;

View file

@ -77,8 +77,19 @@
/* The data segment of the pseudo real mode. */
#define GRUB_MEMORY_MACHINE_PSEUDO_REAL_DSEG 0x20
#define GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR 0x400
#ifndef ASM_FILE
/* See http://heim.ifi.uio.no/~stanisls/helppc/bios_data_area.html for a
description of the BIOS Data Area layout. */
struct grub_machine_bios_data_area
{
grub_uint8_t unused1[0x17];
grub_uint8_t keyboard_flag_lower; /* 0x17 */
grub_uint8_t unused2[0xf0 - 0x18];
};
struct grub_machine_mmap_entry
{
grub_uint32_t size;

View file

@ -1,6 +1,26 @@
/*
* 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_CPU_XNU_H
#define GRUB_CPU_XNU_H 1
#include <grub/err.h>
#define GRUB_XNU_PAGESIZE 4096
typedef grub_uint32_t grub_xnu_ptr_t;

View file

@ -32,6 +32,12 @@ struct grub_menu_entry
/* The title name. */
const char *title;
/* If set means not everybody is allowed to boot this entry. */
int restricted;
/* Allowed users. */
const char *users;
/* The classes associated with the menu entry:
used to choose an icon or other style attributes.
This is a dummy head node for the linked list, so for an entry E,

View file

@ -37,8 +37,42 @@ 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);
char *EXPORT_FUNC(grub_strcat) (char *dest, const char *src);
char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c);
static inline char *
grub_strcat (char *dest, const char *src)
{
char *p = dest;
while (*p)
p++;
while ((*p = *src) != '\0')
{
p++;
src++;
}
return dest;
}
static inline char *
grub_strncat (char *dest, const char *src, int c)
{
char *p = dest;
while (*p)
p++;
while ((*p = *src) != '\0' && c--)
{
p++;
src++;
}
*p = '\0';
return dest;
}
/* Prototypes for aliases. */
#if !defined (GRUB_UTIL) || !defined (APPLE_CC)
@ -49,19 +83,41 @@ void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n);
int EXPORT_FUNC(grub_strcasecmp) (const char *s1, const char *s2);
int EXPORT_FUNC(grub_strncasecmp) (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);
int EXPORT_FUNC(grub_iswordseparator) (int c);
int EXPORT_FUNC(grub_isspace) (int c);
int EXPORT_FUNC(grub_isprint) (int c);
int EXPORT_FUNC(grub_isalpha) (int c);
int EXPORT_FUNC(grub_isgraph) (int c);
int EXPORT_FUNC(grub_isdigit) (int c);
int EXPORT_FUNC(grub_tolower) (int c);
static inline int
grub_isalpha (int c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
static inline int
grub_isgraph (int c)
{
return (c >= '!' && c <= '~');
}
static inline int
grub_isdigit (int c)
{
return (c >= '0' && c <= '9');
}
static inline int
grub_tolower (int c)
{
if (c >= 'A' && c <= 'Z')
return c - 'A' + 'a';
return c;
}
static inline int
grub_toupper (int c)
{
@ -71,6 +127,40 @@ grub_toupper (int c)
return c;
}
static inline int
grub_strcasecmp (const char *s1, const char *s2)
{
while (*s1 && *s2)
{
if (grub_tolower (*s1) != grub_tolower (*s2))
break;
s1++;
s2++;
}
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
}
static inline int
grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
{
if (n == 0)
return 0;
while (*s1 && *s2 && --n)
{
if (grub_tolower (*s1) != grub_tolower (*s2))
break;
s1++;
s2++;
}
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
}
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);
char *EXPORT_FUNC(grub_strdup) (const char *s);

View file

@ -99,7 +99,7 @@
#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
/* The BSD partition entry. */
struct grub_pc_partition_bsd_entry
struct grub_msdos_partition_bsd_entry
{
grub_uint32_t size;
grub_uint32_t offset;
@ -110,7 +110,7 @@ struct grub_pc_partition_bsd_entry
} __attribute__ ((packed));
/* The BSD disk label. Only define members useful for GRUB. */
struct grub_pc_partition_disk_label
struct grub_msdos_partition_disk_label
{
grub_uint32_t magic;
grub_uint8_t padding[128];
@ -119,11 +119,11 @@ struct grub_pc_partition_disk_label
grub_uint16_t num_partitions;
grub_uint32_t boot_size;
grub_uint32_t superblock_size;
struct grub_pc_partition_bsd_entry entries[GRUB_PC_PARTITION_BSD_MAX_ENTRIES];
struct grub_msdos_partition_bsd_entry entries[GRUB_PC_PARTITION_BSD_MAX_ENTRIES];
} __attribute__ ((packed));
/* The partition entry. */
struct grub_pc_partition_entry
struct grub_msdos_partition_entry
{
/* If active, 0x80, otherwise, 0x00. */
grub_uint8_t flag;
@ -155,20 +155,20 @@ struct grub_pc_partition_entry
} __attribute__ ((packed));
/* The structure of MBR. */
struct grub_pc_partition_mbr
struct grub_msdos_partition_mbr
{
/* The code area (actually, including BPB). */
grub_uint8_t code[446];
/* Four partition entries. */
struct grub_pc_partition_entry entries[4];
struct grub_msdos_partition_entry entries[4];
/* The signature 0xaa55. */
grub_uint16_t signature;
} __attribute__ ((packed));
struct grub_pc_partition
struct grub_msdos_partition
{
/* The DOS partition number. */
int dos_part;
@ -187,13 +187,13 @@ struct grub_pc_partition
};
static inline int
grub_pc_partition_is_empty (int type)
grub_msdos_partition_is_empty (int type)
{
return (type == GRUB_PC_PARTITION_TYPE_NONE);
}
static inline int
grub_pc_partition_is_extended (int type)
grub_msdos_partition_is_extended (int type)
{
return (type == GRUB_PC_PARTITION_TYPE_EXTENDED
|| type == GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED
@ -201,7 +201,7 @@ grub_pc_partition_is_extended (int type)
}
static inline int
grub_pc_partition_is_bsd (int type)
grub_msdos_partition_is_bsd (int type)
{
return (type == GRUB_PC_PARTITION_TYPE_FREEBSD
|| type == GRUB_PC_PARTITION_TYPE_OPENBSD

View file

@ -56,7 +56,7 @@ void grub_cmdline_run (int nested);
/* Defined in `cmdline.c'. */
int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
int echo_char, int readline);
int echo_char, int readline, int history);
grub_err_t grub_set_history (int newsize);
/* Defined in `completion.c'. */

View file

@ -133,7 +133,7 @@ struct grub_fshelp_node
{
struct grub_ntfs_data *data;
char *buf;
grub_uint32_t size;
grub_uint64_t size;
grub_uint32_t ino;
int inode_read;
struct grub_ntfs_attr attr;

View file

@ -84,8 +84,8 @@ void EXPORT_FUNC(grub_partition_map_register) (grub_partition_map_t partmap);
void EXPORT_FUNC(grub_partition_map_unregister) (grub_partition_map_t partmap);
#ifdef GRUB_UTIL
void grub_pc_partition_map_init (void);
void grub_pc_partition_map_fini (void);
void grub_msdos_partition_map_init (void);
void grub_msdos_partition_map_fini (void);
void grub_amiga_partition_map_init (void);
void grub_amiga_partition_map_fini (void);
void grub_apple_partition_map_init (void);

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003,2005,2007,2008 Free Software Foundation, Inc.
* Copyright (C) 2002,2003,2005,2007,2008,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
@ -72,6 +72,12 @@ grub_term_color_state;
#define GRUB_TERM_NEED_INIT (1 << 16)
/* Bitmasks for modifier keys returned by grub_getkeystatus. */
#define GRUB_TERM_STATUS_SHIFT (1 << 0)
#define GRUB_TERM_STATUS_CTRL (1 << 1)
#define GRUB_TERM_STATUS_ALT (1 << 2)
/* Unicode characters for fancy graphics. */
#define GRUB_TERM_DISP_LEFT 0x2190
#define GRUB_TERM_DISP_UP 0x2191
@ -157,6 +163,9 @@ struct grub_term_input
/* Get a character. */
int (*getkey) (void);
/* Get keyboard modifier status. */
int (*getkeystatus) (void);
};
typedef struct grub_term_input *grub_term_input_t;
@ -275,6 +284,7 @@ void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
grub_ssize_t EXPORT_FUNC(grub_getcharwidth) (grub_uint32_t code);
int EXPORT_FUNC(grub_getkey) (void);
int EXPORT_FUNC(grub_checkkey) (void);
int EXPORT_FUNC(grub_getkeystatus) (void);
grub_uint16_t EXPORT_FUNC(grub_getwh) (void);
grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);