Initial commit from Ventoy@7cbdc5c
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/* cache.h - Flush the processor's cache. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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_CACHE_H
|
||||
#define GRUB_CACHE_H 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
#if defined (__i386__) || defined (__x86_64__)
|
||||
static inline void
|
||||
grub_arch_sync_caches (void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
#else
|
||||
void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len);
|
||||
#endif
|
||||
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
#if defined (__aarch64__) || defined (__ia64__) || defined (__powerpc__) || \
|
||||
defined (__sparc__)
|
||||
|
||||
#elif defined (__i386__) || defined (__x86_64__)
|
||||
static inline void
|
||||
grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)),
|
||||
grub_size_t len __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
#elif defined(__mips__) && (_MIPS_SIM != _ABI64)
|
||||
void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, grub_size_t len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __arm__
|
||||
void
|
||||
grub_arm_cache_enable (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_CACHE_HEADER */
|
||||
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,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
|
||||
* 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_CHARSET_HEADER
|
||||
#define GRUB_CHARSET_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_UINT8_1_LEADINGBIT 0x80
|
||||
#define GRUB_UINT8_2_LEADINGBITS 0xc0
|
||||
#define GRUB_UINT8_3_LEADINGBITS 0xe0
|
||||
#define GRUB_UINT8_4_LEADINGBITS 0xf0
|
||||
#define GRUB_UINT8_5_LEADINGBITS 0xf8
|
||||
#define GRUB_UINT8_6_LEADINGBITS 0xfc
|
||||
#define GRUB_UINT8_7_LEADINGBITS 0xfe
|
||||
|
||||
#define GRUB_UINT8_1_TRAILINGBIT 0x01
|
||||
#define GRUB_UINT8_2_TRAILINGBITS 0x03
|
||||
#define GRUB_UINT8_3_TRAILINGBITS 0x07
|
||||
#define GRUB_UINT8_4_TRAILINGBITS 0x0f
|
||||
#define GRUB_UINT8_5_TRAILINGBITS 0x1f
|
||||
#define GRUB_UINT8_6_TRAILINGBITS 0x3f
|
||||
|
||||
#define GRUB_MAX_UTF8_PER_UTF16 4
|
||||
/* You need at least one UTF-8 byte to have one UTF-16 word.
|
||||
You need at least three UTF-8 bytes to have 2 UTF-16 words (surrogate pairs).
|
||||
*/
|
||||
#define GRUB_MAX_UTF16_PER_UTF8 1
|
||||
#define GRUB_MAX_UTF8_PER_CODEPOINT 4
|
||||
|
||||
#define GRUB_UCS2_LIMIT 0x10000
|
||||
#define GRUB_UTF16_UPPER_SURROGATE(code) \
|
||||
(0xD800 | ((((code) - GRUB_UCS2_LIMIT) >> 10) & 0x3ff))
|
||||
#define GRUB_UTF16_LOWER_SURROGATE(code) \
|
||||
(0xDC00 | (((code) - GRUB_UCS2_LIMIT) & 0x3ff))
|
||||
|
||||
/* 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. */
|
||||
static inline int
|
||||
grub_utf8_process (grub_uint8_t c, grub_uint32_t *code, int *count)
|
||||
{
|
||||
if (*count)
|
||||
{
|
||||
if ((c & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||
{
|
||||
*count = 0;
|
||||
/* invalid */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*code <<= 6;
|
||||
*code |= (c & GRUB_UINT8_6_TRAILINGBITS);
|
||||
(*count)--;
|
||||
/* Overlong. */
|
||||
if ((*count == 1 && *code <= 0x1f)
|
||||
|| (*count == 2 && *code <= 0xf))
|
||||
{
|
||||
*code = 0;
|
||||
*count = 0;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((c & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||
{
|
||||
*code = c;
|
||||
return 1;
|
||||
}
|
||||
if ((c & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS)
|
||||
{
|
||||
*count = 1;
|
||||
*code = c & GRUB_UINT8_5_TRAILINGBITS;
|
||||
/* Overlong */
|
||||
if (*code <= 1)
|
||||
{
|
||||
*count = 0;
|
||||
*code = 0;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if ((c & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS)
|
||||
{
|
||||
*count = 2;
|
||||
*code = c & GRUB_UINT8_4_TRAILINGBITS;
|
||||
return 1;
|
||||
}
|
||||
if ((c & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS)
|
||||
{
|
||||
*count = 3;
|
||||
*code = c & GRUB_UINT8_3_TRAILINGBITS;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
|
||||
bytes (if SRCSIZE is -1, it is ignored) in length to a UTF-16 string.
|
||||
Return the number of characters converted. DEST must be able to hold
|
||||
at least DESTSIZE characters. If an invalid sequence is found, return -1.
|
||||
If SRCEND is not NULL, then *SRCEND is set to the next byte after the
|
||||
last byte used in SRC. */
|
||||
static inline grub_size_t
|
||||
grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend)
|
||||
{
|
||||
grub_uint16_t *p = dest;
|
||||
int count = 0;
|
||||
grub_uint32_t code = 0;
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
|
||||
while (srcsize && destsize)
|
||||
{
|
||||
int was_count = count;
|
||||
if (srcsize != (grub_size_t)-1)
|
||||
srcsize--;
|
||||
if (!grub_utf8_process (*src++, &code, &count))
|
||||
{
|
||||
code = '?';
|
||||
count = 0;
|
||||
/* Character c may be valid, don't eat it. */
|
||||
if (was_count)
|
||||
src--;
|
||||
}
|
||||
if (count != 0)
|
||||
continue;
|
||||
if (code == 0)
|
||||
break;
|
||||
if (destsize < 2 && code >= GRUB_UCS2_LIMIT)
|
||||
break;
|
||||
if (code >= GRUB_UCS2_LIMIT)
|
||||
{
|
||||
*p++ = GRUB_UTF16_UPPER_SURROGATE (code);
|
||||
*p++ = GRUB_UTF16_LOWER_SURROGATE (code);
|
||||
destsize -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*p++ = code;
|
||||
destsize--;
|
||||
}
|
||||
}
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
return p - dest;
|
||||
}
|
||||
|
||||
/* Determine the last position where the UTF-8 string [beg, end) can
|
||||
be safely cut. */
|
||||
static inline grub_size_t
|
||||
grub_getend (const char *beg, const char *end)
|
||||
{
|
||||
const char *ptr;
|
||||
for (ptr = end - 1; ptr >= beg; ptr--)
|
||||
if ((*ptr & GRUB_UINT8_2_LEADINGBITS) != GRUB_UINT8_1_LEADINGBIT)
|
||||
break;
|
||||
if (ptr < beg)
|
||||
return 0;
|
||||
if ((*ptr & GRUB_UINT8_1_LEADINGBIT) == 0)
|
||||
return ptr + 1 - beg;
|
||||
if ((*ptr & GRUB_UINT8_3_LEADINGBITS) == GRUB_UINT8_2_LEADINGBITS
|
||||
&& ptr + 2 <= end)
|
||||
return ptr + 2 - beg;
|
||||
if ((*ptr & GRUB_UINT8_4_LEADINGBITS) == GRUB_UINT8_3_LEADINGBITS
|
||||
&& ptr + 3 <= end)
|
||||
return ptr + 3 - beg;
|
||||
if ((*ptr & GRUB_UINT8_5_LEADINGBITS) == GRUB_UINT8_4_LEADINGBITS
|
||||
&& ptr + 4 <= end)
|
||||
return ptr + 4 - beg;
|
||||
/* Invalid character or incomplete. Cut before it. */
|
||||
return ptr - beg;
|
||||
}
|
||||
|
||||
/* Convert UTF-16 to UTF-8. */
|
||||
static inline grub_uint8_t *
|
||||
grub_utf16_to_utf8 (grub_uint8_t *dest, const grub_uint16_t *src,
|
||||
grub_size_t size)
|
||||
{
|
||||
grub_uint32_t code_high = 0;
|
||||
|
||||
while (size--)
|
||||
{
|
||||
grub_uint32_t code = *src++;
|
||||
|
||||
if (code_high)
|
||||
{
|
||||
if (code >= 0xDC00 && code <= 0xDFFF)
|
||||
{
|
||||
/* Surrogate pair. */
|
||||
code = ((code_high - 0xD800) << 10) + (code - 0xDC00) + 0x10000;
|
||||
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Error... */
|
||||
*dest++ = '?';
|
||||
/* *src may be valid. Don't eat it. */
|
||||
src--;
|
||||
}
|
||||
|
||||
code_high = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (code <= 0x007F)
|
||||
*dest++ = code;
|
||||
else if (code <= 0x07FF)
|
||||
{
|
||||
*dest++ = (code >> 6) | 0xC0;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else if (code >= 0xD800 && code <= 0xDBFF)
|
||||
{
|
||||
code_high = code;
|
||||
continue;
|
||||
}
|
||||
else if (code >= 0xDC00 && code <= 0xDFFF)
|
||||
{
|
||||
/* Error... */
|
||||
*dest++ = '?';
|
||||
}
|
||||
else if (code < 0x10000)
|
||||
{
|
||||
*dest++ = (code >> 12) | 0xE0;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (const grub_uint32_t *src, grub_size_t size);
|
||||
|
||||
int
|
||||
grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize);
|
||||
|
||||
grub_ssize_t grub_utf8_to_ucs4_alloc (const char *msg,
|
||||
grub_uint32_t **unicode_msg,
|
||||
grub_uint32_t **last_position);
|
||||
|
||||
/* Returns the number of bytes the string src would occupy is converted
|
||||
to UTF-8, excluding \0. */
|
||||
grub_size_t
|
||||
grub_get_num_of_utf8_bytes (const grub_uint32_t *src, grub_size_t size);
|
||||
|
||||
/* Converts UCS-4 to UTF-8. Returns the number of bytes effectively written
|
||||
excluding the trailing \0. */
|
||||
grub_size_t
|
||||
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);
|
||||
|
||||
const grub_uint32_t *
|
||||
grub_unicode_get_comb_start (const grub_uint32_t *str,
|
||||
const grub_uint32_t *cur);
|
||||
|
||||
int
|
||||
grub_utf8_get_num_code (const char *src, grub_size_t srcsize);
|
||||
|
||||
const char *
|
||||
grub_utf8_offset_code (const char *src, grub_size_t srcsize, int num);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/* compiler.h - macros for various compiler features */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010,2014 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_COMPILER_HEADER
|
||||
#define GRUB_COMPILER_HEADER 1
|
||||
|
||||
/* GCC version checking borrowed from glibc. */
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
# define GNUC_PREREQ(maj,min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
#else
|
||||
# define GNUC_PREREQ(maj,min) 0
|
||||
#endif
|
||||
|
||||
/* Does this compiler support compile-time error attributes? */
|
||||
#if GNUC_PREREQ(4,3)
|
||||
# define ATTRIBUTE_ERROR(msg) \
|
||||
__attribute__ ((__error__ (msg)))
|
||||
#else
|
||||
# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn))
|
||||
#endif
|
||||
|
||||
#if GNUC_PREREQ(4,4)
|
||||
# define GNU_PRINTF gnu_printf
|
||||
#else
|
||||
# define GNU_PRINTF printf
|
||||
#endif
|
||||
|
||||
#if GNUC_PREREQ(3,4)
|
||||
# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
|
||||
#else
|
||||
# define WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
#define UNUSED __attribute__((__unused__))
|
||||
|
||||
#endif /* ! GRUB_COMPILER_HEADER */
|
||||
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,2005,2006,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
|
||||
* 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_DISK_HEADER
|
||||
#define GRUB_DISK_HEADER 1
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/device.h>
|
||||
/* For NULL. */
|
||||
#include <grub/mm.h>
|
||||
|
||||
/* These are used to set a device id. When you add a new disk device,
|
||||
you must define a new id for it here. */
|
||||
enum grub_disk_dev_id
|
||||
{
|
||||
GRUB_DISK_DEVICE_BIOSDISK_ID,
|
||||
GRUB_DISK_DEVICE_OFDISK_ID,
|
||||
GRUB_DISK_DEVICE_LOOPBACK_ID,
|
||||
GRUB_DISK_DEVICE_EFIDISK_ID,
|
||||
GRUB_DISK_DEVICE_DISKFILTER_ID,
|
||||
GRUB_DISK_DEVICE_HOST_ID,
|
||||
GRUB_DISK_DEVICE_ATA_ID,
|
||||
GRUB_DISK_DEVICE_MEMDISK_ID,
|
||||
GRUB_DISK_DEVICE_NAND_ID,
|
||||
GRUB_DISK_DEVICE_SCSI_ID,
|
||||
GRUB_DISK_DEVICE_CRYPTODISK_ID,
|
||||
GRUB_DISK_DEVICE_ARCDISK_ID,
|
||||
GRUB_DISK_DEVICE_HOSTDISK_ID,
|
||||
GRUB_DISK_DEVICE_PROCFS_ID,
|
||||
GRUB_DISK_DEVICE_CBFSDISK_ID,
|
||||
GRUB_DISK_DEVICE_UBOOTDISK_ID,
|
||||
GRUB_DISK_DEVICE_XEN,
|
||||
GRUB_DISK_DEVICE_OBDISK_ID,
|
||||
};
|
||||
|
||||
struct grub_disk;
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_disk_memberlist;
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GRUB_DISK_PULL_NONE,
|
||||
GRUB_DISK_PULL_REMOVABLE,
|
||||
GRUB_DISK_PULL_RESCAN,
|
||||
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
|
||||
{
|
||||
/* The device name. */
|
||||
const char *name;
|
||||
|
||||
/* The device id used by the cache manager. */
|
||||
enum grub_disk_dev_id id;
|
||||
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*disk_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. */
|
||||
grub_err_t (*disk_open) (const char *name, struct grub_disk *disk);
|
||||
|
||||
/* Close the disk DISK. */
|
||||
void (*disk_close) (struct grub_disk *disk);
|
||||
|
||||
/* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF. */
|
||||
grub_err_t (*disk_read) (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, char *buf);
|
||||
|
||||
/* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK. */
|
||||
grub_err_t (*disk_write) (struct grub_disk *disk, grub_disk_addr_t sector,
|
||||
grub_size_t size, const char *buf);
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_disk_memberlist *(*disk_memberlist) (struct grub_disk *disk);
|
||||
const char * (*disk_raidname) (struct grub_disk *disk);
|
||||
#endif
|
||||
|
||||
/* The next disk device. */
|
||||
struct grub_disk_dev *next;
|
||||
};
|
||||
typedef struct grub_disk_dev *grub_disk_dev_t;
|
||||
|
||||
extern grub_disk_dev_t EXPORT_VAR (grub_disk_dev_list);
|
||||
|
||||
struct grub_partition;
|
||||
|
||||
typedef void (*grub_disk_read_hook_t) (grub_disk_addr_t sector,
|
||||
unsigned offset, unsigned length,
|
||||
void *data);
|
||||
|
||||
/* Disk. */
|
||||
struct grub_disk
|
||||
{
|
||||
/* The disk name. */
|
||||
const char *name;
|
||||
|
||||
/* The underlying disk device. */
|
||||
grub_disk_dev_t dev;
|
||||
|
||||
/* The total number of sectors. */
|
||||
grub_uint64_t total_sectors;
|
||||
|
||||
/* Logarithm of sector size. */
|
||||
unsigned int log_sector_size;
|
||||
|
||||
/* Maximum number of sectors read divided by GRUB_DISK_CACHE_SIZE. */
|
||||
unsigned int max_agglomerate;
|
||||
|
||||
/* The id used by the disk cache manager. */
|
||||
unsigned long id;
|
||||
|
||||
/* The partition information. This is machine-specific. */
|
||||
struct grub_partition *partition;
|
||||
|
||||
/* Called when a sector was read. OFFSET is between 0 and
|
||||
the sector size minus 1, and LENGTH is between 0 and the sector size. */
|
||||
grub_disk_read_hook_t read_hook;
|
||||
|
||||
/* Caller-specific data passed to the read hook. */
|
||||
void *read_hook_data;
|
||||
|
||||
/* Device-specific data. */
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_disk *grub_disk_t;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
struct grub_disk_memberlist
|
||||
{
|
||||
grub_disk_t disk;
|
||||
struct grub_disk_memberlist *next;
|
||||
};
|
||||
typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
|
||||
#endif
|
||||
|
||||
/* The sector size. */
|
||||
#define GRUB_DISK_SECTOR_SIZE 0x200
|
||||
#define GRUB_DISK_SECTOR_BITS 9
|
||||
|
||||
/* The maximum number of disk caches. */
|
||||
#define GRUB_DISK_CACHE_NUM 1021
|
||||
|
||||
/* The size of a disk cache in 512B units. Must be at least as big as the
|
||||
largest supported sector size, currently 16K. */
|
||||
#define GRUB_DISK_CACHE_BITS 6
|
||||
#define GRUB_DISK_CACHE_SIZE (1 << GRUB_DISK_CACHE_BITS)
|
||||
|
||||
#define GRUB_DISK_MAX_MAX_AGGLOMERATE ((1 << (30 - GRUB_DISK_CACHE_BITS - GRUB_DISK_SECTOR_BITS)) - 1)
|
||||
|
||||
/* Return value of grub_disk_get_size() in case disk size is unknown. */
|
||||
#define GRUB_DISK_SIZE_UNKNOWN 0xffffffffffffffffULL
|
||||
|
||||
/* This is called from the memory manager. */
|
||||
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 (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->disk_iterate && (p->disk_iterate) (hook, hook_data, pull))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
|
||||
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
|
||||
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read)(void *chunklist, grub_uint64_t sector,
|
||||
grub_uint64_t size, grub_uint32_t log_sector_size);
|
||||
grub_err_t EXPORT_FUNC(grub_disk_blocklist_read2)(grub_disk_t disk, grub_uint64_t sector,
|
||||
grub_uint64_t size, char *buf);
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
void *buf);
|
||||
grub_err_t grub_disk_write (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
const void *buf);
|
||||
extern grub_err_t (*EXPORT_VAR(grub_disk_write_weak)) (grub_disk_t disk,
|
||||
grub_disk_addr_t sector,
|
||||
grub_off_t offset,
|
||||
grub_size_t size,
|
||||
const void *buf);
|
||||
|
||||
|
||||
grub_uint64_t EXPORT_FUNC(grub_disk_get_size) (grub_disk_t disk);
|
||||
|
||||
#if DISK_CACHE_STATS
|
||||
void
|
||||
EXPORT_FUNC(grub_disk_cache_get_performance) (unsigned long *hits, unsigned long *misses);
|
||||
#endif
|
||||
|
||||
extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
|
||||
extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
|
||||
|
||||
static inline void
|
||||
grub_stop_disk_firmware (void)
|
||||
{
|
||||
/* To prevent two drivers operating on the same disks. */
|
||||
grub_disk_firmware_is_tainted = 1;
|
||||
if (grub_disk_firmware_fini)
|
||||
{
|
||||
grub_disk_firmware_fini ();
|
||||
grub_disk_firmware_fini = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disk cache. */
|
||||
struct grub_disk_cache
|
||||
{
|
||||
enum grub_disk_dev_id dev_id;
|
||||
unsigned long disk_id;
|
||||
grub_disk_addr_t sector;
|
||||
char *data;
|
||||
int lock;
|
||||
};
|
||||
|
||||
extern struct grub_disk_cache EXPORT_VAR(grub_disk_cache_table)[GRUB_DISK_CACHE_NUM];
|
||||
|
||||
#if defined (GRUB_UTIL)
|
||||
void grub_lvm_init (void);
|
||||
void grub_ldm_init (void);
|
||||
void grub_mdraid09_init (void);
|
||||
void grub_mdraid1x_init (void);
|
||||
void grub_diskfilter_init (void);
|
||||
void grub_lvm_fini (void);
|
||||
void grub_ldm_fini (void);
|
||||
void grub_mdraid09_fini (void);
|
||||
void grub_mdraid1x_fini (void);
|
||||
void grub_diskfilter_fini (void);
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_DISK_HEADER */
|
||||
@@ -0,0 +1,309 @@
|
||||
/* dl.h - types and prototypes for loadable module support */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,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
|
||||
* 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_DL_H
|
||||
#define GRUB_DL_H 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#ifndef ASM_FILE
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/elf.h>
|
||||
#include <grub/list.h>
|
||||
#include <grub/misc.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros GRUB_MOD_INIT and GRUB_MOD_FINI are also used by build rules
|
||||
* to collect module names, so we define them only when they are not
|
||||
* defined already.
|
||||
*/
|
||||
#ifndef ASM_FILE
|
||||
|
||||
#ifndef GRUB_MOD_INIT
|
||||
|
||||
#if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_KERNEL)
|
||||
|
||||
#define GRUB_MOD_INIT(name) \
|
||||
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
|
||||
static void \
|
||||
grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
|
||||
|
||||
#define GRUB_MOD_FINI(name) \
|
||||
static void grub_mod_fini (void) __attribute__ ((used)); \
|
||||
static void \
|
||||
grub_mod_fini (void)
|
||||
|
||||
#elif defined (GRUB_KERNEL)
|
||||
|
||||
#define GRUB_MOD_INIT(name) \
|
||||
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
|
||||
void \
|
||||
grub_##name##_init (void) { grub_mod_init (0); } \
|
||||
static void \
|
||||
grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
|
||||
|
||||
#define GRUB_MOD_FINI(name) \
|
||||
static void grub_mod_fini (void) __attribute__ ((used)); \
|
||||
void \
|
||||
grub_##name##_fini (void) { grub_mod_fini (); } \
|
||||
static void \
|
||||
grub_mod_fini (void)
|
||||
|
||||
#else
|
||||
|
||||
#define GRUB_MOD_INIT(name) \
|
||||
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
|
||||
void grub_##name##_init (void); \
|
||||
void \
|
||||
grub_##name##_init (void) { grub_mod_init (0); } \
|
||||
static void \
|
||||
grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
|
||||
|
||||
#define GRUB_MOD_FINI(name) \
|
||||
static void grub_mod_fini (void) __attribute__ ((used)); \
|
||||
void grub_##name##_fini (void); \
|
||||
void \
|
||||
grub_##name##_fini (void) { grub_mod_fini (); } \
|
||||
static void \
|
||||
grub_mod_fini (void)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef ASM_FILE
|
||||
#ifdef __APPLE__
|
||||
#define GRUB_MOD_SECTION(x) "_" #x ", _" #x ""
|
||||
#else
|
||||
#define GRUB_MOD_SECTION(x) "." #x
|
||||
#endif
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
#define GRUB_MOD_SECTION(x) _ ## x , _ ##x
|
||||
#else
|
||||
#define GRUB_MOD_SECTION(x) . ## x
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Me, Vladimir Serbinenko, hereby I add this module check as per new
|
||||
GNU module policy. Note that this license check is informative only.
|
||||
Modules have to be licensed under GPLv3 or GPLv3+ (optionally
|
||||
multi-licensed under other licences as well) independently of the
|
||||
presence of this check and solely by linking (module loading in GRUB
|
||||
constitutes linking) and GRUB core being licensed under GPLv3+.
|
||||
Be sure to understand your license obligations.
|
||||
*/
|
||||
#ifndef ASM_FILE
|
||||
#if GNUC_PREREQ (3,2)
|
||||
#define ATTRIBUTE_USED __used__
|
||||
#else
|
||||
#define ATTRIBUTE_USED __unused__
|
||||
#endif
|
||||
#define GRUB_MOD_LICENSE(license) \
|
||||
static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION (module_license)), ATTRIBUTE_USED)) = "LICENSE=" license;
|
||||
#define GRUB_MOD_DEP(name) \
|
||||
static const char grub_module_depend_##name[] \
|
||||
__attribute__((section(GRUB_MOD_SECTION(moddeps)), ATTRIBUTE_USED)) = #name
|
||||
#define GRUB_MOD_NAME(name) \
|
||||
static const char grub_module_name_##name[] \
|
||||
__attribute__((section(GRUB_MOD_SECTION(modname)), __used__)) = #name
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
.macro GRUB_MOD_LICENSE
|
||||
.section GRUB_MOD_SECTION(module_license)
|
||||
.ascii "LICENSE="
|
||||
.ascii $0
|
||||
.byte 0
|
||||
.endm
|
||||
#else
|
||||
.macro GRUB_MOD_LICENSE license
|
||||
.section GRUB_MOD_SECTION(module_license), "a"
|
||||
.ascii "LICENSE="
|
||||
.ascii "\license"
|
||||
.byte 0
|
||||
.endm
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Under GPL license obligations you have to distribute your module
|
||||
under GPLv3(+). However, you can also distribute the same code under
|
||||
another license as long as GPLv3(+) version is provided.
|
||||
*/
|
||||
#define GRUB_MOD_DUAL_LICENSE(x)
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
struct grub_dl_segment
|
||||
{
|
||||
struct grub_dl_segment *next;
|
||||
void *addr;
|
||||
grub_size_t size;
|
||||
unsigned section;
|
||||
};
|
||||
typedef struct grub_dl_segment *grub_dl_segment_t;
|
||||
|
||||
struct grub_dl;
|
||||
|
||||
struct grub_dl_dep
|
||||
{
|
||||
struct grub_dl_dep *next;
|
||||
struct grub_dl *mod;
|
||||
};
|
||||
typedef struct grub_dl_dep *grub_dl_dep_t;
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
struct grub_dl
|
||||
{
|
||||
char *name;
|
||||
int ref_count;
|
||||
int persistent;
|
||||
grub_dl_dep_t dep;
|
||||
grub_dl_segment_t segment;
|
||||
Elf_Sym *symtab;
|
||||
grub_size_t symsize;
|
||||
void (*init) (struct grub_dl *mod);
|
||||
void (*fini) (void);
|
||||
#if !defined (__i386__) && !defined (__x86_64__)
|
||||
void *got;
|
||||
void *gotptr;
|
||||
void *tramp;
|
||||
void *trampptr;
|
||||
#endif
|
||||
#if defined(__mips__) && (_MIPS_SIM != _ABI64)
|
||||
grub_uint32_t *reginfo;
|
||||
#endif
|
||||
void *base;
|
||||
grub_size_t sz;
|
||||
struct grub_dl *next;
|
||||
};
|
||||
#endif
|
||||
typedef struct grub_dl *grub_dl_t;
|
||||
|
||||
grub_dl_t grub_dl_load_file (const char *filename);
|
||||
grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
|
||||
grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
|
||||
grub_dl_t EXPORT_FUNC(grub_dl_load_core_noinit) (void *addr, grub_size_t size);
|
||||
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
|
||||
void grub_dl_unload_unneeded (void);
|
||||
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
|
||||
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
|
||||
extern grub_dl_t EXPORT_VAR(grub_dl_head);
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
|
||||
#define FOR_DL_MODULES(var) FOR_LIST_ELEMENTS ((var), (grub_dl_head))
|
||||
|
||||
#ifdef GRUB_MACHINE_EMU
|
||||
void *
|
||||
grub_osdep_dl_memalign (grub_size_t align, grub_size_t size);
|
||||
void
|
||||
grub_dl_osdep_dl_free (void *ptr);
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_dl_init (grub_dl_t mod)
|
||||
{
|
||||
if (mod->init)
|
||||
(mod->init) (mod);
|
||||
|
||||
mod->next = grub_dl_head;
|
||||
grub_dl_head = mod;
|
||||
}
|
||||
|
||||
static inline grub_dl_t
|
||||
grub_dl_get (const char *name)
|
||||
{
|
||||
grub_dl_t l;
|
||||
|
||||
FOR_DL_MODULES(l)
|
||||
if (grub_strcmp (name, l->name) == 0)
|
||||
return l;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_dl_set_persistent (grub_dl_t mod)
|
||||
{
|
||||
mod->persistent = 1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_dl_is_persistent (grub_dl_t mod)
|
||||
{
|
||||
return mod->persistent;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
||||
int isfunc, grub_dl_t mod);
|
||||
|
||||
grub_err_t grub_arch_dl_check_header (void *ehdr);
|
||||
#ifndef GRUB_UTIL
|
||||
grub_err_t
|
||||
grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
|
||||
Elf_Shdr *s, grub_dl_segment_t seg);
|
||||
#endif
|
||||
|
||||
#if defined (__mips__) && (_MIPS_SIM != _ABI64)
|
||||
#define GRUB_LINKER_HAVE_INIT 1
|
||||
void grub_arch_dl_init_linker (void);
|
||||
#endif
|
||||
|
||||
#define GRUB_IA64_DL_TRAMP_ALIGN 16
|
||||
#define GRUB_IA64_DL_GOT_ALIGN 16
|
||||
|
||||
grub_err_t
|
||||
grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got);
|
||||
grub_err_t
|
||||
grub_arm64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got);
|
||||
|
||||
#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_get_tramp_got_size grub_ia64_dl_get_tramp_got_size
|
||||
#elif defined (__aarch64__)
|
||||
#define grub_arch_dl_get_tramp_got_size grub_arm64_dl_get_tramp_got_size
|
||||
#else
|
||||
grub_err_t
|
||||
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
|
||||
grub_size_t *got);
|
||||
#endif
|
||||
|
||||
#if defined (__powerpc__) || (defined (__mips__) && (_MIPS_SIM != _ABI64)) || defined (__arm__) || \
|
||||
(defined(__riscv) && (__riscv_xlen == 32))
|
||||
#define GRUB_ARCH_DL_TRAMP_ALIGN 4
|
||||
#define GRUB_ARCH_DL_GOT_ALIGN 4
|
||||
#endif
|
||||
|
||||
#if defined (__aarch64__) || defined (__sparc__) || (defined (__mips__) && (_MIPS_SIM == _ABI64)) || \
|
||||
(defined(__riscv) && (__riscv_xlen == 64))
|
||||
#define GRUB_ARCH_DL_TRAMP_ALIGN 8
|
||||
#define GRUB_ARCH_DL_GOT_ALIGN 8
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_DL_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,125 @@
|
||||
/* efi.h - declare variables and functions for EFI support */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,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
|
||||
* 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_EFI_EFI_HEADER
|
||||
#define GRUB_EFI_EFI_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/efi/api.h>
|
||||
|
||||
/* Functions. */
|
||||
void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
|
||||
void *registration);
|
||||
grub_efi_handle_t *
|
||||
EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type,
|
||||
grub_efi_guid_t *protocol,
|
||||
void *search_key,
|
||||
grub_efi_uintn_t *num_handles);
|
||||
void *EXPORT_FUNC(grub_efi_open_protocol) (grub_efi_handle_t handle,
|
||||
grub_efi_guid_t *protocol,
|
||||
grub_efi_uint32_t attributes);
|
||||
int EXPORT_FUNC(grub_efi_set_text_mode) (int on);
|
||||
void EXPORT_FUNC(grub_efi_stall) (grub_efi_uintn_t microseconds);
|
||||
void *
|
||||
EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address,
|
||||
grub_efi_uintn_t pages,
|
||||
grub_efi_allocate_type_t alloctype,
|
||||
grub_efi_memory_type_t memtype);
|
||||
void *
|
||||
EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address,
|
||||
grub_efi_uintn_t pages);
|
||||
void *
|
||||
EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages);
|
||||
void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address,
|
||||
grub_efi_uintn_t pages);
|
||||
grub_efi_uintn_t EXPORT_FUNC(grub_efi_find_mmap_size) (void);
|
||||
int
|
||||
EXPORT_FUNC(grub_efi_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);
|
||||
void grub_efi_memory_fini (void);
|
||||
grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle);
|
||||
void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
|
||||
char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
|
||||
grub_efi_device_path_t *
|
||||
EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle);
|
||||
grub_efi_device_path_t *
|
||||
EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp);
|
||||
grub_efi_device_path_t *
|
||||
EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp);
|
||||
grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf,
|
||||
grub_efi_uintn_t *map_key,
|
||||
grub_efi_uintn_t *efi_desc_size,
|
||||
grub_efi_uint32_t *efi_desc_version);
|
||||
grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memory_map_size,
|
||||
grub_efi_uintn_t descriptor_size,
|
||||
grub_efi_uint32_t descriptor_version,
|
||||
grub_efi_memory_descriptor_t *virtual_map);
|
||||
void *EXPORT_FUNC (grub_efi_get_variable) (const char *variable,
|
||||
const grub_efi_guid_t *guid,
|
||||
grub_size_t *datasize_out);
|
||||
grub_err_t
|
||||
EXPORT_FUNC (grub_efi_set_variable) (const char *var,
|
||||
const grub_efi_guid_t *guid,
|
||||
void *data,
|
||||
grub_size_t datasize);
|
||||
int
|
||||
EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
|
||||
const grub_efi_device_path_t *dp2);
|
||||
|
||||
void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size);
|
||||
void * EXPORT_FUNC (grub_efi_allocate_chain_buf) (grub_uint64_t size);
|
||||
void EXPORT_FUNC (grub_efi_get_reserved_page_num) (grub_uint64_t *total, grub_uint64_t *org_required, grub_uint64_t *new_required);
|
||||
|
||||
extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
|
||||
char **device,
|
||||
char **path);
|
||||
|
||||
#if defined(__arm__) || defined(__aarch64__) || defined(__riscv)
|
||||
void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
|
||||
grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
|
||||
#include <grub/cpu/linux.h>
|
||||
grub_err_t grub_arch_efi_linux_check_image(struct linux_arch_kernel_header *lh);
|
||||
grub_err_t grub_arch_efi_linux_boot_image(grub_addr_t addr, grub_size_t size,
|
||||
char *args);
|
||||
#endif
|
||||
|
||||
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);
|
||||
void grub_efi_fini (void);
|
||||
void grub_efi_set_prefix (void);
|
||||
|
||||
/* Variables. */
|
||||
extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
|
||||
extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
|
||||
|
||||
extern int EXPORT_VAR(grub_efi_is_finished);
|
||||
|
||||
struct grub_net_card;
|
||||
|
||||
grub_efi_handle_t
|
||||
grub_efinet_get_device_handle (struct grub_net_card *card);
|
||||
|
||||
#endif /* ! GRUB_EFI_EFI_HEADER */
|
||||
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,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
|
||||
* 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_EFI_PE32_HEADER
|
||||
#define GRUB_EFI_PE32_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
/* The MSDOS compatibility stub. This was copied from the output of
|
||||
objcopy, and it is not necessary to care about what this means. */
|
||||
#define GRUB_PE32_MSDOS_STUB \
|
||||
{ \
|
||||
0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, \
|
||||
0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, \
|
||||
0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, \
|
||||
0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, \
|
||||
0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68, \
|
||||
0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, \
|
||||
0x61, 0x6d, 0x20, 0x63, 0x61, 0x6e, 0x6e, 0x6f, \
|
||||
0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6e, \
|
||||
0x20, 0x69, 0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, \
|
||||
0x6d, 0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a, \
|
||||
0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \
|
||||
}
|
||||
|
||||
#define GRUB_PE32_MSDOS_STUB_SIZE 0x80
|
||||
|
||||
#define GRUB_PE32_MAGIC 0x5a4d
|
||||
|
||||
/* According to the spec, the minimal alignment is 512 bytes...
|
||||
But some examples (such as EFI drivers in the Intel
|
||||
Sample Implementation) use 32 bytes (0x20) instead, and it seems
|
||||
to be working.
|
||||
|
||||
However, there is firmware showing up in the field now with
|
||||
page alignment constraints to guarantee that page protection
|
||||
bits take effect. Because currently existing GRUB code can not
|
||||
properly distinguish between in-memory and in-file layout, let's
|
||||
bump all alignment to GRUB_EFI_PAGE_SIZE. */
|
||||
#define GRUB_PE32_SECTION_ALIGNMENT GRUB_EFI_PAGE_SIZE
|
||||
#define GRUB_PE32_FILE_ALIGNMENT GRUB_PE32_SECTION_ALIGNMENT
|
||||
|
||||
struct grub_pe32_coff_header
|
||||
{
|
||||
grub_uint16_t machine;
|
||||
grub_uint16_t num_sections;
|
||||
grub_uint32_t time;
|
||||
grub_uint32_t symtab_offset;
|
||||
grub_uint32_t num_symbols;
|
||||
grub_uint16_t optional_header_size;
|
||||
grub_uint16_t characteristics;
|
||||
};
|
||||
|
||||
#define GRUB_PE32_MACHINE_I386 0x14c
|
||||
#define GRUB_PE32_MACHINE_MIPS 0x166
|
||||
#define GRUB_PE32_MACHINE_IA64 0x200
|
||||
#define GRUB_PE32_MACHINE_X86_64 0x8664
|
||||
#define GRUB_PE32_MACHINE_ARMTHUMB_MIXED 0x01c2
|
||||
#define GRUB_PE32_MACHINE_ARM64 0xAA64
|
||||
#define GRUB_PE32_MACHINE_RISCV32 0x5032
|
||||
#define GRUB_PE32_MACHINE_RISCV64 0x5064
|
||||
|
||||
#define GRUB_PE32_RELOCS_STRIPPED 0x0001
|
||||
#define GRUB_PE32_EXECUTABLE_IMAGE 0x0002
|
||||
#define GRUB_PE32_LINE_NUMS_STRIPPED 0x0004
|
||||
#define GRUB_PE32_LOCAL_SYMS_STRIPPED 0x0008
|
||||
#define GRUB_PE32_AGGRESSIVE_WS_TRIM 0x0010
|
||||
#define GRUB_PE32_LARGE_ADDRESS_AWARE 0x0020
|
||||
#define GRUB_PE32_16BIT_MACHINE 0x0040
|
||||
#define GRUB_PE32_BYTES_REVERSED_LO 0x0080
|
||||
#define GRUB_PE32_32BIT_MACHINE 0x0100
|
||||
#define GRUB_PE32_DEBUG_STRIPPED 0x0200
|
||||
#define GRUB_PE32_REMOVABLE_RUN_FROM_SWAP 0x0400
|
||||
#define GRUB_PE32_SYSTEM 0x1000
|
||||
#define GRUB_PE32_DLL 0x2000
|
||||
#define GRUB_PE32_UP_SYSTEM_ONLY 0x4000
|
||||
#define GRUB_PE32_BYTES_REVERSED_HI 0x8000
|
||||
|
||||
struct grub_pe32_data_directory
|
||||
{
|
||||
grub_uint32_t rva;
|
||||
grub_uint32_t size;
|
||||
};
|
||||
|
||||
struct grub_pe32_optional_header
|
||||
{
|
||||
grub_uint16_t magic;
|
||||
grub_uint8_t major_linker_version;
|
||||
grub_uint8_t minor_linker_version;
|
||||
grub_uint32_t code_size;
|
||||
grub_uint32_t data_size;
|
||||
grub_uint32_t bss_size;
|
||||
grub_uint32_t entry_addr;
|
||||
grub_uint32_t code_base;
|
||||
|
||||
grub_uint32_t data_base;
|
||||
grub_uint32_t image_base;
|
||||
|
||||
grub_uint32_t section_alignment;
|
||||
grub_uint32_t file_alignment;
|
||||
grub_uint16_t major_os_version;
|
||||
grub_uint16_t minor_os_version;
|
||||
grub_uint16_t major_image_version;
|
||||
grub_uint16_t minor_image_version;
|
||||
grub_uint16_t major_subsystem_version;
|
||||
grub_uint16_t minor_subsystem_version;
|
||||
grub_uint32_t reserved;
|
||||
grub_uint32_t image_size;
|
||||
grub_uint32_t header_size;
|
||||
grub_uint32_t checksum;
|
||||
grub_uint16_t subsystem;
|
||||
grub_uint16_t dll_characteristics;
|
||||
|
||||
grub_uint32_t stack_reserve_size;
|
||||
grub_uint32_t stack_commit_size;
|
||||
grub_uint32_t heap_reserve_size;
|
||||
grub_uint32_t heap_commit_size;
|
||||
|
||||
grub_uint32_t loader_flags;
|
||||
grub_uint32_t num_data_directories;
|
||||
|
||||
/* Data directories. */
|
||||
struct grub_pe32_data_directory export_table;
|
||||
struct grub_pe32_data_directory import_table;
|
||||
struct grub_pe32_data_directory resource_table;
|
||||
struct grub_pe32_data_directory exception_table;
|
||||
struct grub_pe32_data_directory certificate_table;
|
||||
struct grub_pe32_data_directory base_relocation_table;
|
||||
struct grub_pe32_data_directory debug;
|
||||
struct grub_pe32_data_directory architecture;
|
||||
struct grub_pe32_data_directory global_ptr;
|
||||
struct grub_pe32_data_directory tls_table;
|
||||
struct grub_pe32_data_directory load_config_table;
|
||||
struct grub_pe32_data_directory bound_import;
|
||||
struct grub_pe32_data_directory iat;
|
||||
struct grub_pe32_data_directory delay_import_descriptor;
|
||||
struct grub_pe32_data_directory com_runtime_header;
|
||||
struct grub_pe32_data_directory reserved_entry;
|
||||
};
|
||||
|
||||
struct grub_pe64_optional_header
|
||||
{
|
||||
grub_uint16_t magic;
|
||||
grub_uint8_t major_linker_version;
|
||||
grub_uint8_t minor_linker_version;
|
||||
grub_uint32_t code_size;
|
||||
grub_uint32_t data_size;
|
||||
grub_uint32_t bss_size;
|
||||
grub_uint32_t entry_addr;
|
||||
grub_uint32_t code_base;
|
||||
|
||||
grub_uint64_t image_base;
|
||||
|
||||
grub_uint32_t section_alignment;
|
||||
grub_uint32_t file_alignment;
|
||||
grub_uint16_t major_os_version;
|
||||
grub_uint16_t minor_os_version;
|
||||
grub_uint16_t major_image_version;
|
||||
grub_uint16_t minor_image_version;
|
||||
grub_uint16_t major_subsystem_version;
|
||||
grub_uint16_t minor_subsystem_version;
|
||||
grub_uint32_t reserved;
|
||||
grub_uint32_t image_size;
|
||||
grub_uint32_t header_size;
|
||||
grub_uint32_t checksum;
|
||||
grub_uint16_t subsystem;
|
||||
grub_uint16_t dll_characteristics;
|
||||
|
||||
grub_uint64_t stack_reserve_size;
|
||||
grub_uint64_t stack_commit_size;
|
||||
grub_uint64_t heap_reserve_size;
|
||||
grub_uint64_t heap_commit_size;
|
||||
|
||||
grub_uint32_t loader_flags;
|
||||
grub_uint32_t num_data_directories;
|
||||
|
||||
/* Data directories. */
|
||||
struct grub_pe32_data_directory export_table;
|
||||
struct grub_pe32_data_directory import_table;
|
||||
struct grub_pe32_data_directory resource_table;
|
||||
struct grub_pe32_data_directory exception_table;
|
||||
struct grub_pe32_data_directory certificate_table;
|
||||
struct grub_pe32_data_directory base_relocation_table;
|
||||
struct grub_pe32_data_directory debug;
|
||||
struct grub_pe32_data_directory architecture;
|
||||
struct grub_pe32_data_directory global_ptr;
|
||||
struct grub_pe32_data_directory tls_table;
|
||||
struct grub_pe32_data_directory load_config_table;
|
||||
struct grub_pe32_data_directory bound_import;
|
||||
struct grub_pe32_data_directory iat;
|
||||
struct grub_pe32_data_directory delay_import_descriptor;
|
||||
struct grub_pe32_data_directory com_runtime_header;
|
||||
struct grub_pe32_data_directory reserved_entry;
|
||||
};
|
||||
|
||||
#define GRUB_PE32_PE32_MAGIC 0x10b
|
||||
#define GRUB_PE32_PE64_MAGIC 0x20b
|
||||
|
||||
#define GRUB_PE32_SUBSYSTEM_EFI_APPLICATION 10
|
||||
|
||||
#define GRUB_PE32_NUM_DATA_DIRECTORIES 16
|
||||
|
||||
struct grub_pe32_section_table
|
||||
{
|
||||
char name[8];
|
||||
grub_uint32_t virtual_size;
|
||||
grub_uint32_t virtual_address;
|
||||
grub_uint32_t raw_data_size;
|
||||
grub_uint32_t raw_data_offset;
|
||||
grub_uint32_t relocations_offset;
|
||||
grub_uint32_t line_numbers_offset;
|
||||
grub_uint16_t num_relocations;
|
||||
grub_uint16_t num_line_numbers;
|
||||
grub_uint32_t characteristics;
|
||||
};
|
||||
|
||||
#define GRUB_PE32_SCN_CNT_CODE 0x00000020
|
||||
#define GRUB_PE32_SCN_CNT_INITIALIZED_DATA 0x00000040
|
||||
#define GRUB_PE32_SCN_MEM_DISCARDABLE 0x02000000
|
||||
#define GRUB_PE32_SCN_MEM_EXECUTE 0x20000000
|
||||
#define GRUB_PE32_SCN_MEM_READ 0x40000000
|
||||
#define GRUB_PE32_SCN_MEM_WRITE 0x80000000
|
||||
|
||||
#define GRUB_PE32_SCN_ALIGN_1BYTES 0x00100000
|
||||
#define GRUB_PE32_SCN_ALIGN_2BYTES 0x00200000
|
||||
#define GRUB_PE32_SCN_ALIGN_4BYTES 0x00300000
|
||||
#define GRUB_PE32_SCN_ALIGN_8BYTES 0x00400000
|
||||
#define GRUB_PE32_SCN_ALIGN_16BYTES 0x00500000
|
||||
#define GRUB_PE32_SCN_ALIGN_32BYTES 0x00600000
|
||||
#define GRUB_PE32_SCN_ALIGN_64BYTES 0x00700000
|
||||
|
||||
#define GRUB_PE32_SCN_ALIGN_SHIFT 20
|
||||
#define GRUB_PE32_SCN_ALIGN_MASK 7
|
||||
|
||||
#define GRUB_PE32_SIGNATURE_SIZE 4
|
||||
|
||||
struct grub_pe32_header
|
||||
{
|
||||
/* This should be filled in with GRUB_PE32_MSDOS_STUB. */
|
||||
grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
|
||||
|
||||
/* This is always PE\0\0. */
|
||||
char signature[GRUB_PE32_SIGNATURE_SIZE];
|
||||
|
||||
/* The COFF file header. */
|
||||
struct grub_pe32_coff_header coff_header;
|
||||
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P == 8
|
||||
/* The Optional header. */
|
||||
struct grub_pe64_optional_header optional_header;
|
||||
#else
|
||||
/* The Optional header. */
|
||||
struct grub_pe32_optional_header optional_header;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct grub_pe32_fixup_block
|
||||
{
|
||||
grub_uint32_t page_rva;
|
||||
grub_uint32_t block_size;
|
||||
grub_uint16_t entries[0];
|
||||
};
|
||||
|
||||
#define GRUB_PE32_FIXUP_ENTRY(type, offset) (((type) << 12) | (offset))
|
||||
|
||||
#define GRUB_PE32_REL_BASED_ABSOLUTE 0
|
||||
#define GRUB_PE32_REL_BASED_HIGH 1
|
||||
#define GRUB_PE32_REL_BASED_LOW 2
|
||||
#define GRUB_PE32_REL_BASED_HIGHLOW 3
|
||||
#define GRUB_PE32_REL_BASED_HIGHADJ 4
|
||||
#define GRUB_PE32_REL_BASED_MIPS_JMPADDR 5
|
||||
#define GRUB_PE32_REL_BASED_MIPS_LOW 6
|
||||
#define GRUB_PE32_REL_BASED_MIPS_HIGH 4
|
||||
#define GRUB_PE32_REL_BASED_MIPS_HIGHER 7
|
||||
#define GRUB_PE32_REL_BASED_MIPS_HIGHEST 8
|
||||
#define GRUB_PE32_REL_BASED_ARM_MOV32A 5
|
||||
#define GRUB_PE32_REL_BASED_RISCV_HI20 5
|
||||
#define GRUB_PE32_REL_BASED_SECTION 6
|
||||
#define GRUB_PE32_REL_BASED_REL 7
|
||||
#define GRUB_PE32_REL_BASED_ARM_MOV32T 7
|
||||
#define GRUB_PE32_REL_BASED_RISCV_LOW12I 7
|
||||
#define GRUB_PE32_REL_BASED_RISCV_LOW12S 8
|
||||
#define GRUB_PE32_REL_BASED_IA64_IMM64 9
|
||||
#define GRUB_PE32_REL_BASED_DIR64 10
|
||||
#define GRUB_PE32_REL_BASED_HIGH3ADJ 11
|
||||
|
||||
struct grub_pe32_symbol
|
||||
{
|
||||
union
|
||||
{
|
||||
char short_name[8];
|
||||
grub_uint32_t long_name[2];
|
||||
};
|
||||
|
||||
grub_uint32_t value;
|
||||
grub_uint16_t section;
|
||||
grub_uint16_t type;
|
||||
grub_uint8_t storage_class;
|
||||
grub_uint8_t num_aux;
|
||||
} GRUB_PACKED;
|
||||
|
||||
#define GRUB_PE32_SYM_CLASS_EXTERNAL 2
|
||||
#define GRUB_PE32_SYM_CLASS_STATIC 3
|
||||
#define GRUB_PE32_SYM_CLASS_FILE 0x67
|
||||
|
||||
#define GRUB_PE32_DT_FUNCTION 0x20
|
||||
|
||||
struct grub_pe32_reloc
|
||||
{
|
||||
grub_uint32_t offset;
|
||||
grub_uint32_t symtab_index;
|
||||
grub_uint16_t type;
|
||||
} GRUB_PACKED;
|
||||
|
||||
#define GRUB_PE32_REL_I386_DIR32 0x6
|
||||
#define GRUB_PE32_REL_I386_REL32 0x14
|
||||
|
||||
#endif /* ! GRUB_EFI_PE32_HEADER */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2005,2006,2007,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_ENV_HEADER
|
||||
#define GRUB_ENV_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/menu.h>
|
||||
|
||||
#define VTOY_SB_POLICY_BYPASS 0
|
||||
#define VTOY_SB_POLICY_CHECK 1
|
||||
extern grub_uint8_t EXPORT_VAR(g_sys_sb);
|
||||
extern grub_uint8_t EXPORT_VAR(g_sb_policy);
|
||||
|
||||
struct grub_env_var;
|
||||
|
||||
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);
|
||||
|
||||
struct grub_env_var
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
grub_env_read_hook_t read_hook;
|
||||
grub_env_write_hook_t write_hook;
|
||||
struct grub_env_var *next;
|
||||
struct grub_env_var **prevp;
|
||||
struct grub_env_var *sorted_next;
|
||||
int global;
|
||||
};
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
|
||||
const char *EXPORT_FUNC(grub_env_get) (const char *name);
|
||||
void EXPORT_FUNC(grub_env_unset) (const char *name);
|
||||
struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
|
||||
|
||||
#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
|
||||
|
||||
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
|
||||
grub_env_read_hook_t read_hook,
|
||||
grub_env_write_hook_t write_hook);
|
||||
grub_err_t EXPORT_FUNC(grub_register_vtoy_menu_lang_hook) (grub_env_read_hook_t read_hook);
|
||||
|
||||
grub_err_t grub_env_context_open (void);
|
||||
grub_err_t grub_env_context_close (void);
|
||||
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
|
||||
|
||||
void grub_env_unset_menu (void);
|
||||
grub_menu_t grub_env_get_menu (void);
|
||||
void grub_env_set_menu (grub_menu_t nmenu);
|
||||
|
||||
grub_err_t
|
||||
grub_env_extractor_open (int source);
|
||||
|
||||
grub_err_t
|
||||
grub_env_extractor_close (int source);
|
||||
|
||||
|
||||
#endif /* ! GRUB_ENV_HEADER */
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,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_FILE_HEADER
|
||||
#define GRUB_FILE_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/fs.h>
|
||||
#include <grub/disk.h>
|
||||
|
||||
enum grub_file_type
|
||||
{
|
||||
GRUB_FILE_TYPE_NONE = 0,
|
||||
/* GRUB module to be loaded. */
|
||||
GRUB_FILE_TYPE_GRUB_MODULE,
|
||||
/* Loopback file to be represented as disk. */
|
||||
GRUB_FILE_TYPE_LOOPBACK,
|
||||
/* Linux kernel to be loaded. */
|
||||
GRUB_FILE_TYPE_LINUX_KERNEL,
|
||||
/* Linux initrd. */
|
||||
GRUB_FILE_TYPE_LINUX_INITRD,
|
||||
|
||||
/* Multiboot kernel. */
|
||||
GRUB_FILE_TYPE_MULTIBOOT_KERNEL,
|
||||
/* Multiboot module. */
|
||||
GRUB_FILE_TYPE_MULTIBOOT_MODULE,
|
||||
|
||||
/* Xen hypervisor - used on ARM only. */
|
||||
GRUB_FILE_TYPE_XEN_HYPERVISOR,
|
||||
/* Xen module - used on ARM only. */
|
||||
GRUB_FILE_TYPE_XEN_MODULE,
|
||||
|
||||
GRUB_FILE_TYPE_BSD_KERNEL,
|
||||
GRUB_FILE_TYPE_FREEBSD_ENV,
|
||||
GRUB_FILE_TYPE_FREEBSD_MODULE,
|
||||
GRUB_FILE_TYPE_FREEBSD_MODULE_ELF,
|
||||
GRUB_FILE_TYPE_NETBSD_MODULE,
|
||||
GRUB_FILE_TYPE_OPENBSD_RAMDISK,
|
||||
|
||||
GRUB_FILE_TYPE_XNU_INFO_PLIST,
|
||||
GRUB_FILE_TYPE_XNU_MKEXT,
|
||||
GRUB_FILE_TYPE_XNU_KEXT,
|
||||
GRUB_FILE_TYPE_XNU_KERNEL,
|
||||
GRUB_FILE_TYPE_XNU_RAMDISK,
|
||||
GRUB_FILE_TYPE_XNU_HIBERNATE_IMAGE,
|
||||
GRUB_FILE_XNU_DEVPROP,
|
||||
|
||||
GRUB_FILE_TYPE_PLAN9_KERNEL,
|
||||
|
||||
GRUB_FILE_TYPE_NTLDR,
|
||||
GRUB_FILE_TYPE_TRUECRYPT,
|
||||
GRUB_FILE_TYPE_FREEDOS,
|
||||
GRUB_FILE_TYPE_PXECHAINLOADER,
|
||||
GRUB_FILE_TYPE_PCCHAINLOADER,
|
||||
|
||||
GRUB_FILE_TYPE_COREBOOT_CHAINLOADER,
|
||||
|
||||
GRUB_FILE_TYPE_EFI_CHAINLOADED_IMAGE,
|
||||
|
||||
/* File holding signature. */
|
||||
GRUB_FILE_TYPE_SIGNATURE,
|
||||
/* File holding public key to verify signature once. */
|
||||
GRUB_FILE_TYPE_PUBLIC_KEY,
|
||||
/* File holding public key to add to trused keys. */
|
||||
GRUB_FILE_TYPE_PUBLIC_KEY_TRUST,
|
||||
/* File of which we intend to print a blocklist to the user. */
|
||||
GRUB_FILE_TYPE_PRINT_BLOCKLIST,
|
||||
/* File we intend to use for test loading or testing speed. */
|
||||
GRUB_FILE_TYPE_TESTLOAD,
|
||||
/* File we open only to get its size. E.g. in ls output. */
|
||||
GRUB_FILE_TYPE_GET_SIZE,
|
||||
/* Font file. */
|
||||
GRUB_FILE_TYPE_FONT,
|
||||
/* File holding encryption key for encrypted ZFS. */
|
||||
GRUB_FILE_TYPE_ZFS_ENCRYPTION_KEY,
|
||||
/* File we open n grub-fstest. */
|
||||
GRUB_FILE_TYPE_FSTEST,
|
||||
/* File we open n grub-mount. */
|
||||
GRUB_FILE_TYPE_MOUNT,
|
||||
/* File which we attempt to identify the type of. */
|
||||
GRUB_FILE_TYPE_FILE_ID,
|
||||
/* File holding ACPI table. */
|
||||
GRUB_FILE_TYPE_ACPI_TABLE,
|
||||
/* File holding Device Tree. */
|
||||
GRUB_FILE_TYPE_DEVICE_TREE_IMAGE,
|
||||
/* File we intend show to user. */
|
||||
GRUB_FILE_TYPE_CAT,
|
||||
GRUB_FILE_TYPE_HEXCAT,
|
||||
/* One of pair of files we intend to compare. */
|
||||
GRUB_FILE_TYPE_CMP,
|
||||
/* List of hashes for hashsum. */
|
||||
GRUB_FILE_TYPE_HASHLIST,
|
||||
/* File hashed by hashsum. */
|
||||
GRUB_FILE_TYPE_TO_HASH,
|
||||
/* Keyboard layout. */
|
||||
GRUB_FILE_TYPE_KEYBOARD_LAYOUT,
|
||||
/* Picture file. */
|
||||
GRUB_FILE_TYPE_PIXMAP,
|
||||
/* *.lst shipped by GRUB. */
|
||||
GRUB_FILE_TYPE_GRUB_MODULE_LIST,
|
||||
/* config file. */
|
||||
GRUB_FILE_TYPE_CONFIG,
|
||||
GRUB_FILE_TYPE_THEME,
|
||||
GRUB_FILE_TYPE_GETTEXT_CATALOG,
|
||||
GRUB_FILE_TYPE_FS_SEARCH,
|
||||
GRUB_FILE_TYPE_AUDIO,
|
||||
GRUB_FILE_TYPE_VBE_DUMP,
|
||||
|
||||
GRUB_FILE_TYPE_LOADENV,
|
||||
GRUB_FILE_TYPE_SAVEENV,
|
||||
|
||||
GRUB_FILE_TYPE_VERIFY_SIGNATURE,
|
||||
|
||||
GRUB_FILE_TYPE_MASK = 0xffff,
|
||||
|
||||
/* --skip-sig is specified. */
|
||||
GRUB_FILE_TYPE_SKIP_SIGNATURE = 0x10000,
|
||||
GRUB_FILE_TYPE_NO_DECOMPRESS = 0x20000,
|
||||
GRUB_FILE_TYPE_NO_VLNK = 0x40000,
|
||||
};
|
||||
|
||||
/* File description. */
|
||||
struct grub_file
|
||||
{
|
||||
/* File name. */
|
||||
char *name;
|
||||
|
||||
int vlnk;
|
||||
|
||||
/* The underlying device. */
|
||||
grub_device_t device;
|
||||
|
||||
/* The underlying filesystem. */
|
||||
grub_fs_t fs;
|
||||
|
||||
/* The current offset. */
|
||||
grub_off_t offset;
|
||||
grub_off_t progress_offset;
|
||||
|
||||
/* Progress info. */
|
||||
grub_uint64_t last_progress_time;
|
||||
grub_off_t last_progress_offset;
|
||||
grub_uint64_t estimated_speed;
|
||||
|
||||
/* The file size. */
|
||||
grub_off_t size;
|
||||
|
||||
/* If file is not easily seekable. Should be set by underlying layer. */
|
||||
int not_easily_seekable;
|
||||
|
||||
/* Filesystem-specific data. */
|
||||
void *data;
|
||||
|
||||
/* This is called when a sector is read. Used only for a disk device. */
|
||||
grub_disk_read_hook_t read_hook;
|
||||
|
||||
/* Caller-specific data passed to the read hook. */
|
||||
void *read_hook_data;
|
||||
};
|
||||
typedef struct grub_file *grub_file_t;
|
||||
|
||||
extern grub_disk_read_hook_t EXPORT_VAR(grub_file_progress_hook);
|
||||
|
||||
/* Filters with lower ID are executed first. */
|
||||
typedef enum grub_file_filter_id
|
||||
{
|
||||
GRUB_FILE_FILTER_VERIFY,
|
||||
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_LZOPIO,
|
||||
} grub_file_filter_id_t;
|
||||
|
||||
typedef grub_file_t (*grub_file_filter_t) (grub_file_t in, enum grub_file_type type);
|
||||
|
||||
extern grub_file_filter_t EXPORT_VAR(grub_file_filters)[GRUB_FILE_FILTER_MAX];
|
||||
|
||||
static inline void
|
||||
grub_file_filter_register (grub_file_filter_id_t id, grub_file_filter_t filter)
|
||||
{
|
||||
grub_file_filters[id] = filter;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_file_filter_unregister (grub_file_filter_id_t id)
|
||||
{
|
||||
grub_file_filters[id] = 0;
|
||||
}
|
||||
|
||||
/* Get a device name from NAME. */
|
||||
char *EXPORT_FUNC(grub_file_get_device_name) (const char *name);
|
||||
|
||||
int EXPORT_FUNC(ventoy_check_file_exist) (const char * fmt, ...);
|
||||
grub_file_t EXPORT_FUNC(grub_file_open) (const char *name, enum grub_file_type type);
|
||||
grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
|
||||
grub_size_t len);
|
||||
grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
|
||||
grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
|
||||
|
||||
int EXPORT_FUNC(grub_file_is_vlnk_suffix)(const char *name, int len);
|
||||
int EXPORT_FUNC(grub_file_add_vlnk)(const char *src, const char *dst);
|
||||
int EXPORT_FUNC(grub_file_vtoy_vlnk)(const char *src, const char *dst);
|
||||
const char * EXPORT_FUNC(grub_file_get_vlnk)(const char *name, int *vlnk);
|
||||
|
||||
/* Return value of grub_file_size() in case file size is unknown. */
|
||||
#define GRUB_FILE_SIZE_UNKNOWN 0xffffffffffffffffULL
|
||||
|
||||
static inline grub_off_t
|
||||
grub_file_size (const grub_file_t file)
|
||||
{
|
||||
return file->size;
|
||||
}
|
||||
|
||||
static inline grub_off_t
|
||||
grub_file_tell (const grub_file_t file)
|
||||
{
|
||||
return file->offset;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_file_seekable (const grub_file_t file)
|
||||
{
|
||||
return !file->not_easily_seekable;
|
||||
}
|
||||
|
||||
grub_file_t
|
||||
grub_file_offset_open (grub_file_t parent, enum grub_file_type type,
|
||||
grub_off_t start, grub_off_t size);
|
||||
void
|
||||
grub_file_offset_close (grub_file_t file);
|
||||
|
||||
#endif /* ! GRUB_FILE_HEADER */
|
||||
@@ -0,0 +1,133 @@
|
||||
/* fs.h - filesystem manager */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,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
|
||||
* 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_FS_HEADER
|
||||
#define GRUB_FS_HEADER 1
|
||||
|
||||
#include <grub/device.h>
|
||||
#include <grub/symbol.h>
|
||||
#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;
|
||||
|
||||
struct grub_dirhook_info
|
||||
{
|
||||
unsigned dir:1;
|
||||
unsigned mtimeset:1;
|
||||
unsigned case_insensitive:1;
|
||||
unsigned inodeset:1;
|
||||
grub_int32_t mtime;
|
||||
grub_uint64_t inode;
|
||||
grub_uint64_t size;
|
||||
};
|
||||
|
||||
typedef int (*grub_fs_dir_hook_t) (const char *filename,
|
||||
const struct grub_dirhook_info *info,
|
||||
void *data);
|
||||
|
||||
/* Filesystem descriptor. */
|
||||
struct grub_fs
|
||||
{
|
||||
/* The next filesystem. */
|
||||
struct grub_fs *next;
|
||||
struct grub_fs **prev;
|
||||
|
||||
/* My name. */
|
||||
const char *name;
|
||||
|
||||
/* Call HOOK with each file under DIR. */
|
||||
grub_err_t (*fs_dir) (grub_device_t device, const char *path,
|
||||
grub_fs_dir_hook_t hook, void *hook_data);
|
||||
|
||||
/* Open a file named NAME and initialize FILE. */
|
||||
grub_err_t (*fs_open) (struct grub_file *file, const char *name);
|
||||
|
||||
/* Read LEN bytes data from FILE into BUF. */
|
||||
grub_ssize_t (*fs_read) (struct grub_file *file, char *buf, grub_size_t len);
|
||||
|
||||
/* Close the file FILE. */
|
||||
grub_err_t (*fs_close) (struct grub_file *file);
|
||||
|
||||
/* Return the label of the device DEVICE in LABEL. The label is
|
||||
returned in a grub_malloc'ed buffer and should be freed by the
|
||||
caller. */
|
||||
grub_err_t (*fs_label) (grub_device_t device, char **label);
|
||||
|
||||
/* Return the uuid of the device DEVICE in UUID. The uuid is
|
||||
returned in a grub_malloc'ed buffer and should be freed by the
|
||||
caller. */
|
||||
grub_err_t (*fs_uuid) (grub_device_t device, char **uuid);
|
||||
|
||||
/* Get writing time of filesystem. */
|
||||
grub_err_t (*fs_mtime) (grub_device_t device, grub_int32_t *timebuf);
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
/* Determine sectors available for embedding. */
|
||||
grub_err_t (*fs_embed) (grub_device_t device, unsigned int *nsectors,
|
||||
unsigned int max_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;
|
||||
|
||||
/* Whether blocklist installs have a chance to work. */
|
||||
int blocklist_install;
|
||||
#endif
|
||||
};
|
||||
typedef struct grub_fs *grub_fs_t;
|
||||
|
||||
/* This is special, because block lists are not files in usual sense. */
|
||||
extern struct grub_fs grub_fs_blocklist;
|
||||
|
||||
/* This hook is used to automatically load filesystem modules.
|
||||
If this hook loads a module, return non-zero. Otherwise return zero.
|
||||
The newly loaded filesystem is assumed to be inserted into the head of
|
||||
the linked list GRUB_FS_LIST through the function grub_fs_register. */
|
||||
typedef int (*grub_fs_autoload_hook_t) (void);
|
||||
extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook);
|
||||
extern grub_fs_t EXPORT_VAR (grub_fs_list);
|
||||
|
||||
#ifndef GRUB_LST_GENERATOR
|
||||
static inline void
|
||||
grub_fs_register (grub_fs_t fs)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_fs_unregister (grub_fs_t fs)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (fs));
|
||||
}
|
||||
|
||||
#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
|
||||
|
||||
grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
|
||||
grub_fs_t EXPORT_FUNC(grub_fs_list_probe) (grub_device_t device, const char **list);
|
||||
|
||||
#endif /* ! GRUB_FS_HEADER */
|
||||
@@ -0,0 +1,128 @@
|
||||
/* gfxmenu_view.h - gfxmenu view interface. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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
|
||||
* 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_GFXMENU_VIEW_HEADER
|
||||
#define GRUB_GFXMENU_VIEW_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
|
||||
struct grub_gfxmenu_view; /* Forward declaration of opaque type. */
|
||||
typedef struct grub_gfxmenu_view *grub_gfxmenu_view_t;
|
||||
|
||||
|
||||
grub_gfxmenu_view_t grub_gfxmenu_view_new (const char *theme_path,
|
||||
int width, int height);
|
||||
|
||||
void grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view);
|
||||
|
||||
/* Set properties on the view based on settings from the specified
|
||||
theme file. */
|
||||
grub_err_t grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view,
|
||||
const char *theme_path);
|
||||
|
||||
grub_err_t grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
|
||||
const char *pattern, const char *theme_dir);
|
||||
|
||||
void grub_gfxmenu_view_draw (grub_gfxmenu_view_t view);
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_menu (grub_gfxmenu_view_t view);
|
||||
|
||||
void
|
||||
grub_gfxmenu_redraw_timeout (grub_gfxmenu_view_t view);
|
||||
|
||||
void
|
||||
grub_gfxmenu_view_redraw (grub_gfxmenu_view_t view,
|
||||
const grub_video_rect_t *region);
|
||||
|
||||
void
|
||||
grub_gfxmenu_clear_timeout (void *data);
|
||||
void
|
||||
grub_gfxmenu_print_timeout (int timeout, void *data);
|
||||
void
|
||||
grub_gfxmenu_set_chosen_entry (int entry, void *data);
|
||||
void
|
||||
grub_gfxmenu_scroll_chosen_entry (void *data, int diren);
|
||||
|
||||
grub_err_t grub_font_draw_string (const char *str,
|
||||
grub_font_t font,
|
||||
grub_video_color_t color,
|
||||
int left_x, int baseline_y);
|
||||
int grub_font_get_string_width (grub_font_t font,
|
||||
const char *str);
|
||||
|
||||
|
||||
/* Implementation details -- this should not be used outside of the
|
||||
view itself. */
|
||||
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/icon_manager.h>
|
||||
|
||||
/* Definition of the private representation of the view. */
|
||||
struct grub_gfxmenu_view
|
||||
{
|
||||
grub_video_rect_t screen;
|
||||
|
||||
int need_to_check_sanity;
|
||||
grub_video_rect_t terminal_rect;
|
||||
int terminal_border;
|
||||
|
||||
grub_font_t title_font;
|
||||
grub_font_t message_font;
|
||||
char *terminal_font_name;
|
||||
grub_video_rgba_color_t title_color;
|
||||
grub_video_rgba_color_t message_color;
|
||||
grub_video_rgba_color_t message_bg_color;
|
||||
struct grub_video_bitmap *raw_desktop_image;
|
||||
struct grub_video_bitmap *scaled_desktop_image;
|
||||
grub_video_bitmap_selection_method_t desktop_image_scale_method;
|
||||
grub_video_bitmap_h_align_t desktop_image_h_align;
|
||||
grub_video_bitmap_v_align_t desktop_image_v_align;
|
||||
grub_video_rgba_color_t desktop_color;
|
||||
grub_gfxmenu_box_t terminal_box;
|
||||
char *title_text;
|
||||
char *progress_message_text;
|
||||
char *theme_path;
|
||||
|
||||
grub_gui_container_t canvas;
|
||||
|
||||
int double_repaint;
|
||||
|
||||
int selected;
|
||||
|
||||
grub_video_rect_t progress_message_frame;
|
||||
|
||||
grub_menu_t menu;
|
||||
|
||||
int nested;
|
||||
|
||||
int first_timeout;
|
||||
|
||||
int *menu_title_offset;
|
||||
};
|
||||
|
||||
#endif /* ! GRUB_GFXMENU_VIEW_HEADER */
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2005,2006,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
|
||||
* 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_KERNEL_HEADER
|
||||
#define GRUB_KERNEL_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
enum
|
||||
{
|
||||
OBJ_TYPE_ELF,
|
||||
OBJ_TYPE_MEMDISK,
|
||||
OBJ_TYPE_CONFIG,
|
||||
OBJ_TYPE_PREFIX,
|
||||
OBJ_TYPE_PUBKEY,
|
||||
OBJ_TYPE_DTB
|
||||
};
|
||||
|
||||
/* The module header. */
|
||||
struct grub_module_header
|
||||
{
|
||||
/* The type of object. */
|
||||
grub_uint32_t type;
|
||||
/* The size of object (including this header). */
|
||||
grub_uint32_t size;
|
||||
};
|
||||
|
||||
/* "gmim" (GRUB Module Info Magic). */
|
||||
#define GRUB_MODULE_MAGIC 0x676d696d
|
||||
|
||||
struct grub_module_info32
|
||||
{
|
||||
/* Magic number so we know we have modules present. */
|
||||
grub_uint32_t magic;
|
||||
/* The offset of the modules. */
|
||||
grub_uint32_t offset;
|
||||
/* The size of all modules plus this header. */
|
||||
grub_uint32_t size;
|
||||
};
|
||||
|
||||
struct grub_module_info64
|
||||
{
|
||||
/* Magic number so we know we have modules present. */
|
||||
grub_uint32_t magic;
|
||||
grub_uint32_t padding;
|
||||
/* The offset of the modules. */
|
||||
grub_uint64_t offset;
|
||||
/* The size of all modules plus this header. */
|
||||
grub_uint64_t size;
|
||||
};
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
/* Space isn't reusable on some platforms. */
|
||||
/* On Qemu the preload space is readonly. */
|
||||
/* On emu there is no preload space. */
|
||||
/* On ieee1275 our code assumes that heap is p=v which isn't guaranteed for module space. */
|
||||
#if defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_EMU) \
|
||||
|| defined (GRUB_MACHINE_EFI) \
|
||||
|| (defined (GRUB_MACHINE_IEEE1275) && !defined (__sparc__))
|
||||
#define GRUB_KERNEL_PRELOAD_SPACE_REUSABLE 0
|
||||
#endif
|
||||
|
||||
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) \
|
||||
|| defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) \
|
||||
|| defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_ARC) \
|
||||
|| (defined (__sparc__) && defined (GRUB_MACHINE_IEEE1275)) \
|
||||
|| defined (GRUB_MACHINE_UBOOT) || defined (GRUB_MACHINE_XEN) \
|
||||
|| defined(GRUB_MACHINE_XEN_PVH)
|
||||
/* FIXME: stack is between 2 heap regions. Move it. */
|
||||
#define GRUB_KERNEL_PRELOAD_SPACE_REUSABLE 1
|
||||
#endif
|
||||
|
||||
#ifndef GRUB_KERNEL_PRELOAD_SPACE_REUSABLE
|
||||
#error "Please check if preload space is reusable on this platform!"
|
||||
#endif
|
||||
|
||||
#if GRUB_TARGET_SIZEOF_VOID_P == 8
|
||||
#define grub_module_info grub_module_info64
|
||||
#else
|
||||
#define grub_module_info grub_module_info32
|
||||
#endif
|
||||
|
||||
extern grub_addr_t EXPORT_VAR (grub_modbase);
|
||||
|
||||
void EXPORT_FUNC(ventoy_env_hook_root)(int hook);
|
||||
|
||||
#define FOR_MODULES(var) for (\
|
||||
var = (grub_modbase && ((((struct grub_module_info *) grub_modbase)->magic) == GRUB_MODULE_MAGIC)) ? (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 + 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);
|
||||
|
||||
#endif
|
||||
|
||||
/* The start point of the C code. */
|
||||
void grub_main (void) __attribute__ ((noreturn));
|
||||
|
||||
/* The machine-specific initialization. This must initialize memory. */
|
||||
void grub_machine_init (void);
|
||||
|
||||
/* The machine-specific finalization. */
|
||||
void EXPORT_FUNC(grub_machine_fini) (int flags);
|
||||
|
||||
/* The machine-specific prefix initialization. */
|
||||
void
|
||||
grub_machine_get_bootlocation (char **device, char **path);
|
||||
|
||||
/* Register all the exported symbols. This is automatically generated. */
|
||||
void grub_register_exported_symbols (void);
|
||||
|
||||
extern void (*EXPORT_VAR(grub_net_poll_cards_idle)) (void);
|
||||
|
||||
#endif /* ! GRUB_KERNEL_HEADER */
|
||||
@@ -0,0 +1,119 @@
|
||||
/* menu.h - Menu model function prototypes and data structures. */
|
||||
/*
|
||||
* 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_MENU_HEADER
|
||||
#define GRUB_MENU_HEADER 1
|
||||
|
||||
struct bls_entry
|
||||
{
|
||||
struct bls_entry *next;
|
||||
struct bls_entry *prev;
|
||||
struct keyval **keyvals;
|
||||
int nkeyvals;
|
||||
char *filename;
|
||||
int visible;
|
||||
};
|
||||
|
||||
struct grub_menu_entry_class
|
||||
{
|
||||
char *name;
|
||||
struct grub_menu_entry_class *next;
|
||||
};
|
||||
|
||||
/* The menu entry. */
|
||||
struct grub_menu_entry
|
||||
{
|
||||
/* The title name. */
|
||||
const char *title;
|
||||
|
||||
/* The identifier. */
|
||||
const char *id;
|
||||
|
||||
/* 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,
|
||||
E.classes->next is the first class if it is not NULL. */
|
||||
struct grub_menu_entry_class *classes;
|
||||
|
||||
/* The sourcecode of the menu entry, used by the editor. */
|
||||
const char *sourcecode;
|
||||
|
||||
/* Parameters to be passed to menu definition. */
|
||||
int argc;
|
||||
char **args;
|
||||
|
||||
int hotkey;
|
||||
|
||||
int submenu;
|
||||
|
||||
/* The next element. */
|
||||
struct grub_menu_entry *next;
|
||||
|
||||
/* BLS used to populate the entry */
|
||||
struct bls_entry *bls;
|
||||
};
|
||||
typedef struct grub_menu_entry *grub_menu_entry_t;
|
||||
|
||||
/* The menu. */
|
||||
struct grub_menu
|
||||
{
|
||||
/* The size of a menu. */
|
||||
int size;
|
||||
|
||||
/* The list of menu entries. */
|
||||
grub_menu_entry_t entry_list;
|
||||
};
|
||||
typedef struct grub_menu *grub_menu_t;
|
||||
|
||||
/* Callback structure menu viewers can use to provide user feedback when
|
||||
default entries are executed, possibly including fallback entries. */
|
||||
typedef struct grub_menu_execute_callback
|
||||
{
|
||||
/* Called immediately before ENTRY is booted. */
|
||||
void (*notify_booting) (grub_menu_entry_t entry, void *userdata);
|
||||
|
||||
/* Called when executing one entry has failed, and another entry, ENTRY, will
|
||||
be executed as a fallback. The implementation of this function should
|
||||
delay for a period of at least 2 seconds before returning in order to
|
||||
allow the user time to read the information before it can be lost by
|
||||
executing ENTRY. */
|
||||
void (*notify_fallback) (grub_menu_entry_t entry, void *userdata);
|
||||
|
||||
/* Called when an entry has failed to execute and there is no remaining
|
||||
fallback entry to attempt. */
|
||||
void (*notify_failure) (void *userdata);
|
||||
}
|
||||
*grub_menu_execute_callback_t;
|
||||
|
||||
grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no);
|
||||
int grub_menu_get_timeout (void);
|
||||
void grub_menu_set_timeout (int timeout);
|
||||
void grub_menu_entry_run (grub_menu_entry_t entry);
|
||||
int grub_menu_get_default_entry_index (grub_menu_t menu);
|
||||
|
||||
void grub_menu_init (void);
|
||||
void grub_menu_fini (void);
|
||||
|
||||
#endif /* GRUB_MENU_HEADER */
|
||||
@@ -0,0 +1,49 @@
|
||||
/* menu_viewer.h - Interface to menu viewer implementations. */
|
||||
/*
|
||||
* 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_MENU_VIEWER_HEADER
|
||||
#define GRUB_MENU_VIEWER_HEADER 1
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
struct grub_menu_viewer
|
||||
{
|
||||
struct grub_menu_viewer *next;
|
||||
void *data;
|
||||
void (*set_chosen_entry) (int entry, void *data);
|
||||
void (*scroll_chosen_entry) (void *data, int diren);
|
||||
void (*print_timeout) (int timeout, void *data);
|
||||
void (*clear_timeout) (void *data);
|
||||
void (*fini) (void *fini);
|
||||
};
|
||||
|
||||
void grub_menu_register_viewer (struct grub_menu_viewer *viewer);
|
||||
|
||||
grub_err_t
|
||||
grub_menu_try_text (struct grub_term_output *term,
|
||||
int entry, grub_menu_t menu, int nested);
|
||||
|
||||
extern grub_err_t (*grub_gfxmenu_try_hook) (int entry, grub_menu_t menu,
|
||||
int nested);
|
||||
|
||||
#endif /* GRUB_MENU_VIEWER_HEADER */
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef GRUB_MIPS64_ASM_HEADER
|
||||
#define GRUB_MIPS64_ASM_HEADER 1
|
||||
|
||||
#define GRUB_ASM_T4 $a4
|
||||
#define GRUB_ASM_T5 $a5
|
||||
#define GRUB_ASM_SZREG 8
|
||||
#define GRUB_ASM_REG_S sd
|
||||
#define GRUB_ASM_REG_L ld
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2004,2006,2007,2017 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/types.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
#endif /* ! GRUB_LOADER_MACHINE_HEADER */
|
||||
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2017 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_EFI_LOONGSON_HEADER
|
||||
#define GRUB_EFI_LOONGSON_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
#include <grub/efi/api.h>
|
||||
|
||||
#define GRUB_EFI_LOONGSON_SMBIOS_TABLE_GUID \
|
||||
{ 0x4660f721, 0x2ec5, 0x416a, \
|
||||
{ 0x89, 0x9a, 0x43, 0x18, 0x02, 0x50, 0xa0, 0xc9 } \
|
||||
}
|
||||
|
||||
#define GRUB_EFI_LOONGSON_MMAP_MAX 128
|
||||
typedef enum
|
||||
{
|
||||
GRUB_EFI_LOONGSON_SYSTEM_RAM_LOW = 1,
|
||||
GRUB_EFI_LOONGSON_SYSTEM_RAM_HIGH,
|
||||
GRUB_EFI_LOONGSON_MEMORY_RESERVED,
|
||||
GRUB_EFI_LOONGSON_PCI_IO,
|
||||
GRUB_EFI_LOONGSON_PCI_MEM,
|
||||
GRUB_EFI_LOONGSON_CFG_REG,
|
||||
GRUB_EFI_LOONGSON_VIDEO_ROM,
|
||||
GRUB_EFI_LOONGSON_ADAPTER_ROM,
|
||||
GRUB_EFI_LOONGSON_ACPI_TABLE,
|
||||
GRUB_EFI_LOONGSON_SMBIOS_TABLE,
|
||||
GRUB_EFI_LOONGSON_UMA_VIDEO_RAM,
|
||||
GRUB_EFI_LOONGSON_VUMA_VIDEO_RAM,
|
||||
GRUB_EFI_LOONGSON_SYSTEM_RAM_LOW_DMA,
|
||||
GRUB_EFI_LOONGSON_SYSTEM_RAM_HIGH_DMA,
|
||||
GRUB_EFI_LOONGSON_ACPI_NVS,
|
||||
GRUB_EFI_LOONGSON_MAX_MEMORY_TYPE
|
||||
}
|
||||
grub_efi_loongson_memory_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers; /* version */
|
||||
grub_uint32_t nr_map; /* number of memory_maps */
|
||||
grub_uint32_t mem_freq; /* memory frequence */
|
||||
struct mem_map {
|
||||
grub_uint32_t node_id; /* node_id which memory attached to */
|
||||
grub_uint32_t mem_type; /* system memory, pci memory, pci io, etc. */
|
||||
grub_uint64_t mem_start; /* memory map start address */
|
||||
grub_uint32_t mem_size; /* each memory_map size, not the total size */
|
||||
} map[GRUB_EFI_LOONGSON_MMAP_MAX];
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_memory_map;
|
||||
|
||||
/*
|
||||
* Capability and feature descriptor structure for MIPS CPU
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers; /* version */
|
||||
grub_uint32_t processor_id; /* PRID, e.g. 6305, 6306 */
|
||||
grub_uint32_t cputype; /* Loongson_3A/3B, etc. */
|
||||
grub_uint32_t total_node; /* num of total numa nodes */
|
||||
grub_uint16_t cpu_startup_core_id; /* Boot core id */
|
||||
grub_uint16_t reserved_cores_mask;
|
||||
grub_uint32_t cpu_clock_freq; /* cpu_clock */
|
||||
grub_uint32_t nr_cpus;
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_cpu_info;
|
||||
|
||||
#define GRUB_EFI_LOONGSON_MAX_UARTS 64
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint32_t iotype; /* see include/linux/serial_core.h */
|
||||
grub_uint32_t uartclk;
|
||||
grub_uint32_t int_offset;
|
||||
grub_uint64_t uart_base;
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_uart_device;
|
||||
|
||||
#define GRUB_EFI_LOONGSON_MAX_SENSORS 64
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[32]; /* a formal name */
|
||||
char label[64]; /* a flexible description */
|
||||
grub_uint32_t type; /* SENSOR_* */
|
||||
grub_uint32_t id; /* instance id of a sensor-class */
|
||||
grub_uint32_t fan_policy;
|
||||
grub_uint32_t fan_percent; /* only for constant speed policy */
|
||||
grub_uint64_t base_addr; /* base address of device registers */
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_sensor_device;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers; /* version */
|
||||
grub_uint32_t ccnuma_smp; /* 0: no numa; 1: has numa */
|
||||
grub_uint32_t sing_double_channel; /* 1:single; 2:double */
|
||||
grub_uint32_t nr_uarts;
|
||||
grub_efi_loongson_uart_device uarts[GRUB_EFI_LOONGSON_MAX_UARTS];
|
||||
grub_uint32_t nr_sensors;
|
||||
grub_efi_loongson_sensor_device sensors[GRUB_EFI_LOONGSON_MAX_SENSORS];
|
||||
char has_ec;
|
||||
char ec_name[32];
|
||||
grub_uint64_t ec_base_addr;
|
||||
char has_tcm;
|
||||
char tcm_name[32];
|
||||
grub_uint64_t tcm_base_addr;
|
||||
grub_uint64_t workarounds; /* see workarounds.h */
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_system_info;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers;
|
||||
grub_uint16_t size;
|
||||
grub_uint16_t rtr_bus;
|
||||
grub_uint16_t rtr_devfn;
|
||||
grub_uint32_t vendor;
|
||||
grub_uint32_t device;
|
||||
grub_uint32_t PIC_type; /* conform use HT or PCI to route to CPU-PIC */
|
||||
grub_uint64_t ht_int_bit; /* 3A: 1<<24; 3B: 1<<16 */
|
||||
grub_uint64_t ht_enable; /* irqs used in this PIC */
|
||||
grub_uint32_t node_id; /* node id: 0x0-0; 0x1-1; 0x10-2; 0x11-3 */
|
||||
grub_uint64_t pci_mem_start_addr;
|
||||
grub_uint64_t pci_mem_end_addr;
|
||||
grub_uint64_t pci_io_start_addr;
|
||||
grub_uint64_t pci_io_end_addr;
|
||||
grub_uint64_t pci_config_addr;
|
||||
grub_uint32_t dma_mask_bits;
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_irq_src_routing_table;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers; /* version */
|
||||
grub_uint16_t size;
|
||||
grub_uint8_t flag;
|
||||
char description[64];
|
||||
} GRUB_PACKED
|
||||
grub_efi_loongson_interface_info;
|
||||
|
||||
#define GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER 128
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint64_t start; /* resource start address */
|
||||
grub_uint64_t end; /* resource end address */
|
||||
char name[64];
|
||||
grub_uint32_t flags;
|
||||
}
|
||||
grub_efi_loongson_resource;
|
||||
|
||||
/* arch specific additions */
|
||||
typedef struct
|
||||
{
|
||||
}
|
||||
grub_efi_loongson_archdev_data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char name[64]; /* hold the device name */
|
||||
grub_uint32_t num_resources; /* number of device_resource */
|
||||
/* for each device's resource */
|
||||
grub_efi_loongson_resource resource[GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER];
|
||||
/* arch specific additions */
|
||||
grub_efi_loongson_archdev_data archdata;
|
||||
}
|
||||
grub_efi_loongson_board_devices;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers; /* version */
|
||||
char special_name[64]; /* special_atribute_name */
|
||||
grub_uint32_t loongson_special_type; /* type of special device */
|
||||
/* for each device's resource */
|
||||
grub_efi_loongson_resource resource[GRUB_EFI_LOONGSON_MAX_RESOURCE_NUMBER];
|
||||
}
|
||||
grub_efi_loongson_special_attribute;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint64_t memory_offset; /* efi_loongson_memory_map struct offset */
|
||||
grub_uint64_t cpu_offset; /* efi_loongson_cpuinfo struct offset */
|
||||
grub_uint64_t system_offset; /* efi_loongson_system_info struct offset */
|
||||
grub_uint64_t irq_offset; /* efi_loongson_irq_src_routing_table struct offset */
|
||||
grub_uint64_t interface_offset; /* interface_info struct offset */
|
||||
grub_uint64_t special_offset; /* efi_loongson_special_attribute struct offset */
|
||||
grub_uint64_t boarddev_table_offset; /* efi_loongson_board_devices offset */
|
||||
}
|
||||
grub_efi_loongson_params;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint16_t vers; /* version */
|
||||
grub_uint64_t vga_bios; /* vga_bios address */
|
||||
grub_efi_loongson_params lp;
|
||||
}
|
||||
grub_efi_loongson_smbios_table;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint64_t reset_cold;
|
||||
grub_uint64_t reset_warm;
|
||||
grub_uint64_t reset_type;
|
||||
grub_uint64_t shutdown;
|
||||
grub_uint64_t do_suspend; /* NULL if not support */
|
||||
}
|
||||
grub_efi_loongson_reset_system;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_uint64_t mps; /* MPS table */
|
||||
grub_uint64_t acpi; /* ACPI table (IA64 ext 0.71) */
|
||||
grub_uint64_t acpi20; /* ACPI table (ACPI 2.0) */
|
||||
grub_efi_loongson_smbios_table smbios; /* SM BIOS table */
|
||||
grub_uint64_t sal_systab; /* SAL system table */
|
||||
grub_uint64_t boot_info; /* boot info table */
|
||||
}
|
||||
grub_efi_loongson;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
grub_efi_loongson efi;
|
||||
grub_efi_loongson_reset_system reset_system;
|
||||
}
|
||||
grub_efi_loongson_boot_params;
|
||||
|
||||
extern grub_uint64_t grub_efi_loongson_reset_system_addr;
|
||||
|
||||
extern void grub_efi_loongson_reset_cold (void);
|
||||
extern void grub_efi_loongson_reset_warm (void);
|
||||
extern void grub_efi_loongson_reset_shutdown (void);
|
||||
extern void grub_efi_loongson_reset_suspend (void);
|
||||
|
||||
void grub_efi_loongson_init (void);
|
||||
void grub_efi_loongson_fini (void);
|
||||
void grub_efi_loongson_alloc_boot_params (void);
|
||||
void grub_efi_loongson_free_boot_params (void);
|
||||
void * grub_efi_loongson_get_smbios_table (void);
|
||||
|
||||
int EXPORT_FUNC(grub_efi_is_loongson) (void);
|
||||
|
||||
grub_uint8_t
|
||||
EXPORT_FUNC(grub_efi_loongson_calculatesum8) (const grub_uint8_t *Buffer, grub_efi_uintn_t Length);
|
||||
|
||||
grub_uint8_t
|
||||
EXPORT_FUNC(grub_efi_loongson_grub_calculatechecksum8) (const grub_uint8_t *Buffer, grub_efi_uintn_t Length);
|
||||
|
||||
|
||||
void *
|
||||
EXPORT_FUNC(grub_efi_loongson_get_boot_params) (void);
|
||||
|
||||
typedef struct _extention_list_hdr{
|
||||
grub_uint64_t signature;
|
||||
grub_uint32_t length;
|
||||
grub_uint8_t revision;
|
||||
grub_uint8_t checksum;
|
||||
struct _extention_list_hdr *next;
|
||||
}GRUB_PACKED
|
||||
ext_list;
|
||||
|
||||
typedef struct bootparamsinterface {
|
||||
grub_uint64_t signature; //{'B', 'P', 'I', '_', '0', '_', '1'}
|
||||
grub_efi_system_table_t *systemtable;
|
||||
ext_list *extlist;
|
||||
}GRUB_PACKED
|
||||
bootparamsinterface;
|
||||
|
||||
typedef struct {
|
||||
ext_list header; // {'M', 'E', 'M'}
|
||||
grub_uint8_t mapcount;
|
||||
struct GRUB_PACKED memmap {
|
||||
grub_uint32_t memtype;
|
||||
grub_uint64_t memstart;
|
||||
grub_uint64_t memsize;
|
||||
} map[GRUB_EFI_LOONGSON_MMAP_MAX];
|
||||
}GRUB_PACKED
|
||||
mem_map;
|
||||
|
||||
typedef struct {
|
||||
ext_list header; // {VBIOS}
|
||||
grub_uint64_t vbiosaddr;
|
||||
}GRUB_PACKED
|
||||
vbios;
|
||||
|
||||
grub_uint32_t
|
||||
EXPORT_FUNC (grub_efi_loongson_memmap_sort) (struct memmap array[], grub_uint32_t length, mem_map * bpmem, grub_uint32_t index, grub_uint32_t memtype);
|
||||
#endif /* ! GRUB_EFI_LOONGSON_HEADER */
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef GRUB_MEMORY_CPU_HEADER
|
||||
#include <grub/efi/memory.h>
|
||||
|
||||
//#define GRUB_EFI_MAX_USABLE_ADDRESS 0x980000000fffffffUL
|
||||
#define GRUB_EFI_MAX_USABLE_ADDRESS 0x98000000ffffffffUL
|
||||
|
||||
#endif /* ! GRUB_MEMORY_CPU_HEADER */
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009,2017 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_IO_H
|
||||
#define GRUB_IO_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
typedef grub_addr_t grub_port_t;
|
||||
|
||||
static __inline unsigned char
|
||||
grub_inb (grub_port_t port)
|
||||
{
|
||||
return *(volatile grub_uint8_t *) port;
|
||||
}
|
||||
|
||||
static __inline unsigned short int
|
||||
grub_inw (grub_port_t port)
|
||||
{
|
||||
return *(volatile grub_uint16_t *) port;
|
||||
}
|
||||
|
||||
static __inline unsigned int
|
||||
grub_inl (grub_port_t port)
|
||||
{
|
||||
return *(volatile grub_uint32_t *) port;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
grub_outb (unsigned char value, grub_port_t port)
|
||||
{
|
||||
*(volatile grub_uint8_t *) port = value;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
grub_outw (unsigned short int value, grub_port_t port)
|
||||
{
|
||||
*(volatile grub_uint16_t *) port = value;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
grub_outl (unsigned int value, grub_port_t port)
|
||||
{
|
||||
*(volatile grub_uint32_t *) port = value;
|
||||
}
|
||||
|
||||
#endif /* _SYS_IO_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2006,2007,2008,2009,2017 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_KERNEL_CPU_HEADER
|
||||
#define GRUB_KERNEL_CPU_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
|
||||
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2017 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_MEMORY_CPU_HEADER
|
||||
#define GRUB_MEMORY_CPU_HEADER 1
|
||||
|
||||
#ifndef ASM_FILE
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
#endif
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
typedef grub_addr_t grub_phys_addr_t;
|
||||
|
||||
static inline grub_phys_addr_t
|
||||
grub_vtop (void *a)
|
||||
{
|
||||
if (-1 == ((grub_int64_t) a >> 32))
|
||||
return ((grub_phys_addr_t) a) & 0x1fffffffUL;
|
||||
return ((grub_phys_addr_t) a) & 0xffffffffffffUL;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
grub_map_memory (grub_phys_addr_t a, grub_size_t size)
|
||||
{
|
||||
if ((a + size) < 0x20000000UL)
|
||||
return (void *) (a | 0xffffffff80000000UL);
|
||||
// return (void *) (a | 0x9800000000000000UL);
|
||||
return (void *) ((a&0x8fffffff) | 0xffffffff00000000UL);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_unmap_memory (void *a __attribute__ ((unused)),
|
||||
grub_size_t size __attribute__ ((unused)))
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010,2017 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_REGISTERS_CPU_HEADER
|
||||
#define GRUB_REGISTERS_CPU_HEADER 1
|
||||
|
||||
#ifdef ASM_FILE
|
||||
#define GRUB_CPU_REGISTER_WRAP(x) x
|
||||
#else
|
||||
#define GRUB_CPU_REGISTER_WRAP(x) #x
|
||||
#endif
|
||||
|
||||
#define GRUB_CPU_MIPS_COP0_TIMER_COUNT GRUB_CPU_REGISTER_WRAP($9)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2017 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_RELOCATOR_CPU_HEADER
|
||||
#define GRUB_RELOCATOR_CPU_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/relocator.h>
|
||||
|
||||
struct grub_relocator64_state
|
||||
{
|
||||
/* gpr[0] is ignored since it's hardwired to 0. */
|
||||
grub_uint64_t gpr[32];
|
||||
/* Register holding target $pc. */
|
||||
int jumpreg;
|
||||
};
|
||||
|
||||
grub_err_t
|
||||
grub_relocator64_boot (struct grub_relocator *rel,
|
||||
struct grub_relocator64_state state);
|
||||
|
||||
#endif /* ! GRUB_RELOCATOR_CPU_HEADER */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2004,2006,2007,2009,2017 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_SETJMP_CPU_HEADER
|
||||
#define GRUB_SETJMP_CPU_HEADER 1
|
||||
|
||||
typedef grub_uint64_t grub_jmp_buf[12];
|
||||
|
||||
int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE;
|
||||
void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn));
|
||||
|
||||
#endif /* ! GRUB_SETJMP_CPU_HEADER */
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003,2004,2005,2007,2017 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 KERNEL_CPU_TIME_HEADER
|
||||
#define KERNEL_CPU_TIME_HEADER 1
|
||||
|
||||
#ifndef GRUB_UTIL
|
||||
|
||||
#define GRUB_TICKS_PER_SECOND (grub_arch_cpuclock / 2)
|
||||
|
||||
void grub_timer_init (grub_uint32_t cpuclock);
|
||||
|
||||
/* Return the real time in ticks. */
|
||||
grub_uint64_t grub_get_rtc (void);
|
||||
|
||||
extern grub_uint32_t grub_arch_cpuclock;
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_cpu_idle(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2006,2007,2009,2017 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_TYPES_CPU_HEADER
|
||||
#define GRUB_TYPES_CPU_HEADER 1
|
||||
|
||||
/* The size of void *. */
|
||||
#define GRUB_TARGET_SIZEOF_VOID_P 8
|
||||
|
||||
/* The size of long. */
|
||||
#define GRUB_TARGET_SIZEOF_LONG 8
|
||||
|
||||
#ifdef GRUB_CPU_MIPS64EL
|
||||
/* mips64EL is little-endian. */
|
||||
#undef GRUB_TARGET_WORDS_BIGENDIAN
|
||||
#elif defined (GRUB_CPU_MIPS64)
|
||||
/* mips64 is big-endian. */
|
||||
#define GRUB_TARGET_WORDS_BIGENDIAN
|
||||
#elif !defined (GRUB_SYMBOL_GENERATOR)
|
||||
#error Neither GRUB_CPU_MIPS64 nor GRUB_CPU_MIPS64EL is defined
|
||||
#endif
|
||||
|
||||
#endif /* ! GRUB_TYPES_CPU_HEADER */
|
||||
@@ -0,0 +1,466 @@
|
||||
/* misc.h - prototypes for misc functions */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2005,2006,2007,2008,2009,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_MISC_HEADER
|
||||
#define GRUB_MISC_HEADER 1
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/compiler.h>
|
||||
|
||||
#define ALIGN_UP(addr, align) \
|
||||
((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
|
||||
#define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1))
|
||||
#define ALIGN_DOWN(addr, align) \
|
||||
((addr) & ~((typeof (addr)) align - 1))
|
||||
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
|
||||
#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
|
||||
|
||||
#define grub_dprintf(condition, ...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, __VA_ARGS__)
|
||||
|
||||
void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
|
||||
char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
|
||||
|
||||
static inline char *
|
||||
grub_strncpy (char *dest, const char *src, int c)
|
||||
{
|
||||
char *p = dest;
|
||||
|
||||
while ((*p++ = *src++) != '\0' && --c)
|
||||
;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
grub_stpcpy (char *dest, const char *src)
|
||||
{
|
||||
char *d = dest;
|
||||
const char *s = src;
|
||||
|
||||
do
|
||||
*d++ = *s;
|
||||
while (*s++ != '\0');
|
||||
|
||||
return d - 1;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) && !defined (GRUB_UTIL)
|
||||
#if defined (__MINGW32__) || defined (__CYGWIN__) || defined (__MINGW64__)
|
||||
#define GRUB_ASM_ATTR __attribute__ ((sysv_abi))
|
||||
#else
|
||||
#define GRUB_ASM_ATTR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/* Copied from gnulib.
|
||||
Written by Bruno Haible <[email protected]>, 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);
|
||||
|
||||
static inline int
|
||||
grub_isprint (int c)
|
||||
{
|
||||
return (c >= ' ' && c <= '~');
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_iscntrl (int c)
|
||||
{
|
||||
return (c >= 0x00 && c <= 0x1F) || c == 0x7F;
|
||||
}
|
||||
|
||||
static inline int
|
||||
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)
|
||||
{
|
||||
return (c >= '!' && c <= '~');
|
||||
}
|
||||
|
||||
static inline int
|
||||
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)
|
||||
{
|
||||
return grub_isalpha (c) || grub_isdigit (c);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return c - 'a' + 'A';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static inline int
|
||||
grub_strcasecmp (const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1 && *s2)
|
||||
{
|
||||
if (grub_tolower ((grub_uint8_t) *s1)
|
||||
!= grub_tolower ((grub_uint8_t) *s2))
|
||||
break;
|
||||
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return (int) grub_tolower ((grub_uint8_t) *s1)
|
||||
- (int) grub_tolower ((grub_uint8_t) *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 ((grub_uint8_t) *s1)
|
||||
- (int) grub_tolower ((grub_uint8_t) *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);
|
||||
|
||||
static inline long
|
||||
grub_strtol (const char *str, char **end, int base)
|
||||
{
|
||||
int negative = 0;
|
||||
unsigned long long magnitude;
|
||||
|
||||
while (*str && grub_isspace (*str))
|
||||
str++;
|
||||
|
||||
if (*str == '-')
|
||||
{
|
||||
negative = 1;
|
||||
str++;
|
||||
}
|
||||
|
||||
magnitude = grub_strtoull (str, end, base);
|
||||
if (negative)
|
||||
{
|
||||
if (magnitude > (unsigned long) GRUB_LONG_MAX + 1)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
|
||||
return GRUB_LONG_MIN;
|
||||
}
|
||||
return -((long) magnitude);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (magnitude > GRUB_LONG_MAX)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
|
||||
return GRUB_LONG_MAX;
|
||||
}
|
||||
return (long) magnitude;
|
||||
}
|
||||
}
|
||||
|
||||
char *EXPORT_FUNC(grub_strdup) (const char *s) WARN_UNUSED_RESULT;
|
||||
char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n) WARN_UNUSED_RESULT;
|
||||
void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
|
||||
grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) WARN_UNUSED_RESULT;
|
||||
int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
|
||||
int EXPORT_FUNC(grub_printf_) (const char *fmt, ...) __attribute__ ((format (GNU_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
|
||||
grub_puts (const char *s)
|
||||
{
|
||||
const char nl[2] = "\n";
|
||||
grub_xputs (s);
|
||||
grub_xputs (nl);
|
||||
|
||||
return 1; /* Cannot fail. */
|
||||
}
|
||||
|
||||
int EXPORT_FUNC(grub_puts_) (const char *s);
|
||||
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||
const int line,
|
||||
const char *condition,
|
||||
const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 4, 5)));
|
||||
int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
|
||||
int EXPORT_FUNC(grub_snprintf) (char *str, grub_size_t n, const char *fmt, ...)
|
||||
__attribute__ ((format (GNU_PRINTF, 3, 4)));
|
||||
int EXPORT_FUNC(grub_vsnprintf) (char *str, grub_size_t n, const char *fmt,
|
||||
va_list args);
|
||||
char *EXPORT_FUNC(grub_xasprintf) (const char *fmt, ...)
|
||||
__attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT;
|
||||
char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) WARN_UNUSED_RESULT;
|
||||
void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
|
||||
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
|
||||
grub_uint64_t d,
|
||||
grub_uint64_t *r);
|
||||
|
||||
/* Must match softdiv group in gentpl.py. */
|
||||
#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__) || \
|
||||
(defined(__riscv) && (__riscv_xlen == 32)))
|
||||
#define GRUB_DIVISION_IN_SOFTWARE 1
|
||||
#else
|
||||
#define GRUB_DIVISION_IN_SOFTWARE 0
|
||||
#endif
|
||||
|
||||
/* Some division functions need to be in kernel if compiler generates calls
|
||||
to them. Otherwise we still need them for consistent tests but they go
|
||||
into a separate module. */
|
||||
#if GRUB_DIVISION_IN_SOFTWARE
|
||||
#define EXPORT_FUNC_IF_SOFTDIV EXPORT_FUNC
|
||||
#else
|
||||
#define EXPORT_FUNC_IF_SOFTDIV(x) x
|
||||
#endif
|
||||
|
||||
grub_int64_t
|
||||
EXPORT_FUNC_IF_SOFTDIV(grub_divmod64s) (grub_int64_t n,
|
||||
grub_int64_t d,
|
||||
grub_int64_t *r);
|
||||
|
||||
grub_uint32_t
|
||||
EXPORT_FUNC_IF_SOFTDIV (grub_divmod32) (grub_uint32_t n,
|
||||
grub_uint32_t d,
|
||||
grub_uint32_t *r);
|
||||
|
||||
grub_int32_t
|
||||
EXPORT_FUNC_IF_SOFTDIV (grub_divmod32s) (grub_int32_t n,
|
||||
grub_int32_t d,
|
||||
grub_int32_t *r);
|
||||
|
||||
/* Inline functions. */
|
||||
|
||||
static inline char *
|
||||
grub_memchr (const void *p, int c, grub_size_t len)
|
||||
{
|
||||
const char *s = (const char *) p;
|
||||
const char *e = s + len;
|
||||
|
||||
for (; s < e; s++)
|
||||
if (*s == c)
|
||||
return (char *) s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline unsigned int
|
||||
grub_abs (int x)
|
||||
{
|
||||
if (x < 0)
|
||||
return (unsigned int) (-x);
|
||||
else
|
||||
return (unsigned int) x;
|
||||
}
|
||||
|
||||
/* Reboot the machine. */
|
||||
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) || \
|
||||
defined (GRUB_MACHINE_EFI)
|
||||
void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn));
|
||||
#else
|
||||
void grub_reboot (void) __attribute__ ((noreturn));
|
||||
#endif
|
||||
|
||||
#if defined (__clang__) && !defined (GRUB_UTIL)
|
||||
void __attribute__ ((noreturn)) EXPORT_FUNC (abort) (void);
|
||||
#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__) && (_MIPS_SIM != _ABI64)) && !defined (GRUB_MACHINE_EMU)
|
||||
void EXPORT_FUNC (grub_halt) (void) __attribute__ ((noreturn));
|
||||
#else
|
||||
void grub_halt (void) __attribute__ ((noreturn));
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_EMU
|
||||
/* Flag to check if module loading is available. */
|
||||
extern const int EXPORT_VAR(grub_no_modules);
|
||||
#else
|
||||
#define grub_no_modules 0
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_error_save (struct grub_error_saved *save)
|
||||
{
|
||||
grub_memcpy (save->errmsg, grub_errmsg, sizeof (save->errmsg));
|
||||
save->grub_errno = grub_errno;
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_error_load (const struct grub_error_saved *save)
|
||||
{
|
||||
grub_memcpy (grub_errmsg, save->errmsg, sizeof (grub_errmsg));
|
||||
grub_errno = save->grub_errno;
|
||||
}
|
||||
|
||||
#if BOOT_TIME_STATS
|
||||
struct grub_boot_time
|
||||
{
|
||||
struct grub_boot_time *next;
|
||||
grub_uint64_t tp;
|
||||
const char *file;
|
||||
int line;
|
||||
char *msg;
|
||||
};
|
||||
|
||||
extern struct grub_boot_time *EXPORT_VAR(grub_boot_time_head);
|
||||
|
||||
void EXPORT_FUNC(grub_real_boot_time) (const char *file,
|
||||
const int line,
|
||||
const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 3, 4)));
|
||||
#define grub_boot_time(...) grub_real_boot_time(GRUB_FILE, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define grub_boot_time(...)
|
||||
#endif
|
||||
|
||||
#define grub_max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define grub_min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#endif /* ! GRUB_MISC_HEADER */
|
||||
@@ -0,0 +1,177 @@
|
||||
/* normal.h - prototypes for the normal mode */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2005,2006,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
|
||||
* 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_NORMAL_HEADER
|
||||
#define GRUB_NORMAL_HEADER 1
|
||||
|
||||
#include <grub/term.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/file.h>
|
||||
|
||||
/* The standard left and right margin for some messages. */
|
||||
#define STANDARD_MARGIN 6
|
||||
|
||||
/* The type of a completion item. */
|
||||
enum grub_completion_type
|
||||
{
|
||||
GRUB_COMPLETION_TYPE_COMMAND,
|
||||
GRUB_COMPLETION_TYPE_DEVICE,
|
||||
GRUB_COMPLETION_TYPE_PARTITION,
|
||||
GRUB_COMPLETION_TYPE_FILE,
|
||||
GRUB_COMPLETION_TYPE_ARGUMENT
|
||||
};
|
||||
typedef enum grub_completion_type grub_completion_type_t;
|
||||
|
||||
extern struct grub_menu_viewer grub_normal_text_menu_viewer;
|
||||
extern int grub_normal_exit_level;
|
||||
|
||||
/* Defined in `main.c'. */
|
||||
void grub_enter_normal_mode (const char *config);
|
||||
void grub_normal_execute (const char *config, int nested, int batch);
|
||||
struct grub_term_screen_geometry
|
||||
{
|
||||
/* The number of entries shown at a time. */
|
||||
int num_entries;
|
||||
int first_entry_y;
|
||||
int first_entry_x;
|
||||
int entry_width;
|
||||
int timeout_y;
|
||||
int timeout_lines;
|
||||
int border;
|
||||
int right_margin;
|
||||
};
|
||||
|
||||
void grub_menu_init_page (int nested, int edit,
|
||||
struct grub_term_screen_geometry *geo,
|
||||
struct grub_term_output *term);
|
||||
void grub_normal_init_page (struct grub_term_output *term, int y);
|
||||
char *grub_file_getline (grub_file_t file);
|
||||
void grub_cmdline_run (int nested, int force_auth);
|
||||
|
||||
/* Defined in `cmdline.c'. */
|
||||
char *grub_cmdline_get (const char *prompt);
|
||||
grub_err_t grub_set_history (int newsize);
|
||||
|
||||
/* Defined in `completion.c'. */
|
||||
char *grub_normal_do_completion (char *buf, int *restore,
|
||||
void (*hook) (const char *item, grub_completion_type_t type, int count));
|
||||
|
||||
/* Defined in `misc.c'. */
|
||||
grub_err_t grub_normal_print_device_info (const char *name);
|
||||
|
||||
/* Defined in `color.c'. */
|
||||
char *grub_env_write_color_normal (struct grub_env_var *var, const char *val);
|
||||
char *grub_env_write_color_highlight (struct grub_env_var *var, const char *val);
|
||||
int grub_parse_color_name_pair (grub_uint8_t *ret, const char *name);
|
||||
|
||||
/* Defined in `menu_text.c'. */
|
||||
void grub_wait_after_message (void);
|
||||
void
|
||||
grub_print_ucs4 (const grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
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,
|
||||
int margin_left, int margin_right,
|
||||
struct grub_term_output *term);
|
||||
grub_size_t grub_getstringwidth (grub_uint32_t * str,
|
||||
const grub_uint32_t * last_position,
|
||||
struct grub_term_output *term);
|
||||
void grub_print_message_indented (const char *msg, int margin_left,
|
||||
int margin_right,
|
||||
struct grub_term_output *term);
|
||||
void
|
||||
grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested);
|
||||
grub_err_t
|
||||
grub_show_menu (grub_menu_t menu, int nested, int autobooted);
|
||||
|
||||
/* Defined in `handler.c'. */
|
||||
void read_handler_list (void);
|
||||
void free_handler_list (void);
|
||||
|
||||
/* Defined in `dyncmd.c'. */
|
||||
void read_command_list (const char *prefix);
|
||||
|
||||
/* Defined in `autofs.c'. */
|
||||
void read_fs_list (const char *prefix);
|
||||
|
||||
void grub_context_init (void);
|
||||
void grub_context_fini (void);
|
||||
|
||||
void read_crypto_list (const char *prefix);
|
||||
|
||||
void read_terminal_list (const char *prefix);
|
||||
|
||||
void grub_set_more (int onoff);
|
||||
|
||||
void grub_normal_reset_more (void);
|
||||
|
||||
void grub_xputs_normal (const char *str);
|
||||
|
||||
extern int grub_extractor_level;
|
||||
|
||||
grub_err_t
|
||||
grub_normal_add_menu_entry (int argc, const char **args, char **classes,
|
||||
const char *id,
|
||||
const char *users, const char *hotkey,
|
||||
const char *prefix, const char *sourcecode,
|
||||
int submenu, int *index, struct bls_entry *bls);
|
||||
|
||||
grub_err_t
|
||||
grub_normal_set_password (const char *user, const char *password);
|
||||
|
||||
void grub_normal_free_menu (grub_menu_t menu);
|
||||
|
||||
void grub_normal_auth_init (void);
|
||||
void grub_normal_auth_fini (void);
|
||||
|
||||
void
|
||||
grub_xnputs (const char *str, grub_size_t msg_len);
|
||||
|
||||
grub_command_t
|
||||
grub_dyncmd_get_cmd (grub_command_t cmd);
|
||||
|
||||
void
|
||||
grub_gettext_reread_prefix (const char *val);
|
||||
|
||||
enum grub_human_size_type
|
||||
{
|
||||
GRUB_HUMAN_SIZE_NORMAL,
|
||||
GRUB_HUMAN_SIZE_SHORT,
|
||||
GRUB_HUMAN_SIZE_SPEED,
|
||||
};
|
||||
|
||||
const char *
|
||||
grub_get_human_size (grub_uint64_t size, enum grub_human_size_type type);
|
||||
|
||||
#endif /* ! GRUB_NORMAL_HEADER */
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2004,2006,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_PART_HEADER
|
||||
#define GRUB_PART_HEADER 1
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
struct grub_disk;
|
||||
|
||||
typedef struct grub_partition *grub_partition_t;
|
||||
|
||||
#ifdef GRUB_UTIL
|
||||
typedef enum
|
||||
{
|
||||
GRUB_EMBED_PCBIOS
|
||||
} 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
|
||||
{
|
||||
/* The next partition map type. */
|
||||
struct grub_partition_map *next;
|
||||
struct grub_partition_map **prev;
|
||||
|
||||
/* The name of the partition map type. */
|
||||
const char *name;
|
||||
|
||||
/* Call HOOK with each partition, until HOOK returns non-zero. */
|
||||
grub_err_t (*iterate) (struct grub_disk *disk,
|
||||
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,
|
||||
unsigned int max_nsectors,
|
||||
grub_embed_type_t embed_type,
|
||||
grub_disk_addr_t **sectors);
|
||||
#endif
|
||||
};
|
||||
typedef struct grub_partition_map *grub_partition_map_t;
|
||||
|
||||
/* Partition description. */
|
||||
struct grub_partition
|
||||
{
|
||||
/* The partition number. */
|
||||
int number;
|
||||
|
||||
/* The start sector (relative to parent). */
|
||||
grub_disk_addr_t start;
|
||||
|
||||
/* The length in sector units. */
|
||||
grub_uint64_t len;
|
||||
|
||||
/* The offset of the partition table. */
|
||||
grub_disk_addr_t offset;
|
||||
|
||||
/* The index of this partition in the partition table. */
|
||||
int index;
|
||||
|
||||
/* Parent partition (physically contains this partition). */
|
||||
struct grub_partition *parent;
|
||||
|
||||
/* The type partition map. */
|
||||
grub_partition_map_t partmap;
|
||||
|
||||
/* The type of partition whne it's on MSDOS.
|
||||
Used for embedding detection. */
|
||||
grub_uint8_t msdostype;
|
||||
|
||||
/* The attrib field for GPT. Needed for priority detection. */
|
||||
grub_uint64_t gpt_attrib;
|
||||
};
|
||||
|
||||
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,
|
||||
grub_partition_iterate_hook_t hook,
|
||||
void *hook_data);
|
||||
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
|
||||
|
||||
|
||||
extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
|
||||
|
||||
#ifndef GRUB_LST_GENERATOR
|
||||
static inline void
|
||||
grub_partition_map_register (grub_partition_map_t partmap)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
|
||||
GRUB_AS_LIST (partmap));
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
grub_partition_map_unregister (grub_partition_map_t partmap)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (partmap));
|
||||
}
|
||||
|
||||
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
|
||||
|
||||
|
||||
static inline grub_disk_addr_t
|
||||
grub_partition_get_start (const grub_partition_t p)
|
||||
{
|
||||
grub_partition_t part;
|
||||
grub_uint64_t part_start = 0;
|
||||
|
||||
for (part = p; part; part = part->parent)
|
||||
part_start += part->start;
|
||||
|
||||
return part_start;
|
||||
}
|
||||
|
||||
static inline grub_uint64_t
|
||||
grub_partition_get_len (const grub_partition_t p)
|
||||
{
|
||||
return p->len;
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_PART_HEADER */
|
||||
@@ -0,0 +1,205 @@
|
||||
/* serial.h - serial device interface */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_SERIAL_HEADER
|
||||
#define GRUB_SERIAL_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#if (defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)
|
||||
#include <grub/cpu/io.h>
|
||||
#endif
|
||||
#include <grub/usb.h>
|
||||
#include <grub/list.h>
|
||||
#include <grub/term.h>
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_ARC
|
||||
#include <grub/arc/arc.h>
|
||||
#endif
|
||||
|
||||
struct grub_serial_port;
|
||||
struct grub_serial_config;
|
||||
|
||||
struct grub_serial_driver
|
||||
{
|
||||
grub_err_t (*configure) (struct grub_serial_port *port,
|
||||
struct grub_serial_config *config);
|
||||
int (*fetch) (struct grub_serial_port *port);
|
||||
void (*put) (struct grub_serial_port *port, const int c);
|
||||
void (*fini) (struct grub_serial_port *port);
|
||||
};
|
||||
|
||||
/* The type of parity. */
|
||||
typedef enum
|
||||
{
|
||||
GRUB_SERIAL_PARITY_NONE,
|
||||
GRUB_SERIAL_PARITY_ODD,
|
||||
GRUB_SERIAL_PARITY_EVEN,
|
||||
} grub_serial_parity_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GRUB_SERIAL_STOP_BITS_1,
|
||||
GRUB_SERIAL_STOP_BITS_1_5,
|
||||
GRUB_SERIAL_STOP_BITS_2,
|
||||
} grub_serial_stop_bits_t;
|
||||
|
||||
struct grub_serial_config
|
||||
{
|
||||
unsigned speed;
|
||||
int word_len;
|
||||
grub_serial_parity_t parity;
|
||||
grub_serial_stop_bits_t stop_bits;
|
||||
grub_uint64_t base_clock;
|
||||
int rtscts;
|
||||
};
|
||||
|
||||
struct grub_serial_port
|
||||
{
|
||||
struct grub_serial_port *next;
|
||||
struct grub_serial_port **prev;
|
||||
char *name;
|
||||
struct grub_serial_driver *driver;
|
||||
struct grub_serial_config config;
|
||||
int configured;
|
||||
int broken;
|
||||
|
||||
/* This should be void *data but since serial is useful as an early console
|
||||
when malloc isn't available it's a union.
|
||||
*/
|
||||
union
|
||||
{
|
||||
#if (defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)
|
||||
grub_port_t port;
|
||||
#endif
|
||||
struct
|
||||
{
|
||||
grub_usb_device_t usbdev;
|
||||
int configno;
|
||||
int interfno;
|
||||
char buf[64];
|
||||
int bufstart, bufend;
|
||||
struct grub_usb_desc_endp *in_endp;
|
||||
struct grub_usb_desc_endp *out_endp;
|
||||
};
|
||||
struct grub_escc_descriptor *escc_desc;
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
struct
|
||||
{
|
||||
grub_ieee1275_ihandle_t handle;
|
||||
struct ofserial_hash_ent *elem;
|
||||
};
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
struct grub_efi_serial_io_interface *interface;
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_ARC
|
||||
struct
|
||||
{
|
||||
grub_arc_fileno_t handle;
|
||||
int handle_valid;
|
||||
};
|
||||
#endif
|
||||
};
|
||||
grub_term_output_t term_out;
|
||||
grub_term_input_t term_in;
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
struct grub_serial_config config =
|
||||
{
|
||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
.speed = 115200,
|
||||
/* On Loongson machines serial port has only 3 wires. */
|
||||
.rtscts = 0,
|
||||
#else
|
||||
.speed = 9600,
|
||||
.rtscts = 1,
|
||||
#endif
|
||||
.word_len = 8,
|
||||
.parity = GRUB_SERIAL_PARITY_NONE,
|
||||
.stop_bits = GRUB_SERIAL_STOP_BITS_1,
|
||||
.base_clock = 0
|
||||
};
|
||||
|
||||
return port->driver->configure (port, &config);
|
||||
}
|
||||
|
||||
#if (defined(__mips__) && _MIPS_SIM != _ABI64) || defined (__i386__) || defined (__x86_64__)
|
||||
void grub_ns8250_init (void);
|
||||
char *grub_serial_ns8250_add_port (grub_port_t port);
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
void grub_ofserial_init (void);
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
void
|
||||
grub_efiserial_init (void);
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_ARC
|
||||
void
|
||||
grub_arcserial_init (void);
|
||||
const char *
|
||||
grub_arcserial_add_port (const char *path);
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
#ifndef GRUB_MACHINE_EMU
|
||||
extern void grub_serial_init (void);
|
||||
extern void grub_serial_fini (void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2019 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_SMBIOS_HEADER
|
||||
#define GRUB_SMBIOS_HEADER 1
|
||||
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_SMBIOS_TYPE_END_OF_TABLE ((grub_uint8_t)127)
|
||||
|
||||
struct grub_smbios_ieps
|
||||
{
|
||||
grub_uint8_t anchor[5]; /* "_DMI_" */
|
||||
grub_uint8_t checksum;
|
||||
grub_uint16_t table_length;
|
||||
grub_uint32_t table_address;
|
||||
grub_uint16_t structures;
|
||||
grub_uint8_t revision;
|
||||
} GRUB_PACKED;
|
||||
|
||||
struct grub_smbios_eps
|
||||
{
|
||||
grub_uint8_t anchor[4]; /* "_SM_" */
|
||||
grub_uint8_t checksum;
|
||||
grub_uint8_t length; /* 0x1f */
|
||||
grub_uint8_t version_major;
|
||||
grub_uint8_t version_minor;
|
||||
grub_uint16_t maximum_structure_size;
|
||||
grub_uint8_t revision;
|
||||
grub_uint8_t formatted[5];
|
||||
struct grub_smbios_ieps intermediate;
|
||||
} GRUB_PACKED;
|
||||
|
||||
struct grub_smbios_eps3
|
||||
{
|
||||
grub_uint8_t anchor[5]; /* "_SM3_" */
|
||||
grub_uint8_t checksum;
|
||||
grub_uint8_t length; /* 0x18 */
|
||||
grub_uint8_t version_major;
|
||||
grub_uint8_t version_minor;
|
||||
grub_uint8_t docrev;
|
||||
grub_uint8_t revision;
|
||||
grub_uint8_t reserved;
|
||||
grub_uint32_t maximum_table_length;
|
||||
grub_uint64_t table_address;
|
||||
} GRUB_PACKED;
|
||||
|
||||
extern struct grub_smbios_eps *grub_machine_smbios_get_eps (void);
|
||||
extern struct grub_smbios_eps3 *grub_machine_smbios_get_eps3 (void);
|
||||
|
||||
extern struct grub_smbios_eps *EXPORT_FUNC (grub_smbios_get_eps) (void);
|
||||
|
||||
#endif /* ! GRUB_SMBIOS_HEADER */
|
||||
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2003,2005,2007,2008,2009,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_TERM_HEADER
|
||||
#define GRUB_TERM_HEADER 1
|
||||
|
||||
#define GRUB_TERM_NO_KEY 0
|
||||
|
||||
/* Internal codes used by GRUB to represent terminal input. */
|
||||
/* Only for keys otherwise not having shifted modification. */
|
||||
#define GRUB_TERM_SHIFT 0x01000000
|
||||
#define GRUB_TERM_CTRL 0x02000000
|
||||
#define GRUB_TERM_ALT 0x04000000
|
||||
|
||||
/* Keys without associated character. */
|
||||
#define GRUB_TERM_EXTENDED 0x00800000
|
||||
#define GRUB_TERM_KEY_MASK 0x00ffffff
|
||||
|
||||
#define GRUB_TERM_KEY_LEFT (GRUB_TERM_EXTENDED | 0x4b)
|
||||
#define GRUB_TERM_KEY_RIGHT (GRUB_TERM_EXTENDED | 0x4d)
|
||||
#define GRUB_TERM_KEY_UP (GRUB_TERM_EXTENDED | 0x48)
|
||||
#define GRUB_TERM_KEY_DOWN (GRUB_TERM_EXTENDED | 0x50)
|
||||
#define GRUB_TERM_KEY_HOME (GRUB_TERM_EXTENDED | 0x47)
|
||||
#define GRUB_TERM_KEY_END (GRUB_TERM_EXTENDED | 0x4f)
|
||||
#define GRUB_TERM_KEY_DC (GRUB_TERM_EXTENDED | 0x53)
|
||||
#define GRUB_TERM_KEY_PPAGE (GRUB_TERM_EXTENDED | 0x49)
|
||||
#define GRUB_TERM_KEY_NPAGE (GRUB_TERM_EXTENDED | 0x51)
|
||||
#define GRUB_TERM_KEY_F1 (GRUB_TERM_EXTENDED | 0x3b)
|
||||
#define GRUB_TERM_KEY_F2 (GRUB_TERM_EXTENDED | 0x3c)
|
||||
#define GRUB_TERM_KEY_F3 (GRUB_TERM_EXTENDED | 0x3d)
|
||||
#define GRUB_TERM_KEY_F4 (GRUB_TERM_EXTENDED | 0x3e)
|
||||
#define GRUB_TERM_KEY_F5 (GRUB_TERM_EXTENDED | 0x3f)
|
||||
#define GRUB_TERM_KEY_F6 (GRUB_TERM_EXTENDED | 0x40)
|
||||
#define GRUB_TERM_KEY_F7 (GRUB_TERM_EXTENDED | 0x41)
|
||||
#define GRUB_TERM_KEY_F8 (GRUB_TERM_EXTENDED | 0x42)
|
||||
#define GRUB_TERM_KEY_F9 (GRUB_TERM_EXTENDED | 0x43)
|
||||
#define GRUB_TERM_KEY_F10 (GRUB_TERM_EXTENDED | 0x44)
|
||||
#define GRUB_TERM_KEY_F11 (GRUB_TERM_EXTENDED | 0x57)
|
||||
#define GRUB_TERM_KEY_F12 (GRUB_TERM_EXTENDED | 0x58)
|
||||
#define GRUB_TERM_KEY_INSERT (GRUB_TERM_EXTENDED | 0x52)
|
||||
#define GRUB_TERM_KEY_CENTER (GRUB_TERM_EXTENDED | 0x4c)
|
||||
|
||||
/* Hex value is used for ESC, since '\e' is nonstandard */
|
||||
#define GRUB_TERM_ESC 0x1b
|
||||
#define GRUB_TERM_TAB '\t'
|
||||
#define GRUB_TERM_BACKSPACE '\b'
|
||||
|
||||
#define GRUB_PROGRESS_NO_UPDATE -1
|
||||
#define GRUB_PROGRESS_FAST 0
|
||||
#define GRUB_PROGRESS_SLOW 2
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/symbol.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/unicode.h>
|
||||
#include <grub/list.h>
|
||||
|
||||
/* These are used to represent the various color states we use. */
|
||||
typedef enum
|
||||
{
|
||||
/* The color used to display all text that does not use the
|
||||
user defined colors below. */
|
||||
GRUB_TERM_COLOR_STANDARD,
|
||||
/* The user defined colors for normal text. */
|
||||
GRUB_TERM_COLOR_NORMAL,
|
||||
/* The user defined colors for highlighted text. */
|
||||
GRUB_TERM_COLOR_HIGHLIGHT
|
||||
}
|
||||
grub_term_color_state;
|
||||
|
||||
/* Flags for representing the capabilities of a terminal. */
|
||||
/* Some notes about the flags:
|
||||
- These flags are used by higher-level functions but not terminals
|
||||
themselves.
|
||||
- If a terminal is dumb, you may assume that only putchar, getkey and
|
||||
checkkey are called.
|
||||
- Some fancy features (setcolorstate, setcolor and setcursor) can be set
|
||||
to NULL. */
|
||||
|
||||
/* Set when input characters shouldn't be echoed back. */
|
||||
#define GRUB_TERM_NO_ECHO (1 << 0)
|
||||
/* Set when the editing feature should be disabled. */
|
||||
#define GRUB_TERM_NO_EDIT (1 << 1)
|
||||
/* Set when the terminal cannot do fancy things. */
|
||||
#define GRUB_TERM_DUMB (1 << 2)
|
||||
/* Which encoding does terminal expect stream to be. */
|
||||
#define GRUB_TERM_CODE_TYPE_SHIFT 3
|
||||
#define GRUB_TERM_CODE_TYPE_MASK (7 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* Only ASCII characters accepted. */
|
||||
#define GRUB_TERM_CODE_TYPE_ASCII (0 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* Expects CP-437 characters (ASCII + pseudographics). */
|
||||
#define GRUB_TERM_CODE_TYPE_CP437 (1 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* UTF-8 stream in logical order. Usually used for terminals
|
||||
which just forward the stream to another computer. */
|
||||
#define GRUB_TERM_CODE_TYPE_UTF8_LOGICAL (2 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* UTF-8 in visual order. Like UTF-8 logical but for buggy endpoints. */
|
||||
#define GRUB_TERM_CODE_TYPE_UTF8_VISUAL (3 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
/* Glyph description in visual order. */
|
||||
#define GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS (4 << GRUB_TERM_CODE_TYPE_SHIFT)
|
||||
|
||||
|
||||
/* Bitmasks for modifier keys returned by grub_getkeystatus. */
|
||||
#define GRUB_TERM_STATUS_RSHIFT (1 << 0)
|
||||
#define GRUB_TERM_STATUS_LSHIFT (1 << 1)
|
||||
#define GRUB_TERM_STATUS_RCTRL (1 << 2)
|
||||
#define GRUB_TERM_STATUS_RALT (1 << 3)
|
||||
#define GRUB_TERM_STATUS_SCROLL (1 << 4)
|
||||
#define GRUB_TERM_STATUS_NUM (1 << 5)
|
||||
#define GRUB_TERM_STATUS_CAPS (1 << 6)
|
||||
#define GRUB_TERM_STATUS_LCTRL (1 << 8)
|
||||
#define GRUB_TERM_STATUS_LALT (1 << 9)
|
||||
|
||||
/* Menu-related geometrical constants. */
|
||||
|
||||
/* The number of columns/lines between messages/borders/etc. */
|
||||
#define GRUB_TERM_MARGIN 1
|
||||
|
||||
/* The number of columns of scroll information. */
|
||||
#define GRUB_TERM_SCROLL_WIDTH 1
|
||||
|
||||
struct grub_term_input
|
||||
{
|
||||
/* The next terminal. */
|
||||
struct grub_term_input *next;
|
||||
struct grub_term_input **prev;
|
||||
|
||||
/* The terminal name. */
|
||||
const char *name;
|
||||
|
||||
/* Initialize the terminal. */
|
||||
grub_err_t (*init) (struct grub_term_input *term);
|
||||
|
||||
/* Clean up the terminal. */
|
||||
grub_err_t (*fini) (struct grub_term_input *term);
|
||||
|
||||
/* Get a character if any input character is available. Otherwise return -1 */
|
||||
int (*getkey) (struct grub_term_input *term);
|
||||
|
||||
/* Get keyboard modifier status. */
|
||||
int (*getkeystatus) (struct grub_term_input *term);
|
||||
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_term_input *grub_term_input_t;
|
||||
|
||||
/* Made in a way to fit into uint32_t and so be passed in a register. */
|
||||
struct grub_term_coordinate
|
||||
{
|
||||
grub_uint16_t x;
|
||||
grub_uint16_t y;
|
||||
};
|
||||
|
||||
struct grub_term_output
|
||||
{
|
||||
/* The next terminal. */
|
||||
struct grub_term_output *next;
|
||||
struct grub_term_output **prev;
|
||||
|
||||
/* The terminal name. */
|
||||
const char *name;
|
||||
|
||||
/* Initialize the terminal. */
|
||||
grub_err_t (*init) (struct grub_term_output *term);
|
||||
|
||||
/* Clean up the terminal. */
|
||||
grub_err_t (*fini) (struct grub_term_output *term);
|
||||
|
||||
/* Put a character. C is encoded in Unicode. */
|
||||
void (*putchar) (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
/* Get the number of columns occupied by a given character C. C is
|
||||
encoded in Unicode. */
|
||||
grub_size_t (*getcharwidth) (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c);
|
||||
|
||||
/* Get the screen size. */
|
||||
struct grub_term_coordinate (*getwh) (struct grub_term_output *term);
|
||||
|
||||
/* Get the cursor position. The return value is ((X << 8) | Y). */
|
||||
struct grub_term_coordinate (*getxy) (struct grub_term_output *term);
|
||||
|
||||
/* Go to the position (X, Y). */
|
||||
void (*gotoxy) (struct grub_term_output *term,
|
||||
struct grub_term_coordinate pos);
|
||||
|
||||
/* Clear the screen. */
|
||||
void (*cls) (struct grub_term_output *term);
|
||||
|
||||
/* Set the current color to be used */
|
||||
void (*setcolorstate) (struct grub_term_output *term,
|
||||
grub_term_color_state state);
|
||||
|
||||
/* Turn on/off the cursor. */
|
||||
void (*setcursor) (struct grub_term_output *term, int on);
|
||||
|
||||
/* Update the screen. */
|
||||
void (*refresh) (struct grub_term_output *term);
|
||||
|
||||
/* gfxterm only: put in fullscreen mode. */
|
||||
grub_err_t (*fullscreen) (void);
|
||||
|
||||
/* The feature flags defined above. */
|
||||
grub_uint32_t flags;
|
||||
|
||||
/* Progress data. */
|
||||
grub_uint32_t progress_update_divisor;
|
||||
grub_uint32_t progress_update_counter;
|
||||
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_term_output *grub_term_output_t;
|
||||
|
||||
#define GRUB_TERM_DEFAULT_NORMAL_COLOR 0x07
|
||||
#define GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR 0x70
|
||||
#define GRUB_TERM_DEFAULT_STANDARD_COLOR 0x07
|
||||
|
||||
/* 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);
|
||||
extern struct grub_term_input *EXPORT_VAR(grub_term_inputs);
|
||||
|
||||
static inline void
|
||||
grub_term_register_input (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
if (grub_term_inputs)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
else
|
||||
{
|
||||
/* If this is the first terminal, enable automatically. */
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_input_inactive (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_input_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_input_t term)
|
||||
{
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
if (grub_term_outputs)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
else
|
||||
{
|
||||
/* If this is the first terminal, enable automatically. */
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output_inactive (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs_disabled),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_register_output_active (const char *name __attribute__ ((unused)),
|
||||
grub_term_output_t term)
|
||||
{
|
||||
if (! term->init || term->init (term) == GRUB_ERR_NONE)
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_term_outputs),
|
||||
GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_unregister_input (grub_term_input_t term)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_unregister_output (grub_term_output_t term)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
grub_list_remove (GRUB_AS_LIST (term));
|
||||
}
|
||||
|
||||
#define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
|
||||
#define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled))
|
||||
#define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs))
|
||||
#define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled))
|
||||
|
||||
void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
|
||||
int EXPORT_FUNC(grub_getkey) (void);
|
||||
int EXPORT_FUNC(grub_getkey_noblock) (void);
|
||||
extern int (*EXPORT_VAR (grub_key_remap))(int key);
|
||||
void grub_cls (void);
|
||||
void EXPORT_FUNC(grub_refresh) (void);
|
||||
void grub_puts_terminal (const char *str, struct grub_term_output *term);
|
||||
struct grub_term_coordinate *grub_term_save_pos (void);
|
||||
void grub_term_restore_pos (struct grub_term_coordinate *pos);
|
||||
|
||||
static inline unsigned grub_term_width (struct grub_term_output *term)
|
||||
{
|
||||
return term->getwh(term).x ? : 80;
|
||||
}
|
||||
|
||||
static inline unsigned grub_term_height (struct grub_term_output *term)
|
||||
{
|
||||
return term->getwh(term).y ? : 24;
|
||||
}
|
||||
|
||||
static inline struct grub_term_coordinate
|
||||
grub_term_getxy (struct grub_term_output *term)
|
||||
{
|
||||
return term->getxy (term);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_refresh (struct grub_term_output *term)
|
||||
{
|
||||
if (term->refresh)
|
||||
term->refresh (term);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_gotoxy (struct grub_term_output *term, struct grub_term_coordinate pos)
|
||||
{
|
||||
term->gotoxy (term, pos);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_setcolorstate (struct grub_term_output *term,
|
||||
grub_term_color_state state)
|
||||
{
|
||||
if (term->setcolorstate)
|
||||
term->setcolorstate (term, state);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
struct grub_term_output *term;
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
grub_term_setcolorstate (term, state);
|
||||
}
|
||||
|
||||
/* Turn on/off the cursor. */
|
||||
static inline void
|
||||
grub_term_setcursor (struct grub_term_output *term, int on)
|
||||
{
|
||||
if (term->setcursor)
|
||||
term->setcursor (term, on);
|
||||
}
|
||||
|
||||
static inline void
|
||||
grub_term_cls (struct grub_term_output *term)
|
||||
{
|
||||
if (term->cls)
|
||||
(term->cls) (term);
|
||||
else
|
||||
{
|
||||
grub_putcode ('\n', term);
|
||||
grub_term_refresh (term);
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_FONT_SOURCE
|
||||
|
||||
grub_size_t
|
||||
grub_unicode_estimate_width (const struct grub_unicode_glyph *c);
|
||||
|
||||
#else
|
||||
|
||||
static inline grub_size_t
|
||||
grub_unicode_estimate_width (const struct grub_unicode_glyph *c __attribute__ ((unused)))
|
||||
{
|
||||
if (grub_unicode_get_comb_type (c->base))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define GRUB_TERM_TAB_WIDTH 8
|
||||
|
||||
static inline grub_size_t
|
||||
grub_term_getcharwidth (struct grub_term_output *term,
|
||||
const struct grub_unicode_glyph *c)
|
||||
{
|
||||
if (c->base == '\t')
|
||||
return GRUB_TERM_TAB_WIDTH;
|
||||
|
||||
if (term->getcharwidth)
|
||||
return term->getcharwidth (term, c);
|
||||
else if (((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||
== GRUB_TERM_CODE_TYPE_UTF8_LOGICAL)
|
||||
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||
== GRUB_TERM_CODE_TYPE_UTF8_VISUAL)
|
||||
|| ((term->flags & GRUB_TERM_CODE_TYPE_MASK)
|
||||
== GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS))
|
||||
return grub_unicode_estimate_width (c);
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct grub_term_autoload
|
||||
{
|
||||
struct grub_term_autoload *next;
|
||||
char *name;
|
||||
char *modname;
|
||||
};
|
||||
|
||||
extern struct grub_term_autoload *grub_term_input_autoload;
|
||||
extern struct grub_term_autoload *grub_term_output_autoload;
|
||||
|
||||
static inline void
|
||||
grub_print_spaces (struct grub_term_output *term, int number_spaces)
|
||||
{
|
||||
while (--number_spaces >= 0)
|
||||
grub_putcode (' ', term);
|
||||
}
|
||||
|
||||
extern void (*EXPORT_VAR (grub_term_poll_usb)) (int wait_for_completion);
|
||||
|
||||
#define GRUB_TERM_REPEAT_PRE_INTERVAL 400
|
||||
#define GRUB_TERM_REPEAT_INTERVAL 50
|
||||
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
#endif /* ! GRUB_TERM_HEADER */
|
||||
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* 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_UTIL_INSTALL_HEADER
|
||||
#define GRUB_UTIL_INSTALL_HEADER 1
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <grub/device.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/emu/hostfile.h>
|
||||
|
||||
#define GRUB_INSTALL_OPTIONS \
|
||||
{ "modules", GRUB_INSTALL_OPTIONS_MODULES, N_("MODULES"), \
|
||||
0, N_("pre-load specified modules MODULES"), 1 }, \
|
||||
{ "dtb", GRUB_INSTALL_OPTIONS_DTB, N_("FILE"), \
|
||||
0, N_("embed a specific DTB"), 1 }, \
|
||||
{ "install-modules", GRUB_INSTALL_OPTIONS_INSTALL_MODULES, \
|
||||
N_("MODULES"), 0, \
|
||||
N_("install only MODULES and their dependencies [default=all]"), 1 }, \
|
||||
{ "themes", GRUB_INSTALL_OPTIONS_INSTALL_THEMES, N_("THEMES"), \
|
||||
0, N_("install THEMES [default=%s]"), 1 }, \
|
||||
{ "fonts", GRUB_INSTALL_OPTIONS_INSTALL_FONTS, N_("FONTS"), \
|
||||
0, N_("install FONTS [default=%s]"), 1 }, \
|
||||
{ "locales", GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, N_("LOCALES"),\
|
||||
0, N_("install only LOCALES [default=all]"), 1 }, \
|
||||
{ "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \
|
||||
"no|xz|gz|lzo", 0, \
|
||||
N_("compress GRUB files [optional]"), 1 }, \
|
||||
{"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \
|
||||
"xz|none|auto", \
|
||||
0, N_("choose the compression to use for core image"), 2}, \
|
||||
/* TRANSLATORS: platform here isn't identifier. It can be translated. */ \
|
||||
{ "directory", 'd', N_("DIR"), 0, \
|
||||
N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
|
||||
{ "override-directory", GRUB_INSTALL_OPTIONS_DIRECTORY2, \
|
||||
N_("DIR"), OPTION_HIDDEN, \
|
||||
N_("use images and modules under DIR [default=%s/<platform>]"), 1 }, \
|
||||
{ "locale-directory", GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY, \
|
||||
N_("DIR"), 0, \
|
||||
N_("use translations under DIR [default=%s]"), 1 }, \
|
||||
{ "themes-directory", GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY, \
|
||||
N_("DIR"), OPTION_HIDDEN, \
|
||||
N_("use themes under DIR [default=%s]"), 1 }, \
|
||||
{ "grub-mkimage", GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE, \
|
||||
"FILE", OPTION_HIDDEN, 0, 1 }, \
|
||||
/* TRANSLATORS: "embed" is a verb (command description). "*/ \
|
||||
{ "pubkey", 'k', N_("FILE"), 0, \
|
||||
N_("embed FILE as public key for signature checking"), 0}, \
|
||||
{ "verbose", 'v', 0, 0, \
|
||||
N_("print verbose messages."), 1 }
|
||||
|
||||
int
|
||||
grub_install_parse (int key, char *arg);
|
||||
|
||||
void
|
||||
grub_install_push_module (const char *val);
|
||||
|
||||
void
|
||||
grub_install_pop_module (void);
|
||||
|
||||
char *
|
||||
grub_install_help_filter (int key, const char *text,
|
||||
void *input __attribute__ ((unused)));
|
||||
|
||||
enum grub_install_plat
|
||||
{
|
||||
GRUB_INSTALL_PLATFORM_I386_PC,
|
||||
GRUB_INSTALL_PLATFORM_I386_EFI,
|
||||
GRUB_INSTALL_PLATFORM_I386_QEMU,
|
||||
GRUB_INSTALL_PLATFORM_I386_COREBOOT,
|
||||
GRUB_INSTALL_PLATFORM_I386_MULTIBOOT,
|
||||
GRUB_INSTALL_PLATFORM_I386_IEEE1275,
|
||||
GRUB_INSTALL_PLATFORM_X86_64_EFI,
|
||||
GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON,
|
||||
GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275,
|
||||
GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275,
|
||||
GRUB_INSTALL_PLATFORM_MIPSEL_ARC,
|
||||
GRUB_INSTALL_PLATFORM_MIPS_ARC,
|
||||
GRUB_INSTALL_PLATFORM_IA64_EFI,
|
||||
GRUB_INSTALL_PLATFORM_ARM_UBOOT,
|
||||
GRUB_INSTALL_PLATFORM_ARM_EFI,
|
||||
GRUB_INSTALL_PLATFORM_MIPSEL_QEMU_MIPS,
|
||||
GRUB_INSTALL_PLATFORM_MIPS_QEMU_MIPS,
|
||||
GRUB_INSTALL_PLATFORM_I386_XEN,
|
||||
GRUB_INSTALL_PLATFORM_X86_64_XEN,
|
||||
GRUB_INSTALL_PLATFORM_I386_XEN_PVH,
|
||||
GRUB_INSTALL_PLATFORM_ARM64_EFI,
|
||||
GRUB_INSTALL_PLATFORM_MIPS64EL_EFI,
|
||||
GRUB_INSTALL_PLATFORM_ARM_COREBOOT,
|
||||
GRUB_INSTALL_PLATFORM_RISCV32_EFI,
|
||||
GRUB_INSTALL_PLATFORM_RISCV64_EFI,
|
||||
GRUB_INSTALL_PLATFORM_MAX
|
||||
};
|
||||
|
||||
enum grub_install_options {
|
||||
GRUB_INSTALL_OPTIONS_DIRECTORY = 'd',
|
||||
GRUB_INSTALL_OPTIONS_VERBOSITY = 'v',
|
||||
GRUB_INSTALL_OPTIONS_MODULES = 0x201,
|
||||
GRUB_INSTALL_OPTIONS_INSTALL_MODULES,
|
||||
GRUB_INSTALL_OPTIONS_INSTALL_THEMES,
|
||||
GRUB_INSTALL_OPTIONS_INSTALL_FONTS,
|
||||
GRUB_INSTALL_OPTIONS_INSTALL_LOCALES,
|
||||
GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS,
|
||||
GRUB_INSTALL_OPTIONS_DIRECTORY2,
|
||||
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY,
|
||||
GRUB_INSTALL_OPTIONS_THEMES_DIRECTORY,
|
||||
GRUB_INSTALL_OPTIONS_GRUB_MKIMAGE,
|
||||
GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS,
|
||||
GRUB_INSTALL_OPTIONS_DTB
|
||||
};
|
||||
|
||||
extern char *grub_install_source_directory;
|
||||
|
||||
enum grub_install_plat
|
||||
grub_install_get_target (const char *src);
|
||||
void
|
||||
grub_install_mkdir_p (const char *dst);
|
||||
|
||||
void
|
||||
grub_install_copy_files (const char *src,
|
||||
const char *dst,
|
||||
enum grub_install_plat platid);
|
||||
char *
|
||||
grub_install_get_platform_name (enum grub_install_plat platid);
|
||||
|
||||
const char *
|
||||
grub_install_get_platform_cpu (enum grub_install_plat platid);
|
||||
|
||||
const char *
|
||||
grub_install_get_platform_platform (enum grub_install_plat platid);
|
||||
|
||||
char *
|
||||
grub_install_get_platforms_string (void);
|
||||
|
||||
typedef enum {
|
||||
GRUB_COMPRESSION_AUTO,
|
||||
GRUB_COMPRESSION_NONE,
|
||||
GRUB_COMPRESSION_XZ,
|
||||
GRUB_COMPRESSION_LZMA
|
||||
} grub_compression_t;
|
||||
|
||||
void
|
||||
grub_install_make_image_wrap (const char *dir, const char *prefix,
|
||||
const char *outname, char *memdisk_path,
|
||||
char *config_path,
|
||||
const char *format, int note);
|
||||
void
|
||||
grub_install_make_image_wrap_file (const char *dir, const char *prefix,
|
||||
FILE *fp, const char *outname,
|
||||
char *memdisk_path,
|
||||
char *config_path,
|
||||
const char *mkimage_target, int note);
|
||||
|
||||
int
|
||||
grub_install_copy_file (const char *src,
|
||||
const char *dst,
|
||||
int is_critical);
|
||||
|
||||
struct grub_install_image_target_desc;
|
||||
|
||||
void
|
||||
grub_install_generate_image (const char *dir, const char *prefix,
|
||||
FILE *out,
|
||||
const char *outname, char *mods[],
|
||||
char *memdisk_path, char **pubkey_paths,
|
||||
size_t npubkeys,
|
||||
char *config_path,
|
||||
const struct grub_install_image_target_desc *image_target,
|
||||
int note,
|
||||
grub_compression_t comp, const char *dtb_file);
|
||||
|
||||
const struct grub_install_image_target_desc *
|
||||
grub_install_get_image_target (const char *arg);
|
||||
|
||||
void
|
||||
grub_util_bios_setup (const char *dir,
|
||||
const char *boot_file, const char *core_file,
|
||||
const char *dest, int force,
|
||||
int fs_probe, int allow_floppy,
|
||||
int add_rs_codes);
|
||||
void
|
||||
grub_util_sparc_setup (const char *dir,
|
||||
const char *boot_file, const char *core_file,
|
||||
const char *dest, int force,
|
||||
int fs_probe, int allow_floppy,
|
||||
int add_rs_codes);
|
||||
|
||||
char *
|
||||
grub_install_get_image_targets_string (void);
|
||||
|
||||
const char *
|
||||
grub_util_get_target_dirname (const struct grub_install_image_target_desc *t);
|
||||
|
||||
void
|
||||
grub_install_create_envblk_file (const char *name);
|
||||
|
||||
const char *
|
||||
grub_install_get_default_arm_platform (void);
|
||||
|
||||
const char *
|
||||
grub_install_get_default_x86_platform (void);
|
||||
|
||||
int
|
||||
grub_install_register_efi (grub_device_t efidir_grub_dev,
|
||||
const char *efifile_path,
|
||||
const char *efi_distributor);
|
||||
|
||||
void
|
||||
grub_install_register_ieee1275 (int is_prep, const char *install_device,
|
||||
int partno, const char *relpath);
|
||||
|
||||
void
|
||||
grub_install_sgi_setup (const char *install_device,
|
||||
const char *imgfile, const char *destname);
|
||||
|
||||
int
|
||||
grub_install_compress_gzip (const char *src, const char *dest);
|
||||
int
|
||||
grub_install_compress_lzop (const char *src, const char *dest);
|
||||
int
|
||||
grub_install_compress_xz (const char *src, const char *dest);
|
||||
|
||||
void
|
||||
grub_install_get_blocklist (grub_device_t root_dev,
|
||||
const char *core_path, const char *core_img,
|
||||
size_t core_size,
|
||||
void (*callback) (grub_disk_addr_t sector,
|
||||
unsigned offset,
|
||||
unsigned length,
|
||||
void *data),
|
||||
void *hook_data);
|
||||
|
||||
void
|
||||
grub_util_create_envblk_file (const char *name);
|
||||
|
||||
void
|
||||
grub_util_glue_efi (const char *file32, const char *file64, const char *out);
|
||||
|
||||
void
|
||||
grub_util_render_label (const char *label_font,
|
||||
const char *label_bgcolor,
|
||||
const char *label_color,
|
||||
const char *label_string,
|
||||
const char *label);
|
||||
|
||||
const char *
|
||||
grub_util_get_target_name (const struct grub_install_image_target_desc *t);
|
||||
|
||||
extern char *grub_install_copy_buffer;
|
||||
#define GRUB_INSTALL_COPY_BUFFER_SIZE 1048576
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,331 @@
|
||||
/******************************************************************************
|
||||
* ventoy.h
|
||||
*
|
||||
* Copyright (c) 2020, longpanda <[email protected]>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __VENTOY_H__
|
||||
#define __VENTOY_H__
|
||||
|
||||
#define COMPILE_ASSERT(a, expr) extern char __compile_assert##a[(expr) ? 1 : -1]
|
||||
|
||||
#define VENTOY_COMPATIBLE_STR "VENTOY COMPATIBLE"
|
||||
#define VENTOY_COMPATIBLE_STR_LEN 17
|
||||
|
||||
#define VENTOY_GUID { 0x77772020, 0x2e77, 0x6576, { 0x6e, 0x74, 0x6f, 0x79, 0x2e, 0x6e, 0x65, 0x74 }}
|
||||
|
||||
typedef enum ventoy_fs_type
|
||||
{
|
||||
ventoy_fs_exfat = 0, /* 0: exfat */
|
||||
ventoy_fs_ntfs, /* 1: NTFS */
|
||||
ventoy_fs_ext, /* 2: ext2/ext3/ext4 */
|
||||
ventoy_fs_xfs, /* 3: XFS */
|
||||
ventoy_fs_udf, /* 4: UDF */
|
||||
ventoy_fs_fat, /* 5: FAT */
|
||||
ventoy_fs_btrfs, /* 6: BTRFS */
|
||||
|
||||
ventoy_fs_max
|
||||
}ventoy_fs_type;
|
||||
|
||||
typedef enum ventoy_chain_type
|
||||
{
|
||||
ventoy_chain_linux = 0, /* 0: linux */
|
||||
ventoy_chain_windows, /* 1: windows */
|
||||
ventoy_chain_wim, /* 2: wim */
|
||||
|
||||
ventoy_chain_max
|
||||
}ventoy_chain_type;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct ventoy_guid
|
||||
{
|
||||
grub_uint32_t data1;
|
||||
grub_uint16_t data2;
|
||||
grub_uint16_t data3;
|
||||
grub_uint8_t data4[8];
|
||||
}ventoy_guid;
|
||||
|
||||
|
||||
typedef struct ventoy_image_disk_region
|
||||
{
|
||||
grub_uint32_t image_sector_count; /* image sectors contained in this region (in 2048) */
|
||||
grub_uint32_t image_start_sector; /* image sector start (in 2048) */
|
||||
grub_uint64_t disk_start_sector; /* disk sector start (in 512) */
|
||||
}ventoy_image_disk_region;
|
||||
|
||||
typedef struct ventoy_image_location
|
||||
{
|
||||
ventoy_guid guid;
|
||||
|
||||
/* image sector size, 2048/512 */
|
||||
grub_uint32_t image_sector_size;
|
||||
|
||||
/* disk sector size, normally the value is 512 */
|
||||
grub_uint32_t disk_sector_size;
|
||||
|
||||
grub_uint32_t region_count;
|
||||
|
||||
/*
|
||||
* disk region data (region_count)
|
||||
* If the image file has more than one fragments in disk,
|
||||
* there will be more than one region data here.
|
||||
*
|
||||
*/
|
||||
ventoy_image_disk_region regions[1];
|
||||
|
||||
/* ventoy_image_disk_region regions[2~region_count-1] */
|
||||
}ventoy_image_location;
|
||||
|
||||
|
||||
typedef struct ventoy_os_param
|
||||
{
|
||||
ventoy_guid guid; // VENTOY_GUID
|
||||
grub_uint8_t chksum; // checksum
|
||||
|
||||
grub_uint8_t vtoy_disk_guid[16];
|
||||
grub_uint64_t vtoy_disk_size; // disk size in bytes
|
||||
grub_uint16_t vtoy_disk_part_id; // begin with 1
|
||||
grub_uint16_t vtoy_disk_part_type; // 0:exfat 1:ntfs other: reserved
|
||||
char vtoy_img_path[384]; // It seems to be enough, utf-8 format
|
||||
grub_uint64_t vtoy_img_size; // image file size in bytes
|
||||
|
||||
/*
|
||||
* Ventoy will write a copy of ventoy_image_location data into runtime memory
|
||||
* this is the physically address and length of that memory.
|
||||
* Address 0 means no such data exist.
|
||||
* Address will be aligned by 4KB.
|
||||
*
|
||||
*/
|
||||
grub_uint64_t vtoy_img_location_addr;
|
||||
grub_uint32_t vtoy_img_location_len;
|
||||
|
||||
/*
|
||||
* These 32 bytes are reserved by ventoy.
|
||||
*
|
||||
* vtoy_reserved[0]: vtoy_break_level
|
||||
* vtoy_reserved[1]: vtoy_debug_level
|
||||
* vtoy_reserved[2]: vtoy_chain_type 0:Linux 1:Windows 2:wimfile
|
||||
* vtoy_reserved[3]: vtoy_iso_format 0:iso9660 1:udf
|
||||
* vtoy_reserved[4]: vtoy_windows_cd_prompt
|
||||
* vtoy_reserved[5]: vtoy_linux_remount
|
||||
* vtoy_reserved[6]: vtoy_vlnk
|
||||
* vtoy_reserved[7~10]: vtoy_disk_sig[4] used for vlnk
|
||||
* vtoy_reserved[11]: vtoy_win_uefi_max_res
|
||||
*
|
||||
*/
|
||||
grub_uint8_t vtoy_reserved[32]; // Internal use by ventoy
|
||||
|
||||
grub_uint8_t vtoy_disk_signature[4];
|
||||
|
||||
grub_uint8_t reserved[27];
|
||||
}ventoy_os_param;
|
||||
|
||||
|
||||
typedef struct ventoy_windows_data
|
||||
{
|
||||
char auto_install_script[384];
|
||||
char injection_archive[384];
|
||||
grub_uint8_t windows11_bypass_check;
|
||||
|
||||
grub_uint32_t auto_install_len;
|
||||
|
||||
grub_uint8_t windows11_bypass_nro;
|
||||
|
||||
grub_uint8_t reserved[255 - 5];
|
||||
|
||||
/* auto_intall file buf */
|
||||
/* ...... + auto_install_len */
|
||||
}ventoy_windows_data;
|
||||
|
||||
|
||||
typedef struct ventoy_secure_data
|
||||
{
|
||||
grub_uint8_t magic1[16]; /* VENTOY_GUID */
|
||||
grub_uint8_t diskuuid[16];
|
||||
grub_uint8_t Checksum[16];
|
||||
grub_uint8_t adminSHA256[32];
|
||||
grub_uint8_t reserved[4000];
|
||||
grub_uint8_t magic2[16]; /* VENTOY_GUID */
|
||||
}ventoy_secure_data;
|
||||
|
||||
|
||||
typedef struct ventoy_vlnk
|
||||
{
|
||||
ventoy_guid guid; // VENTOY_GUID
|
||||
grub_uint32_t crc32; // crc32
|
||||
grub_uint32_t disk_signature;
|
||||
grub_uint64_t part_offset; // in bytes
|
||||
char filepath[384];
|
||||
grub_uint8_t reserved[96];
|
||||
}ventoy_vlnk;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
// compile assert check : sizeof(ventoy_os_param) must be 512
|
||||
COMPILE_ASSERT(1,sizeof(ventoy_os_param) == 512);
|
||||
COMPILE_ASSERT(2,sizeof(ventoy_secure_data) == 4096);
|
||||
COMPILE_ASSERT(3,sizeof(ventoy_vlnk) == 512);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma pack(4)
|
||||
|
||||
typedef struct ventoy_chain_head
|
||||
{
|
||||
ventoy_os_param os_param;
|
||||
|
||||
grub_uint32_t disk_drive;
|
||||
grub_uint32_t drive_map;
|
||||
grub_uint32_t disk_sector_size;
|
||||
|
||||
grub_uint64_t real_img_size_in_bytes;
|
||||
grub_uint64_t virt_img_size_in_bytes;
|
||||
grub_uint32_t boot_catalog;
|
||||
grub_uint8_t boot_catalog_sector[2048];
|
||||
|
||||
grub_uint32_t img_chunk_offset;
|
||||
grub_uint32_t img_chunk_num;
|
||||
|
||||
grub_uint32_t override_chunk_offset;
|
||||
grub_uint32_t override_chunk_num;
|
||||
|
||||
grub_uint32_t virt_chunk_offset;
|
||||
grub_uint32_t virt_chunk_num;
|
||||
}ventoy_chain_head;
|
||||
|
||||
typedef struct ventoy_image_desc
|
||||
{
|
||||
grub_uint64_t disk_size;
|
||||
grub_uint64_t part1_size;
|
||||
grub_uint8_t disk_uuid[16];
|
||||
grub_uint8_t disk_signature[4];
|
||||
grub_uint32_t img_chunk_count;
|
||||
/* ventoy_img_chunk list */
|
||||
}ventoy_image_desc;
|
||||
|
||||
|
||||
|
||||
typedef struct ventoy_img_chunk
|
||||
{
|
||||
grub_uint32_t img_start_sector; // sector size: 2KB
|
||||
grub_uint32_t img_end_sector; // included
|
||||
|
||||
grub_uint64_t disk_start_sector; // in disk_sector_size
|
||||
grub_uint64_t disk_end_sector; // included
|
||||
}ventoy_img_chunk;
|
||||
|
||||
|
||||
typedef struct ventoy_override_chunk
|
||||
{
|
||||
grub_uint64_t img_offset;
|
||||
grub_uint32_t override_size;
|
||||
grub_uint8_t override_data[512];
|
||||
}ventoy_override_chunk;
|
||||
|
||||
typedef struct ventoy_virt_chunk
|
||||
{
|
||||
grub_uint32_t mem_sector_start;
|
||||
grub_uint32_t mem_sector_end;
|
||||
grub_uint32_t mem_sector_offset;
|
||||
grub_uint32_t remap_sector_start;
|
||||
grub_uint32_t remap_sector_end;
|
||||
grub_uint32_t org_sector_start;
|
||||
}ventoy_virt_chunk;
|
||||
|
||||
#define DEFAULT_CHUNK_NUM 1024
|
||||
typedef struct ventoy_img_chunk_list
|
||||
{
|
||||
char *buf;
|
||||
grub_uint32_t last_off;
|
||||
grub_uint32_t err_code;
|
||||
|
||||
grub_uint32_t max_chunk;
|
||||
grub_uint32_t cur_chunk;
|
||||
ventoy_img_chunk *chunk;
|
||||
}ventoy_img_chunk_list;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define ventoy_filt_register grub_file_filter_register
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
#define VTOY_MAX_CONF_REPLACE 2
|
||||
#define GRUB_FILE_REPLACE_MAGIC 0x1258BEEF
|
||||
#define GRUB_IMG_REPLACE_MAGIC 0x1259BEEF
|
||||
|
||||
typedef const char * (*grub_env_get_pf)(const char *name);
|
||||
typedef int (*grub_env_set_pf)(const char *name, const char *val);
|
||||
typedef int (*grub_env_printf_pf)(const char *fmt, ...);
|
||||
|
||||
typedef struct ventoy_grub_param_file_replace
|
||||
{
|
||||
grub_uint32_t magic;
|
||||
char old_file_name[4][256];
|
||||
grub_uint32_t old_name_cnt;
|
||||
grub_uint32_t new_file_virtual_id;
|
||||
}ventoy_grub_param_file_replace;
|
||||
|
||||
typedef struct ventoy_grub_param
|
||||
{
|
||||
grub_env_get_pf grub_env_get;
|
||||
grub_env_set_pf grub_env_set;
|
||||
ventoy_grub_param_file_replace file_replace;
|
||||
ventoy_grub_param_file_replace img_replace[VTOY_MAX_CONF_REPLACE];
|
||||
grub_env_printf_pf grub_env_printf;
|
||||
}ventoy_grub_param;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define VTOY_CHUNK_BUF_SIZE (4 * 1024 * 1024)
|
||||
|
||||
typedef enum vtoy_chunk_err
|
||||
{
|
||||
VTOY_CHUNK_ERR_NONE = 0,
|
||||
VTOY_CHUNK_ERR_MULTI_DEV,
|
||||
VTOY_CHUNK_ERR_RAID,
|
||||
VTOY_CHUNK_ERR_COMPRESS,
|
||||
VTOY_CHUNK_ERR_NOT_FLAT,
|
||||
VTOY_CHUNK_ERR_OVER_FLOW,
|
||||
VTOY_CHUNK_ERR_MAX
|
||||
}vtoy_chunk_err;
|
||||
|
||||
int grub_ext_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||
int grub_btrfs_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||
int grub_fat_get_file_chunk(grub_uint64_t part_start, grub_file_t file, ventoy_img_chunk_list *chunk_list);
|
||||
void grub_iso9660_set_nojoliet(int nojoliet);
|
||||
int grub_iso9660_is_joliet(void);
|
||||
grub_uint64_t grub_iso9660_get_last_read_pos(grub_file_t file);
|
||||
grub_uint64_t grub_iso9660_get_last_file_dirent_pos(grub_file_t file);
|
||||
grub_uint64_t grub_udf_get_file_offset(grub_file_t file);
|
||||
grub_uint64_t grub_udf_get_last_pd_size_offset(void);
|
||||
grub_uint64_t grub_udf_get_last_file_attr_offset
|
||||
(
|
||||
grub_file_t file,
|
||||
grub_uint32_t *startBlock,
|
||||
grub_uint64_t *fe_entry_size_offset
|
||||
);
|
||||
int ventoy_is_efi_os(void);
|
||||
void ventoy_memfile_env_set(const char *prefix, const void *buf, unsigned long long len);
|
||||
|
||||
#endif /* __VENTOY_H__ */
|
||||
|
||||
Reference in New Issue
Block a user