Refresh GRUB scripts, config, and integration documentation

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-18 00:48:58 +01:00
parent 90168fb789
commit 8ca7e02398
2449 changed files with 1155215 additions and 38 deletions
@@ -0,0 +1,53 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2004,2005,2007 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_ACORN_FILECORE_HEADER
#define GRUB_ACORN_FILECORE_HEADER 1
#include <grub/types.h>
struct grub_filecore_disc_record
{
grub_uint8_t log2secsize;
grub_uint8_t secspertrack;
grub_uint8_t heads;
grub_uint8_t density;
grub_uint8_t idlen;
grub_uint8_t log2bpmb;
grub_uint8_t skew;
grub_uint8_t bootoption;
/* In bits 0-5, flags in bits 6 and 7. */
grub_uint8_t lowsector;
grub_uint8_t nzones;
grub_uint16_t zone_spare;
grub_uint32_t root_address;
/* Disc size in bytes. */
grub_uint32_t disc_size;
grub_uint16_t cycle_id;
char disc_name[10];
/* Yes, it is 32 bits! */
grub_uint32_t disctype;
/* Most significant part of the disc size. */
grub_uint32_t disc_size2;
grub_uint8_t share_size;
grub_uint8_t big_flag;
grub_uint8_t reserved[18];
};
#endif /* ! GRUB_ACORN_FILECORE_HEADER */
@@ -0,0 +1,301 @@
/*
* 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_ACPI_HEADER
#define GRUB_ACPI_HEADER 1
#ifndef GRUB_DSDT_TEST
#include <grub/types.h>
#include <grub/err.h>
#else
#define GRUB_PACKED __attribute__ ((packed))
#endif
#define GRUB_RSDP_SIGNATURE "RSD PTR "
#define GRUB_RSDP_SIGNATURE_SIZE 8
struct grub_acpi_rsdp_v10
{
grub_uint8_t signature[GRUB_RSDP_SIGNATURE_SIZE];
grub_uint8_t checksum;
grub_uint8_t oemid[6];
grub_uint8_t revision;
grub_uint32_t rsdt_addr;
} GRUB_PACKED;
struct grub_acpi_rsdp_v20
{
struct grub_acpi_rsdp_v10 rsdpv1;
grub_uint32_t length;
grub_uint64_t xsdt_addr;
grub_uint8_t checksum;
grub_uint8_t reserved[3];
} GRUB_PACKED;
struct grub_acpi_table_header
{
grub_uint8_t signature[4];
grub_uint32_t length;
grub_uint8_t revision;
grub_uint8_t checksum;
grub_uint8_t oemid[6];
grub_uint8_t oemtable[8];
grub_uint32_t oemrev;
grub_uint8_t creator_id[4];
grub_uint32_t creator_rev;
} GRUB_PACKED;
#define GRUB_ACPI_FADT_SIGNATURE "FACP"
struct grub_acpi_fadt
{
struct grub_acpi_table_header hdr;
grub_uint32_t facs_addr;
grub_uint32_t dsdt_addr;
grub_uint8_t somefields1[20];
grub_uint32_t pm1a;
grub_uint8_t somefields2[8];
grub_uint32_t pmtimer;
grub_uint8_t somefields3[32];
grub_uint32_t flags;
grub_uint8_t somefields4[16];
grub_uint64_t facs_xaddr;
grub_uint64_t dsdt_xaddr;
grub_uint8_t somefields5[96];
} GRUB_PACKED;
#define GRUB_ACPI_MADT_SIGNATURE "APIC"
struct grub_acpi_madt_entry_header
{
grub_uint8_t type;
grub_uint8_t len;
};
struct grub_acpi_madt
{
struct grub_acpi_table_header hdr;
grub_uint32_t lapic_addr;
grub_uint32_t flags;
struct grub_acpi_madt_entry_header entries[0];
} GRUB_PACKED;
enum
{
GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC = 0,
GRUB_ACPI_MADT_ENTRY_TYPE_IOAPIC = 1,
GRUB_ACPI_MADT_ENTRY_TYPE_INTERRUPT_OVERRIDE = 2,
GRUB_ACPI_MADT_ENTRY_TYPE_LAPIC_NMI = 4,
GRUB_ACPI_MADT_ENTRY_TYPE_SAPIC = 6,
GRUB_ACPI_MADT_ENTRY_TYPE_LSAPIC = 7,
GRUB_ACPI_MADT_ENTRY_TYPE_PLATFORM_INT_SOURCE = 8
};
struct grub_acpi_madt_entry_lapic
{
struct grub_acpi_madt_entry_header hdr;
grub_uint8_t acpiid;
grub_uint8_t apicid;
grub_uint32_t flags;
};
struct grub_acpi_madt_entry_ioapic
{
struct grub_acpi_madt_entry_header hdr;
grub_uint8_t id;
grub_uint8_t pad;
grub_uint32_t address;
grub_uint32_t global_sys_interrupt;
};
struct grub_acpi_madt_entry_interrupt_override
{
struct grub_acpi_madt_entry_header hdr;
grub_uint8_t bus;
grub_uint8_t source;
grub_uint32_t global_sys_interrupt;
grub_uint16_t flags;
} GRUB_PACKED;
struct grub_acpi_madt_entry_lapic_nmi
{
struct grub_acpi_madt_entry_header hdr;
grub_uint8_t acpiid;
grub_uint16_t flags;
grub_uint8_t lint;
} GRUB_PACKED;
struct grub_acpi_madt_entry_sapic
{
struct grub_acpi_madt_entry_header hdr;
grub_uint8_t id;
grub_uint8_t pad;
grub_uint32_t global_sys_interrupt_base;
grub_uint64_t addr;
};
struct grub_acpi_madt_entry_lsapic
{
struct grub_acpi_madt_entry_header hdr;
grub_uint8_t cpu_id;
grub_uint8_t id;
grub_uint8_t eid;
grub_uint8_t pad[3];
grub_uint32_t flags;
grub_uint32_t cpu_uid;
grub_uint8_t cpu_uid_str[0];
};
struct grub_acpi_madt_entry_platform_int_source
{
struct grub_acpi_madt_entry_header hdr;
grub_uint16_t flags;
grub_uint8_t inttype;
grub_uint8_t cpu_id;
grub_uint8_t cpu_eid;
grub_uint8_t sapic_vector;
grub_uint32_t global_sys_int;
grub_uint32_t src_flags;
};
enum
{
GRUB_ACPI_MADT_ENTRY_SAPIC_FLAGS_ENABLED = 1
};
struct grub_acpi_genaddr {
grub_uint8_t space_id;
#define GRUB_ACPI_GENADDR_MEM_SPACE 0x00
#define GRUB_ACPI_GENADDR_IO_SPACE 0x01
grub_uint8_t bit_width;
grub_uint8_t bit_offset;
grub_uint8_t access_size;
#define GRUB_ACPI_GENADDR_SIZE_LGCY 0x00
#define GRUB_ACPI_GENADDR_SIZE_BYTE 0x01
#define GRUB_ACPI_GENADDR_SIZE_WORD 0x02
#define GRUB_ACPI_GENADDR_SIZE_DWORD 0x03
#define GRUB_ACPI_GENADDR_SIZE_QWORD 0x04
grub_uint64_t addr;
} GRUB_PACKED;
#define GRUB_ACPI_SPCR_SIGNATURE "SPCR"
struct grub_acpi_spcr {
struct grub_acpi_table_header hdr;
grub_uint8_t intf_type;
#define GRUB_ACPI_SPCR_INTF_TYPE_16550 0x00
#define GRUB_ACPI_SPCR_INTF_TYPE_16550X 0x01
grub_uint8_t reserved_0[3];
struct grub_acpi_genaddr base_addr;
grub_uint8_t interrupt_type;
grub_uint8_t irq;
grub_uint32_t gsi;
grub_uint8_t baud_rate;
#define GRUB_ACPI_SPCR_BAUD_CURRENT 0x00
#define GRUB_ACPI_SPCR_BAUD_9600 0x03
#define GRUB_ACPI_SPCR_BAUD_19200 0x04
#define GRUB_ACPI_SPCR_BAUD_57600 0x06
#define GRUB_ACPI_SPCR_BAUD_115200 0x07
grub_uint8_t parity;
grub_uint8_t stop_bits;
grub_uint8_t flow_control;
#define GRUB_ACPI_SPCR_FC_DCD_TX (1 << 0)
#define GRUB_ACPI_SPCR_FC_RTSCTS (1 << 1)
#define GRUB_ACPI_SPCR_FC_XONXOFF (1 << 2)
grub_uint8_t terminal_type;
grub_uint8_t language;
grub_uint16_t pci_device_id;
grub_uint16_t pci_vendor_id;
grub_uint8_t pci_bus;
grub_uint8_t pci_device;
grub_uint8_t pci_function;
grub_uint32_t pci_flags;
grub_uint8_t pci_segment;
grub_uint32_t reserved_1;
} GRUB_PACKED;
#ifndef GRUB_DSDT_TEST
struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void);
struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void);
struct grub_acpi_rsdp_v10 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv1) (void);
struct grub_acpi_rsdp_v20 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv2) (void);
grub_uint8_t EXPORT_FUNC(grub_byte_checksum) (void *base, grub_size_t size);
grub_err_t grub_acpi_create_ebda (void);
void grub_acpi_halt (void);
#endif
#define GRUB_ACPI_SLP_EN (1 << 13)
#define GRUB_ACPI_SLP_TYP_OFFSET 10
enum
{
GRUB_ACPI_OPCODE_ZERO = 0, GRUB_ACPI_OPCODE_ONE = 1,
GRUB_ACPI_OPCODE_NAME = 8, GRUB_ACPI_OPCODE_ALIAS = 0x06,
GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a,
GRUB_ACPI_OPCODE_WORD_CONST = 0x0b,
GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c,
GRUB_ACPI_OPCODE_STRING_CONST = 0x0d,
GRUB_ACPI_OPCODE_SCOPE = 0x10,
GRUB_ACPI_OPCODE_BUFFER = 0x11,
GRUB_ACPI_OPCODE_PACKAGE = 0x12,
GRUB_ACPI_OPCODE_METHOD = 0x14, GRUB_ACPI_OPCODE_EXTOP = 0x5b,
GRUB_ACPI_OPCODE_ADD = 0x72,
GRUB_ACPI_OPCODE_CONCAT = 0x73,
GRUB_ACPI_OPCODE_SUBTRACT = 0x74,
GRUB_ACPI_OPCODE_MULTIPLY = 0x77,
GRUB_ACPI_OPCODE_DIVIDE = 0x78,
GRUB_ACPI_OPCODE_LSHIFT = 0x79,
GRUB_ACPI_OPCODE_RSHIFT = 0x7a,
GRUB_ACPI_OPCODE_AND = 0x7b,
GRUB_ACPI_OPCODE_NAND = 0x7c,
GRUB_ACPI_OPCODE_OR = 0x7d,
GRUB_ACPI_OPCODE_NOR = 0x7e,
GRUB_ACPI_OPCODE_XOR = 0x7f,
GRUB_ACPI_OPCODE_CONCATRES = 0x84,
GRUB_ACPI_OPCODE_MOD = 0x85,
GRUB_ACPI_OPCODE_INDEX = 0x88,
GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD = 0x8a,
GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b,
GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c,
GRUB_ACPI_OPCODE_TOSTRING = 0x9c,
GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff
};
enum
{
GRUB_ACPI_EXTOPCODE_MUTEX = 0x01,
GRUB_ACPI_EXTOPCODE_EVENT_OP = 0x02,
GRUB_ACPI_EXTOPCODE_OPERATION_REGION = 0x80,
GRUB_ACPI_EXTOPCODE_FIELD_OP = 0x81,
GRUB_ACPI_EXTOPCODE_DEVICE_OP = 0x82,
GRUB_ACPI_EXTOPCODE_PROCESSOR_OP = 0x83,
GRUB_ACPI_EXTOPCODE_POWER_RES_OP = 0x84,
GRUB_ACPI_EXTOPCODE_THERMAL_ZONE_OP = 0x85,
GRUB_ACPI_EXTOPCODE_INDEX_FIELD_OP = 0x86,
GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87,
};
struct grub_acpi_fadt *
EXPORT_FUNC(grub_acpi_find_fadt) (void);
void *
EXPORT_FUNC(grub_acpi_find_table) (const char *sig);
#endif /* ! GRUB_ACPI_HEADER */
@@ -0,0 +1,129 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 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/>.
*/
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)exec.h 8.1 (Berkeley) 6/11/93
* $FreeBSD$
*/
#ifndef GRUB_AOUT_HEADER
#define GRUB_AOUT_HEADER 1
#include <grub/types.h>
#include <grub/file.h>
struct grub_aout32_header
{
grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
grub_uint32_t a_text; /* text segment size */
grub_uint32_t a_data; /* initialized data size */
grub_uint32_t a_bss; /* uninitialized data size */
grub_uint32_t a_syms; /* symbol table size */
grub_uint32_t a_entry; /* entry point */
grub_uint32_t a_trsize; /* text relocation size */
grub_uint32_t a_drsize; /* data relocation size */
};
struct grub_aout64_header
{
grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
grub_uint64_t a_text; /* text segment size */
grub_uint64_t a_data; /* initialized data size */
grub_uint64_t a_bss; /* uninitialized data size */
grub_uint64_t a_syms; /* symbol table size */
grub_uint64_t a_entry; /* entry point */
grub_uint64_t a_trsize; /* text relocation size */
grub_uint64_t a_drsize; /* data relocation size */
};
union grub_aout_header
{
struct grub_aout32_header aout32;
struct grub_aout64_header aout64;
};
#define AOUT_TYPE_NONE 0
#define AOUT_TYPE_AOUT32 1
#define AOUT_TYPE_AOUT64 6
#define AOUT32_OMAGIC 0x107 /* 0407 old impure format */
#define AOUT32_NMAGIC 0x108 /* 0410 read-only text */
#define AOUT32_ZMAGIC 0x10b /* 0413 demand load format */
#define AOUT32_QMAGIC 0xcc /* 0314 "compact" demand load format */
#define AOUT64_OMAGIC 0x1001
#define AOUT64_ZMAGIC 0x1002
#define AOUT64_NMAGIC 0x1003
#define AOUT_MID_ZERO 0 /* unknown - implementation dependent */
#define AOUT_MID_SUN010 1 /* sun 68010/68020 binary */
#define AOUT_MID_SUN020 2 /* sun 68020-only binary */
#define AOUT_MID_I386 134 /* i386 BSD binary */
#define AOUT_MID_SPARC 138 /* sparc */
#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
#define AOUT_MID_SUN 0x103
#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
#define AOUT_FLAG_PIC 0x10 /* contains position independent code */
#define AOUT_FLAG_DYNAMIC 0x20 /* contains run-time link-edit info */
#define AOUT_FLAG_DPMASK 0x30 /* mask for the above */
#define AOUT_GETMAGIC(header) ((header).a_midmag & 0xffff)
#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
#ifndef GRUB_UTIL
int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
void *load_addr, int load_size,
grub_size_t bss_size);
#endif
#endif /* ! GRUB_AOUT_HEADER */
@@ -0,0 +1,284 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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_ARC_HEADER
#define GRUB_ARC_HEADER 1
#include <grub/types.h>
#include <grub/symbol.h>
typedef unsigned grub_arc_enum_t;
typedef grub_uint64_t grub_arc_ularge_t;
typedef unsigned long grub_arc_ulong_t;
typedef long grub_arc_long_t;
typedef unsigned short grub_arc_ushort_t;
typedef unsigned char grub_arc_uchar_t;
typedef grub_arc_long_t grub_arc_err_t;
typedef grub_arc_ulong_t grub_arc_fileno_t;
struct grub_arc_memory_descriptor
{
grub_arc_enum_t type;
grub_arc_ulong_t start_page;
grub_arc_ulong_t num_pages;
};
enum grub_arc_memory_type
{
GRUB_ARC_MEMORY_EXCEPTION_BLOCK,
GRUB_ARC_MEMORY_SYSTEM_PARAMETER_BLOCK,
#ifdef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_MEMORY_FREE_CONTIGUOUS,
#endif
GRUB_ARC_MEMORY_FREE,
GRUB_ARC_MEMORY_BADRAM,
GRUB_ARC_MEMORY_LOADED, GRUB_ARC_MEMORY_FW_TEMPORARY,
GRUB_ARC_MEMORY_FW_PERMANENT,
#ifndef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_MEMORY_FREE_CONTIGUOUS,
#endif
};
struct grub_arc_timeinfo
{
grub_arc_ushort_t y;
grub_arc_ushort_t m;
grub_arc_ushort_t d;
grub_arc_ushort_t h;
grub_arc_ushort_t min;
grub_arc_ushort_t s;
grub_arc_ushort_t ms;
};
struct grub_arc_display_status
{
grub_arc_ushort_t x;
grub_arc_ushort_t y;
grub_arc_ushort_t w;
grub_arc_ushort_t h;
grub_arc_uchar_t fgcolor;
grub_arc_uchar_t bgcolor;
grub_arc_uchar_t high_intensity;
grub_arc_uchar_t underscored;
grub_arc_uchar_t reverse_video;
};
enum
{
GRUB_ARC_COMPONENT_FLAG_OUT = 0x40,
GRUB_ARC_COMPONENT_FLAG_IN = 0x20,
};
struct grub_arc_component
{
grub_arc_enum_t class;
grub_arc_enum_t type;
grub_arc_enum_t flags;
grub_arc_ushort_t version;
grub_arc_ushort_t rev;
grub_arc_ulong_t key;
grub_arc_ulong_t affinity;
grub_arc_ulong_t configdatasize;
grub_arc_ulong_t idlen;
const char *idstr;
};
enum
{
#ifdef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_COMPONENT_TYPE_ARC = 1,
#else
GRUB_ARC_COMPONENT_TYPE_ARC,
#endif
GRUB_ARC_COMPONENT_TYPE_CPU,
GRUB_ARC_COMPONENT_TYPE_FPU,
GRUB_ARC_COMPONENT_TYPE_PRI_I_CACHE,
GRUB_ARC_COMPONENT_TYPE_PRI_D_CACHE,
GRUB_ARC_COMPONENT_TYPE_SEC_I_CACHE,
GRUB_ARC_COMPONENT_TYPE_SEC_D_CACHE,
GRUB_ARC_COMPONENT_TYPE_SEC_CACHE,
GRUB_ARC_COMPONENT_TYPE_EISA,
GRUB_ARC_COMPONENT_TYPE_TCA,
GRUB_ARC_COMPONENT_TYPE_SCSI,
GRUB_ARC_COMPONENT_TYPE_DTIA,
GRUB_ARC_COMPONENT_TYPE_MULTIFUNC,
GRUB_ARC_COMPONENT_TYPE_DISK_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_TAPE_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_CDROM_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_WORM_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_SERIAL_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_NET_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_DISPLAY_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_PARALLEL_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_POINTER_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_KBD_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_AUDIO_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_OTHER_CONTROLLER,
GRUB_ARC_COMPONENT_TYPE_DISK,
GRUB_ARC_COMPONENT_TYPE_FLOPPY,
GRUB_ARC_COMPONENT_TYPE_TAPE,
GRUB_ARC_COMPONENT_TYPE_MODEM,
GRUB_ARC_COMPONENT_TYPE_MONITOR,
GRUB_ARC_COMPONENT_TYPE_PRINTER,
GRUB_ARC_COMPONENT_TYPE_POINTER,
GRUB_ARC_COMPONENT_TYPE_KBD,
GRUB_ARC_COMPONENT_TYPE_TERMINAL,
#ifndef GRUB_CPU_WORDS_BIGENDIAN
GRUB_ARC_COMPONENT_TYPE_OTHER_PERIPHERAL,
#endif
GRUB_ARC_COMPONENT_TYPE_LINE,
GRUB_ARC_COMPONENT_TYPE_NET,
GRUB_ARC_COMPONENT_TYPE_MEMORY_UNIT,
};
enum grub_arc_file_access
{
GRUB_ARC_FILE_ACCESS_OPEN_RO,
GRUB_ARC_FILE_ACCESS_OPEN_WO,
GRUB_ARC_FILE_ACCESS_OPEN_RW,
};
struct grub_arc_fileinfo
{
grub_arc_ularge_t start;
grub_arc_ularge_t end;
grub_arc_ularge_t current;
grub_arc_enum_t type;
grub_arc_ulong_t fnamelength;
grub_arc_uchar_t attr;
char filename[32];
};
struct grub_arc_firmware_vector
{
/* 0x00. */
void *load;
void *invoke;
void *execute;
void *halt;
/* 0x10. */
void (*powerdown) (void);
void (*restart) (void);
void (*reboot) (void);
void (*exit) (void);
/* 0x20. */
void *reserved1;
const struct grub_arc_component * (*getpeer) (const struct grub_arc_component *comp);
const struct grub_arc_component * (*getchild) (const struct grub_arc_component *comp);
void *getparent;
/* 0x30. */
void *getconfigurationdata;
void *addchild;
void *deletecomponent;
void *getcomponent;
/* 0x40. */
void *saveconfiguration;
void *getsystemid;
struct grub_arc_memory_descriptor *(*getmemorydescriptor) (struct grub_arc_memory_descriptor *current);
void *reserved2;
/* 0x50. */
struct grub_arc_timeinfo *(*gettime) (void);
void *getrelativetime;
void *getdirectoryentry;
grub_arc_err_t (*open) (const char *path, grub_arc_enum_t mode,
grub_arc_fileno_t *fileno);
/* 0x60. */
grub_arc_err_t (*close) (grub_arc_fileno_t fileno);
grub_arc_err_t (*read) (grub_arc_fileno_t fileno, void *buf,
grub_arc_ulong_t n,
grub_arc_ulong_t *count);
grub_arc_err_t (*get_read_status) (grub_arc_fileno_t fileno);
grub_arc_err_t (*write) (grub_arc_fileno_t fileno, const void *buf,
grub_arc_ulong_t n,
grub_arc_ulong_t *count);
/* 0x70. */
grub_arc_err_t (*seek) (grub_arc_fileno_t fileno,
grub_arc_ularge_t *pos, grub_arc_enum_t mode);
void *mount;
const char * (*getenvironmentvariable) (const char *name);
void *setenvironmentvariable;
/* 0x80. */
grub_arc_err_t (*getfileinformation) (grub_arc_fileno_t fileno,
struct grub_arc_fileinfo *info);
void *setfileinformation;
void *flushallcaches;
void *testunicodecharacter;
/* 0x90. */
struct grub_arc_display_status * (*getdisplaystatus) (grub_arc_fileno_t fileno);
};
struct grub_arc_adapter
{
grub_arc_ulong_t adapter_type;
grub_arc_ulong_t adapter_vector_length;
void *adapter_vector;
};
struct grub_arc_system_parameter_block
{
grub_arc_ulong_t signature;
grub_arc_ulong_t length;
grub_arc_ushort_t version;
grub_arc_ushort_t revision;
void *restartblock;
void *debugblock;
void *gevector;
void *utlbmissvector;
grub_arc_ulong_t firmware_vector_length;
struct grub_arc_firmware_vector *firmwarevector;
grub_arc_ulong_t private_vector_length;
void *private_vector;
grub_arc_ulong_t adapter_count;
struct grub_arc_adapter adapters[0];
};
#define GRUB_ARC_SYSTEM_PARAMETER_BLOCK ((struct grub_arc_system_parameter_block *) 0xa0001000)
#define GRUB_ARC_FIRMWARE_VECTOR (GRUB_ARC_SYSTEM_PARAMETER_BLOCK->firmwarevector)
#define GRUB_ARC_STDIN 0
#define GRUB_ARC_STDOUT 1
typedef int (*grub_arc_iterate_devs_hook_t)
(const char *name, const struct grub_arc_component *comp, void *data);
int EXPORT_FUNC (grub_arc_iterate_devs) (grub_arc_iterate_devs_hook_t hook,
void *hook_data,
int alt_names);
char *EXPORT_FUNC (grub_arc_alt_name_to_norm) (const char *name, const char *suffix);
int EXPORT_FUNC (grub_arc_is_device_serial) (const char *name, int alt_names);
#define FOR_ARC_CHILDREN(comp, parent) for (comp = GRUB_ARC_FIRMWARE_VECTOR->getchild (parent); comp; comp = GRUB_ARC_FIRMWARE_VECTOR->getpeer (comp))
extern void grub_arcdisk_init (void);
extern void grub_arcdisk_fini (void);
#endif
@@ -0,0 +1,31 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 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_CONSOLE_MACHINE_HEADER
#define GRUB_CONSOLE_MACHINE_HEADER 1
#include <grub/symbol.h>
/* Initialize the console system. */
void grub_console_init_early (void);
void grub_console_init_lately (void);
/* Finish the console system. */
void grub_console_fini (void);
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
@@ -0,0 +1,63 @@
/* archelp.h -- Archive helper functions */
/*
* 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_ARCHELP_HEADER
#define GRUB_ARCHELP_HEADER 1
#include <grub/fs.h>
#include <grub/file.h>
typedef enum
{
GRUB_ARCHELP_ATTR_TYPE = 0160000,
GRUB_ARCHELP_ATTR_FILE = 0100000,
GRUB_ARCHELP_ATTR_DIR = 0040000,
GRUB_ARCHELP_ATTR_LNK = 0120000,
GRUB_ARCHELP_ATTR_NOTIME = 0x80000000,
GRUB_ARCHELP_ATTR_END = 0xffffffff
} grub_archelp_mode_t;
struct grub_archelp_data;
struct grub_archelp_ops
{
grub_err_t
(*find_file) (struct grub_archelp_data *data, char **name,
grub_int32_t *mtime,
grub_archelp_mode_t *mode);
char *
(*get_link_target) (struct grub_archelp_data *data);
void
(*rewind) (struct grub_archelp_data *data);
};
grub_err_t
grub_archelp_dir (struct grub_archelp_data *data,
struct grub_archelp_ops *ops,
const char *path_in,
grub_fs_dir_hook_t hook, void *hook_data);
grub_err_t
grub_archelp_open (struct grub_archelp_data *data,
struct grub_archelp_ops *ops,
const char *name_in);
#endif
@@ -0,0 +1,29 @@
/*
* 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_MACHINE_CONSOLE_HEADER
#define GRUB_MACHINE_CONSOLE_HEADER 1
void grub_video_coreboot_fb_init (void);
void grub_video_coreboot_fb_early_init (void);
void grub_video_coreboot_fb_late_init (void);
void grub_video_coreboot_fb_fini (void);
extern struct grub_linuxbios_table_framebuffer *grub_video_coreboot_fbtable;
#endif /* ! GRUB_MACHINE_CONSOLE_HEADER */
@@ -0,0 +1,44 @@
/*
* 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_KERNEL_MACHINE_HEADER
#define GRUB_KERNEL_MACHINE_HEADER 1
#ifndef ASM_FILE
#include <grub/symbol.h>
#include <grub/types.h>
struct grub_fdt_board
{
const char *vendor, *part;
const grub_uint8_t *dtb;
grub_size_t dtb_size;
};
extern struct grub_fdt_board grub_fdt_boards[];
void grub_machine_timer_init (void);
void grub_pl050_init (void);
void grub_cros_init (void);
void grub_rk3288_spi_init (void);
extern grub_addr_t EXPORT_VAR (start_of_ram);
#endif /* ! ASM_FILE */
#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
@@ -0,0 +1,21 @@
#ifndef GRUB_ARM_CROS_EC_H
#define GRUB_ARM_CROS_EC_H 1
#include <grub/types.h>
#include <grub/fdtbus.h>
#define GRUB_CROS_EC_KEYSCAN_COLS 13
#define GRUB_CROS_EC_KEYSCAN_ROWS 8
struct grub_cros_ec_keyscan {
grub_uint8_t data[GRUB_CROS_EC_KEYSCAN_COLS];
};
int
grub_cros_ec_scan_keyboard (const struct grub_fdtbus_dev *dev,
struct grub_cros_ec_keyscan *scan);
int
grub_cros_ec_validate (const struct grub_fdtbus_dev *dev);
#endif
@@ -0,0 +1,6 @@
#ifndef GRUB_MEMORY_CPU_HEADER
#include <grub/efi/memory.h>
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffff
#endif /* ! GRUB_MEMORY_CPU_HEADER */
@@ -0,0 +1,52 @@
/* linux.h - ARM linux specific definitions */
/*
* 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_ARM_LINUX_HEADER
#define GRUB_ARM_LINUX_HEADER 1
#include "system.h"
#include <grub/efi/pe32.h>
#if defined GRUB_MACHINE_UBOOT
# include <grub/uboot/uboot.h>
# define LINUX_ADDRESS (start_of_ram + 0x8000)
# define LINUX_INITRD_ADDRESS (start_of_ram + 0x03000000)
# define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000)
# define grub_arm_firmware_get_boot_data grub_uboot_get_boot_data
# define grub_arm_firmware_get_machine_type grub_uboot_get_machine_type
#elif defined (GRUB_MACHINE_COREBOOT)
#include <grub/fdtbus.h>
#include <grub/arm/coreboot/kernel.h>
# define LINUX_ADDRESS (start_of_ram + 0x8000)
# define LINUX_INITRD_ADDRESS (start_of_ram + 0x03000000)
# define LINUX_FDT_ADDRESS (LINUX_INITRD_ADDRESS - 0x10000)
static inline const void *
grub_arm_firmware_get_boot_data (void)
{
return grub_fdtbus_get_fdt ();
}
static inline grub_uint32_t
grub_arm_firmware_get_machine_type (void)
{
return GRUB_ARM_MACHINE_TYPE_FDT;
}
#endif
#endif /* ! GRUB_ARM_LINUX_HEADER */
@@ -0,0 +1,51 @@
/*
* 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_ARM_RELOC_H
#define GRUB_ARM_RELOC_H 1
grub_err_t grub_arm_reloc_abs32 (grub_uint32_t *addr, Elf32_Addr sym_addr);
int
grub_arm_thm_call_check_offset (grub_int32_t offset, int is_thumb);
grub_int32_t
grub_arm_thm_call_get_offset (grub_uint16_t *target);
grub_err_t
grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset);
grub_int32_t
grub_arm_thm_jump19_get_offset (grub_uint16_t *target);
void
grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset);
int
grub_arm_thm_jump19_check_offset (grub_int32_t offset);
grub_int32_t
grub_arm_jump24_get_offset (grub_uint32_t *target);
int
grub_arm_jump24_check_offset (grub_int32_t offset);
void
grub_arm_jump24_set_offset (grub_uint32_t *target,
grub_int32_t offset);
grub_uint16_t
grub_arm_thm_movw_movt_get_value (grub_uint16_t *target);
void
grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value);
#endif
@@ -0,0 +1,27 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2004,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_SETJMP_CPU_HEADER
#define GRUB_SETJMP_CPU_HEADER 1
typedef unsigned long grub_jmp_buf[10];
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,16 @@
#ifndef GRUB_STARTUP_CPU_HEADER
#define GRUB_STARTUP_CPU_HEADER
struct grub_arm_startup_registers
{
/* registers 0-11 */
/* for U-boot r[1] is machine type */
/* for U-boot r[2] is boot data */
grub_uint32_t r[12];
grub_uint32_t sp;
grub_uint32_t lr;
};
extern struct grub_arm_startup_registers grub_arm_saved_registers;
#endif
@@ -0,0 +1,19 @@
#ifndef GRUB_SYSTEM_CPU_HEADER
#define GRUB_SYSTEM_CPU_HEADER
#include <grub/symbol.h>
#include <grub/types.h>
enum
{
GRUB_ARM_MACHINE_TYPE_RASPBERRY_PI = 3138,
GRUB_ARM_MACHINE_TYPE_FDT = 0xFFFFFFFF
};
void EXPORT_FUNC(grub_arm_disable_caches_mmu) (void);
void grub_arm_enable_caches_mmu (void);
void grub_arm_enable_mmu (grub_uint32_t *mmu_tables);
void grub_arm_clear_mmu_v6 (void);
#endif /* ! GRUB_SYSTEM_CPU_HEADER */
@@ -0,0 +1,29 @@
/*
* 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 KERNEL_CPU_TIME_HEADER
#define KERNEL_CPU_TIME_HEADER 1
static __inline void
grub_cpu_idle (void)
{
/* FIXME: this can't work until we handle interrupts. */
/* asm volatile ("wfi"); */
}
#endif /* ! KERNEL_CPU_TIME_HEADER */
@@ -0,0 +1,34 @@
/*
* 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_TYPES_CPU_HEADER
#define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */
#define GRUB_TARGET_SIZEOF_VOID_P 4
/* The size of long. */
#define GRUB_TARGET_SIZEOF_LONG 4
/* currently only support little-endian. */
#undef GRUB_TARGET_WORDS_BIGENDIAN
/* Unaligned accesses only supported if MMU enabled */
//#define GRUB_HAVE_UNALIGNED_ACCESS 1
#endif /* ! GRUB_TYPES_CPU_HEADER */
@@ -0,0 +1,32 @@
/*
* 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_KERNEL_MACHINE_HEADER
#define GRUB_KERNEL_MACHINE_HEADER 1
#ifndef ASM_FILE
#include <grub/symbol.h>
#include <grub/types.h>
#endif /* ! ASM_FILE */
#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE
#define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (16 * 1024 * 1024)
#endif /* ! GRUB_KERNEL_MACHINE_HEADER */
@@ -0,0 +1,6 @@
#ifndef GRUB_MEMORY_CPU_HEADER
#include <grub/efi/memory.h>
#define GRUB_EFI_MAX_USABLE_ADDRESS 0xffffffffffffULL
#endif /* ! GRUB_MEMORY_CPU_HEADER */
@@ -0,0 +1,41 @@
/*
* 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_ARM64_RELOC_H
#define GRUB_ARM64_RELOC_H 1
struct grub_arm64_trampoline
{
grub_uint32_t ldr; /* ldr x16, 8 */
grub_uint32_t br; /* br x16 */
grub_uint64_t addr;
};
int grub_arm_64_check_xxxx26_offset (grub_int64_t offset);
void
grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset);
int
grub_arm64_check_hi21_signed (grub_int64_t offset);
void
grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset);
void
grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target);
void
grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target);
#endif
@@ -0,0 +1,27 @@
/*
* 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_SETJMP_CPU_HEADER
#define GRUB_SETJMP_CPU_HEADER 1
typedef unsigned long long grub_jmp_buf[13];
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,29 @@
/*
* 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 KERNEL_CPU_TIME_HEADER
#define KERNEL_CPU_TIME_HEADER 1
static __inline void
grub_cpu_idle (void)
{
/* FIXME: this can't work until we handle interrupts. */
/* asm volatile ("wfi"); */
}
#endif /* ! KERNEL_CPU_TIME_HEADER */
@@ -0,0 +1,34 @@
/*
* 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_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
/* currently only support little-endian. */
#undef GRUB_TARGET_WORDS_BIGENDIAN
/* Unaligned accesses only supported if MMU enabled */
#undef GRUB_HAVE_UNALIGNED_ACCESS
#endif /* ! GRUB_TYPES_CPU_HEADER */
@@ -0,0 +1,40 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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_AT_KEYBOARD_HEADER
#define GRUB_AT_KEYBOARD_HEADER 1
/* Used for sending commands to the controller. */
#define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02)
#define KEYBOARD_COMMAND_READ 0x20
#define KEYBOARD_COMMAND_WRITE 0x60
#define KEYBOARD_COMMAND_ENABLE 0xf4
#define KEYBOARD_COMMAND_REBOOT 0xfe
#define KEYBOARD_AT_TRANSLATE 0x40
#define KEYBOARD_AT_DISABLE 0x10
#define KEYBOARD_ISMAKE(x) !((x) & 0x80)
#define KEYBOARD_ISREADY(x) ((x) & 0x01)
#define KEYBOARD_SCANCODE(x) ((x) & 0x7f)
extern void grub_at_keyboard_init (void);
extern void grub_at_keyboard_fini (void);
int grub_at_keyboard_is_alive (void);
#endif
@@ -0,0 +1,225 @@
/* ata.h - ATA disk access. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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_ATA_HEADER
#define GRUB_ATA_HEADER 1
#include <grub/misc.h>
#include <grub/symbol.h>
#include <grub/disk.h>
/* XXX: For now this only works on i386. */
#include <grub/cpu/io.h>
typedef enum
{
GRUB_ATA_CHS,
GRUB_ATA_LBA,
GRUB_ATA_LBA48
} grub_ata_addressing_t;
#define GRUB_ATA_CH0_PORT1 0x1f0
#define GRUB_ATA_CH1_PORT1 0x170
#define GRUB_ATA_CH0_PORT2 0x3f6
#define GRUB_ATA_CH1_PORT2 0x376
#define GRUB_ATA_REG_DATA 0
#define GRUB_ATA_REG_ERROR 1
#define GRUB_ATA_REG_FEATURES 1
#define GRUB_ATA_REG_SECTORS 2
#define GRUB_ATAPI_REG_IREASON 2
#define GRUB_ATA_REG_SECTNUM 3
#define GRUB_ATA_REG_CYLLSB 4
#define GRUB_ATA_REG_CYLMSB 5
#define GRUB_ATA_REG_LBALOW 3
#define GRUB_ATA_REG_LBAMID 4
#define GRUB_ATAPI_REG_CNTLOW 4
#define GRUB_ATA_REG_LBAHIGH 5
#define GRUB_ATAPI_REG_CNTHIGH 5
#define GRUB_ATA_REG_DISK 6
#define GRUB_ATA_REG_CMD 7
#define GRUB_ATA_REG_STATUS 7
#define GRUB_ATA_REG2_CONTROL 0
#define GRUB_ATA_STATUS_ERR 0x01
#define GRUB_ATA_STATUS_INDEX 0x02
#define GRUB_ATA_STATUS_ECC 0x04
#define GRUB_ATA_STATUS_DRQ 0x08
#define GRUB_ATA_STATUS_SEEK 0x10
#define GRUB_ATA_STATUS_WRERR 0x20
#define GRUB_ATA_STATUS_READY 0x40
#define GRUB_ATA_STATUS_BUSY 0x80
/* ATAPI interrupt reason values (I/O, D/C bits). */
#define GRUB_ATAPI_IREASON_MASK 0x3
#define GRUB_ATAPI_IREASON_DATA_OUT 0x0
#define GRUB_ATAPI_IREASON_CMD_OUT 0x1
#define GRUB_ATAPI_IREASON_DATA_IN 0x2
#define GRUB_ATAPI_IREASON_ERROR 0x3
enum grub_ata_commands
{
GRUB_ATA_CMD_CHECK_POWER_MODE = 0xe5,
GRUB_ATA_CMD_IDENTIFY_DEVICE = 0xec,
GRUB_ATA_CMD_IDENTIFY_PACKET_DEVICE = 0xa1,
GRUB_ATA_CMD_IDLE = 0xe3,
GRUB_ATA_CMD_PACKET = 0xa0,
GRUB_ATA_CMD_READ_SECTORS = 0x20,
GRUB_ATA_CMD_READ_SECTORS_EXT = 0x24,
GRUB_ATA_CMD_READ_SECTORS_DMA = 0xc8,
GRUB_ATA_CMD_READ_SECTORS_DMA_EXT = 0x25,
GRUB_ATA_CMD_SECURITY_FREEZE_LOCK = 0xf5,
GRUB_ATA_CMD_SET_FEATURES = 0xef,
GRUB_ATA_CMD_SLEEP = 0xe6,
GRUB_ATA_CMD_SMART = 0xb0,
GRUB_ATA_CMD_STANDBY_IMMEDIATE = 0xe0,
GRUB_ATA_CMD_WRITE_SECTORS = 0x30,
GRUB_ATA_CMD_WRITE_SECTORS_EXT = 0x34,
GRUB_ATA_CMD_WRITE_SECTORS_DMA_EXT = 0x35,
GRUB_ATA_CMD_WRITE_SECTORS_DMA = 0xca,
};
enum grub_ata_timeout_milliseconds
{
GRUB_ATA_TOUT_STD = 1000, /* 1s standard timeout. */
GRUB_ATA_TOUT_DATA = 10000, /* 10s DATA I/O timeout. */
GRUB_ATA_TOUT_SPINUP = 10000, /* Give the device 10s on first try to spinon. */
};
typedef union
{
grub_uint8_t raw[11];
struct
{
union
{
grub_uint8_t features;
grub_uint8_t error;
};
union
{
grub_uint8_t sectors;
grub_uint8_t atapi_ireason;
};
union
{
grub_uint8_t lba_low;
grub_uint8_t sectnum;
};
union
{
grub_uint8_t lba_mid;
grub_uint8_t cyllsb;
grub_uint8_t atapi_cntlow;
};
union
{
grub_uint8_t lba_high;
grub_uint8_t cylmsb;
grub_uint8_t atapi_cnthigh;
};
grub_uint8_t disk;
union
{
grub_uint8_t cmd;
grub_uint8_t status;
};
grub_uint8_t sectors48;
grub_uint8_t lba48_low;
grub_uint8_t lba48_mid;
grub_uint8_t lba48_high;
};
} grub_ata_regs_t;
/* ATA pass through parameters and function. */
struct grub_disk_ata_pass_through_parms
{
grub_ata_regs_t taskfile;
void * buffer;
grub_size_t size;
int write;
void *cmd;
int cmdsize;
int dma;
};
struct grub_ata
{
/* Addressing methods available for accessing this device. If CHS
is only available, use that. Otherwise use LBA, except for the
high sectors. In that case use LBA48. */
grub_ata_addressing_t addr;
/* Sector count. */
grub_uint64_t size;
grub_uint32_t log_sector_size;
/* CHS maximums. */
grub_uint16_t cylinders;
grub_uint16_t heads;
grub_uint16_t sectors_per_track;
/* Set to 0 for ATA, set to 1 for ATAPI. */
int atapi;
int dma;
grub_size_t maxbuffer;
int *present;
void *data;
struct grub_ata_dev *dev;
};
typedef struct grub_ata *grub_ata_t;
typedef int (*grub_ata_dev_iterate_hook_t) (int id, int bus, void *data);
struct grub_ata_dev
{
/* Call HOOK with each device name, until HOOK returns non-zero. */
int (*iterate) (grub_ata_dev_iterate_hook_t hook, void *hook_data,
grub_disk_pull_t pull);
/* Open the device named NAME, and set up SCSI. */
grub_err_t (*open) (int id, int bus, struct grub_ata *scsi);
/* Close the scsi device SCSI. */
void (*close) (struct grub_ata *ata);
/* Read SIZE bytes from the device SCSI into BUF after sending the
command CMD of size CMDSIZE. */
grub_err_t (*readwrite) (struct grub_ata *ata,
struct grub_disk_ata_pass_through_parms *parms,
int spinup);
/* The next scsi device. */
struct grub_ata_dev *next;
};
typedef struct grub_ata_dev *grub_ata_dev_t;
void grub_ata_dev_register (grub_ata_dev_t dev);
void grub_ata_dev_unregister (grub_ata_dev_t dev);
#endif /* ! GRUB_ATA_HEADER */
@@ -0,0 +1,37 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_AUTH_HEADER
#define GRUB_AUTH_HEADER 1
#include <grub/err.h>
#include <grub/crypto.h>
#define GRUB_AUTH_MAX_PASSLEN 1024
typedef grub_err_t (*grub_auth_callback_t) (const char *, const char *, void *);
grub_err_t grub_auth_register_authentication (const char *user,
grub_auth_callback_t callback,
void *arg);
grub_err_t grub_auth_unregister_authentication (const char *user);
grub_err_t grub_auth_authenticate (const char *user);
grub_err_t grub_auth_deauthenticate (const char *user);
grub_err_t grub_auth_check_authentication (const char *userlist);
#endif /* ! GRUB_AUTH_HEADER */
@@ -0,0 +1,64 @@
/*
* 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/>.
*/
/* This file provides some abstractions so that the same code compiles with
both efi and efiemu
*/
#ifndef GRUB_AUTOEFI_HEADER
#define GRUB_AUTOEFI_HEADER 1
#ifdef GRUB_MACHINE_EFI
# include <grub/efi/efi.h>
# define grub_autoefi_get_memory_map grub_efi_get_memory_map
# define grub_autoefi_finish_boot_services grub_efi_finish_boot_services
# define grub_autoefi_exit_boot_services grub_efi_exit_boot_services
# define grub_autoefi_system_table grub_efi_system_table
# define grub_autoefi_mmap_iterate grub_machine_mmap_iterate
# define grub_autoefi_set_virtual_address_map grub_efi_set_virtual_address_map
static inline grub_err_t grub_autoefi_prepare (void)
{
return GRUB_ERR_NONE;
};
# define SYSTEM_TABLE_SIZEOF(x) (sizeof(grub_efi_system_table->x))
# define SYSTEM_TABLE_VAR(x) ((void *)&(grub_efi_system_table->x))
# define SYSTEM_TABLE_PTR(x) ((void *)(grub_efi_system_table->x))
# define SIZEOF_OF_UINTN sizeof (grub_efi_uintn_t)
# define SYSTEM_TABLE(x) (grub_efi_system_table->x)
# define grub_autoefi_finish_boot_services grub_efi_finish_boot_services
# define EFI_PRESENT 1
#else
# include <grub/efiemu/efiemu.h>
# define grub_autoefi_get_memory_map grub_efiemu_get_memory_map
# define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services
# define grub_autoefi_exit_boot_services grub_efiemu_exit_boot_services
# define grub_autoefi_system_table grub_efiemu_system_table
# define grub_autoefi_mmap_iterate grub_efiemu_mmap_iterate
# define grub_autoefi_prepare grub_efiemu_prepare
# define grub_autoefi_set_virtual_address_map grub_efiemu_set_virtual_address_map
# define SYSTEM_TABLE_SIZEOF GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF
# define SYSTEM_TABLE_VAR GRUB_EFIEMU_SYSTEM_TABLE_VAR
# define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR
# define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN
# define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE
# define grub_efi_allocate_fixed(x,y) (x)
# define grub_efi_free_pages(x,y) GRUB_EFI_SUCCESS
# define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services
# define EFI_PRESENT 1
#endif
#endif
@@ -0,0 +1,26 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_BACKTRACE_HEADER
#define GRUB_BACKTRACE_HEADER 1
void grub_backtrace (void);
void grub_backtrace_pointer (void *ptr);
void grub_backtrace_print_address (void *addr);
#endif
@@ -0,0 +1,107 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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_BITMAP_HEADER
#define GRUB_BITMAP_HEADER 1
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/video.h>
#include <grub/safemath.h>
#define IMAGE_HW_MAX_PX 16384
struct grub_video_bitmap
{
/* Bitmap format description. */
struct grub_video_mode_info mode_info;
/* Pointer to bitmap data formatted according to mode_info. */
void *data;
};
struct grub_video_bitmap_reader
{
/* File extension for this bitmap type (including dot). */
const char *extension;
/* Reader function to load bitmap. */
grub_err_t (*reader) (struct grub_video_bitmap **bitmap,
const char *filename);
/* Next reader. */
struct grub_video_bitmap_reader *next;
};
typedef struct grub_video_bitmap_reader *grub_video_bitmap_reader_t;
void EXPORT_FUNC (grub_video_bitmap_reader_register) (grub_video_bitmap_reader_t reader);
void EXPORT_FUNC (grub_video_bitmap_reader_unregister) (grub_video_bitmap_reader_t reader);
grub_err_t EXPORT_FUNC (grub_video_bitmap_create) (struct grub_video_bitmap **bitmap,
unsigned int width, unsigned int height,
enum grub_video_blit_format blit_format);
grub_err_t EXPORT_FUNC (grub_video_bitmap_destroy) (struct grub_video_bitmap *bitmap);
grub_err_t EXPORT_FUNC (grub_video_bitmap_load) (struct grub_video_bitmap **bitmap,
const char *filename);
/* Return bitmap width. */
static inline unsigned int
grub_video_bitmap_get_width (struct grub_video_bitmap *bitmap)
{
if (!bitmap)
return 0;
return bitmap->mode_info.width;
}
/* Return bitmap height. */
static inline unsigned int
grub_video_bitmap_get_height (struct grub_video_bitmap *bitmap)
{
if (!bitmap)
return 0;
return bitmap->mode_info.height;
}
/*
* Calculate and store the size of data buffer of 1bit bitmap in result.
* Equivalent to "*result = (width * height + 7) / 8" if no overflow occurs.
* Return true when overflow occurs or false if there is no overflow.
* This function is intentionally implemented as a macro instead of
* an inline function. Although a bit awkward, it preserves data types for
* safemath macros and reduces macro side effects as much as possible.
*
* XXX: Will report false overflow if width * height > UINT64_MAX.
*/
#define grub_video_bitmap_calc_1bpp_bufsz(width, height, result) \
({ \
grub_uint64_t _bitmap_pixels; \
grub_mul ((width), (height), &_bitmap_pixels) ? 1 : \
grub_cast (_bitmap_pixels / GRUB_CHAR_BIT + !!(_bitmap_pixels % GRUB_CHAR_BIT), (result)); \
})
void EXPORT_FUNC (grub_video_bitmap_get_mode_info) (struct grub_video_bitmap *bitmap,
struct grub_video_mode_info *mode_info);
void *EXPORT_FUNC (grub_video_bitmap_get_data) (struct grub_video_bitmap *bitmap);
#endif /* ! GRUB_BITMAP_HEADER */
@@ -0,0 +1,85 @@
/* bitmap_scale.h - Bitmap scaling functions. */
/*
* 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_BITMAP_SCALE_HEADER
#define GRUB_BITMAP_SCALE_HEADER 1
#include <grub/err.h>
#include <grub/types.h>
#include <grub/bitmap_scale.h>
enum grub_video_bitmap_scale_method
{
/* Choose the fastest interpolation algorithm. */
GRUB_VIDEO_BITMAP_SCALE_METHOD_FASTEST,
/* Choose the highest quality interpolation algorithm. */
GRUB_VIDEO_BITMAP_SCALE_METHOD_BEST,
/* Specific algorithms: */
/* Nearest neighbor interpolation. */
GRUB_VIDEO_BITMAP_SCALE_METHOD_NEAREST,
/* Bilinear interpolation. */
GRUB_VIDEO_BITMAP_SCALE_METHOD_BILINEAR
};
typedef enum grub_video_bitmap_selection_method
{
GRUB_VIDEO_BITMAP_SELECTION_METHOD_STRETCH,
GRUB_VIDEO_BITMAP_SELECTION_METHOD_CROP,
GRUB_VIDEO_BITMAP_SELECTION_METHOD_PADDING,
GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITWIDTH,
GRUB_VIDEO_BITMAP_SELECTION_METHOD_FITHEIGHT
} grub_video_bitmap_selection_method_t;
typedef enum grub_video_bitmap_v_align
{
GRUB_VIDEO_BITMAP_V_ALIGN_TOP,
GRUB_VIDEO_BITMAP_V_ALIGN_CENTER,
GRUB_VIDEO_BITMAP_V_ALIGN_BOTTOM
} grub_video_bitmap_v_align_t;
typedef enum grub_video_bitmap_h_align
{
GRUB_VIDEO_BITMAP_H_ALIGN_LEFT,
GRUB_VIDEO_BITMAP_H_ALIGN_CENTER,
GRUB_VIDEO_BITMAP_H_ALIGN_RIGHT
} grub_video_bitmap_h_align_t;
grub_err_t
EXPORT_FUNC (grub_video_bitmap_create_scaled) (struct grub_video_bitmap **dst,
int dst_width, int dst_height,
struct grub_video_bitmap *src,
enum
grub_video_bitmap_scale_method
scale_method);
grub_err_t
EXPORT_FUNC (grub_video_bitmap_scale_proportional)
(struct grub_video_bitmap **dst,
int dst_width, int dst_height,
struct grub_video_bitmap *src,
enum grub_video_bitmap_scale_method
scale_method,
grub_video_bitmap_selection_method_t
selection_method,
grub_video_bitmap_v_align_t v_align,
grub_video_bitmap_h_align_t h_align);
#endif /* ! GRUB_BITMAP_SCALE_HEADER */
@@ -0,0 +1,106 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,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_BSDLABEL_PARTITION_HEADER
#define GRUB_BSDLABEL_PARTITION_HEADER 1
/* Constants for BSD disk label. */
#define GRUB_PC_PARTITION_BSD_LABEL_SECTOR 1
#define GRUB_PC_PARTITION_BSD_LABEL_MAGIC 0x82564557
/* BSD partition types. */
enum
{
GRUB_PC_PARTITION_BSD_TYPE_UNUSED = 0,
GRUB_PC_PARTITION_BSD_TYPE_SWAP = 1,
GRUB_PC_PARTITION_BSD_TYPE_V6 = 2,
GRUB_PC_PARTITION_BSD_TYPE_V7 = 3,
GRUB_PC_PARTITION_BSD_TYPE_SYSV = 4,
GRUB_PC_PARTITION_BSD_TYPE_V71K = 5,
GRUB_PC_PARTITION_BSD_TYPE_V8 = 6,
GRUB_PC_PARTITION_BSD_TYPE_BSDFFS = 7,
GRUB_PC_PARTITION_BSD_TYPE_MSDOS = 8,
GRUB_PC_PARTITION_BSD_TYPE_BSDLFS = 9,
GRUB_PC_PARTITION_BSD_TYPE_OTHER = 10,
GRUB_PC_PARTITION_BSD_TYPE_HPFS = 11,
GRUB_PC_PARTITION_BSD_TYPE_ISO9660 = 12,
GRUB_PC_PARTITION_BSD_TYPE_BOOT = 13
};
/* FreeBSD-specific types. */
enum
{
GRUB_PC_PARTITION_FREEBSD_TYPE_VINUM = 14,
GRUB_PC_PARTITION_FREEBSD_TYPE_RAID = 15,
GRUB_PC_PARTITION_FREEBSD_TYPE_JFS2 = 21
};
/* NetBSD-specific types. */
enum
{
GRUB_PC_PARTITION_NETBSD_TYPE_ADOS = 14,
GRUB_PC_PARTITION_NETBSD_TYPE_HFS = 15,
GRUB_PC_PARTITION_NETBSD_TYPE_FILECORE = 16,
GRUB_PC_PARTITION_NETBSD_TYPE_EXT2FS = 17,
GRUB_PC_PARTITION_NETBSD_TYPE_NTFS = 18,
GRUB_PC_PARTITION_NETBSD_TYPE_RAID = 19,
GRUB_PC_PARTITION_NETBSD_TYPE_CCD = 20,
GRUB_PC_PARTITION_NETBSD_TYPE_JFS2 = 21,
GRUB_PC_PARTITION_NETBSD_TYPE_APPLEUFS = 22
};
/* OpenBSD-specific types. */
enum
{
GRUB_PC_PARTITION_OPENBSD_TYPE_ADOS = 14,
GRUB_PC_PARTITION_OPENBSD_TYPE_HFS = 15,
GRUB_PC_PARTITION_OPENBSD_TYPE_FILECORE = 16,
GRUB_PC_PARTITION_OPENBSD_TYPE_EXT2FS = 17,
GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS = 18,
GRUB_PC_PARTITION_OPENBSD_TYPE_RAID = 19
};
#define GRUB_PC_PARTITION_BSD_LABEL_WHOLE_DISK_PARTITION 2
/* The BSD partition entry. */
struct grub_partition_bsd_entry
{
grub_uint32_t size;
grub_uint32_t offset;
grub_uint32_t fragment_size;
grub_uint8_t fs_type;
grub_uint8_t fs_fragments;
grub_uint16_t fs_cylinders;
} GRUB_PACKED;
/* The BSD disk label. Only define members useful for GRUB. */
struct grub_partition_bsd_disk_label
{
grub_uint32_t magic;
grub_uint16_t type;
grub_uint8_t unused1[18];
grub_uint8_t packname[16];
grub_uint8_t unused2[92];
grub_uint32_t magic2;
grub_uint16_t checksum;
grub_uint16_t num_partitions;
grub_uint32_t boot_size;
grub_uint32_t superblock_size;
} GRUB_PACKED;
#endif /* ! GRUB_PC_PARTITION_HEADER */
@@ -0,0 +1,71 @@
/* btrfs.c - B-tree file system. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011,2012,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_BTRFS_H
#define GRUB_BTRFS_H 1
enum
{
GRUB_BTRFS_ITEM_TYPE_INODE_ITEM = 0x01,
GRUB_BTRFS_ITEM_TYPE_INODE_REF = 0x0c,
GRUB_BTRFS_ITEM_TYPE_DIR_ITEM = 0x54,
GRUB_BTRFS_ITEM_TYPE_EXTENT_ITEM = 0x6c,
GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM = 0x84,
GRUB_BTRFS_ITEM_TYPE_ROOT_BACKREF = 0x90,
GRUB_BTRFS_ITEM_TYPE_DEVICE = 0xd8,
GRUB_BTRFS_ITEM_TYPE_CHUNK = 0xe4
};
enum
{
GRUB_BTRFS_ROOT_VOL_OBJECTID = 5,
GRUB_BTRFS_TREE_ROOT_OBJECTID = 0x100,
};
struct grub_btrfs_root_item
{
grub_uint8_t dummy[0xb0];
grub_uint64_t tree;
grub_uint64_t inode;
};
struct grub_btrfs_key
{
grub_uint64_t object_id;
grub_uint8_t type;
grub_uint64_t offset;
} GRUB_PACKED;
struct grub_btrfs_root_backref
{
grub_uint64_t inode_id;
grub_uint64_t seqnr;
grub_uint16_t n;
char name[0];
};
struct grub_btrfs_inode_ref
{
grub_uint64_t idxid;
grub_uint16_t n;
char name[0];
};
#endif
@@ -0,0 +1,144 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2021 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_BUFFER_H
#define GRUB_BUFFER_H 1
#include <grub/err.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/safemath.h>
#include <grub/types.h>
struct grub_buffer
{
grub_uint8_t *data;
grub_size_t sz;
grub_size_t pos;
grub_size_t used;
};
/*
* grub_buffer_t represents a simple variable sized byte buffer with
* read and write cursors. It currently only implements
* functionality required by the only user in GRUB (append byte[s],
* peeking data at a specified position and updating the read cursor.
* Some things that this doesn't do yet are:
* - Reading a portion of the buffer by copying data from the current
* read position in to a caller supplied destination buffer and then
* automatically updating the read cursor.
* - Dropping the read part at the start of the buffer when an append
* requires more space.
*/
typedef struct grub_buffer *grub_buffer_t;
/* Allocate a new buffer with the specified initial size. */
extern grub_buffer_t grub_buffer_new (grub_size_t sz);
/* Free the buffer and its resources. */
extern void grub_buffer_free (grub_buffer_t buf);
/* Return the number of unread bytes in this buffer. */
static inline grub_size_t
grub_buffer_get_unread_bytes (grub_buffer_t buf)
{
return buf->used - buf->pos;
}
/*
* Ensure that the buffer size is at least the requested
* number of bytes.
*/
extern grub_err_t grub_buffer_ensure_space (grub_buffer_t buf, grub_size_t req);
/*
* Append the specified number of bytes from the supplied
* data to the buffer.
*/
static inline grub_err_t
grub_buffer_append_data (grub_buffer_t buf, const void *data, grub_size_t len)
{
grub_size_t req;
if (grub_add (buf->used, len, &req))
return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
if (grub_buffer_ensure_space (buf, req) != GRUB_ERR_NONE)
return grub_errno;
grub_memcpy (&buf->data[buf->used], data, len);
buf->used = req;
return GRUB_ERR_NONE;
}
/* Append the supplied character to the buffer. */
static inline grub_err_t
grub_buffer_append_char (grub_buffer_t buf, char c)
{
return grub_buffer_append_data (buf, &c, 1);
}
/*
* Forget and return the underlying data buffer. The caller
* becomes the owner of this buffer, and must free it when it
* is no longer required.
*/
extern void *grub_buffer_take_data (grub_buffer_t buf);
/* Reset this buffer. Note that this does not deallocate any resources. */
void grub_buffer_reset (grub_buffer_t buf);
/*
* Return a pointer to the underlying data buffer at the specified
* offset from the current read position. Note that this pointer may
* become invalid if the buffer is mutated further.
*/
static inline void *
grub_buffer_peek_data_at (grub_buffer_t buf, grub_size_t off)
{
if (grub_add (buf->pos, off, &off))
{
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
return NULL;
}
if (off >= buf->used)
{
grub_error (GRUB_ERR_OUT_OF_RANGE, N_("peek out of range"));
return NULL;
}
return &buf->data[off];
}
/*
* Return a pointer to the underlying data buffer at the current
* read position. Note that this pointer may become invalid if the
* buffer is mutated further.
*/
static inline void *
grub_buffer_peek_data (grub_buffer_t buf)
{
return grub_buffer_peek_data_at (buf, 0);
}
/* Advance the read position by the specified number of bytes. */
extern grub_err_t grub_buffer_advance_read_pos (grub_buffer_t buf, grub_size_t n);
#endif /* GRUB_BUFFER_H */
@@ -0,0 +1,30 @@
/* bufio.h - prototypes for bufio */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 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_BUFIO_H
#define GRUB_BUFIO_H 1
#include <grub/file.h>
grub_file_t EXPORT_FUNC (grub_bufio_open) (grub_file_t io, grub_size_t size);
grub_file_t EXPORT_FUNC (grub_buffile_open) (const char *name,
enum grub_file_type type,
grub_size_t size);
#endif /* ! GRUB_BUFIO_H */
@@ -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)))
{
}
#else
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,178 @@
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
* Copyright (C) 2012 Google, Inc.
* Copyright (C) 2013 The Chromium OS Authors. All rights reserved.
*
* This file is dual-licensed. You can choose between:
* - The GNU GPL, version 2, as published by the Free Software Foundation
* - The revised BSD license (without advertising clause)
*
* ---------------------------------------------------------------------------
* 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; version 2 of the License.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
* ---------------------------------------------------------------------------
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ---------------------------------------------------------------------------
*/
#ifndef _CBFS_CORE_H_
#define _CBFS_CORE_H_
#include <grub/types.h>
/** These are standard values for the known compression
alogrithms that coreboot knows about for stages and
payloads. Of course, other CBFS users can use whatever
values they want, as long as they understand them. */
#define CBFS_COMPRESS_NONE 0
#define CBFS_COMPRESS_LZMA 1
/** These are standard component types for well known
components (i.e - those that coreboot needs to consume.
Users are welcome to use any other value for their
components */
#define CBFS_TYPE_STAGE 0x10
#define CBFS_TYPE_PAYLOAD 0x20
#define CBFS_TYPE_OPTIONROM 0x30
#define CBFS_TYPE_BOOTSPLASH 0x40
#define CBFS_TYPE_RAW 0x50
#define CBFS_TYPE_VSA 0x51
#define CBFS_TYPE_MBI 0x52
#define CBFS_TYPE_MICROCODE 0x53
#define CBFS_COMPONENT_CMOS_DEFAULT 0xaa
#define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa
#define CBFS_HEADER_MAGIC 0x4F524243
#define CBFS_HEADER_VERSION1 0x31313131
#define CBFS_HEADER_VERSION2 0x31313132
#define CBFS_HEADER_VERSION CBFS_HEADER_VERSION2
#define CBFS_HEADER_INVALID_ADDRESS ((void*)(0xffffffff))
/** this is the master cbfs header - it need to be located somewhere available
to bootblock (to load romstage). Where it actually lives is up to coreboot.
On x86, a pointer to this header will live at 0xFFFFFFFC.
For other platforms, you need to define CONFIG_CBFS_HEADER_ROM_OFFSET */
struct cbfs_header {
grub_uint32_t magic;
grub_uint32_t version;
grub_uint32_t romsize;
grub_uint32_t bootblocksize;
grub_uint32_t align;
grub_uint32_t offset;
grub_uint32_t architecture;
grub_uint32_t pad[1];
} GRUB_PACKED;
/* "Unknown" refers to CBFS headers version 1,
* before the architecture was defined (i.e., x86 only).
*/
#define CBFS_ARCHITECTURE_UNKNOWN 0xFFFFFFFF
#define CBFS_ARCHITECTURE_X86 0x00000001
#define CBFS_ARCHITECTURE_ARMV7 0x00000010
/** This is a component header - every entry in the CBFS
will have this header.
This is how the component is arranged in the ROM:
-------------- <- 0
component header
-------------- <- sizeof(struct component)
component name
-------------- <- offset
data
...
-------------- <- offset + len
*/
#define CBFS_FILE_MAGIC "LARCHIVE"
struct cbfs_file {
char magic[8];
grub_uint32_t len;
grub_uint32_t type;
grub_uint32_t checksum;
grub_uint32_t offset;
} GRUB_PACKED;
/*** Component sub-headers ***/
/* Following are component sub-headers for the "standard"
component types */
/** This is the sub-header for stage components. Stages are
loaded by coreboot during the normal boot process */
struct cbfs_stage {
grub_uint32_t compression; /** Compression type */
grub_uint64_t entry; /** entry point */
grub_uint64_t load; /** Where to load in memory */
grub_uint32_t len; /** length of data to load */
grub_uint32_t memlen; /** total length of object in memory */
} GRUB_PACKED;
/** this is the sub-header for payload components. Payloads
are loaded by coreboot at the end of the boot process */
struct cbfs_payload_segment {
grub_uint32_t type;
grub_uint32_t compression;
grub_uint32_t offset;
grub_uint64_t load_addr;
grub_uint32_t len;
grub_uint32_t mem_len;
} GRUB_PACKED;
struct cbfs_payload {
struct cbfs_payload_segment segments;
};
#define PAYLOAD_SEGMENT_CODE 0x45444F43
#define PAYLOAD_SEGMENT_DATA 0x41544144
#define PAYLOAD_SEGMENT_BSS 0x20535342
#define PAYLOAD_SEGMENT_PARAMS 0x41524150
#define PAYLOAD_SEGMENT_ENTRY 0x52544E45
struct cbfs_optionrom {
grub_uint32_t compression;
grub_uint32_t len;
} GRUB_PACKED;
#endif
@@ -0,0 +1,323 @@
/*
* 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);
#endif
@@ -0,0 +1,128 @@
/*
* 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_CMOS_H
#define GRUB_CMOS_H 1
#include <grub/types.h>
#if !defined (__powerpc__) && !defined (__sparc__)
#include <grub/cpu/io.h>
#include <grub/cpu/cmos.h>
#endif
#define GRUB_CMOS_INDEX_SECOND 0
#define GRUB_CMOS_INDEX_SECOND_ALARM 1
#define GRUB_CMOS_INDEX_MINUTE 2
#define GRUB_CMOS_INDEX_MINUTE_ALARM 3
#define GRUB_CMOS_INDEX_HOUR 4
#define GRUB_CMOS_INDEX_HOUR_ALARM 5
#define GRUB_CMOS_INDEX_DAY_OF_WEEK 6
#define GRUB_CMOS_INDEX_DAY_OF_MONTH 7
#define GRUB_CMOS_INDEX_MONTH 8
#define GRUB_CMOS_INDEX_YEAR 9
#define GRUB_CMOS_INDEX_STATUS_A 0xA
#define GRUB_CMOS_INDEX_STATUS_B 0xB
#define GRUB_CMOS_INDEX_STATUS_C 0xC
#define GRUB_CMOS_INDEX_STATUS_D 0xD
#define GRUB_CMOS_STATUS_B_DAYLIGHT 1
#define GRUB_CMOS_STATUS_B_24HOUR 2
#define GRUB_CMOS_STATUS_B_BINARY 4
static inline grub_uint8_t
grub_bcd_to_num (grub_uint8_t a)
{
return ((a >> 4) * 10 + (a & 0xF));
}
static inline grub_uint8_t
grub_num_to_bcd (grub_uint8_t a)
{
return (((a / 10) << 4) + (a % 10));
}
#if !defined (__powerpc__) && !defined (__sparc__)
static inline grub_err_t
grub_cmos_read (grub_uint8_t index, grub_uint8_t *val)
{
if (index & 0x80)
{
grub_outb (index & 0x7f, GRUB_CMOS_ADDR_REG_HI);
*val = grub_inb (GRUB_CMOS_DATA_REG_HI);
}
else
{
grub_outb (index & 0x7f, GRUB_CMOS_ADDR_REG);
*val = grub_inb (GRUB_CMOS_DATA_REG);
}
return GRUB_ERR_NONE;
}
static inline grub_err_t
grub_cmos_write (grub_uint8_t index, grub_uint8_t value)
{
if (index & 0x80)
{
grub_outb (index & 0x7f, GRUB_CMOS_ADDR_REG_HI);
grub_outb (value, GRUB_CMOS_DATA_REG_HI);
}
else
{
grub_outb (index & 0x7f, GRUB_CMOS_ADDR_REG);
grub_outb (value, GRUB_CMOS_DATA_REG);
}
return GRUB_ERR_NONE;
}
#else
grub_err_t grub_cmos_find_port (void);
extern volatile grub_uint8_t *grub_cmos_port;
static inline grub_err_t
grub_cmos_read (grub_uint8_t index, grub_uint8_t *val)
{
if (!grub_cmos_port)
{
grub_err_t err;
err = grub_cmos_find_port ();
if (err)
return err;
}
grub_cmos_port[((index & 0x80) >> 6) | 0] = index & 0x7f;
*val = grub_cmos_port[((index & 0x80) >> 6) | 1];
return GRUB_ERR_NONE;
}
static inline grub_err_t
grub_cmos_write (grub_uint8_t index, grub_uint8_t val)
{
if (!grub_cmos_port)
{
grub_err_t err;
err = grub_cmos_find_port ();
if (err)
return err;
}
grub_cmos_port[((index & 0x80) >> 6) | 0] = index;
grub_cmos_port[((index & 0x80) >> 6) | 1] = val;
return GRUB_ERR_NONE;
}
#endif
#endif /* GRUB_CMOS_H */
@@ -0,0 +1,30 @@
/*
* 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_VIDEO_COLOR_HEADER
#define GRUB_VIDEO_COLOR_HEADER 1
#include <grub/video.h>
int grub_video_get_named_color (const char *name,
grub_video_rgba_color_t *color);
grub_err_t grub_video_parse_color (const char *s,
grub_video_rgba_color_t *color);
#endif
@@ -0,0 +1,134 @@
/*
* 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_COMMAND_HEADER
#define GRUB_COMMAND_HEADER 1
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/list.h>
#include <grub/misc.h>
typedef enum grub_command_flags
{
/* This is an extended command. */
GRUB_COMMAND_FLAG_EXTCMD = 0x10,
/* This is an dynamic command. */
GRUB_COMMAND_FLAG_DYNCMD = 0x20,
/* This command accepts block arguments. */
GRUB_COMMAND_FLAG_BLOCKS = 0x40,
/* This command accepts unknown arguments as direct parameters. */
GRUB_COMMAND_ACCEPT_DASH = 0x80,
/* This command accepts only options preceding direct arguments. */
GRUB_COMMAND_OPTIONS_AT_START = 0x100,
/* Can be executed in an entries extractor. */
GRUB_COMMAND_FLAG_EXTRACTOR = 0x200
} grub_command_flags_t;
struct grub_command;
typedef grub_err_t (*grub_command_func_t) (struct grub_command *cmd,
int argc, char **argv);
#define GRUB_COMMAND_PRIO_MASK 0xff
#define GRUB_COMMAND_FLAG_ACTIVE 0x100
/* The command description. */
struct grub_command
{
/* The next element. */
struct grub_command *next;
struct grub_command **prev;
/* The name. */
const char *name;
/* The priority. */
int prio;
/* The callback function. */
grub_command_func_t func;
/* The flags. */
grub_command_flags_t flags;
/* The summary of the command usage. */
const char *summary;
/* The description of the command. */
const char *description;
/* Arbitrary data. */
void *data;
};
typedef struct grub_command *grub_command_t;
extern grub_command_t EXPORT_VAR(grub_command_list);
grub_command_t
EXPORT_FUNC(grub_register_command_prio) (const char *name,
grub_command_func_t func,
const char *summary,
const char *description,
int prio);
grub_command_t
EXPORT_FUNC(grub_register_command_lockdown) (const char *name,
grub_command_func_t func,
const char *summary,
const char *description);
void EXPORT_FUNC(grub_unregister_command) (grub_command_t cmd);
static inline grub_command_t
grub_register_command (const char *name,
grub_command_func_t func,
const char *summary,
const char *description)
{
return grub_register_command_prio (name, func, summary, description, 0);
}
static inline grub_command_t
grub_register_command_p1 (const char *name,
grub_command_func_t func,
const char *summary,
const char *description)
{
return grub_register_command_prio (name, func, summary, description, 1);
}
static inline grub_command_t
grub_command_find (const char *name)
{
return grub_named_list_find (GRUB_AS_NAMED_LIST (grub_command_list), name);
}
static inline grub_err_t
grub_command_execute (const char *name, int argc, char **argv)
{
grub_command_t cmd;
cmd = grub_command_find (name);
return (cmd) ? cmd->func (cmd, argc, argv) : GRUB_ERR_FILE_NOT_FOUND;
}
#define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list)
#define FOR_COMMANDS_SAFE(var, next) FOR_LIST_ELEMENTS_SAFE((var), (next), grub_command_list)
void grub_register_core_commands (void);
#endif /* ! GRUB_COMMAND_HEADER */
@@ -0,0 +1,265 @@
/* compiler-rt-emu.h - prototypes for compiler helpers. */
/*
* 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_RT_HEADER
#define GRUB_COMPILER_RT_HEADER 1
#include <config-util.h>
#include <grub/types.h>
#include <grub/symbol.h>
#ifdef HAVE___UDIVSI3
grub_uint32_t
EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b);
#endif
#ifdef HAVE___UMODSI3
grub_uint32_t
EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
#endif
#ifdef HAVE___DIVSI3
grub_int32_t
EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b);
#endif
#ifdef HAVE___MODSI3
grub_int32_t
EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b);
#endif
#ifdef HAVE___DIVDI3
grub_int64_t
EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b);
#endif
#ifdef HAVE___MODDI3
grub_int64_t
EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b);
#endif
#ifdef HAVE___UDIVDI3
grub_uint64_t
EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b);
#endif
#ifdef HAVE___UMODDI3
grub_uint64_t
EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b);
#endif
#ifdef HAVE___CTZDI2
unsigned
EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
#endif
#ifdef HAVE___CTZSI2
unsigned
EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
#endif
#ifdef HAVE___CLZDI2
int
EXPORT_FUNC (__clzdi2) (grub_uint64_t x);
#endif
#ifdef HAVE___AEABI_UIDIV
grub_uint32_t
EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);
#endif
#ifdef HAVE___AEABI_UIDIVMOD
grub_uint32_t
EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b);
#endif
#ifdef HAVE___AEABI_IDIV
grub_int32_t
EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b);
#endif
#ifdef HAVE___AEABI_IDIVMOD
grub_int32_t
EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b);
#endif
#ifdef HAVE___AEABI_ULCMP
int
EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b);
#endif
/* Needed for allowing modules to be compiled as thumb. */
#ifdef HAVE___MULDI3
grub_uint64_t
EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b);
#endif
#ifdef HAVE___AEABI_LMUL
grub_uint64_t
EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b);
#endif
#ifdef HAVE___AEABI_MEMCPY
void *
EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n);
#endif
#ifdef HAVE___AEABI_MEMCPY4
void *
EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n);
#endif
#ifdef HAVE___AEABI_MEMCPY8
void *
EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n);
#endif
#ifdef HAVE___AEABI_MEMSET
void *
EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n);
#endif
#ifdef HAVE___AEABI_MEMCLR
void *
EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n);
#endif
#ifdef HAVE___AEABI_MEMCLR4
void *
EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n);
#endif
#ifdef HAVE___AEABI_MEMCLR8
void *
EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n);
#endif
#ifdef HAVE___AEABI_LASR
grub_uint64_t
EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b);
#endif
#ifdef HAVE___AEABI_LLSL
grub_uint64_t
EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b);
#endif
#ifdef HAVE___AEABI_LLSR
grub_uint64_t
EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b);
#endif
#ifdef HAVE__RESTGPR_14_X
void EXPORT_FUNC (_restgpr_14_x) (void);
void EXPORT_FUNC (_restgpr_15_x) (void);
void EXPORT_FUNC (_restgpr_16_x) (void);
void EXPORT_FUNC (_restgpr_17_x) (void);
void EXPORT_FUNC (_restgpr_18_x) (void);
void EXPORT_FUNC (_restgpr_19_x) (void);
void EXPORT_FUNC (_restgpr_20_x) (void);
void EXPORT_FUNC (_restgpr_21_x) (void);
void EXPORT_FUNC (_restgpr_22_x) (void);
void EXPORT_FUNC (_restgpr_23_x) (void);
void EXPORT_FUNC (_restgpr_24_x) (void);
void EXPORT_FUNC (_restgpr_25_x) (void);
void EXPORT_FUNC (_restgpr_26_x) (void);
void EXPORT_FUNC (_restgpr_27_x) (void);
void EXPORT_FUNC (_restgpr_28_x) (void);
void EXPORT_FUNC (_restgpr_29_x) (void);
void EXPORT_FUNC (_restgpr_30_x) (void);
void EXPORT_FUNC (_restgpr_31_x) (void);
void EXPORT_FUNC (_savegpr_14) (void);
void EXPORT_FUNC (_savegpr_15) (void);
void EXPORT_FUNC (_savegpr_16) (void);
void EXPORT_FUNC (_savegpr_17) (void);
void EXPORT_FUNC (_savegpr_18) (void);
void EXPORT_FUNC (_savegpr_19) (void);
void EXPORT_FUNC (_savegpr_20) (void);
void EXPORT_FUNC (_savegpr_21) (void);
void EXPORT_FUNC (_savegpr_22) (void);
void EXPORT_FUNC (_savegpr_23) (void);
void EXPORT_FUNC (_savegpr_24) (void);
void EXPORT_FUNC (_savegpr_25) (void);
void EXPORT_FUNC (_savegpr_26) (void);
void EXPORT_FUNC (_savegpr_27) (void);
void EXPORT_FUNC (_savegpr_28) (void);
void EXPORT_FUNC (_savegpr_29) (void);
void EXPORT_FUNC (_savegpr_30) (void);
void EXPORT_FUNC (_savegpr_31) (void);
#endif
#ifdef HAVE___UCMPDI2
int
EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
#endif
#ifdef HAVE___ASHLDI3
grub_uint64_t
EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b);
#endif
#ifdef HAVE___ASHRDI3
grub_uint64_t
EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b);
#endif
#ifdef HAVE___LSHRDI3
grub_uint64_t
EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
#endif
#ifdef HAVE___BSWAPSI2
grub_uint32_t
EXPORT_FUNC(__bswapsi2) (grub_uint32_t u);
#endif
#ifdef HAVE___BSWAPDI2
grub_uint64_t
EXPORT_FUNC(__bswapdi2) (grub_uint64_t u);
#endif
int EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n);
void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
void *EXPORT_FUNC(memset) (void *s, int c, grub_size_t n);
#ifdef HAVE___BZERO
void EXPORT_FUNC (__bzero) (void *s, grub_size_t n);
#endif
#ifdef HAVE___REGISTER_FRAME_INFO
void EXPORT_FUNC (__register_frame_info) (void);
#endif
#ifdef HAVE___DEREGISTER_FRAME_INFO
void EXPORT_FUNC (__deregister_frame_info) (void);
#endif
#ifdef HAVE____CHKSTK_MS
void EXPORT_FUNC (___chkstk_ms) (void);
#endif
#ifdef HAVE___CHKSTK_MS
void EXPORT_FUNC (__chkstk_ms) (void);
#endif
#endif
@@ -0,0 +1,213 @@
/* compiler-rt.h - prototypes for compiler helpers. */
/*
* 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_RT_HEADER
#define GRUB_COMPILER_RT_HEADER 1
#include <stdarg.h>
#include <grub/types.h>
#include <grub/symbol.h>
#include <grub/misc.h>
#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE
grub_uint32_t
EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b);
grub_uint32_t
EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b);
grub_int32_t
EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b);
grub_int32_t
EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b);
grub_int64_t
EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b);
grub_int64_t
EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b);
grub_uint64_t
EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b);
grub_uint64_t
EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b);
#endif
#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || \
defined (__arm__) || defined(__riscv)
unsigned
EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
#define NEED_CTZDI2 1
#endif
#if defined (__mips__) || defined (__arm__) || \
(defined(__riscv) && (__riscv_xlen == 32))
unsigned
EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
#define NEED_CTZSI2 1
#endif
#ifdef __arm__
grub_uint32_t
EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b);
grub_uint32_t
EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b);
grub_int32_t
EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b);
grub_int32_t
EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b);
int
EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b);
/* Needed for allowing modules to be compiled as thumb. */
grub_uint64_t
EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b);
grub_uint64_t
EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b);
void *
EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n);
void *
EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n);
void *
EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n);
void *
EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n);
void EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n);
void EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n);
void EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n);
grub_uint64_t
EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b);
grub_uint64_t
EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b);
grub_uint64_t
EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b);
#endif
#if defined(__mips__) || defined(__riscv) || defined(__sparc__)
int
EXPORT_FUNC (__clzsi2) (grub_uint32_t val);
#endif
#if defined(__mips__) || defined(__riscv) || defined(__sparc__)
int
EXPORT_FUNC (__clzdi2) (grub_uint64_t val);
#endif
#if defined (__powerpc__)
void EXPORT_FUNC (_restgpr_14_x) (void);
void EXPORT_FUNC (_restgpr_15_x) (void);
void EXPORT_FUNC (_restgpr_16_x) (void);
void EXPORT_FUNC (_restgpr_17_x) (void);
void EXPORT_FUNC (_restgpr_18_x) (void);
void EXPORT_FUNC (_restgpr_19_x) (void);
void EXPORT_FUNC (_restgpr_20_x) (void);
void EXPORT_FUNC (_restgpr_21_x) (void);
void EXPORT_FUNC (_restgpr_22_x) (void);
void EXPORT_FUNC (_restgpr_23_x) (void);
void EXPORT_FUNC (_restgpr_24_x) (void);
void EXPORT_FUNC (_restgpr_25_x) (void);
void EXPORT_FUNC (_restgpr_26_x) (void);
void EXPORT_FUNC (_restgpr_27_x) (void);
void EXPORT_FUNC (_restgpr_28_x) (void);
void EXPORT_FUNC (_restgpr_29_x) (void);
void EXPORT_FUNC (_restgpr_30_x) (void);
void EXPORT_FUNC (_restgpr_31_x) (void);
void EXPORT_FUNC (_savegpr_14) (void);
void EXPORT_FUNC (_savegpr_15) (void);
void EXPORT_FUNC (_savegpr_16) (void);
void EXPORT_FUNC (_savegpr_17) (void);
void EXPORT_FUNC (_savegpr_18) (void);
void EXPORT_FUNC (_savegpr_19) (void);
void EXPORT_FUNC (_savegpr_20) (void);
void EXPORT_FUNC (_savegpr_21) (void);
void EXPORT_FUNC (_savegpr_22) (void);
void EXPORT_FUNC (_savegpr_23) (void);
void EXPORT_FUNC (_savegpr_24) (void);
void EXPORT_FUNC (_savegpr_25) (void);
void EXPORT_FUNC (_savegpr_26) (void);
void EXPORT_FUNC (_savegpr_27) (void);
void EXPORT_FUNC (_savegpr_28) (void);
void EXPORT_FUNC (_savegpr_29) (void);
void EXPORT_FUNC (_savegpr_30) (void);
void EXPORT_FUNC (_savegpr_31) (void);
#endif
#if defined (__powerpc__) || defined(__mips__) || defined (__arm__) || \
(defined(__riscv) && (__riscv_xlen == 32))
int
EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
grub_uint64_t
EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b);
grub_uint64_t
EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b);
grub_uint64_t
EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
#endif
#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || \
defined (__arm__) || defined(__riscv)
grub_uint32_t
EXPORT_FUNC(__bswapsi2) (grub_uint32_t u);
grub_uint64_t
EXPORT_FUNC(__bswapdi2) (grub_uint64_t u);
#endif
#if defined (__APPLE__) && defined(__i386__)
#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0)))
#else
#define GRUB_BUILTIN_ATTR
#endif
/* Prototypes for aliases. */
int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n);
void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n);
void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n);
#ifdef __APPLE__
void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n);
#endif
#if defined (__MINGW32__) || defined (__CYGWIN__)
void EXPORT_FUNC (__register_frame_info) (void);
void EXPORT_FUNC (__deregister_frame_info) (void);
void EXPORT_FUNC (___chkstk_ms) (void);
void EXPORT_FUNC (__chkstk_ms) (void);
#endif
#endif
@@ -0,0 +1,59 @@
/* 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 GRUB_ATTRIBUTE_ERROR(msg) \
__attribute__ ((__error__ (msg)))
#else
# define GRUB_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
#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
# define CLANG_PREREQ(maj,min) \
((__clang_major__ > (maj)) || \
(__clang_major__ == (maj) && __clang_minor__ >= (min)))
#else
# define CLANG_PREREQ(maj,min) 0
#endif
#endif /* ! GRUB_COMPILER_HEADER */
@@ -0,0 +1,114 @@
/* memory.h - describe the memory map */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2007,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _GRUB_MACHINE_LBIO_HEADER
#define _GRUB_MACHINE_LBIO_HEADER 1
#include <grub/types.h>
#include <grub/err.h>
struct grub_linuxbios_table_header
{
grub_uint8_t signature[4];
grub_uint32_t header_size;
grub_uint32_t header_checksum;
grub_uint32_t table_size;
grub_uint32_t table_checksum;
grub_uint32_t table_entries;
};
typedef struct grub_linuxbios_table_header *grub_linuxbios_table_header_t;
struct grub_linuxbios_timestamp_entry
{
grub_uint32_t id;
grub_uint64_t tsc;
} GRUB_PACKED;
struct grub_linuxbios_timestamp_table
{
grub_uint64_t base_tsc;
grub_uint32_t capacity;
grub_uint32_t used;
struct grub_linuxbios_timestamp_entry entries[0];
} GRUB_PACKED;
struct grub_linuxbios_mainboard
{
grub_uint8_t vendor;
grub_uint8_t part_number;
char strings[0];
};
struct grub_linuxbios_table_item
{
grub_uint32_t tag;
grub_uint32_t size;
};
typedef struct grub_linuxbios_table_item *grub_linuxbios_table_item_t;
enum
{
GRUB_LINUXBIOS_MEMBER_UNUSED = 0x00,
GRUB_LINUXBIOS_MEMBER_MEMORY = 0x01,
GRUB_LINUXBIOS_MEMBER_MAINBOARD = 0x03,
GRUB_LINUXBIOS_MEMBER_CONSOLE = 0x10,
GRUB_LINUXBIOS_MEMBER_LINK = 0x11,
GRUB_LINUXBIOS_MEMBER_FRAMEBUFFER = 0x12,
GRUB_LINUXBIOS_MEMBER_TIMESTAMPS = 0x16,
GRUB_LINUXBIOS_MEMBER_CBMEMC = 0x17
};
struct grub_linuxbios_table_framebuffer {
grub_uint64_t lfb;
grub_uint32_t width;
grub_uint32_t height;
grub_uint32_t pitch;
grub_uint8_t bpp;
grub_uint8_t red_field_pos;
grub_uint8_t red_mask_size;
grub_uint8_t green_field_pos;
grub_uint8_t green_mask_size;
grub_uint8_t blue_field_pos;
grub_uint8_t blue_mask_size;
grub_uint8_t reserved_field_pos;
grub_uint8_t reserved_mask_size;
} GRUB_PACKED;
struct grub_linuxbios_mem_region
{
grub_uint64_t addr;
grub_uint64_t size;
#define GRUB_MACHINE_MEMORY_AVAILABLE 1
grub_uint32_t type;
} GRUB_PACKED;
typedef struct grub_linuxbios_mem_region *mem_region_t;
grub_err_t
EXPORT_FUNC(grub_linuxbios_table_iterate) (int (*hook) (grub_linuxbios_table_item_t,
void *),
void *hook_data);
grub_linuxbios_table_header_t
grub_linuxbios_get_tables (void);
int
grub_linuxbios_check_signature (grub_linuxbios_table_header_t tbl_header);
#endif
@@ -0,0 +1,422 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 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/>.
*/
/* Contains elements based on gcrypt-module.h and gcrypt.h.in.
If it's changed please update this file. */
#ifndef GRUB_CRYPTO_HEADER
#define GRUB_CRYPTO_HEADER 1
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/err.h>
#include <grub/mm.h>
typedef enum
{
GPG_ERR_NO_ERROR,
GPG_ERR_BAD_MPI,
GPG_ERR_BAD_SECKEY,
GPG_ERR_BAD_SIGNATURE,
GPG_ERR_CIPHER_ALGO,
GPG_ERR_CONFLICT,
GPG_ERR_DECRYPT_FAILED,
GPG_ERR_DIGEST_ALGO,
GPG_ERR_GENERAL,
GPG_ERR_INTERNAL,
GPG_ERR_INV_ARG,
GPG_ERR_INV_CIPHER_MODE,
GPG_ERR_INV_FLAG,
GPG_ERR_INV_KEYLEN,
GPG_ERR_INV_OBJ,
GPG_ERR_INV_OP,
GPG_ERR_INV_SEXP,
GPG_ERR_INV_VALUE,
GPG_ERR_MISSING_VALUE,
GPG_ERR_NO_ENCRYPTION_SCHEME,
GPG_ERR_NO_OBJ,
GPG_ERR_NO_PRIME,
GPG_ERR_NO_SIGNATURE_SCHEME,
GPG_ERR_NOT_FOUND,
GPG_ERR_NOT_IMPLEMENTED,
GPG_ERR_NOT_SUPPORTED,
GPG_ERR_PUBKEY_ALGO,
GPG_ERR_SELFTEST_FAILED,
GPG_ERR_TOO_SHORT,
GPG_ERR_UNSUPPORTED,
GPG_ERR_WEAK_KEY,
GPG_ERR_WRONG_KEY_USAGE,
GPG_ERR_WRONG_PUBKEY_ALGO,
GPG_ERR_OUT_OF_MEMORY,
GPG_ERR_TOO_LARGE,
GPG_ERR_ENOMEM
} gpg_err_code_t;
typedef gpg_err_code_t gpg_error_t;
typedef gpg_error_t gcry_error_t;
typedef gpg_err_code_t gcry_err_code_t;
#define gcry_error_t gcry_err_code_t
#if 0
enum gcry_cipher_modes
{
GCRY_CIPHER_MODE_NONE = 0, /* Not yet specified. */
GCRY_CIPHER_MODE_ECB = 1, /* Electronic codebook. */
GCRY_CIPHER_MODE_CFB = 2, /* Cipher feedback. */
GCRY_CIPHER_MODE_CBC = 3, /* Cipher block chaining. */
GCRY_CIPHER_MODE_STREAM = 4, /* Used with stream ciphers. */
GCRY_CIPHER_MODE_OFB = 5, /* Outer feedback. */
GCRY_CIPHER_MODE_CTR = 6 /* Counter. */
};
#endif
/* Don't rely on this. Check! */
#define GRUB_CRYPTO_MAX_MDLEN 64
#define GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE 16
#define GRUB_CRYPTO_MAX_MD_CONTEXT_SIZE 256
/* Type for the cipher_setkey function. */
typedef gcry_err_code_t (*gcry_cipher_setkey_t) (void *c,
const unsigned char *key,
unsigned keylen);
/* Type for the cipher_encrypt function. */
typedef void (*gcry_cipher_encrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf);
/* Type for the cipher_decrypt function. */
typedef void (*gcry_cipher_decrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf);
/* Type for the cipher_stencrypt function. */
typedef void (*gcry_cipher_stencrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf,
unsigned int n);
/* Type for the cipher_stdecrypt function. */
typedef void (*gcry_cipher_stdecrypt_t) (void *c,
unsigned char *outbuf,
const unsigned char *inbuf,
unsigned int n);
typedef struct gcry_cipher_oid_spec
{
const char *oid;
int mode;
} gcry_cipher_oid_spec_t;
/* Module specification structure for ciphers. */
typedef struct gcry_cipher_spec
{
const char *name;
const char **aliases;
gcry_cipher_oid_spec_t *oids;
grub_size_t blocksize;
grub_size_t keylen;
grub_size_t contextsize;
gcry_cipher_setkey_t setkey;
gcry_cipher_encrypt_t encrypt;
gcry_cipher_decrypt_t decrypt;
gcry_cipher_stencrypt_t stencrypt;
gcry_cipher_stdecrypt_t stdecrypt;
#ifdef GRUB_UTIL
const char *modname;
#endif
struct gcry_cipher_spec *next;
} gcry_cipher_spec_t;
/* Type for the md_init function. */
typedef void (*gcry_md_init_t) (void *c);
/* Type for the md_write function. */
typedef void (*gcry_md_write_t) (void *c, const void *buf, grub_size_t nbytes);
/* Type for the md_final function. */
typedef void (*gcry_md_final_t) (void *c);
/* Type for the md_read function. */
typedef unsigned char *(*gcry_md_read_t) (void *c);
typedef struct gcry_md_oid_spec
{
const char *oidstring;
} gcry_md_oid_spec_t;
/* Module specification structure for message digests. */
typedef struct gcry_md_spec
{
const char *name;
unsigned char *asnoid;
int asnlen;
gcry_md_oid_spec_t *oids;
grub_size_t mdlen;
gcry_md_init_t init;
gcry_md_write_t write;
gcry_md_final_t final;
gcry_md_read_t read;
grub_size_t contextsize; /* allocate this amount of context */
/* Block size, needed for HMAC. */
grub_size_t blocksize;
#ifdef GRUB_UTIL
const char *modname;
#endif
struct gcry_md_spec *next;
} gcry_md_spec_t;
struct gcry_mpi;
typedef struct gcry_mpi *gcry_mpi_t;
/* Type for the pk_generate function. */
typedef gcry_err_code_t (*gcry_pk_generate_t) (int algo,
unsigned int nbits,
unsigned long use_e,
gcry_mpi_t *skey,
gcry_mpi_t **retfactors);
/* Type for the pk_check_secret_key function. */
typedef gcry_err_code_t (*gcry_pk_check_secret_key_t) (int algo,
gcry_mpi_t *skey);
/* Type for the pk_encrypt function. */
typedef gcry_err_code_t (*gcry_pk_encrypt_t) (int algo,
gcry_mpi_t *resarr,
gcry_mpi_t data,
gcry_mpi_t *pkey,
int flags);
/* Type for the pk_decrypt function. */
typedef gcry_err_code_t (*gcry_pk_decrypt_t) (int algo,
gcry_mpi_t *result,
gcry_mpi_t *data,
gcry_mpi_t *skey,
int flags);
/* Type for the pk_sign function. */
typedef gcry_err_code_t (*gcry_pk_sign_t) (int algo,
gcry_mpi_t *resarr,
gcry_mpi_t data,
gcry_mpi_t *skey);
/* Type for the pk_verify function. */
typedef gcry_err_code_t (*gcry_pk_verify_t) (int algo,
gcry_mpi_t hash,
gcry_mpi_t *data,
gcry_mpi_t *pkey,
int (*cmp) (void *, gcry_mpi_t),
void *opaquev);
/* Type for the pk_get_nbits function. */
typedef unsigned (*gcry_pk_get_nbits_t) (int algo, gcry_mpi_t *pkey);
/* Module specification structure for message digests. */
typedef struct gcry_pk_spec
{
const char *name;
const char **aliases;
const char *elements_pkey;
const char *elements_skey;
const char *elements_enc;
const char *elements_sig;
const char *elements_grip;
int use;
gcry_pk_generate_t generate;
gcry_pk_check_secret_key_t check_secret_key;
gcry_pk_encrypt_t encrypt;
gcry_pk_decrypt_t decrypt;
gcry_pk_sign_t sign;
gcry_pk_verify_t verify;
gcry_pk_get_nbits_t get_nbits;
#ifdef GRUB_UTIL
const char *modname;
#endif
} gcry_pk_spec_t;
struct grub_crypto_cipher_handle
{
const struct gcry_cipher_spec *cipher;
char ctx[0];
};
typedef struct grub_crypto_cipher_handle *grub_crypto_cipher_handle_t;
struct grub_crypto_hmac_handle;
const gcry_cipher_spec_t *
grub_crypto_lookup_cipher_by_name (const char *name);
grub_crypto_cipher_handle_t
grub_crypto_cipher_open (const struct gcry_cipher_spec *cipher);
gcry_err_code_t
grub_crypto_cipher_set_key (grub_crypto_cipher_handle_t cipher,
const unsigned char *key,
unsigned keylen);
static inline void
grub_crypto_cipher_close (grub_crypto_cipher_handle_t cipher)
{
grub_free (cipher);
}
static inline void
grub_crypto_xor (void *out, const void *in1, const void *in2, grub_size_t size)
{
const grub_uint8_t *in1ptr = in1, *in2ptr = in2;
grub_uint8_t *outptr = out;
while (size && (((grub_addr_t) in1ptr & (sizeof (grub_uint64_t) - 1))
|| ((grub_addr_t) in2ptr & (sizeof (grub_uint64_t) - 1))
|| ((grub_addr_t) outptr & (sizeof (grub_uint64_t) - 1))))
{
*outptr = *in1ptr ^ *in2ptr;
in1ptr++;
in2ptr++;
outptr++;
size--;
}
while (size >= sizeof (grub_uint64_t))
{
/* We've already checked that all pointers are aligned. */
*(grub_uint64_t *) (void *) outptr
= (*(const grub_uint64_t *) (const void *) in1ptr
^ *(const grub_uint64_t *) (const void *) in2ptr);
in1ptr += sizeof (grub_uint64_t);
in2ptr += sizeof (grub_uint64_t);
outptr += sizeof (grub_uint64_t);
size -= sizeof (grub_uint64_t);
}
while (size)
{
*outptr = *in1ptr ^ *in2ptr;
in1ptr++;
in2ptr++;
outptr++;
size--;
}
}
gcry_err_code_t
grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size);
gcry_err_code_t
grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size);
gcry_err_code_t
grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size,
void *iv_in);
gcry_err_code_t
grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher,
void *out, const void *in, grub_size_t size,
void *iv);
void
grub_cipher_register (gcry_cipher_spec_t *cipher);
void
grub_cipher_unregister (gcry_cipher_spec_t *cipher);
void
grub_md_register (gcry_md_spec_t *digest);
void
grub_md_unregister (gcry_md_spec_t *cipher);
extern struct gcry_pk_spec *grub_crypto_pk_dsa;
extern struct gcry_pk_spec *grub_crypto_pk_ecdsa;
extern struct gcry_pk_spec *grub_crypto_pk_ecdh;
extern struct gcry_pk_spec *grub_crypto_pk_rsa;
void
grub_crypto_hash (const gcry_md_spec_t *hash, void *out, const void *in,
grub_size_t inlen);
const gcry_md_spec_t *
grub_crypto_lookup_md_by_name (const char *name);
grub_err_t
grub_crypto_gcry_error (gcry_err_code_t in);
void grub_burn_stack (grub_size_t size);
struct grub_crypto_hmac_handle *
grub_crypto_hmac_init (const struct gcry_md_spec *md,
const void *key, grub_size_t keylen);
void
grub_crypto_hmac_write (struct grub_crypto_hmac_handle *hnd,
const void *data,
grub_size_t datalen);
gcry_err_code_t
grub_crypto_hmac_fini (struct grub_crypto_hmac_handle *hnd, void *out);
gcry_err_code_t
grub_crypto_hmac_buffer (const struct gcry_md_spec *md,
const void *key, grub_size_t keylen,
const void *data, grub_size_t datalen, void *out);
extern gcry_md_spec_t _gcry_digest_spec_md5;
extern gcry_md_spec_t _gcry_digest_spec_sha1;
extern gcry_md_spec_t _gcry_digest_spec_sha256;
extern gcry_md_spec_t _gcry_digest_spec_sha512;
extern gcry_md_spec_t _gcry_digest_spec_crc32;
extern gcry_cipher_spec_t _gcry_cipher_spec_aes;
#define GRUB_MD_MD5 ((const gcry_md_spec_t *) &_gcry_digest_spec_md5)
#define GRUB_MD_SHA1 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha1)
#define GRUB_MD_SHA256 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha256)
#define GRUB_MD_SHA512 ((const gcry_md_spec_t *) &_gcry_digest_spec_sha512)
#define GRUB_MD_CRC32 ((const gcry_md_spec_t *) &_gcry_digest_spec_crc32)
#define GRUB_CIPHER_AES ((const gcry_cipher_spec_t *) &_gcry_cipher_spec_aes)
/* Implement PKCS#5 PBKDF2 as per RFC 2898. The PRF to use is HMAC variant
of digest supplied by MD. Inputs are the password P of length PLEN,
the salt S of length SLEN, the iteration counter C (> 0), and the
desired derived output length DKLEN. Output buffer is DK which
must have room for at least DKLEN octets. The output buffer will
be filled with the derived data. */
gcry_err_code_t
grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
const grub_uint8_t *P, grub_size_t Plen,
const grub_uint8_t *S, grub_size_t Slen,
unsigned int c,
grub_uint8_t *DK, grub_size_t dkLen);
int
grub_crypto_memcmp (const void *a, const void *b, grub_size_t n);
int
grub_password_get (char buf[], unsigned buf_size);
/* For indistinguishibility. */
#define GRUB_ACCESS_DENIED grub_error (GRUB_ERR_ACCESS_DENIED, N_("access denied"))
extern void (*grub_crypto_autoload_hook) (const char *name);
void _gcry_assert_failed (const char *expr, const char *file, int line,
const char *func) __attribute__ ((noreturn));
void _gcry_burn_stack (int bytes);
void _gcry_log_error( const char *fmt, ... ) __attribute__ ((format (__printf__, 1, 2)));
#ifdef GRUB_UTIL
void grub_gcry_init_all (void);
void grub_gcry_fini_all (void);
int
grub_get_random (void *out, grub_size_t len);
#endif
#endif
@@ -0,0 +1,190 @@
/*
* 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_CRYPTODISK_HEADER
#define GRUB_CRYPTODISK_HEADER 1
#include <grub/disk.h>
#include <grub/file.h>
#include <grub/crypto.h>
#include <grub/list.h>
#ifdef GRUB_UTIL
#include <grub/emu/hostdisk.h>
#endif
typedef enum
{
GRUB_CRYPTODISK_MODE_ECB,
GRUB_CRYPTODISK_MODE_CBC,
GRUB_CRYPTODISK_MODE_PCBC,
GRUB_CRYPTODISK_MODE_XTS,
GRUB_CRYPTODISK_MODE_LRW
} grub_cryptodisk_mode_t;
typedef enum
{
GRUB_CRYPTODISK_MODE_IV_NULL,
GRUB_CRYPTODISK_MODE_IV_PLAIN,
GRUB_CRYPTODISK_MODE_IV_PLAIN64,
GRUB_CRYPTODISK_MODE_IV_ESSIV,
GRUB_CRYPTODISK_MODE_IV_BENBI,
GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64,
GRUB_CRYPTODISK_MODE_IV_BYTECOUNT64_HASH
} grub_cryptodisk_mode_iv_t;
#define GRUB_CRYPTODISK_MAX_UUID_LENGTH 71
/* LUKS1 specification defines the block size to always be 512 bytes. */
#define GRUB_LUKS1_LOG_SECTOR_SIZE 9
/* By default dm-crypt increments the IV every 512 bytes. */
#define GRUB_CRYPTODISK_IV_LOG_SIZE 9
#define GRUB_CRYPTODISK_GF_LOG_SIZE 7
#define GRUB_CRYPTODISK_GF_SIZE (1U << GRUB_CRYPTODISK_GF_LOG_SIZE)
#define GRUB_CRYPTODISK_GF_LOG_BYTES (GRUB_CRYPTODISK_GF_LOG_SIZE - 3)
#define GRUB_CRYPTODISK_GF_BYTES (1U << GRUB_CRYPTODISK_GF_LOG_BYTES)
#define GRUB_CRYPTODISK_MAX_KEYLEN 128
#define GRUB_CRYPTODISK_MAX_PASSPHRASE 256
#define GRUB_CRYPTODISK_MAX_KEYFILE_SIZE 8192
struct grub_cryptodisk;
typedef gcry_err_code_t
(*grub_cryptodisk_rekey_func_t) (struct grub_cryptodisk *dev,
grub_uint64_t zoneno);
struct grub_cryptomount_args
{
/* scan: Flag to indicate that only bootable volumes should be decrypted */
grub_uint32_t check_boot : 1;
/* scan: Only volumes matching this UUID should be decrpyted */
char *search_uuid;
/* recover_key: Key data used to decrypt voume */
grub_uint8_t *key_data;
/* recover_key: Length of key_data */
grub_size_t key_len;
grub_file_t hdr_file;
};
typedef struct grub_cryptomount_args *grub_cryptomount_args_t;
struct grub_cryptodisk
{
struct grub_cryptodisk *next;
struct grub_cryptodisk **prev;
char *source;
/*
* The number of sectors the start of the encrypted data is offset into the
* underlying disk, where sectors are the size noted by log_sector_size.
*/
grub_disk_addr_t offset_sectors;
/* Total number of encrypted sectors of size (1 << log_sector_size). */
grub_disk_addr_t total_sectors;
grub_disk_t source_disk;
int ref;
grub_crypto_cipher_handle_t cipher;
grub_crypto_cipher_handle_t secondary_cipher;
grub_crypto_cipher_handle_t essiv_cipher;
const gcry_md_spec_t *essiv_hash, *hash, *iv_hash;
grub_cryptodisk_mode_t mode;
grub_cryptodisk_mode_iv_t mode_iv;
int benbi_log;
unsigned long id, source_id;
enum grub_disk_dev_id source_dev_id;
char uuid[GRUB_CRYPTODISK_MAX_UUID_LENGTH + 1];
grub_uint8_t lrw_key[GRUB_CRYPTODISK_GF_BYTES];
grub_uint8_t *lrw_precalc;
grub_uint8_t iv_prefix[64];
grub_size_t iv_prefix_len;
grub_uint8_t key[GRUB_CRYPTODISK_MAX_KEYLEN];
grub_size_t keysize;
#ifdef GRUB_UTIL
char *cheat;
grub_util_fd_t cheat_fd;
#endif
const char *modname;
int log_sector_size;
grub_cryptodisk_rekey_func_t rekey;
int rekey_shift;
grub_uint8_t rekey_key[64];
grub_uint64_t last_rekey;
int rekey_derived_size;
grub_disk_addr_t partition_start;
};
typedef struct grub_cryptodisk *grub_cryptodisk_t;
struct grub_cryptodisk_dev
{
struct grub_cryptodisk_dev *next;
struct grub_cryptodisk_dev **prev;
grub_cryptodisk_t (*scan) (grub_disk_t disk, grub_cryptomount_args_t cargs);
grub_err_t (*recover_key) (grub_disk_t disk, grub_cryptodisk_t dev, grub_cryptomount_args_t cargs);
};
typedef struct grub_cryptodisk_dev *grub_cryptodisk_dev_t;
extern grub_cryptodisk_dev_t EXPORT_VAR (grub_cryptodisk_list);
#ifndef GRUB_LST_GENERATOR
static inline void
grub_cryptodisk_dev_register (grub_cryptodisk_dev_t cr)
{
grub_list_push (GRUB_AS_LIST_P (&grub_cryptodisk_list), GRUB_AS_LIST (cr));
}
#endif
static inline void
grub_cryptodisk_dev_unregister (grub_cryptodisk_dev_t cr)
{
grub_list_remove (GRUB_AS_LIST (cr));
}
#define FOR_CRYPTODISK_DEVS(var) FOR_LIST_ELEMENTS((var), (grub_cryptodisk_list))
grub_err_t
grub_cryptodisk_setcipher (grub_cryptodisk_t crypt, const char *ciphername, const char *ciphermode);
gcry_err_code_t
grub_cryptodisk_setkey (grub_cryptodisk_t dev,
grub_uint8_t *key, grub_size_t keysize);
gcry_err_code_t
grub_cryptodisk_decrypt (struct grub_cryptodisk *dev,
grub_uint8_t * data, grub_size_t len,
grub_disk_addr_t sector, grub_size_t log_sector_size);
grub_err_t
grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
grub_disk_t source);
#ifdef GRUB_UTIL
grub_err_t
grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
grub_disk_t source, const char *cheat);
void
grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
void (*cb) (const char *val, void *data),
void *data);
char *
grub_util_get_geli_uuid (const char *dev);
#endif
grub_cryptodisk_t grub_cryptodisk_get_by_uuid (const char *uuid);
grub_cryptodisk_t grub_cryptodisk_get_by_source_disk (grub_disk_t disk);
#endif
@@ -0,0 +1,198 @@
/*
* 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_CS5536_HEADER
#define GRUB_CS5536_HEADER 1
#ifndef ASM_FILE
#include <grub/pci.h>
#include <grub/err.h>
#include <grub/smbus.h>
#endif
#define GRUB_CS5536_PCIID 0x208f1022
#define GRUB_CS5536_MSR_MAILBOX_CONFIG_ENABLED 0x1
#define GRUB_CS5536_MSR_MAILBOX_CONFIG 0xf0
#define GRUB_CS5536_MSR_MAILBOX_ADDR 0xf4
#define GRUB_CS5536_MSR_MAILBOX_DATA0 0xf8
#define GRUB_CS5536_MSR_MAILBOX_DATA1 0xfc
#define GRUB_CS5536_MSR_IRQ_MAP_BAR 0x80000008
#define GRUB_CS5536_MSR_SMB_BAR 0x8000000b
#define GRUB_CS5536_SMBUS_REGS_SIZE 8
#define GRUB_CS5536_GPIO_REGS_SIZE 256
#define GRUB_CS5536_MFGPT_REGS_SIZE 64
#define GRUB_CS5536_IRQ_MAP_REGS_SIZE 32
#define GRUB_CS5536_PM_REGS_SIZE 128
#define GRUB_CS5536_ACPI_REGS_SIZE 32
#define GRUB_CS5536_USB_OPTION_REGS_SIZE 0x1c
#define GRUB_CS5536_USB_OPTION_REG_UOCMUX 1
#define GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_MASK 0x03
#define GRUB_CS5536_USB_OPTION_REG_UOCMUX_PMUX_HC 0x02
#define GRUB_CS5536_DESTINATION_GLIU 0
#define GRUB_CS5536_DESTINATION_GLPCI_SB 1
#define GRUB_CS5536_DESTINATION_USB 2
#define GRUB_CS5536_DESTINATION_IDE 3
#define GRUB_CS5536_DESTINATION_DD 4
#define GRUB_CS5536_DESTINATION_ACC 5
#define GRUB_CS5536_DESTINATION_GLCP 7
#define GRUB_CS5536_P2D_DEST_SHIFT 61
#define GRUB_CS5536_P2D_LOG_ALIGN 12
#define GRUB_CS5536_P2D_ALIGN (1 << GRUB_CS5536_P2D_LOG_ALIGN)
#define GRUB_CS5536_P2D_BASE_SHIFT 20
#define GRUB_CS5536_P2D_MASK_SHIFT 0
#define GRUB_CS5536_MSR_GL_IOD_START 0x000100e0
#define GRUB_CS5536_IOD_DEST_SHIFT 61
#define GRUB_CS5536_IOD_BASE_SHIFT 20
#define GRUB_CS5536_IOD_MASK_SHIFT 0
#define GRUB_CS5536_IOD_ADDR_MASK 0xfffff
#define GRUB_CS5536_MSR_GPIO_BAR 0x8000000c
#define GRUB_CS5536_MSR_MFGPT_BAR 0x8000000d
#define GRUB_CS5536_MSR_ACPI_BAR 0x8000000e
#define GRUB_CS5536_MSR_PM_BAR 0x8000000f
#define GRUB_CS5536_MSR_DIVIL_LEG_IO 0x80000014
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE0 0x00000001
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_RTC_ENABLE1 0x00000002
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_MODE_X86 0x10000000
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_F_REMAP 0x04000000
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_UART1_COM1 0x00070000
#define GRUB_CS5536_MSR_DIVIL_LEG_IO_UART2_COM3 0x00500000
#define GRUB_CS5536_MSR_DIVIL_RESET 0x80000017
#define GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_PRIMARY_MASK 0x80000024
#define GRUB_CS5536_MSR_DIVIL_IRQ_MAPPER_LPC_MASK 0x80000025
#define GRUB_CS5536_DIVIL_LPC_INTERRUPTS 0x1002
#define GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL 0x8000004e
#define GRUB_CS5536_MSR_DIVIL_LPC_SERIAL_IRQ_CONTROL_ENABLE 0x80
#define GRUB_CS5536_MSR_DIVIL_UART1_CONF 0x8000003a
#define GRUB_CS5536_MSR_DIVIL_UART2_CONF 0x8000003e
#define GRUB_CS5536_MSR_USB_OHCI_BASE 0x40000008
#define GRUB_CS5536_MSR_USB_EHCI_BASE 0x40000009
#define GRUB_CS5536_MSR_USB_CONTROLLER_BASE 0x4000000a
#define GRUB_CS5536_MSR_USB_OPTION_CONTROLLER_BASE 0x4000000b
#define GRUB_CS5536_MSR_USB_BASE_ADDR_MASK 0x00ffffff00ULL
#define GRUB_CS5536_MSR_USB_BASE_SMI_ENABLE 0x3f000000000000ULL
#define GRUB_CS5536_MSR_USB_BASE_BUS_MASTER 0x0400000000ULL
#define GRUB_CS5536_MSR_USB_BASE_MEMORY_ENABLE 0x0200000000ULL
#define GRUB_CS5536_MSR_USB_BASE_PME_ENABLED 0x0800000000ULL
#define GRUB_CS5536_MSR_USB_BASE_PME_STATUS 0x1000000000ULL
#define GRUB_CS5536_MSR_USB_EHCI_BASE_FLDJ_SHIFT 40
#define GRUB_CS5536_MSR_IDE_IO_BAR 0x60000008
#define GRUB_CS5536_MSR_IDE_IO_BAR_UNITS 1
#define GRUB_CS5536_MSR_IDE_IO_BAR_ADDR_MASK 0xfffffff0
#define GRUB_CS5536_MSR_IDE_CFG 0x60000010
#define GRUB_CS5536_MSR_IDE_CFG_CHANNEL_ENABLE 2
#define GRUB_CS5536_MSR_IDE_TIMING 0x60000012
#define GRUB_CS5536_MSR_IDE_TIMING_PIO0 0x98
#define GRUB_CS5536_MSR_IDE_TIMING_DRIVE0_SHIFT 24
#define GRUB_CS5536_MSR_IDE_TIMING_DRIVE1_SHIFT 16
#define GRUB_CS5536_MSR_IDE_CAS_TIMING 0x60000013
#define GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_PIO0 0x99
#define GRUB_CS5536_MSR_IDE_CAS_TIMING_CMD_SHIFT 24
#define GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE0_SHIFT 6
#define GRUB_CS5536_MSR_IDE_CAS_TIMING_DRIVE1_SHIFT 4
#define GRUB_CS5536_MSR_IDE_CAS_TIMING_PIO0 2
#define GRUB_CS5536_MSR_GL_PCI_CTRL 0x00000010
#define GRUB_CS5536_MSR_GL_PCI_CTRL_MEMORY_ENABLE 1
#define GRUB_CS5536_MSR_GL_PCI_CTRL_IO_ENABLE 2
#define GRUB_CS5536_MSR_GL_PCI_CTRL_LATENCY_SHIFT 35
#define GRUB_CS5536_MSR_GL_PCI_CTRL_OUT_THR_SHIFT 60
#define GRUB_CS5536_MSR_GL_PCI_CTRL_IN_THR_SHIFT 56
#define GRUB_CS5536_MSR_GL_REGIONS_START 0x00000020
#define GRUB_CS5536_MSR_GL_REGIONS_NUM 16
#define GRUB_CS5536_MSR_GL_REGION_ENABLE 1
#define GRUB_CS5536_MSR_GL_REGION_IO 0x100000000ULL
#define GRUB_CS5536_MSR_GL_REGION_BASE_MASK 0xfffff000ULL
#define GRUB_CS5536_MSR_GL_REGION_IO_BASE_SHIFT 12
#define GRUB_CS5536_MSR_GL_REGION_TOP_MASK 0xfffff00000000000ULL
#define GRUB_CS5536_MSR_GL_REGION_IO_TOP_SHIFT 44
#define GRUB_CS5536_MSR_GL_P2D_START 0x00010020
#define GRUB_CS5536_SMB_REG_DATA 0x0
#define GRUB_CS5536_SMB_REG_STATUS 0x1
#define GRUB_CS5536_SMB_REG_STATUS_SDAST (1 << 6)
#define GRUB_CS5536_SMB_REG_STATUS_BER (1 << 5)
#define GRUB_CS5536_SMB_REG_STATUS_NACK (1 << 4)
#define GRUB_CS5536_SMB_REG_CTRL1 0x3
#define GRUB_CS5536_SMB_REG_CTRL1_START 0x01
#define GRUB_CS5536_SMB_REG_CTRL1_STOP 0x02
#define GRUB_CS5536_SMB_REG_CTRL1_ACK 0x10
#define GRUB_CS5536_SMB_REG_ADDR 0x4
#define GRUB_CS5536_SMB_REG_ADDR_MASTER 0x0
#define GRUB_CS5536_SMB_REG_CTRL2 0x5
#define GRUB_CS5536_SMB_REG_CTRL2_ENABLE 0x1
#define GRUB_CS5536_SMB_REG_CTRL3 0x6
#ifdef ASM_FILE
#define GRUB_ULL(x) x
#else
#define GRUB_ULL(x) x ## ULL
#endif
#define GRUB_CS5536_LBAR_ADDR_MASK GRUB_ULL (0x000000000000fff8)
#define GRUB_CS5536_LBAR_ENABLE GRUB_ULL (0x0000000100000000)
#define GRUB_CS5536_LBAR_MASK_MASK GRUB_ULL (0x0000f00000000000)
#define GRUB_CS5536_LBAR_TURN_ON (GRUB_CS5536_LBAR_ENABLE | GRUB_CS5536_LBAR_MASK_MASK)
/* PMON-compatible LBARs. */
#define GRUB_CS5536_LBAR_GPIO 0xb000
#define GRUB_CS5536_LBAR_ACC 0xb200
#define GRUB_CS5536_LBAR_PM 0xb280
#define GRUB_CS5536_LBAR_MFGPT 0xb300
#define GRUB_CS5536_LBAR_ACPI 0xb340
#define GRUB_CS5536_LBAR_IRQ_MAP 0xb360
#define GRUB_CS5536_LBAR_IDE 0xb380
#define GRUB_CS5536_LBAR_SMBUS 0xb390
#define GRUB_GPIO_SMBUS_PINS ((1 << 14) | (1 << 15))
#define GRUB_GPIO_REG_OUT_EN 0x4
#define GRUB_GPIO_REG_OUT_AUX1 0x10
#define GRUB_GPIO_REG_IN_EN 0x20
#define GRUB_GPIO_REG_IN_AUX1 0x34
#ifndef ASM_FILE
int EXPORT_FUNC (grub_cs5536_find) (grub_pci_device_t *devp);
grub_uint64_t EXPORT_FUNC (grub_cs5536_read_msr) (grub_pci_device_t dev,
grub_uint32_t addr);
void EXPORT_FUNC (grub_cs5536_write_msr) (grub_pci_device_t dev,
grub_uint32_t addr,
grub_uint64_t val);
grub_err_t grub_cs5536_read_spd_byte (grub_port_t smbbase, grub_uint8_t dev,
grub_uint8_t addr, grub_uint8_t *res);
grub_err_t EXPORT_FUNC (grub_cs5536_read_spd) (grub_port_t smbbase,
grub_uint8_t dev,
struct grub_smbus_spd *res);
grub_err_t grub_cs5536_smbus_wait (grub_port_t smbbase);
grub_err_t EXPORT_FUNC (grub_cs5536_init_smbus) (grub_pci_device_t dev,
grub_uint16_t divisor,
grub_port_t *smbbase);
void grub_cs5536_init_geode (grub_pci_device_t dev);
#endif
#endif
@@ -0,0 +1,133 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 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_DATETIME_HEADER
#define KERNEL_DATETIME_HEADER 1
#include <grub/types.h>
#include <grub/err.h>
struct grub_datetime
{
grub_uint16_t year;
grub_uint8_t month;
grub_uint8_t day;
grub_uint8_t hour;
grub_uint8_t minute;
grub_uint8_t second;
};
/* Return date and time. */
#ifdef GRUB_MACHINE_EMU
grub_err_t EXPORT_FUNC(grub_get_datetime) (struct grub_datetime *datetime);
/* Set date and time. */
grub_err_t EXPORT_FUNC(grub_set_datetime) (struct grub_datetime *datetime);
#else
grub_err_t grub_get_datetime (struct grub_datetime *datetime);
/* Set date and time. */
grub_err_t grub_set_datetime (struct grub_datetime *datetime);
#endif
int grub_get_weekday (struct grub_datetime *datetime);
const char *grub_get_weekday_name (struct grub_datetime *datetime);
void grub_unixtime2datetime (grub_int64_t nix,
struct grub_datetime *datetime);
static inline int
grub_datetime2unixtime (const struct grub_datetime *datetime, grub_int64_t *nix)
{
grub_int32_t ret;
int y4, ay;
const grub_uint16_t monthssum[12]
= { 0,
31,
31 + 28,
31 + 28 + 31,
31 + 28 + 31 + 30,
31 + 28 + 31 + 30 + 31,
31 + 28 + 31 + 30 + 31 + 30,
31 + 28 + 31 + 30 + 31 + 30 + 31,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30};
const grub_uint8_t months[12] = {31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
const int SECPERMIN = 60;
const int SECPERHOUR = 60 * SECPERMIN;
const int SECPERDAY = 24 * SECPERHOUR;
const int SECPERYEAR = 365 * SECPERDAY;
const int SECPER4YEARS = 4 * SECPERYEAR + SECPERDAY;
if (datetime->year > 2038 || datetime->year < 1901)
return 0;
if (datetime->month > 12 || datetime->month < 1)
return 0;
/* In the period of validity of unixtime all years divisible by 4
are bissextile*/
/* Convenience: let's have 3 consecutive non-bissextile years
at the beginning of the epoch. So count from 1973 instead of 1970 */
ret = 3 * SECPERYEAR + SECPERDAY;
/* Transform C divisions and modulos to mathematical ones */
y4 = ((datetime->year - 1) >> 2) - (1973 / 4);
ay = datetime->year - 1973 - 4 * y4;
ret += y4 * SECPER4YEARS;
ret += ay * SECPERYEAR;
ret += monthssum[datetime->month - 1] * SECPERDAY;
if (ay == 3 && datetime->month >= 3)
ret += SECPERDAY;
ret += (datetime->day - 1) * SECPERDAY;
if ((datetime->day > months[datetime->month - 1]
&& (!ay || datetime->month != 2 || datetime->day != 29))
|| datetime->day < 1)
return 0;
ret += datetime->hour * SECPERHOUR;
if (datetime->hour > 23)
return 0;
ret += datetime->minute * 60;
if (datetime->minute > 59)
return 0;
ret += datetime->second;
/* Accept leap seconds. */
if (datetime->second > 60)
return 0;
if ((datetime->year > 1980 && ret < 0)
|| (datetime->year < 1960 && ret > 0))
return 0;
*nix = ret;
return 1;
}
#if (defined (__powerpc__) || defined (__sparc__)) && !defined (GRUB_UTIL)
grub_err_t
grub_get_datetime_cmos (struct grub_datetime *datetime);
grub_err_t
grub_set_datetime_cmos (struct grub_datetime *datetime);
#endif
#endif /* ! KERNEL_DATETIME_HEADER */
@@ -0,0 +1,34 @@
/*
* 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_DECOMPRESSOR_HEADER
#define GRUB_DECOMPRESSOR_HEADER 1
void
grub_decompress_core (void *src, void *dst, unsigned long srcsize,
unsigned long dstsize);
void
find_scratch (void *src, void *dst, unsigned long srcsize,
unsigned long dstsize);
#define GRUB_DECOMPRESSOR_DICT_SIZE (1 << 16)
extern void *grub_decompressor_scratch;
#endif
@@ -0,0 +1,30 @@
/*
* 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_DEFLATE_HEADER
#define GRUB_DEFLATE_HEADER 1
grub_ssize_t
grub_zlib_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
char *outbuf, grub_size_t outsize);
grub_ssize_t
grub_deflate_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
char *outbuf, grub_size_t outsize);
#endif
@@ -0,0 +1,43 @@
/* device.h - device manager */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_DEVICE_HEADER
#define GRUB_DEVICE_HEADER 1
#include <grub/symbol.h>
#include <grub/err.h>
struct grub_disk;
struct grub_net;
struct grub_device
{
struct grub_disk *disk;
struct grub_net *net;
};
typedef struct grub_device *grub_device_t;
typedef int (*grub_device_iterate_hook_t) (const char *name, void *data);
grub_device_t EXPORT_FUNC(grub_device_open) (const char *name);
grub_err_t EXPORT_FUNC(grub_device_close) (grub_device_t device);
int EXPORT_FUNC(grub_device_iterate) (grub_device_iterate_hook_t hook,
void *hook_data);
#endif /* ! GRUB_DEVICE_HEADER */
@@ -0,0 +1,317 @@
/*
* 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>
/* For ALIGN_UP. */
#include <grub/misc.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 grub_err_t (*grub_disk_read_hook_t) (grub_disk_addr_t sector,
unsigned offset, unsigned length,
char *buf, 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
/*
* Some drivers have problems with disks above reasonable sizes.
* Set max disk size at 1 EiB.
*/
#define GRUB_DISK_MAX_SECTORS (1ULL << (60 - GRUB_DISK_SECTOR_BITS))
/* The maximum number of disk caches. */
#define GRUB_DISK_CACHE_NUM 1021
/*
* The maximum number of disks in an mdraid device.
*
* GET_DISK_INFO nr_disks (total count) does not map to disk.number,
* which is an internal kernel index. Instead, do what mdadm does
* and keep scanning until we find enough valid disks. The limit is
* copied from there, which notes that it is sufficiently high given
* that the on-disk metadata for v1.x can only support 1920.
*/
#define GRUB_MDRAID_MAX_DISKS 4096
/* 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)
/* Maximum number of sectors to read in LBA mode at once. */
#define GRUB_DISK_MAX_LBA_SECTORS 63
/* Return value of grub_disk_native_sectors() in case disk size is unknown. */
#define GRUB_DISK_SIZE_UNKNOWN 0xffffffffffffffffULL
#define GRUB_DISK_KiB_TO_SECTORS(x) ((x) << (10 - GRUB_DISK_SECTOR_BITS))
/* Convert sector number from one sector size to another. */
static inline grub_disk_addr_t
grub_convert_sector (grub_disk_addr_t sector,
grub_size_t log_sector_size_from,
grub_size_t log_sector_size_to)
{
if (log_sector_size_from == log_sector_size_to)
return sector;
else if (log_sector_size_from < log_sector_size_to)
{
sector = ALIGN_UP (sector, 1 << (log_sector_size_to - log_sector_size_from));
return sector >> (log_sector_size_to - log_sector_size_from);
}
else
return sector << (log_sector_size_from - log_sector_size_to);
}
/* Convert to GRUB native disk sized sector from disk sized sector. */
static inline grub_disk_addr_t
grub_disk_from_native_sector (grub_disk_t disk, grub_disk_addr_t sector)
{
return sector << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
}
/* Convert from GRUB native disk sized sector to disk sized sector. */
static inline grub_disk_addr_t
grub_disk_to_native_sector (grub_disk_t disk, grub_disk_addr_t sector)
{
return sector >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
}
/* 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_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_native_sectors) (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,218 @@
/* diskfilter.h - On disk structures for RAID. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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_DISKFILTER_H
#define GRUB_DISKFILTER_H 1
#include <grub/types.h>
#include <grub/list.h>
enum
{
GRUB_RAID_LAYOUT_RIGHT_MASK = 1,
GRUB_RAID_LAYOUT_SYMMETRIC_MASK = 2,
GRUB_RAID_LAYOUT_MUL_FROM_POS = 4,
GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC = 0,
GRUB_RAID_LAYOUT_RIGHT_ASYMMETRIC = GRUB_RAID_LAYOUT_RIGHT_MASK,
GRUB_RAID_LAYOUT_LEFT_SYMMETRIC = GRUB_RAID_LAYOUT_SYMMETRIC_MASK,
GRUB_RAID_LAYOUT_RIGHT_SYMMETRIC = (GRUB_RAID_LAYOUT_RIGHT_MASK
| GRUB_RAID_LAYOUT_SYMMETRIC_MASK)
};
struct grub_diskfilter_vg {
char *uuid;
grub_size_t uuid_len;
/* Optional. */
char *name;
grub_uint64_t extent_size;
struct grub_diskfilter_pv *pvs;
struct grub_diskfilter_lv *lvs;
struct grub_diskfilter_vg *next;
#ifdef GRUB_UTIL
struct grub_diskfilter *driver;
#endif
};
struct grub_diskfilter_pv_id {
union
{
char *uuid;
int id;
};
grub_size_t uuidlen;
};
struct grub_diskfilter_pv {
struct grub_diskfilter_pv_id id;
/* Optional. */
char *name;
grub_disk_t disk;
grub_disk_addr_t part_start;
grub_disk_addr_t part_size;
grub_disk_addr_t start_sector; /* Sector number where the data area starts. */
struct grub_diskfilter_pv *next;
/* Optional. */
grub_uint8_t *internal_id;
#ifdef GRUB_UTIL
char **partmaps;
#endif
};
struct grub_diskfilter_lv {
/* Name used for disk. */
char *fullname;
char *idname;
/* Optional. */
char *name;
int number;
unsigned int segment_count;
grub_size_t segment_alloc;
grub_uint64_t size;
int became_readable_at;
int scanned;
int visible;
/* Pointer to segment_count segments. */
struct grub_diskfilter_segment *segments;
struct grub_diskfilter_vg *vg;
struct grub_diskfilter_lv *next;
/* Optional. */
char *internal_id;
};
struct grub_diskfilter_segment {
grub_uint64_t start_extent;
grub_uint64_t extent_count;
enum
{
GRUB_DISKFILTER_STRIPED = 0,
GRUB_DISKFILTER_MIRROR = 1,
GRUB_DISKFILTER_RAID4 = 4,
GRUB_DISKFILTER_RAID5 = 5,
GRUB_DISKFILTER_RAID6 = 6,
GRUB_DISKFILTER_RAID10 = 10,
} type;
int layout;
/* valid only for raid10. */
grub_uint64_t raid_member_size;
unsigned int node_count;
unsigned int node_alloc;
struct grub_diskfilter_node *nodes;
unsigned int stripe_size;
};
struct grub_diskfilter_node {
grub_disk_addr_t start;
/* Optional. */
char *name;
struct grub_diskfilter_pv *pv;
struct grub_diskfilter_lv *lv;
};
struct grub_diskfilter_vg *
grub_diskfilter_get_vg_by_uuid (grub_size_t uuidlen, char *uuid);
struct grub_diskfilter
{
struct grub_diskfilter *next;
struct grub_diskfilter **prev;
const char *name;
struct grub_diskfilter_vg * (*detect) (grub_disk_t disk,
struct grub_diskfilter_pv_id *id,
grub_disk_addr_t *start_sector);
};
typedef struct grub_diskfilter *grub_diskfilter_t;
extern grub_diskfilter_t grub_diskfilter_list;
static inline void
grub_diskfilter_register_front (grub_diskfilter_t diskfilter)
{
grub_list_push (GRUB_AS_LIST_P (&grub_diskfilter_list),
GRUB_AS_LIST (diskfilter));
}
static inline void
grub_diskfilter_register_back (grub_diskfilter_t diskfilter)
{
grub_diskfilter_t p, *q;
for (q = &grub_diskfilter_list, p = *q; p; q = &p->next, p = *q);
diskfilter->next = NULL;
diskfilter->prev = q;
*q = diskfilter;
}
static inline void
grub_diskfilter_unregister (grub_diskfilter_t diskfilter)
{
grub_list_remove (GRUB_AS_LIST (diskfilter));
}
struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
const char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size,
int layout, int level);
typedef grub_err_t (*grub_raid5_recover_func_t) (struct grub_diskfilter_segment *array,
int disknr, char *buf,
grub_disk_addr_t sector,
grub_size_t size);
typedef grub_err_t (*grub_raid6_recover_func_t) (struct grub_diskfilter_segment *array,
int disknr, int p, char *buf,
grub_disk_addr_t sector,
grub_size_t size);
extern grub_raid5_recover_func_t grub_raid5_recover_func;
extern grub_raid6_recover_func_t grub_raid6_recover_func;
typedef grub_err_t (* raid_recover_read_t)(void *data, int disk_nr,
grub_uint64_t addr, void *dest,
grub_size_t size);
extern grub_err_t
grub_raid6_recover_gen (void *data, grub_uint64_t nstripes, int disknr, int p,
char *buf, grub_uint64_t sector, grub_size_t size,
int layout, raid_recover_read_t read_func);
grub_err_t grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg);
grub_err_t
grub_diskfilter_read_node (const struct grub_diskfilter_node *node,
grub_disk_addr_t sector,
grub_size_t size, char *buf);
#ifdef GRUB_UTIL
struct grub_diskfilter_pv *
grub_diskfilter_get_pv_from_disk (grub_disk_t disk,
struct grub_diskfilter_vg **vg);
void
grub_diskfilter_get_partmap (grub_disk_t disk,
void (*cb) (const char *val, void *data),
void *data);
#endif
#endif /* ! GRUB_RAID_H */
@@ -0,0 +1,311 @@
/* 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
#ifdef __mips__
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);
extern int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
extern int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
extern int EXPORT_FUNC(grub_dl_ref_count) (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)
#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__) || 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 (__loongarch_lp64) || \
(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 */
@@ -0,0 +1,44 @@
/*
* 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_DMA_H
#define GRUB_DMA_H 1
struct grub_pci_dma_chunk;
struct grub_pci_dma_chunk *EXPORT_FUNC(grub_memalign_dma32) (grub_size_t align,
grub_size_t size);
void EXPORT_FUNC(grub_dma_free) (struct grub_pci_dma_chunk *ch);
volatile void *EXPORT_FUNC(grub_dma_get_virt) (struct grub_pci_dma_chunk *ch);
grub_uint32_t EXPORT_FUNC(grub_dma_get_phys) (struct grub_pci_dma_chunk *ch);
static inline void *
grub_dma_phys2virt (grub_uint32_t phys, struct grub_pci_dma_chunk *chunk)
{
return ((grub_uint8_t *) grub_dma_get_virt (chunk)
+ (phys - grub_dma_get_phys (chunk)));
}
static inline grub_uint32_t
grub_dma_virt2phys (volatile void *virt, struct grub_pci_dma_chunk *chunk)
{
return (((grub_uint8_t *) virt - (grub_uint8_t *) grub_dma_get_virt (chunk))
+ grub_dma_get_phys (chunk));
}
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,151 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2022 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_CC_H
#define GRUB_EFI_CC_H 1
#include <grub/efi/api.h>
#include <grub/efi/efi.h>
#include <grub/err.h>
#define GRUB_EFI_CC_MEASUREMENT_PROTOCOL_GUID \
{ 0x96751a3d, 0x72f4, 0x41a6, \
{ 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b } \
};
struct grub_efi_cc_version
{
grub_efi_uint8_t Major;
grub_efi_uint8_t Minor;
};
typedef struct grub_efi_cc_version grub_efi_cc_version_t;
/* EFI_CC Type/SubType definition. */
#define GRUB_EFI_CC_TYPE_NONE 0
#define GRUB_EFI_CC_TYPE_SEV 1
#define GRUB_EFI_CC_TYPE_TDX 2
struct grub_efi_cc_type
{
grub_efi_uint8_t Type;
grub_efi_uint8_t SubType;
};
typedef struct grub_efi_cc_type grub_efi_cc_type_t;
typedef grub_efi_uint32_t grub_efi_cc_event_log_bitmap_t;
typedef grub_efi_uint32_t grub_efi_cc_event_log_format_t;
typedef grub_efi_uint32_t grub_efi_cc_event_algorithm_bitmap_t;
typedef grub_efi_uint32_t grub_efi_cc_mr_index_t;
/* Intel TDX measure register index. */
#define GRUB_TDX_MR_INDEX_MRTD 0
#define GRUB_TDX_MR_INDEX_RTMR0 1
#define GRUB_TDX_MR_INDEX_RTMR1 2
#define GRUB_TDX_MR_INDEX_RTMR2 3
#define GRUB_TDX_MR_INDEX_RTMR3 4
#define GRUB_EFI_CC_EVENT_LOG_FORMAT_TCG_2 0x00000002
#define GRUB_EFI_CC_BOOT_HASH_ALG_SHA384 0x00000004
#define GRUB_EFI_CC_EVENT_HEADER_VERSION 1
struct grub_efi_cc_event_header
{
/* Size of the event header itself (sizeof(EFI_TD_EVENT_HEADER)). */
grub_efi_uint32_t HeaderSize;
/*
* Header version. For this version of this specification,
* the value shall be 1.
*/
grub_efi_uint16_t HeaderVersion;
/* Index of the MR that shall be extended. */
grub_efi_cc_mr_index_t MrIndex;
/* Type of the event that shall be extended (and optionally logged). */
grub_efi_uint32_t EventType;
} GRUB_PACKED;
typedef struct grub_efi_cc_event_header grub_efi_cc_event_header_t;
struct grub_efi_cc_event
{
/* Total size of the event including the Size component, the header and the Event data. */
grub_efi_uint32_t Size;
grub_efi_cc_event_header_t Header;
grub_efi_uint8_t Event[0];
} GRUB_PACKED;
typedef struct grub_efi_cc_event grub_efi_cc_event_t;
struct grub_efi_cc_boot_service_capability
{
/* Allocated size of the structure. */
grub_efi_uint8_t Size;
/*
* Version of the grub_efi_cc_boot_service_capability_t structure itself.
* For this version of the protocol, the Major version shall be set to 1
* and the Minor version shall be set to 1.
*/
grub_efi_cc_version_t StructureVersion;
/*
* Version of the EFI TD protocol.
* For this version of the protocol, the Major version shall be set to 1
* and the Minor version shall be set to 1.
*/
grub_efi_cc_version_t ProtocolVersion;
/* Supported hash algorithms. */
grub_efi_cc_event_algorithm_bitmap_t HashAlgorithmBitmap;
/* Bitmap of supported event log formats. */
grub_efi_cc_event_log_bitmap_t SupportedEventLogs;
/* Indicates the CC type. */
grub_efi_cc_type_t CcType;
};
typedef struct grub_efi_cc_boot_service_capability grub_efi_cc_boot_service_capability_t;
struct grub_efi_cc_protocol
{
grub_efi_status_t
(__grub_efi_api *get_capability) (struct grub_efi_cc_protocol *this,
grub_efi_cc_boot_service_capability_t *ProtocolCapability);
grub_efi_status_t
(__grub_efi_api *get_event_log) (struct grub_efi_cc_protocol *this,
grub_efi_cc_event_log_format_t EventLogFormat,
grub_efi_physical_address_t *EventLogLocation,
grub_efi_physical_address_t *EventLogLastEntry,
grub_efi_boolean_t *EventLogTruncated);
grub_efi_status_t
(__grub_efi_api *hash_log_extend_event) (struct grub_efi_cc_protocol *this,
grub_efi_uint64_t Flags,
grub_efi_physical_address_t DataToHash,
grub_efi_uint64_t DataToHashLen,
grub_efi_cc_event_t *EfiCcEvent);
grub_efi_status_t
(__grub_efi_api *map_pcr_to_mr_index) (struct grub_efi_cc_protocol *this,
grub_efi_uint32_t PcrIndex,
grub_efi_cc_mr_index_t *MrIndex);
};
typedef struct grub_efi_cc_protocol grub_efi_cc_protocol_t;
#endif
@@ -0,0 +1,31 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,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_EFI_CONSOLE_HEADER
#define GRUB_EFI_CONSOLE_HEADER 1
#include <grub/types.h>
#include <grub/symbol.h>
/* Initialize the console system. */
void grub_console_init (void);
/* Finish the console system. */
void grub_console_fini (void);
#endif /* ! GRUB_EFI_CONSOLE_HEADER */
@@ -0,0 +1,59 @@
/* console_control.h - definitions of the console control protocol */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/>.
*/
/* The console control protocol is not a part of the EFI spec,
but defined in Intel's Sample Implementation. */
#ifndef GRUB_EFI_CONSOLE_CONTROL_HEADER
#define GRUB_EFI_CONSOLE_CONTROL_HEADER 1
#include <grub/efi/api.h>
#define GRUB_EFI_CONSOLE_CONTROL_GUID \
{ 0xf42f7782, 0x12e, 0x4c12, \
{ 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } \
}
enum grub_efi_screen_mode
{
GRUB_EFI_SCREEN_TEXT,
GRUB_EFI_SCREEN_GRAPHICS,
GRUB_EFI_SCREEN_TEXT_MAX_VALUE
};
typedef enum grub_efi_screen_mode grub_efi_screen_mode_t;
struct grub_efi_console_control_protocol
{
grub_efi_status_t
(__grub_efi_api *get_mode) (struct grub_efi_console_control_protocol *this,
grub_efi_screen_mode_t *mode,
grub_efi_boolean_t *uga_exists,
grub_efi_boolean_t *std_in_locked);
grub_efi_status_t
(__grub_efi_api *set_mode) (struct grub_efi_console_control_protocol *this,
grub_efi_screen_mode_t mode);
grub_efi_status_t
(__grub_efi_api *lock_std_in) (struct grub_efi_console_control_protocol *this,
grub_efi_char16_t *password);
};
typedef struct grub_efi_console_control_protocol grub_efi_console_control_protocol_t;
#endif /* ! GRUB_EFI_CONSOLE_CONTROL_HEADER */
@@ -0,0 +1,41 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2022 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/>.
*/
/* debug.h - declare variables and functions for EFI debugging support */
#ifndef GRUB_EFI_DEBUG_HEADER
#define GRUB_EFI_DEBUG_HEADER 1
#include <grub/efi/efi.h>
#include <grub/misc.h>
void grub_efi_register_debug_commands (void);
static inline void
grub_efi_print_gdb_info (void)
{
grub_addr_t text;
text = grub_efi_section_addr (".text");
if (!text)
return;
grub_printf ("dynamic_load_symbols %p\n", (void *)text);
}
#endif /* ! GRUB_EFI_DEBUG_HEADER */
@@ -0,0 +1,33 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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_EFI_DISK_HEADER
#define GRUB_EFI_DISK_HEADER 1
#include <grub/efi/api.h>
#include <grub/symbol.h>
#include <grub/disk.h>
grub_efi_handle_t
EXPORT_FUNC(grub_efidisk_get_device_handle) (grub_disk_t disk);
char *EXPORT_FUNC(grub_efidisk_get_device_name) (grub_efi_handle_t *handle);
void grub_efidisk_init (void);
void grub_efidisk_fini (void);
#endif /* ! GRUB_EFI_DISK_HEADER */
@@ -0,0 +1,54 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2012 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_EDID_HEADER
#define GRUB_EFI_EDID_HEADER 1
/* Based on UEFI specification. */
#define GRUB_EFI_EDID_ACTIVE_GUID \
{ 0xbd8c1056, 0x9f36, 0x44ec, { 0x92, 0xa8, 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 }}
#define GRUB_EFI_EDID_DISCOVERED_GUID \
{0x1c0c34f6,0xd380,0x41fa, {0xa0,0x49,0x8a,0xd0,0x6c,0x1a,0x66,0xaa}}
#define GRUB_EFI_EDID_OVERRIDE_GUID \
{0x48ecb431,0xfb72,0x45c0, {0xa9,0x22,0xf4,0x58,0xfe,0x4,0xb,0xd5}}
struct grub_efi_edid_override;
typedef grub_efi_status_t
(*grub_efi_edid_override_get_edid) (struct grub_efi_edid_override *this,
grub_efi_handle_t *childhandle,
grub_efi_uint32_t *attributes,
grub_efi_uintn_t *edidsize,
grub_efi_uint8_t *edid);
struct grub_efi_edid_override {
grub_efi_edid_override_get_edid get_edid;
};
typedef struct grub_efi_edid_override grub_efi_edid_override_t;
struct grub_efi_active_edid
{
grub_uint32_t size_of_edid;
grub_uint8_t *edid;
};
#endif
@@ -0,0 +1,154 @@
/* 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>
#include <grub/efi/pe32.h>
#define GRUB_LINUX_ARM_MAGIC_SIGNATURE 0x016f2818
struct linux_arch_kernel_header {
grub_uint32_t code0;
grub_uint32_t code1;
grub_uint64_t reserved[6];
grub_uint32_t magic;
grub_uint32_t hdr_offset; /* Offset of PE/COFF header. */
struct grub_pe_image_header pe_image_header;
};
/* Functions. */
void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_guid_t *protocol,
void *registration);
grub_efi_handle_t *
EXPORT_FUNC(grub_efi_locate_handle) (grub_efi_locate_search_type_t search_type,
grub_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_guid_t *protocol,
grub_efi_uint32_t attributes);
grub_efi_status_t
EXPORT_FUNC(grub_efi_close_protocol) (grub_efi_handle_t handle, grub_guid_t *protocol);
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);
grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable_with_attributes) (const char *variable,
const grub_guid_t *guid,
grub_size_t *datasize_out,
void **data_out,
grub_efi_uint32_t *attributes);
grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const char *variable,
const grub_guid_t *guid,
grub_size_t *datasize_out,
void **data_out);
grub_err_t
EXPORT_FUNC (grub_efi_set_variable_with_attributes) (const char *var,
const grub_guid_t *guid,
void *data,
grub_size_t datasize,
grub_efi_uint32_t attributes);
grub_err_t
EXPORT_FUNC (grub_efi_set_variable) (const char *var,
const grub_guid_t *guid,
void *data,
grub_size_t datasize);
grub_err_t
EXPORT_FUNC (grub_efi_set_variable_to_string) (const char *name, const grub_guid_t *guid,
const char *value, grub_efi_uint32_t attributes);
int
EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
const grub_efi_device_path_t *dp2);
extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
char **device,
char **path);
void *
EXPORT_FUNC (grub_efi_find_configuration_table) (const grub_guid_t *target_guid);
#if defined(__arm__) || defined(__aarch64__) || defined(__riscv) || defined(__loongarch__)
void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
#endif
#include <grub/file.h>
grub_err_t grub_arch_efi_linux_load_image_header(grub_file_t file,
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);
grub_addr_t grub_efi_section_addr (const char *section);
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,32 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013-2015 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_FDTLOAD_CPU_HEADER
#define GRUB_FDTLOAD_CPU_HEADER 1
#include <grub/types.h>
#include <grub/err.h>
void *
grub_fdt_load (grub_size_t additional_size);
void
grub_fdt_unload (void);
grub_err_t
grub_fdt_install (void);
#endif
@@ -0,0 +1,115 @@
/*
* 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_EFI_GOP_HEADER
#define GRUB_EFI_GOP_HEADER 1
/* Based on UEFI specification. */
#define GRUB_EFI_GOP_GUID \
{ 0x9042a9de, 0x23dc, 0x4a38, { 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a }}
typedef enum
{
GRUB_EFI_GOT_RGBA8,
GRUB_EFI_GOT_BGRA8,
GRUB_EFI_GOT_BITMASK,
GRUB_EFI_GOT_BLT_ONLY,
}
grub_efi_gop_pixel_format_t;
typedef enum
{
GRUB_EFI_BLT_VIDEO_FILL,
GRUB_EFI_BLT_VIDEO_TO_BLT_BUFFER,
GRUB_EFI_BLT_BUFFER_TO_VIDEO,
GRUB_EFI_BLT_VIDEO_TO_VIDEO,
GRUB_EFI_BLT_OPERATION_MAX
}
grub_efi_gop_blt_operation_t;
struct grub_efi_gop_blt_pixel
{
grub_uint8_t blue;
grub_uint8_t green;
grub_uint8_t red;
grub_uint8_t reserved;
};
struct grub_efi_gop_pixel_bitmask
{
grub_uint32_t r;
grub_uint32_t g;
grub_uint32_t b;
grub_uint32_t a;
};
struct grub_efi_gop_mode_info
{
grub_efi_uint32_t version;
grub_efi_uint32_t width;
grub_efi_uint32_t height;
grub_efi_gop_pixel_format_t pixel_format;
struct grub_efi_gop_pixel_bitmask pixel_bitmask;
grub_efi_uint32_t pixels_per_scanline;
};
struct grub_efi_gop_mode
{
grub_efi_uint32_t max_mode;
grub_efi_uint32_t mode;
struct grub_efi_gop_mode_info *info;
grub_efi_uintn_t info_size;
grub_efi_physical_address_t fb_base;
grub_efi_uintn_t fb_size;
};
/* Forward declaration. */
struct grub_efi_gop;
typedef grub_efi_status_t
(__grub_efi_api *grub_efi_gop_query_mode_t) (struct grub_efi_gop *this,
grub_efi_uint32_t mode_number,
grub_efi_uintn_t *size_of_info,
struct grub_efi_gop_mode_info **info);
typedef grub_efi_status_t
(__grub_efi_api *grub_efi_gop_set_mode_t) (struct grub_efi_gop *this,
grub_efi_uint32_t mode_number);
typedef grub_efi_status_t
(__grub_efi_api *grub_efi_gop_blt_t) (struct grub_efi_gop *this,
void *buffer,
grub_efi_uintn_t operation,
grub_efi_uintn_t sx,
grub_efi_uintn_t sy,
grub_efi_uintn_t dx,
grub_efi_uintn_t dy,
grub_efi_uintn_t width,
grub_efi_uintn_t height,
grub_efi_uintn_t delta);
struct grub_efi_gop
{
grub_efi_gop_query_mode_t query_mode;
grub_efi_gop_set_mode_t set_mode;
grub_efi_gop_blt_t blt;
struct grub_efi_gop_mode *mode;
};
#endif
@@ -0,0 +1,38 @@
/*
* 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_MEMORY_MACHINE_HEADER
#define GRUB_MEMORY_MACHINE_HEADER 1
#include <grub/err.h>
#include <grub/types.h>
/* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region of
memory. It is not concerned with underlying translation management concepts,
but only used as the granule for memory allocations. */
#define GRUB_EFI_PAGE_SHIFT 12
#define GRUB_EFI_PAGE_SIZE (1 << GRUB_EFI_PAGE_SHIFT)
#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT)
#define GRUB_MMAP_REGISTER_BY_FIRMWARE 1
grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size,
int type, int handle);
grub_err_t grub_machine_mmap_unregister (int handle);
#endif /* ! GRUB_MEMORY_MACHINE_HEADER */
@@ -0,0 +1,319 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008 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_PCI_HEADER
#define GRUB_EFI_PCI_HEADER 1
#include <grub/symbol.h>
#define GRUB_EFI_PCI_IO_GUID \
{ 0x4cf5b200, 0x68b8, 0x4ca5, { 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a }}
#define GRUB_EFI_PCI_ROOT_IO_GUID \
{ 0x2F707EBB, 0x4A1A, 0x11d4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}
typedef enum
{
GRUB_EFI_PCI_IO_WIDTH_UINT8,
GRUB_EFI_PCI_IO_WIDTH_UINT16,
GRUB_EFI_PCI_IO_WIDTH_UINT32,
GRUB_EFI_PCI_IO_WIDTH_UINT64,
GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT8,
GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT16,
GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT32,
GRUB_EFI_PCI_IO_WIDTH_FIFO_UINT64,
GRUB_EFI_PCI_IO_WIDTH_FILL_UINT8,
GRUB_EFI_PCI_IO_WIDTH_FILL_UINT16,
GRUB_EFI_PCI_IO_WIDTH_FILL_UINT32,
GRUB_EFI_PCI_IO_WIDTH_FILL_UINT64,
GRUB_EFI_PCI_IO_WIDTH_MAXIMUM,
}
grub_efi_pci_io_width_t;
struct grub_efi_pci_io;
typedef grub_efi_status_t
(*grub_efi_pci_io_mem_t) (struct grub_efi_pci_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint8_t bar_index,
grub_efi_uint64_t offset,
grub_efi_uintn_t count,
void *buffer);
typedef grub_efi_status_t
(*grub_efi_pci_io_config_t) (struct grub_efi_pci_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint32_t offset,
grub_efi_uintn_t count,
void *buffer);
typedef struct
{
grub_efi_pci_io_mem_t read;
grub_efi_pci_io_mem_t write;
} grub_efi_pci_io_access_t;
typedef struct
{
grub_efi_pci_io_config_t read;
grub_efi_pci_io_config_t write;
} grub_efi_pci_io_config_access_t;
typedef enum
{
GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_READ,
GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_WRITE,
GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_COMMON_BUFFER,
GRUB_EFI_PCI_IO_OPERATION_BUS_MASTER_MAXIMUM
}
grub_efi_pci_io_operation_t;
#define GRUB_EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
#define GRUB_EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
#define GRUB_EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
#define GRUB_EFI_PCI_IO_ATTRIBUTE_IO 0x0100
#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
#define GRUB_EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
#define GRUB_EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
#define GRUB_EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
#define GRUB_EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
#define GRUB_EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
#define GRUB_EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
#define GRUB_EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
typedef enum
{
GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_GET,
GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_SET,
GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_ENABLE,
GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_DISABLE,
GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_SUPPORTED,
GRUB_EFI_PCI_IO_ATTRIBUTE_OPERATION_MAXIMUM
}
grub_efi_pci_io_attribute_operation_t;
typedef grub_efi_status_t
(*grub_efi_pci_io_poll_io_mem_t) (struct grub_efi_pci_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint8_t bar_ndex,
grub_efi_uint64_t offset,
grub_efi_uint64_t mask,
grub_efi_uint64_t value,
grub_efi_uint64_t delay,
grub_efi_uint64_t *result);
typedef grub_efi_status_t
(*grub_efi_pci_io_copy_mem_t) (struct grub_efi_pci_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint8_t dest_bar_index,
grub_efi_uint64_t dest_offset,
grub_efi_uint8_t src_bar_index,
grub_efi_uint64_t src_offset,
grub_efi_uintn_t count);
typedef grub_efi_status_t
(*grub_efi_pci_io_map_t) (struct grub_efi_pci_io *this,
grub_efi_pci_io_operation_t operation,
void *host_address,
grub_efi_uintn_t *number_of_bytes,
grub_efi_uint64_t *device_address,
void **mapping);
typedef grub_efi_status_t
(*grub_efi_pci_io_unmap_t) (struct grub_efi_pci_io *this,
void *mapping);
typedef grub_efi_status_t
(*grub_efi_pci_io_allocate_buffer_t) (struct grub_efi_pci_io *this,
grub_efi_allocate_type_t type,
grub_efi_memory_type_t memory_type,
grub_efi_uintn_t pages,
void **host_address,
grub_efi_uint64_t attributes);
typedef grub_efi_status_t
(*grub_efi_pci_io_free_buffer_t) (struct grub_efi_pci_io *this,
grub_efi_allocate_type_t type,
grub_efi_memory_type_t memory_type,
grub_efi_uintn_t pages,
void **host_address,
grub_efi_uint64_t attributes);
typedef grub_efi_status_t
(*grub_efi_pci_io_flush_t) (struct grub_efi_pci_io *this);
typedef grub_efi_status_t
(*grub_efi_pci_io_get_location_t) (struct grub_efi_pci_io *this,
grub_efi_uintn_t *segment_number,
grub_efi_uintn_t *bus_number,
grub_efi_uintn_t *device_number,
grub_efi_uintn_t *function_number);
typedef grub_efi_status_t
(*grub_efi_pci_io_attributes_t) (struct grub_efi_pci_io *this,
grub_efi_pci_io_attribute_operation_t operation,
grub_efi_uint64_t attributes,
grub_efi_uint64_t *result);
typedef grub_efi_status_t
(*grub_efi_pci_io_get_bar_attributes_t) (struct grub_efi_pci_io *this,
grub_efi_uint8_t bar_index,
grub_efi_uint64_t *supports,
void **resources);
typedef grub_efi_status_t
(*grub_efi_pci_io_set_bar_attributes_t) (struct grub_efi_pci_io *this,
grub_efi_uint64_t attributes,
grub_efi_uint8_t bar_index,
grub_efi_uint64_t *offset,
grub_efi_uint64_t *length);
struct grub_efi_pci_io {
grub_efi_pci_io_poll_io_mem_t poll_mem;
grub_efi_pci_io_poll_io_mem_t poll_io;
grub_efi_pci_io_access_t mem;
grub_efi_pci_io_access_t io;
grub_efi_pci_io_config_access_t pci;
grub_efi_pci_io_copy_mem_t copy_mem;
grub_efi_pci_io_map_t map;
grub_efi_pci_io_unmap_t unmap;
grub_efi_pci_io_allocate_buffer_t allocate_buffer;
grub_efi_pci_io_free_buffer_t free_buffer;
grub_efi_pci_io_flush_t flush;
grub_efi_pci_io_get_location_t get_location;
grub_efi_pci_io_attributes_t attributes;
grub_efi_pci_io_get_bar_attributes_t get_bar_attributes;
grub_efi_pci_io_set_bar_attributes_t set_bar_attributes;
grub_efi_uint64_t rom_size;
void *rom_image;
};
typedef struct grub_efi_pci_io grub_efi_pci_io_t;
struct grub_efi_pci_root_io;
typedef struct
{
grub_efi_status_t(*read) (struct grub_efi_pci_root_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint64_t address,
grub_efi_uintn_t count,
void *buffer);
grub_efi_status_t(*write) (struct grub_efi_pci_root_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint64_t address,
grub_efi_uintn_t count,
void *buffer);
} grub_efi_pci_root_io_access_t;
typedef enum
{
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_READ,
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_WRITE,
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_COMMON_BUFFER,
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_READ_64,
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_WRITE_64,
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_COMMON_BUFFER_64,
GRUB_EFI_PCI_ROOT_IO_OPERATION_BUS_MASTER_MAXIMUM
}
grub_efi_pci_root_io_operation_t;
typedef grub_efi_status_t
(*grub_efi_pci_root_io_poll_io_mem_t) (struct grub_efi_pci_root_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint64_t address,
grub_efi_uint64_t mask,
grub_efi_uint64_t value,
grub_efi_uint64_t delay,
grub_efi_uint64_t *result);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_copy_mem_t) (struct grub_efi_pci_root_io *this,
grub_efi_pci_io_width_t width,
grub_efi_uint64_t dest_offset,
grub_efi_uint64_t src_offset,
grub_efi_uintn_t count);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_map_t) (struct grub_efi_pci_root_io *this,
grub_efi_pci_root_io_operation_t operation,
void *host_address,
grub_efi_uintn_t *number_of_bytes,
grub_efi_uint64_t *device_address,
void **mapping);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_unmap_t) (struct grub_efi_pci_root_io *this,
void *mapping);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_allocate_buffer_t) (struct grub_efi_pci_root_io *this,
grub_efi_allocate_type_t type,
grub_efi_memory_type_t memory_type,
grub_efi_uintn_t pages,
void **host_address,
grub_efi_uint64_t attributes);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_free_buffer_t) (struct grub_efi_pci_root_io *this,
grub_efi_uintn_t pages,
void **host_address);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_flush_t) (struct grub_efi_pci_root_io *this);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_get_attributes_t) (struct grub_efi_pci_root_io *this,
grub_efi_uint64_t *supports,
void **resources);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_set_attributes_t) (struct grub_efi_pci_root_io *this,
grub_efi_uint64_t attributes,
grub_efi_uint64_t *offset,
grub_efi_uint64_t *length);
typedef grub_efi_status_t
(*grub_efi_pci_root_io_configuration_t) (struct grub_efi_pci_root_io *this,
void **resources);
struct grub_efi_pci_root_io {
grub_efi_handle_t parent;
grub_efi_pci_root_io_poll_io_mem_t poll_mem;
grub_efi_pci_root_io_poll_io_mem_t poll_io;
grub_efi_pci_root_io_access_t mem;
grub_efi_pci_root_io_access_t io;
grub_efi_pci_root_io_access_t pci;
grub_efi_pci_root_io_copy_mem_t copy_mem;
grub_efi_pci_root_io_map_t map;
grub_efi_pci_root_io_unmap_t unmap;
grub_efi_pci_root_io_allocate_buffer_t allocate_buffer;
grub_efi_pci_root_io_free_buffer_t free_buffer;
grub_efi_pci_root_io_flush_t flush;
grub_efi_pci_root_io_get_attributes_t get_attributes;
grub_efi_pci_root_io_set_attributes_t set_attributes;
grub_efi_pci_root_io_configuration_t configuration;
};
typedef struct grub_efi_pci_root_io grub_efi_pci_root_io_t;
#endif /* !GRUB_EFI_PCI_HEADER */
@@ -0,0 +1,352 @@
/*
* 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
struct grub_msdos_image_header
{
/* This is always 'MZ'. (GRUB_PE32_MAGIC) */
grub_uint16_t msdos_magic;
grub_uint16_t reserved[29];
/* The file offset of the PE image header. */
grub_uint32_t pe_image_header_offset;
};
/* 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_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_LOONGARCH32 0x6232
#define GRUB_PE32_MACHINE_LOONGARCH64 0x6264
#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
#if GRUB_TARGET_SIZEOF_VOID_P == 8
#define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE64_MAGIC
#else
#define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE32_MAGIC
#endif
struct grub_pe_image_header
{
/* 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_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_LOONGARCH32_MARK_LA 8
#define GRUB_PE32_REL_BASED_LOONGARCH64_MARK_LA 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,46 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2020 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_SB_H
#define GRUB_EFI_SB_H 1
#include <grub/types.h>
#include <grub/dl.h>
#define GRUB_EFI_SECUREBOOT_MODE_UNSET 0
#define GRUB_EFI_SECUREBOOT_MODE_UNKNOWN 1
#define GRUB_EFI_SECUREBOOT_MODE_DISABLED 2
#define GRUB_EFI_SECUREBOOT_MODE_ENABLED 3
#ifdef GRUB_MACHINE_EFI
extern grub_uint8_t
EXPORT_FUNC (grub_efi_get_secureboot) (void);
extern bool
EXPORT_FUNC (grub_is_shim_lock_enabled) (void);
extern void
grub_shim_lock_verifier_setup (void);
#else
static inline grub_uint8_t
grub_efi_get_secureboot (void)
{
return GRUB_EFI_SECUREBOOT_MODE_UNSET;
}
#endif
#endif /* GRUB_EFI_SB_H */
@@ -0,0 +1,195 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2018 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_TPM_HEADER
#define GRUB_EFI_TPM_HEADER 1
#define EFI_TPM_GUID {0xf541796d, 0xa62e, 0x4954, {0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd }};
#define EFI_TPM2_GUID {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f }};
#define TCG_ALG_SHA 0x00000004
/* These structs are as defined in the TCG EFI Protocol Specification, family 2.0. */
struct __TCG_VERSION
{
grub_efi_uint8_t Major;
grub_efi_uint8_t Minor;
grub_efi_uint8_t RevMajor;
grub_efi_uint8_t RevMinor;
};
typedef struct __TCG_VERSION TCG_VERSION;
struct __TCG_EFI_BOOT_SERVICE_CAPABILITY
{
/* Size of this structure. */
grub_efi_uint8_t Size;
TCG_VERSION StructureVersion;
TCG_VERSION ProtocolSpecVersion;
/* Hash algorithms supported by this TPM. */
grub_efi_uint8_t HashAlgorithmBitmap;
/* 1 if TPM present. */
char TPMPresentFlag;
/* 1 if TPM deactivated. */
char TPMDeactivatedFlag;
};
typedef struct __TCG_EFI_BOOT_SERVICE_CAPABILITY TCG_EFI_BOOT_SERVICE_CAPABILITY;
struct tdTCG_PCR_EVENT
{
grub_efi_uint32_t PCRIndex;
grub_efi_uint32_t EventType;
grub_efi_uint8_t digest[20];
grub_efi_uint32_t EventSize;
grub_efi_uint8_t Event[1];
};
typedef struct tdTCG_PCR_EVENT TCG_PCR_EVENT;
struct grub_efi_tpm_protocol
{
grub_efi_status_t
(__grub_efi_api *status_check) (struct grub_efi_tpm_protocol *this,
TCG_EFI_BOOT_SERVICE_CAPABILITY *ProtocolCapability,
grub_efi_uint32_t *TCGFeatureFlags,
grub_efi_physical_address_t *EventLogLocation,
grub_efi_physical_address_t *EventLogLastEntry);
grub_efi_status_t
(__grub_efi_api *hash_all) (struct grub_efi_tpm_protocol *this,
grub_efi_uint8_t *HashData,
grub_efi_uint64_t HashLen,
grub_efi_uint32_t AlgorithmId,
grub_efi_uint64_t *HashedDataLen,
grub_efi_uint8_t **HashedDataResult);
grub_efi_status_t
(__grub_efi_api *log_event) (struct grub_efi_tpm_protocol *this,
TCG_PCR_EVENT *TCGLogData,
grub_efi_uint32_t *EventNumber,
grub_efi_uint32_t Flags);
grub_efi_status_t
(__grub_efi_api *pass_through_to_tpm) (struct grub_efi_tpm_protocol *this,
grub_efi_uint32_t TpmInputParameterBlockSize,
grub_efi_uint8_t *TpmInputParameterBlock,
grub_efi_uint32_t TpmOutputParameterBlockSize,
grub_efi_uint8_t *TpmOutputParameterBlock);
grub_efi_status_t
(__grub_efi_api *log_extend_event) (struct grub_efi_tpm_protocol *this,
grub_efi_physical_address_t HashData,
grub_efi_uint64_t HashDataLen,
grub_efi_uint32_t AlgorithmId,
TCG_PCR_EVENT *TCGLogData,
grub_efi_uint32_t *EventNumber,
grub_efi_physical_address_t *EventLogLastEntry);
};
typedef struct grub_efi_tpm_protocol grub_efi_tpm_protocol_t;
typedef grub_efi_uint32_t EFI_TCG2_EVENT_LOG_BITMAP;
typedef grub_efi_uint32_t EFI_TCG2_EVENT_LOG_FORMAT;
typedef grub_efi_uint32_t EFI_TCG2_EVENT_ALGORITHM_BITMAP;
struct tdEFI_TCG2_VERSION
{
grub_efi_uint8_t Major;
grub_efi_uint8_t Minor;
} GRUB_PACKED;
typedef struct tdEFI_TCG2_VERSION EFI_TCG2_VERSION;
struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY
{
grub_efi_uint8_t Size;
EFI_TCG2_VERSION StructureVersion;
EFI_TCG2_VERSION ProtocolVersion;
EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
grub_efi_boolean_t TPMPresentFlag;
grub_efi_uint16_t MaxCommandSize;
grub_efi_uint16_t MaxResponseSize;
grub_efi_uint32_t ManufacturerID;
grub_efi_uint32_t NumberOfPcrBanks;
EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
};
typedef struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY EFI_TCG2_BOOT_SERVICE_CAPABILITY;
typedef grub_efi_uint32_t TCG_PCRINDEX;
typedef grub_efi_uint32_t TCG_EVENTTYPE;
struct tdEFI_TCG2_EVENT_HEADER
{
grub_efi_uint32_t HeaderSize;
grub_efi_uint16_t HeaderVersion;
TCG_PCRINDEX PCRIndex;
TCG_EVENTTYPE EventType;
} GRUB_PACKED;
typedef struct tdEFI_TCG2_EVENT_HEADER EFI_TCG2_EVENT_HEADER;
struct tdEFI_TCG2_EVENT
{
grub_efi_uint32_t Size;
EFI_TCG2_EVENT_HEADER Header;
grub_efi_uint8_t Event[1];
} GRUB_PACKED;
typedef struct tdEFI_TCG2_EVENT EFI_TCG2_EVENT;
struct grub_efi_tpm2_protocol
{
grub_efi_status_t
(__grub_efi_api *get_capability) (struct grub_efi_tpm2_protocol *this,
EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability);
grub_efi_status_t
(__grub_efi_api *get_event_log) (struct grub_efi_tpm2_protocol *this,
EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
grub_efi_physical_address_t *EventLogLocation,
grub_efi_physical_address_t *EventLogLastEntry,
grub_efi_boolean_t *EventLogTruncated);
grub_efi_status_t
(__grub_efi_api *hash_log_extend_event) (struct grub_efi_tpm2_protocol *this,
grub_efi_uint64_t Flags,
grub_efi_physical_address_t DataToHash,
grub_efi_uint64_t DataToHashLen,
EFI_TCG2_EVENT *EfiTcgEvent);
grub_efi_status_t
(__grub_efi_api *submit_command) (struct grub_efi_tpm2_protocol *this,
grub_efi_uint32_t InputParameterBlockSize,
grub_efi_uint8_t *InputParameterBlock,
grub_efi_uint32_t OutputParameterBlockSize,
grub_efi_uint8_t *OutputParameterBlock);
grub_efi_status_t
(__grub_efi_api *get_active_pcr_banks) (struct grub_efi_tpm2_protocol *this,
grub_efi_uint32_t *ActivePcrBanks);
grub_efi_status_t
(__grub_efi_api *set_active_pcr_banks) (struct grub_efi_tpm2_protocol *this,
grub_efi_uint32_t ActivePcrBanks);
grub_efi_status_t
(__grub_efi_api *get_result_of_set_active_pcr_banks) (struct grub_efi_tpm2_protocol *this,
grub_efi_uint32_t *OperationPresent,
grub_efi_uint32_t *Response);
};
typedef struct grub_efi_tpm2_protocol grub_efi_tpm2_protocol_t;
#endif
@@ -0,0 +1,76 @@
/* uga_draw.h - definitions of the uga draw protocol */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 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/>.
*/
/* The console control protocol is not a part of the EFI spec,
but defined in Intel's Sample Implementation. */
#ifndef GRUB_EFI_UGA_DRAW_HEADER
#define GRUB_EFI_UGA_DRAW_HEADER 1
#define GRUB_EFI_UGA_DRAW_GUID \
{ 0x982c298b, 0xf4fa, 0x41cb, { 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 }}
enum grub_efi_uga_blt_operation
{
GRUB_EFI_UGA_VIDEO_FILL,
GRUB_EFI_UGA_VIDEO_TO_BLT,
GRUB_EFI_UGA_BLT_TO_VIDEO,
GRUB_EFI_UGA_VIDEO_TO_VIDEO,
GRUB_EFI_UGA_BLT_MAX
};
struct grub_efi_uga_pixel
{
grub_uint8_t Blue;
grub_uint8_t Green;
grub_uint8_t Red;
grub_uint8_t Reserved;
};
struct grub_efi_uga_draw_protocol
{
grub_efi_status_t
(__grub_efi_api *get_mode) (struct grub_efi_uga_draw_protocol *this,
grub_uint32_t *width,
grub_uint32_t *height,
grub_uint32_t *depth,
grub_uint32_t *refresh_rate);
grub_efi_status_t
(__grub_efi_api *set_mode) (struct grub_efi_uga_draw_protocol *this,
grub_uint32_t width,
grub_uint32_t height,
grub_uint32_t depth,
grub_uint32_t refresh_rate);
grub_efi_status_t
(__grub_efi_api *blt) (struct grub_efi_uga_draw_protocol *this,
struct grub_efi_uga_pixel *blt_buffer,
enum grub_efi_uga_blt_operation blt_operation,
grub_efi_uintn_t src_x,
grub_efi_uintn_t src_y,
grub_efi_uintn_t dest_x,
grub_efi_uintn_t dest_y,
grub_efi_uintn_t width,
grub_efi_uintn_t height,
grub_efi_uintn_t delta);
};
typedef struct grub_efi_uga_draw_protocol grub_efi_uga_draw_protocol_t;
#endif /* ! GRUB_EFI_UGA_DRAW_HEADER */
@@ -0,0 +1,286 @@
/*
* 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_EFI_EMU_HEADER
#define GRUB_EFI_EMU_HEADER 1
#include <grub/efi/api.h>
#include <grub/file.h>
#include <grub/memory.h>
#define GRUB_EFIEMU_PAGESIZE 4096
/* EFI api defined in 32-bit and 64-bit version*/
struct grub_efi_system_table32
{
grub_efi_table_header_t hdr;
grub_efi_uint32_t firmware_vendor;
grub_efi_uint32_t firmware_revision;
grub_efi_uint32_t console_in_handler;
grub_efi_uint32_t con_in;
grub_efi_uint32_t console_out_handler;
grub_efi_uint32_t con_out;
grub_efi_uint32_t standard_error_handle;
grub_efi_uint32_t std_err;
grub_efi_uint32_t runtime_services;
grub_efi_uint32_t boot_services;
grub_efi_uint32_t num_table_entries;
grub_efi_uint32_t configuration_table;
} GRUB_PACKED;
typedef struct grub_efi_system_table32 grub_efi_system_table32_t;
struct grub_efi_system_table64
{
grub_efi_table_header_t hdr;
grub_efi_uint64_t firmware_vendor;
grub_efi_uint32_t firmware_revision;
grub_efi_uint32_t pad;
grub_efi_uint64_t console_in_handler;
grub_efi_uint64_t con_in;
grub_efi_uint64_t console_out_handler;
grub_efi_uint64_t con_out;
grub_efi_uint64_t standard_error_handle;
grub_efi_uint64_t std_err;
grub_efi_uint64_t runtime_services;
grub_efi_uint64_t boot_services;
grub_efi_uint64_t num_table_entries;
grub_efi_uint64_t configuration_table;
} GRUB_PACKED;
typedef struct grub_efi_system_table64 grub_efi_system_table64_t;
struct grub_efiemu_runtime_services32
{
grub_efi_table_header_t hdr;
grub_efi_uint32_t get_time;
grub_efi_uint32_t set_time;
grub_efi_uint32_t get_wakeup_time;
grub_efi_uint32_t set_wakeup_time;
grub_efi_uint32_t set_virtual_address_map;
grub_efi_uint32_t convert_pointer;
grub_efi_uint32_t get_variable;
grub_efi_uint32_t get_next_variable_name;
grub_efi_uint32_t set_variable;
grub_efi_uint32_t get_next_high_monotonic_count;
grub_efi_uint32_t reset_system;
} GRUB_PACKED;
typedef struct grub_efiemu_runtime_services32 grub_efiemu_runtime_services32_t;
struct grub_efiemu_runtime_services64
{
grub_efi_table_header_t hdr;
grub_efi_uint64_t get_time;
grub_efi_uint64_t set_time;
grub_efi_uint64_t get_wakeup_time;
grub_efi_uint64_t set_wakeup_time;
grub_efi_uint64_t set_virtual_address_map;
grub_efi_uint64_t convert_pointer;
grub_efi_uint64_t get_variable;
grub_efi_uint64_t get_next_variable_name;
grub_efi_uint64_t set_variable;
grub_efi_uint64_t get_next_high_monotonic_count;
grub_efi_uint64_t reset_system;
} GRUB_PACKED;
typedef struct grub_efiemu_runtime_services64 grub_efiemu_runtime_services64_t;
extern grub_efi_system_table32_t *grub_efiemu_system_table32;
extern grub_efi_system_table64_t *grub_efiemu_system_table64;
/* Convenience macros to access currently loaded efiemu */
#define grub_efiemu_system_table ((grub_efiemu_sizeof_uintn_t () == 8) \
? (void *) grub_efiemu_system_table64 \
: (void *) grub_efiemu_system_table32)
#define GRUB_EFIEMU_SIZEOF_OF_UINTN (grub_efiemu_sizeof_uintn_t ())
#define GRUB_EFIEMU_SYSTEM_TABLE(x) ((grub_efiemu_sizeof_uintn_t () == 8) \
? grub_efiemu_system_table64->x \
: grub_efiemu_system_table32->x)
#define GRUB_EFIEMU_SYSTEM_TABLE_SET(x,y) ((grub_efiemu_sizeof_uintn_t () == 8)\
? (grub_efiemu_system_table64->x \
= (y)) \
: (grub_efiemu_system_table32->x \
= (y)))
#define GRUB_EFIEMU_SYSTEM_TABLE_PTR(x) ((grub_efiemu_sizeof_uintn_t () == 8)\
? (void *) (grub_addr_t) \
(grub_efiemu_system_table64->x) \
: (void *) (grub_addr_t) \
(grub_efiemu_system_table32->x))
#define GRUB_EFIEMU_SYSTEM_TABLE_VAR(x) ((grub_efiemu_sizeof_uintn_t () == 8) \
? (void *) \
&(grub_efiemu_system_table64->x) \
: (void *) \
&(grub_efiemu_system_table32->x))
#define GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF(x) \
((grub_efiemu_sizeof_uintn_t () == 8) \
? sizeof(grub_efiemu_system_table64->x)\
: sizeof(grub_efiemu_system_table32->x))
#define GRUB_EFIEMU_SYSTEM_TABLE_SIZEOF_TOTAL ((grub_efiemu_sizeof_uintn_t () == 8) ? sizeof(*grub_efiemu_system_table64):sizeof(*grub_efiemu_system_table32))
/* ELF management definitions and functions */
struct grub_efiemu_segment
{
struct grub_efiemu_segment *next;
grub_size_t size;
unsigned section;
int handle;
int ptv_rel_needed;
grub_off_t off;
void *srcptr;
};
typedef struct grub_efiemu_segment *grub_efiemu_segment_t;
struct grub_efiemu_elf_sym
{
int handle;
grub_off_t off;
unsigned section;
};
int grub_efiemu_check_header32 (void *ehdr, grub_size_t size);
int grub_efiemu_check_header64 (void *ehdr, grub_size_t size);
grub_err_t grub_efiemu_loadcore_init32 (void *core,
const char *filename,
grub_size_t core_size,
grub_efiemu_segment_t *segments);
grub_err_t grub_efiemu_loadcore_init64 (void *core, const char *filename,
grub_size_t core_size,
grub_efiemu_segment_t *segments);
grub_err_t grub_efiemu_loadcore_load32 (void *core,
grub_size_t core_size,
grub_efiemu_segment_t segments);
grub_err_t grub_efiemu_loadcore_load64 (void *core,
grub_size_t core_size,
grub_efiemu_segment_t segments);
grub_err_t grub_efiemu_loadcore_unload32 (void);
grub_err_t grub_efiemu_loadcore_unload64 (void);
grub_err_t grub_efiemu_loadcore_unload(void);
grub_err_t grub_efiemu_loadcore_init (grub_file_t file,
const char *filename);
grub_err_t grub_efiemu_loadcore_load (void);
/* Configuration tables manipulation. Definitions and functions */
struct grub_efiemu_configuration_table
{
struct grub_efiemu_configuration_table *next;
grub_guid_t guid;
void * (*get_table) (void *data);
void (*unload) (void *data);
void *data;
};
struct grub_efiemu_configuration_table32
{
grub_packed_guid_t vendor_guid;
grub_efi_uint32_t vendor_table;
} GRUB_PACKED;
typedef struct grub_efiemu_configuration_table32 grub_efiemu_configuration_table32_t;
struct grub_efiemu_configuration_table64
{
grub_packed_guid_t vendor_guid;
grub_efi_uint64_t vendor_table;
} GRUB_PACKED;
typedef struct grub_efiemu_configuration_table64 grub_efiemu_configuration_table64_t;
grub_err_t grub_efiemu_unregister_configuration_table (grub_guid_t guid);
grub_err_t
grub_efiemu_register_configuration_table (grub_guid_t guid,
void * (*get_table) (void *data),
void (*unload) (void *data),
void *data);
/* Memory management functions */
int grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_efi_memory_type_t type);
void *grub_efiemu_mm_obtain_request (int handle);
grub_err_t grub_efiemu_mm_unload (void);
grub_err_t grub_efiemu_mm_do_alloc (void);
grub_err_t grub_efiemu_mm_init (void);
void grub_efiemu_mm_return_request (int handle);
grub_efi_memory_type_t grub_efiemu_mm_get_type (int handle);
/* Drop-in replacements for grub_efi_* and grub_machine_* */
int grub_efiemu_get_memory_map (grub_efi_uintn_t *memory_map_size,
grub_efi_memory_descriptor_t *memory_map,
grub_efi_uintn_t *map_key,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
grub_err_t
grub_efiemu_finish_boot_services (grub_efi_uintn_t *memory_map_size,
grub_efi_memory_descriptor_t *memory_map,
grub_efi_uintn_t *map_key,
grub_efi_uintn_t *descriptor_size,
grub_efi_uint32_t *descriptor_version);
grub_err_t
grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data);
int grub_efiemu_sizeof_uintn_t (void);
grub_err_t
grub_efiemu_get_lower_upper_memory (grub_uint64_t *lower, grub_uint64_t *upper);
/* efiemu main control definitions and functions*/
typedef enum {GRUB_EFIEMU_NOTLOADED,
GRUB_EFIEMU32, GRUB_EFIEMU64} grub_efiemu_mode_t;
struct grub_efiemu_prepare_hook
{
struct grub_efiemu_prepare_hook *next;
grub_err_t (*hook) (void *data);
void (*unload) (void *data);
void *data;
};
grub_err_t grub_efiemu_prepare32 (struct grub_efiemu_prepare_hook
*prepare_hooks,
struct grub_efiemu_configuration_table
*config_tables);
grub_err_t grub_efiemu_prepare64 (struct grub_efiemu_prepare_hook
*prepare_hooks,
struct grub_efiemu_configuration_table
*config_tables);
grub_err_t grub_efiemu_unload (void);
grub_err_t grub_efiemu_prepare (void);
grub_err_t
grub_efiemu_register_prepare_hook (grub_err_t (*hook) (void *data),
void (*unload) (void *data),
void *data);
/* symbols and pointers */
grub_err_t grub_efiemu_alloc_syms (void);
grub_err_t grub_efiemu_request_symbols (int num);
grub_err_t grub_efiemu_resolve_symbol (const char *name,
int *handle, grub_off_t *off);
grub_err_t grub_efiemu_register_symbol (const char *name,
int handle, grub_off_t off);
void grub_efiemu_free_syms (void);
grub_err_t grub_efiemu_write_value (void * addr, grub_uint32_t value,
int plus_handle,
int minus_handle, int ptv_needed, int size);
grub_err_t grub_efiemu_write_sym_markers (void);
grub_err_t grub_efiemu_pnvram (void);
const char *grub_efiemu_get_default_core_name (void);
void grub_efiemu_pnvram_cmd_unregister (void);
grub_err_t grub_efiemu_autocore (void);
grub_err_t grub_efiemu_crc32 (void);
grub_err_t grub_efiemu_crc64 (void);
grub_err_t
grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
grub_efi_uintn_t descriptor_size,
grub_efi_uint32_t descriptor_version
__attribute__ ((unused)),
grub_efi_memory_descriptor_t *virtual_map);
grub_err_t grub_machine_efiemu_init_tables (void);
#endif /* ! GRUB_EFI_EMU_HEADER */
@@ -0,0 +1,37 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_EFI_EMU_RUNTIME_HEADER
#define GRUB_EFI_EMU_RUNTIME_HEADER 1
struct grub_efiemu_ptv_rel
{
grub_uint64_t addr;
grub_efi_memory_type_t plustype;
grub_efi_memory_type_t minustype;
grub_uint32_t size;
} GRUB_PACKED;
struct efi_variable
{
grub_packed_guid_t guid;
grub_uint32_t namelen;
grub_uint32_t size;
grub_efi_uint32_t attributes;
} GRUB_PACKED;
#endif /* ! GRUB_EFI_EMU_RUNTIME_HEADER */
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,82 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004, 2005, 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_ELFLOAD_HEADER
#define GRUB_ELFLOAD_HEADER 1
#include <grub/err.h>
#include <grub/elf.h>
#include <grub/file.h>
#include <grub/symbol.h>
#include <grub/types.h>
struct grub_elf_file
{
grub_file_t file;
union {
Elf64_Ehdr ehdr64;
Elf32_Ehdr ehdr32;
} ehdr;
void *phdrs;
char *filename;
};
typedef struct grub_elf_file *grub_elf_t;
typedef int (*grub_elf32_phdr_iterate_hook_t)
(grub_elf_t elf, Elf32_Phdr *phdr, void *arg);
typedef int (*grub_elf64_phdr_iterate_hook_t)
(grub_elf_t elf, Elf64_Phdr *phdr, void *arg);
grub_elf_t grub_elf_open (const char *, enum grub_file_type type);
grub_elf_t grub_elf_file (grub_file_t file, const char *filename);
grub_err_t grub_elf_close (grub_elf_t);
int grub_elf_is_elf32 (grub_elf_t);
grub_size_t grub_elf32_size (grub_elf_t,
Elf32_Addr *, grub_uint32_t *);
enum grub_elf_load_flags
{
GRUB_ELF_LOAD_FLAGS_NONE = 0,
GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC = 1,
GRUB_ELF_LOAD_FLAGS_BITS = 6,
GRUB_ELF_LOAD_FLAGS_ALL_BITS = 0,
GRUB_ELF_LOAD_FLAGS_28BITS = 2,
GRUB_ELF_LOAD_FLAGS_30BITS = 4,
GRUB_ELF_LOAD_FLAGS_62BITS = 6,
};
grub_err_t grub_elf32_load (grub_elf_t, const char *filename,
void *load_offset, enum grub_elf_load_flags flags, grub_addr_t *,
grub_size_t *);
int grub_elf_is_elf64 (grub_elf_t);
grub_size_t grub_elf64_size (grub_elf_t,
Elf64_Addr *, grub_uint64_t *);
grub_err_t grub_elf64_load (grub_elf_t, const char *filename,
void *load_offset, enum grub_elf_load_flags flags, grub_addr_t *,
grub_size_t *);
grub_err_t grub_elf32_load_phdrs (grub_elf_t elf);
grub_err_t grub_elf64_load_phdrs (grub_elf_t elf);
#define FOR_ELF32_PHDRS(elf, phdr) \
for (grub_elf32_load_phdrs (elf), phdr = elf->phdrs; \
phdr && phdr < (Elf32_Phdr *) elf->phdrs + elf->ehdr.ehdr32.e_phnum; phdr++)
#define FOR_ELF64_PHDRS(elf, phdr) \
for (grub_elf64_load_phdrs (elf), phdr = elf->phdrs; \
phdr && phdr < (Elf64_Phdr *) elf->phdrs + elf->ehdr.ehdr64.e_phnum; phdr++)
#endif /* ! GRUB_ELFLOAD_HEADER */
@@ -0,0 +1,48 @@
/*
* 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_CONFIG_EMU_HEADER
#define GRUB_CONFIG_EMU_HEADER 1
#include <grub/disk.h>
#include <grub/partition.h>
#include <grub/emu/hostfile.h>
#include <stdio.h>
const char *
grub_util_get_config_filename (void);
const char *
grub_util_get_pkgdatadir (void);
const char *
grub_util_get_pkglibdir (void);
const char *
grub_util_get_localedir (void);
struct grub_util_config
{
int is_cryptodisk_enabled;
char *grub_distributor;
};
void
grub_util_load_config (struct grub_util_config *cfg);
void
grub_util_parse_config (FILE *f, struct grub_util_config *cfg, int simple);
#endif
@@ -0,0 +1,28 @@
/*
* 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_CONSOLE_UTIL_HEADER
#define GRUB_CONSOLE_UTIL_HEADER 1
/* Initialize the console system. */
void grub_console_init (void);
/* Finish the console system. */
void grub_console_fini (void);
#endif /* ! GRUB_CONSOLE_UTIL_HEADER */
@@ -0,0 +1,44 @@
/*
* 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_EMU_EXEC_H
#define GRUB_EMU_EXEC_H 1
#include <config.h>
#include <stdarg.h>
#include <sys/types.h>
#include <grub/symbol.h>
pid_t
grub_util_exec_pipe (const char *const *argv, int *fd);
pid_t
grub_util_exec_pipe_stderr (const char *const *argv, int *fd);
int
grub_util_exec_redirect_all (const char *const *argv, const char *stdin_file,
const char *stdout_file, const char *stderr_file);
int
EXPORT_FUNC(grub_util_exec) (const char *const *argv);
int
grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
const char *stdout_file);
int
grub_util_exec_redirect_null (const char *const *argv);
#endif
@@ -0,0 +1,104 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 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_UTIL_GETROOT_HEADER
#define GRUB_UTIL_GETROOT_HEADER 1
#include <grub/types.h>
#include <grub/device.h>
#include <sys/types.h>
#include <stdio.h>
enum grub_dev_abstraction_types {
GRUB_DEV_ABSTRACTION_NONE,
GRUB_DEV_ABSTRACTION_LVM,
GRUB_DEV_ABSTRACTION_RAID,
GRUB_DEV_ABSTRACTION_LUKS,
GRUB_DEV_ABSTRACTION_GELI,
};
char *grub_find_device (const char *dir, dev_t dev);
void grub_util_pull_device (const char *osname);
char **grub_guess_root_devices (const char *dir);
int grub_util_get_dev_abstraction (const char *os_dev);
char *grub_make_system_path_relative_to_its_root (const char *path);
char *
grub_make_system_path_relative_to_its_root_os (const char *path);
char *grub_util_get_grub_dev (const char *os_dev);
#if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
void grub_util_follow_gpart_up (const char *name, grub_disk_addr_t *off_out,
char **name_out);
#endif
#include <sys/stat.h>
#ifdef __linux__
char **
grub_find_root_devices_from_mountinfo (const char *dir, char **relroot);
#endif
/* Devmapper functions provided by getroot_devmapper.c. */
void
grub_util_pull_devmapper (const char *os_dev);
int
grub_util_device_is_mapped_stat (struct stat *st);
void grub_util_devmapper_cleanup (void);
enum grub_dev_abstraction_types
grub_util_get_dm_abstraction (const char *os_dev);
char *
grub_util_get_vg_uuid (const char *os_dev);
char *
grub_util_devmapper_part_to_disk (struct stat *st,
int *is_part, const char *os_dev);
char *
grub_util_get_devmapper_grub_dev (const char *os_dev);
void
grub_util_pull_lvm_by_command (const char *os_dev);
char **
grub_util_find_root_devices_from_poolname (char *poolname);
grub_disk_addr_t
grub_util_find_partition_start (const char *dev);
/* OS-specific functions provided by getroot_*.c. */
enum grub_dev_abstraction_types
grub_util_get_dev_abstraction_os (const char *os_dev);
char *
grub_util_part_to_disk (const char *os_dev, struct stat *st,
int *is_part);
int
grub_util_pull_device_os (const char *osname,
enum grub_dev_abstraction_types ab);
char *
grub_util_get_grub_dev_os (const char *os_dev);
grub_disk_addr_t
grub_util_find_partition_start_os (const char *dev);
char *
grub_util_guess_bios_drive (const char *orig_path);
char *
grub_util_guess_efi_drive (const char *orig_path);
char *
grub_util_guess_baremetal_drive (const char *orig_path);
void
grub_util_fprint_full_disk_name (FILE *f,
const char *drive, grub_device_t dev);
#endif /* ! GRUB_UTIL_GETROOT_HEADER */
@@ -0,0 +1,98 @@
/* biosdisk.h - emulate biosdisk */
/*
* 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_BIOSDISK_MACHINE_UTIL_HEADER
#define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
#include <grub/disk.h>
#include <grub/partition.h>
#include <sys/types.h>
#include <grub/emu/hostfile.h>
grub_util_fd_t
grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int flags,
grub_disk_addr_t *max);
void grub_util_biosdisk_init (const char *dev_map);
void grub_util_biosdisk_fini (void);
char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
const char *grub_util_biosdisk_get_osdev (grub_disk_t disk);
int grub_util_biosdisk_is_present (const char *name);
int grub_util_biosdisk_is_floppy (grub_disk_t disk);
const char *
grub_util_biosdisk_get_compatibility_hint (grub_disk_t disk);
grub_err_t grub_util_biosdisk_flush (struct grub_disk *disk);
grub_err_t
grub_cryptodisk_cheat_mount (const char *sourcedev, const char *cheat);
const char *
grub_util_cryptodisk_get_uuid (grub_disk_t disk);
char *
grub_util_get_ldm (grub_disk_t disk, grub_disk_addr_t start);
int
grub_util_is_ldm (grub_disk_t disk);
#ifdef GRUB_UTIL
grub_err_t
grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
unsigned int max_nsectors,
grub_embed_type_t embed_type,
grub_disk_addr_t **sectors);
#endif
const char *
grub_hostdisk_os_dev_to_grub_drive (const char *os_dev, int add);
char *
grub_util_get_os_disk (const char *os_dev);
int
grub_util_get_dm_node_linear_info (dev_t dev,
int *maj, int *min,
grub_disk_addr_t *st);
/* Supplied by hostdisk_*.c. */
grub_int64_t
grub_util_get_fd_size_os (grub_util_fd_t fd, const char *name, unsigned *log_secsize);
/* REturns partition offset in 512B blocks. */
grub_disk_addr_t
grub_hostdisk_find_partition_start_os (const char *dev);
void
grub_hostdisk_flush_initial_buffer (const char *os_dev);
#ifdef __GNU__
int
grub_util_hurd_get_disk_info (const char *dev, grub_uint32_t *secsize, grub_disk_addr_t *offset,
grub_disk_addr_t *size, char **parent);
#endif
struct grub_util_hostdisk_data
{
char *dev;
int access_mode;
grub_util_fd_t fd;
int is_disk;
int device_map;
};
void grub_host_init (void);
void grub_host_fini (void);
void grub_hostfs_init (void);
void grub_hostfs_fini (void);
#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
@@ -0,0 +1,69 @@
/*
* 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_HOSTFILE_EMU_HEADER
#define GRUB_HOSTFILE_EMU_HEADER 1
#include <grub/disk.h>
#include <grub/partition.h>
#include <sys/types.h>
#include <grub/symbol.h>
#include <grub/osdep/hostfile.h>
int
grub_util_is_directory (const char *path);
int
grub_util_is_special_file (const char *path);
int
EXPORT_FUNC(grub_util_is_regular) (const char *path);
char *
grub_util_path_concat (size_t n, ...);
char *
grub_util_path_concat_ext (size_t n, ...);
int
grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off);
ssize_t
EXPORT_FUNC(grub_util_fd_read) (grub_util_fd_t fd, char *buf, size_t len);
ssize_t
EXPORT_FUNC(grub_util_fd_write) (grub_util_fd_t fd, const char *buf, size_t len);
grub_util_fd_t
EXPORT_FUNC(grub_util_fd_open) (const char *os_dev, int flags);
const char *
EXPORT_FUNC(grub_util_fd_strerror) (void);
int
grub_util_fd_sync (grub_util_fd_t fd);
void
grub_util_disable_fd_syncs (void);
int
EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd);
grub_uint64_t
grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsize);
char *
grub_util_make_temporary_file (void);
char *
grub_util_make_temporary_dir (void);
void
grub_util_unlink_recursive (const char *name);
grub_uint32_t
grub_util_get_mtime (const char *name);
#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
@@ -0,0 +1,78 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_EMU_MISC_H
#define GRUB_EMU_MISC_H 1
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <grub/compiler.h>
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/util/misc.h>
extern int verbosity;
extern const char *program_name;
void grub_init_all (void);
void grub_fini_all (void);
void grub_find_zpool_from_dir (const char *dir,
char **poolname, char **poolfs);
char *grub_make_system_path_relative_to_its_root (const char *path)
WARN_UNUSED_RESULT;
int
grub_util_device_is_mapped (const char *dev);
#define GRUB_HOST_PRIuLONG_LONG "llu"
#define GRUB_HOST_PRIxLONG_LONG "llx"
void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT;
void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2))) WARN_UNUSED_RESULT;
void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2)));
void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (GNU_PRINTF, 1, 2), noreturn));
void EXPORT_FUNC(grub_util_set_kexecute) (void);
int EXPORT_FUNC(grub_util_get_kexecute) (void) WARN_UNUSED_RESULT;
grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
#ifdef HAVE_DEVICE_MAPPER
int grub_device_mapper_supported (void);
#endif
#ifdef GRUB_BUILD
#define grub_util_fopen fopen
#else
FILE *
grub_util_fopen (const char *path, const char *mode);
#endif
int grub_util_file_sync (FILE *f);
#endif /* GRUB_EMU_MISC_H */
@@ -0,0 +1,37 @@
/*
* 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_EMUNET_HEADER
#define GRUB_EMUNET_HEADER 1
#include <grub/types.h>
#include <grub/symbol.h>
grub_ssize_t
EXPORT_FUNC(grub_emunet_send) (const void *packet, grub_size_t sz);
grub_ssize_t
EXPORT_FUNC(grub_emunet_receive) (void *packet, grub_size_t sz);
int
EXPORT_FUNC(grub_emunet_create) (grub_size_t *mtu);
void
EXPORT_FUNC(grub_emunet_close) (void);
#endif
@@ -0,0 +1,73 @@
/*
* 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>
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);
bool EXPORT_FUNC(grub_env_get_bool) (const char *name, bool if_unset);
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 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,46 @@
/*
* 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_PRIVATE_HEADER
#define GRUB_ENV_PRIVATE_HEADER 1
#include <grub/env.h>
/* The size of the hash table. */
#define HASHSZ 13
/* A hashtable for quick lookup of variables. */
struct grub_env_context
{
/* A hash table for variables. */
struct grub_env_var *vars[HASHSZ];
/* One level deeper on the stack. */
struct grub_env_context *prev;
};
/* This is used for sorting only. */
struct grub_env_sorted_var
{
struct grub_env_var *var;
struct grub_env_sorted_var *next;
};
extern struct grub_env_context *EXPORT_VAR(grub_current_context);
#endif /* ! GRUB_ENV_PRIVATE_HEADER */
@@ -0,0 +1,99 @@
/* err.h - error numbers and prototypes */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2005,2007,2008 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_ERR_HEADER
#define GRUB_ERR_HEADER 1
#include <grub/symbol.h>
#include <grub/compiler.h>
#define GRUB_MAX_ERRMSG 256
typedef enum
{
GRUB_ERR_NONE = 0,
GRUB_ERR_TEST_FAILURE,
GRUB_ERR_BAD_MODULE,
GRUB_ERR_OUT_OF_MEMORY,
GRUB_ERR_BAD_FILE_TYPE,
GRUB_ERR_FILE_NOT_FOUND,
GRUB_ERR_FILE_READ_ERROR,
GRUB_ERR_BAD_FILENAME,
GRUB_ERR_UNKNOWN_FS,
GRUB_ERR_BAD_FS,
GRUB_ERR_BAD_NUMBER,
GRUB_ERR_OUT_OF_RANGE,
GRUB_ERR_UNKNOWN_DEVICE,
GRUB_ERR_BAD_DEVICE,
GRUB_ERR_READ_ERROR,
GRUB_ERR_WRITE_ERROR,
GRUB_ERR_UNKNOWN_COMMAND,
GRUB_ERR_INVALID_COMMAND,
GRUB_ERR_BAD_ARGUMENT,
GRUB_ERR_BAD_PART_TABLE,
GRUB_ERR_UNKNOWN_OS,
GRUB_ERR_BAD_OS,
GRUB_ERR_NO_KERNEL,
GRUB_ERR_BAD_FONT,
GRUB_ERR_NOT_IMPLEMENTED_YET,
GRUB_ERR_SYMLINK_LOOP,
GRUB_ERR_BAD_COMPRESSED_DATA,
GRUB_ERR_MENU,
GRUB_ERR_TIMEOUT,
GRUB_ERR_IO,
GRUB_ERR_ACCESS_DENIED,
GRUB_ERR_EXTRACTOR,
GRUB_ERR_NET_BAD_ADDRESS,
GRUB_ERR_NET_ROUTE_LOOP,
GRUB_ERR_NET_NO_ROUTE,
GRUB_ERR_NET_NO_ANSWER,
GRUB_ERR_NET_NO_CARD,
GRUB_ERR_WAIT,
GRUB_ERR_BUG,
GRUB_ERR_NET_PORT_CLOSED,
GRUB_ERR_NET_INVALID_RESPONSE,
GRUB_ERR_NET_UNKNOWN_ERROR,
GRUB_ERR_NET_PACKET_TOO_BIG,
GRUB_ERR_NET_NO_DOMAIN,
GRUB_ERR_EOF,
GRUB_ERR_BAD_SIGNATURE,
GRUB_ERR_BAD_FIRMWARE
}
grub_err_t;
struct grub_error_saved
{
grub_err_t grub_errno;
char errmsg[GRUB_MAX_ERRMSG];
};
extern grub_err_t EXPORT_VAR(grub_errno);
extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG];
grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...)
__attribute__ ((format (GNU_PRINTF, 2, 3)));
void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
void EXPORT_FUNC(grub_error_push) (void);
int EXPORT_FUNC(grub_error_pop) (void);
void EXPORT_FUNC(grub_print_error) (void);
extern int EXPORT_VAR(grub_err_printed_errors);
int grub_err_printf (const char *fmt, ...)
__attribute__ ((format (GNU_PRINTF, 1, 2)));
#endif /* ! GRUB_ERR_HEADER */
@@ -0,0 +1,53 @@
/*
* 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_EXFAT_H
#define GRUB_EXFAT_H 1
#include <grub/types.h>
struct grub_exfat_bpb
{
grub_uint8_t jmp_boot[3];
grub_uint8_t oem_name[8];
grub_uint8_t mbz[53];
grub_uint64_t num_hidden_sectors;
grub_uint64_t num_total_sectors;
grub_uint32_t num_reserved_sectors;
grub_uint32_t sectors_per_fat;
grub_uint32_t cluster_offset;
grub_uint32_t cluster_count;
grub_uint32_t root_cluster;
grub_uint32_t num_serial;
grub_uint16_t fs_revision;
grub_uint16_t volume_flags;
grub_uint8_t bytes_per_sector_shift;
grub_uint8_t sectors_per_cluster_shift;
grub_uint8_t num_fats;
grub_uint8_t num_ph_drive;
grub_uint8_t reserved[8];
} GRUB_PACKED;
#ifdef GRUB_UTIL
#include <grub/disk.h>
grub_disk_addr_t
grub_exfat_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn);
#endif
#endif
@@ -0,0 +1,86 @@
/*
* 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_EXTCMD_HEADER
#define GRUB_EXTCMD_HEADER 1
#include <grub/lib/arg.h>
#include <grub/command.h>
#include <grub/script_sh.h>
struct grub_extcmd;
struct grub_extcmd_context;
typedef grub_err_t (*grub_extcmd_func_t) (struct grub_extcmd_context *ctxt,
int argc, char **args);
/* The argcmd description. */
struct grub_extcmd
{
grub_command_t cmd;
grub_extcmd_func_t func;
/* The argument parser optionlist. */
const struct grub_arg_option *options;
void *data;
};
typedef struct grub_extcmd *grub_extcmd_t;
/* Command context for each instance of execution. */
struct grub_extcmd_context
{
struct grub_extcmd *extcmd;
struct grub_arg_list *state;
/* Script parameter, if any. */
struct grub_script *script;
};
typedef struct grub_extcmd_context *grub_extcmd_context_t;
grub_extcmd_t EXPORT_FUNC(grub_register_extcmd) (const char *name,
grub_extcmd_func_t func,
grub_command_flags_t flags,
const char *summary,
const char *description,
const struct grub_arg_option *parser);
grub_extcmd_t EXPORT_FUNC(grub_register_extcmd_lockdown) (const char *name,
grub_extcmd_func_t func,
grub_command_flags_t flags,
const char *summary,
const char *description,
const struct grub_arg_option *parser);
grub_extcmd_t EXPORT_FUNC(grub_register_extcmd_prio) (const char *name,
grub_extcmd_func_t func,
grub_command_flags_t flags,
const char *summary,
const char *description,
const struct grub_arg_option *parser,
int prio);
void EXPORT_FUNC(grub_unregister_extcmd) (grub_extcmd_t cmd);
grub_err_t EXPORT_FUNC(grub_extcmd_dispatcher) (struct grub_command *cmd,
int argc, char **args,
struct grub_script *script);
#endif /* ! GRUB_EXTCMD_HEADER */
@@ -0,0 +1,77 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,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_FAT_H
#define GRUB_FAT_H 1
#include <grub/types.h>
struct grub_fat_bpb
{
grub_uint8_t jmp_boot[3];
grub_uint8_t oem_name[8];
grub_uint16_t bytes_per_sector;
grub_uint8_t sectors_per_cluster;
grub_uint16_t num_reserved_sectors;
grub_uint8_t num_fats; /* 0x10 */
grub_uint16_t num_root_entries;
grub_uint16_t num_total_sectors_16;
grub_uint8_t media; /* 0x15 */
grub_uint16_t sectors_per_fat_16;
grub_uint16_t sectors_per_track; /* 0x18 */
grub_uint16_t num_heads; /* 0x1A */
grub_uint32_t num_hidden_sectors; /* 0x1C */
grub_uint32_t num_total_sectors_32; /* 0x20 */
union
{
struct
{
grub_uint8_t num_ph_drive;
grub_uint8_t reserved;
grub_uint8_t boot_sig;
grub_uint32_t num_serial;
grub_uint8_t label[11];
grub_uint8_t fstype[8];
} GRUB_PACKED fat12_or_fat16;
struct
{
grub_uint32_t sectors_per_fat_32;
grub_uint16_t extended_flags;
grub_uint16_t fs_version;
grub_uint32_t root_cluster;
grub_uint16_t fs_info;
grub_uint16_t backup_boot_sector;
grub_uint8_t reserved[12];
grub_uint8_t num_ph_drive;
grub_uint8_t reserved1;
grub_uint8_t boot_sig;
grub_uint32_t num_serial;
grub_uint8_t label[11];
grub_uint8_t fstype[8];
} GRUB_PACKED fat32;
} GRUB_PACKED version_specific;
} GRUB_PACKED;
#ifdef GRUB_UTIL
#include <grub/disk.h>
grub_disk_addr_t
grub_fat_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn);
#endif
#endif
@@ -0,0 +1,36 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008 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_FBBLIT_HEADER
#define GRUB_FBBLIT_HEADER 1
/* NOTE: This header is private header for fb driver and should not be used
in other parts of the code. */
struct grub_video_fbblit_info;
/* NOTE: This function assumes that given coordinates are within bounds of
handled data. */
void
grub_video_fb_dispatch_blit (struct grub_video_fbblit_info *target,
struct grub_video_fbblit_info *source,
enum grub_video_blit_operators oper,
int x, int y,
unsigned int width, unsigned int height,
int offset_x, int offset_y);
#endif /* ! GRUB_FBBLIT_HEADER */
@@ -0,0 +1,59 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2008 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_FBFILL_HEADER
#define GRUB_FBFILL_HEADER 1
/* NOTE: This header is private header for fb driver and should not be used
in other parts of the code. */
struct grub_video_fbblit_info;
struct grub_video_fbrender_target
{
/* Copy of the screen's mode info structure, except that width, height and
mode_type has been re-adjusted to requested render target settings. */
struct grub_video_mode_info mode_info;
/* We should not draw outside of viewport. */
grub_video_rect_t viewport;
/* Set region to make a re-draw of a part of the screen. */
grub_video_rect_t region;
/* Should be set to 0 if the viewport is inside of the region. */
int area_enabled;
/* Internal structure - intersection of the viewport and the region. */
grub_video_rect_t area;
/* Internal values - offsets from the left top point of the viewport. */
int area_offset_x;
int area_offset_y;
/* Indicates whether the data has been allocated by us and must be freed
when render target is destroyed. */
int is_allocated;
/* Pointer to data. Can either be in video card memory or in local host's
memory. */
grub_uint8_t *data;
};
void
grub_video_fb_fill_dispatch (struct grub_video_fbblit_info *target,
grub_video_color_t color, int x, int y,
unsigned int width, unsigned int height);
#endif /* ! GRUB_FBFILL_HEADER */
@@ -0,0 +1,64 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/>.
*/
/* NOTE: This header is private header for vbe driver and should not be used
in other parts of the code. */
#ifndef GRUB_VBEUTIL_MACHINE_HEADER
#define GRUB_VBEUTIL_MACHINE_HEADER 1
#include <grub/types.h>
#include <grub/video.h>
struct grub_video_fbblit_info
{
struct grub_video_mode_info *mode_info;
grub_uint8_t *data;
};
/*
* Don't use for 1-bit bitmaps, addressing needs to be done at the bit level
* and it doesn't make sense, in general, to ask for a pointer
* to a particular pixel's data.
*
* This function assumes that bounds checking has been done in previous phase
* and they are opted out in here.
*/
static inline void *
grub_video_fb_get_video_ptr (struct grub_video_fbblit_info *source,
unsigned int x, unsigned int y)
{
return source->data + (grub_addr_t) y * source->mode_info->pitch + (grub_addr_t) x * source->mode_info->bytes_per_pixel;
}
/* Advance pointer by VAL bytes. If there is no unaligned access available,
VAL has to be divisible by size of pointed type.
*/
#ifdef GRUB_HAVE_UNALIGNED_ACCESS
#define GRUB_VIDEO_FB_ADVANCE_POINTER(ptr, val) ((ptr) = (typeof (ptr)) ((char *) ptr + val))
#else
#define GRUB_VIDEO_FB_ADVANCE_POINTER(ptr, val) ((ptr) += (val) / sizeof (*(ptr)))
#endif
grub_video_color_t get_pixel (struct grub_video_fbblit_info *source,
unsigned int x, unsigned int y);
void set_pixel (struct grub_video_fbblit_info *source,
unsigned int x, unsigned int y, grub_video_color_t color);
#endif /* ! GRUB_VBEUTIL_MACHINE_HEADER */
@@ -0,0 +1,147 @@
/*
* 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_FDT_HEADER
#define GRUB_FDT_HEADER 1
#include <grub/types.h>
#include <grub/symbol.h>
/* Space required when preparing the /chosen node after boot has been called. */
#define GRUB_EFI_LINUX_FDT_EXTRA_SPACE 0x400
#define FDT_MAGIC 0xD00DFEED
typedef struct {
grub_uint32_t magic;
grub_uint32_t totalsize;
grub_uint32_t off_dt_struct;
grub_uint32_t off_dt_strings;
grub_uint32_t off_mem_rsvmap;
grub_uint32_t version;
grub_uint32_t last_comp_version;
grub_uint32_t boot_cpuid_phys;
grub_uint32_t size_dt_strings;
grub_uint32_t size_dt_struct;
} grub_fdt_header_t;
struct grub_fdt_empty_tree {
grub_fdt_header_t header;
grub_uint64_t empty_rsvmap[2];
struct {
grub_uint32_t node_start;
grub_uint8_t name[1];
grub_uint32_t node_end;
grub_uint32_t tree_end;
} empty_node;
};
#define GRUB_FDT_EMPTY_TREE_SZ sizeof (struct grub_fdt_empty_tree)
/* Size needed by a property entry: 1 token (FDT_PROPERTY), plus len and nameoff
fields, plus the property value, plus padding if needed. */
#define grub_fdt_prop_entry_size(prop_len) \
(3 * sizeof(grub_uint32_t) + ALIGN_UP(prop_len, sizeof(grub_uint32_t)))
#define grub_fdt_get_header(fdt, field) \
grub_be_to_cpu32(((const grub_fdt_header_t *)(fdt))->field)
#define grub_fdt_set_header(fdt, field, value) \
((grub_fdt_header_t *)(fdt))->field = grub_cpu_to_be32(value)
#define grub_fdt_get_magic(fdt) \
grub_fdt_get_header(fdt, magic)
#define grub_fdt_set_magic(fdt, value) \
grub_fdt_set_header(fdt, magic, value)
#define grub_fdt_get_totalsize(fdt) \
grub_fdt_get_header(fdt, totalsize)
#define grub_fdt_set_totalsize(fdt, value) \
grub_fdt_set_header(fdt, totalsize, value)
#define grub_fdt_get_off_dt_struct(fdt) \
grub_fdt_get_header(fdt, off_dt_struct)
#define grub_fdt_set_off_dt_struct(fdt, value) \
grub_fdt_set_header(fdt, off_dt_struct, value)
#define grub_fdt_get_off_dt_strings(fdt) \
grub_fdt_get_header(fdt, off_dt_strings)
#define grub_fdt_set_off_dt_strings(fdt, value) \
grub_fdt_set_header(fdt, off_dt_strings, value)
#define grub_fdt_get_off_mem_rsvmap(fdt) \
grub_fdt_get_header(fdt, off_mem_rsvmap)
#define grub_fdt_set_off_mem_rsvmap(fdt, value) \
grub_fdt_set_header(fdt, off_mem_rsvmap, value)
#define grub_fdt_get_version(fdt) \
grub_fdt_get_header(fdt, version)
#define grub_fdt_set_version(fdt, value) \
grub_fdt_set_header(fdt, version, value)
#define grub_fdt_get_last_comp_version(fdt) \
grub_fdt_get_header(fdt, last_comp_version)
#define grub_fdt_set_last_comp_version(fdt, value) \
grub_fdt_set_header(fdt, last_comp_version, value)
#define grub_fdt_get_boot_cpuid_phys(fdt) \
grub_fdt_get_header(fdt, boot_cpuid_phys)
#define grub_fdt_set_boot_cpuid_phys(fdt, value) \
grub_fdt_set_header(fdt, boot_cpuid_phys, value)
#define grub_fdt_get_size_dt_strings(fdt) \
grub_fdt_get_header(fdt, size_dt_strings)
#define grub_fdt_set_size_dt_strings(fdt, value) \
grub_fdt_set_header(fdt, size_dt_strings, value)
#define grub_fdt_get_size_dt_struct(fdt) \
grub_fdt_get_header(fdt, size_dt_struct)
#define grub_fdt_set_size_dt_struct(fdt, value) \
grub_fdt_set_header(fdt, size_dt_struct, value)
int EXPORT_FUNC(grub_fdt_create_empty_tree) (void *fdt, unsigned int size);
int EXPORT_FUNC(grub_fdt_check_header) (const void *fdt, unsigned int size);
int EXPORT_FUNC(grub_fdt_check_header_nosize) (const void *fdt);
int EXPORT_FUNC(grub_fdt_find_subnode) (const void *fdt, unsigned int parentoffset,
const char *name);
int EXPORT_FUNC(grub_fdt_first_node) (const void *fdt, unsigned int parentoffset);
int EXPORT_FUNC(grub_fdt_next_node) (const void *fdt, unsigned int currentoffset);
int EXPORT_FUNC(grub_fdt_add_subnode) (void *fdt, unsigned int parentoffset,
const char *name);
const char *
EXPORT_FUNC(grub_fdt_get_nodename) (const void *fdt, unsigned int nodeoffset);
const void *EXPORT_FUNC(grub_fdt_get_prop) (const void *fdt, unsigned int nodeoffset, const char *name,
grub_uint32_t *len);
int EXPORT_FUNC(grub_fdt_set_prop) (void *fdt, unsigned int nodeoffset, const char *name,
const void *val, grub_uint32_t len);
#define grub_fdt_set_prop32(fdt, nodeoffset, name, val) \
({ \
grub_uint32_t _val = grub_cpu_to_be32(val); \
grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 4); \
})
#define grub_fdt_set_prop64(fdt, nodeoffset, name, val) \
({ \
grub_uint64_t _val = grub_cpu_to_be64(val); \
grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8); \
})
/* Setup "reg" property for
* #address-cells = <0x2>
* #size-cells = <0x2>
*/
#define grub_fdt_set_reg64(fdt, nodeoffset, addr, size) \
({ \
grub_uint64_t reg_64[2]; \
reg_64[0] = grub_cpu_to_be64(addr); \
reg_64[1] = grub_cpu_to_be64(size); \
grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \
})
#endif /* ! GRUB_FDT_HEADER */
@@ -0,0 +1,89 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2016 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_FDTBUS_HEADER
#define GRUB_FDTBUS_HEADER 1
#include <grub/fdt.h>
#include <grub/err.h>
struct grub_fdtbus_dev
{
struct grub_fdtbus_dev *next;
struct grub_fdtbus_dev *parent;
int node;
struct grub_fdtbus_driver *driver;
};
struct grub_fdtbus_driver
{
struct grub_fdtbus_driver *next;
struct grub_fdtbus_driver **prev;
const char *compatible;
grub_err_t (*attach) (const struct grub_fdtbus_dev *dev);
void (*detach) (const struct grub_fdtbus_dev *dev);
/* Message bus operations. */
grub_err_t (*send) (const struct grub_fdtbus_dev *dev, const void *data, grub_size_t sz);
grub_err_t (*receive) (const struct grub_fdtbus_dev *dev, void *data, grub_size_t sz);
grub_err_t (*start) (const struct grub_fdtbus_dev *dev);
void (*stop) (const struct grub_fdtbus_dev *dev);
};
extern char EXPORT_VAR(grub_fdtbus_invalid_mapping)[1];
static inline int
grub_fdtbus_is_mapping_valid (volatile void *m)
{
return m != grub_fdtbus_invalid_mapping;
}
volatile void *
EXPORT_FUNC(grub_fdtbus_map_reg) (const struct grub_fdtbus_dev *dev, int reg, grub_size_t *size);
const void *
EXPORT_FUNC(grub_fdtbus_get_fdt) (void);
const char *
EXPORT_FUNC(grub_fdtbus_get_name) (const struct grub_fdtbus_dev *dev);
const void *
EXPORT_FUNC(grub_fdtbus_get_prop) (const struct grub_fdtbus_dev *dev,
const char *name,
grub_uint32_t *len);
void
EXPORT_FUNC(grub_fdtbus_register) (struct grub_fdtbus_driver *driver);
void
EXPORT_FUNC(grub_fdtbus_unregister) (struct grub_fdtbus_driver *driver);
int
EXPORT_FUNC(grub_fdtbus_is_compatible) (const char *compat_string,
const struct grub_fdtbus_dev *dev);
/* Must be called before any register(). */
/* dtb is assumed to be unfreeable and must remain
valid for lifetime of GRUB.
*/
void
grub_fdtbus_init (const void *dtb, grub_size_t size);
#endif
@@ -0,0 +1,246 @@
/*
* 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 holding the encryption key. */
GRUB_FILE_TYPE_CRYPTODISK_ENCRYPTION_KEY,
/* File holding the encryption metadata header */
GRUB_FILE_TYPE_CRYPTODISK_DETACHED_HEADER,
/* 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
};
/* File description. */
struct grub_file
{
/* File name. */
char *name;
/* 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);
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);
/* 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,29 @@
/*
* 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_FILEID_HEADER
#define GRUB_FILEID_HEADER 1
#include <grub/elfload.h>
int
grub_file_check_netbsd32 (grub_elf_t elf);
int
grub_file_check_netbsd64 (grub_elf_t elf);
#endif
@@ -0,0 +1,153 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,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_FONT_HEADER
#define GRUB_FONT_HEADER 1
#include <grub/types.h>
#include <grub/video.h>
#include <grub/file.h>
#include <grub/unicode.h>
/* Forward declaration of opaque structure grub_font.
Users only pass struct grub_font pointers to the font module functions,
and do not have knowledge of the structure contents. */
/* Full structure was moved here for inline function but still
shouldn't be used directly.
*/
struct grub_font
{
char *name;
grub_file_t file;
char *family;
short point_size;
short weight;
short max_char_width;
short max_char_height;
short ascent;
short descent;
short leading;
grub_uint32_t num_chars;
struct char_index_entry *char_index;
grub_uint16_t *bmp_idx;
};
/* Font type used to access font functions. */
typedef struct grub_font *grub_font_t;
struct grub_font_node
{
struct grub_font_node *next;
grub_font_t value;
};
/* Global font registry. */
extern struct grub_font_node *grub_font_list;
struct grub_font_glyph
{
/* Reference to the font this glyph belongs to. */
grub_font_t font;
/* Glyph bitmap width in pixels. */
grub_uint16_t width;
/* Glyph bitmap height in pixels. */
grub_uint16_t height;
/* Glyph bitmap x offset in pixels. Add to screen coordinate. */
grub_int16_t offset_x;
/* Glyph bitmap y offset in pixels. Subtract from screen coordinate. */
grub_int16_t offset_y;
/* Number of pixels to advance to start the next character. */
grub_uint16_t device_width;
/* Row-major order, packed bits (no padding; rows can break within a byte).
The length of the array is (width * height + 7) / 8. Within a
byte, the most significant bit is the first (leftmost/uppermost) pixel.
Pixels are coded as bits, value 1 meaning of opaque pixel and 0 is
transparent. If the length of the array does not fit byte boundary, it
will be padded with 0 bits to make it fit. */
grub_uint8_t bitmap[0];
};
/* Part of code field which is really used as such. */
#define GRUB_FONT_CODE_CHAR_MASK 0x001fffff
#define GRUB_FONT_CODE_RIGHT_JOINED 0x80000000
#define GRUB_FONT_CODE_LEFT_JOINED 0x40000000
/* Initialize the font loader.
Must be called before any fonts are loaded or used. */
void grub_font_loader_init (void);
/* Load a font and add it to the beginning of the global font list.
Returns: 0 upon success; nonzero upon failure. */
grub_font_t EXPORT_FUNC(grub_font_load) (const char *filename);
/* Get the font that has the specified name. Font names are in the form
"Family Name Bold Italic 14", where Bold and Italic are optional.
If no font matches the name specified, the most recently loaded font
is returned as a fallback. */
grub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
const char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
int EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
/* Get the maximum height of any character in the font in pixels. */
static inline int
grub_font_get_max_char_height (grub_font_t font)
{
return font->max_char_height;
}
/* Get the distance in pixels from the top of characters to the baseline. */
static inline int
grub_font_get_ascent (grub_font_t font)
{
return font->ascent;
}
int EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
int EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
int EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
int EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
grub_uint32_t code);
struct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
grub_uint32_t code);
grub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
grub_video_color_t color,
int left_x, int baseline_y);
int
EXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
const struct grub_unicode_glyph *glyph_id);
struct grub_font_glyph *
EXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
const struct grub_unicode_glyph *glyph_id);
#endif /* ! GRUB_FONT_HEADER */
@@ -0,0 +1,38 @@
/*
* 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_FONT_FORMAT_HEADER
#define GRUB_FONT_FORMAT_HEADER 1
/* FONT_FORMAT_PFF2_MAGIC use only 4 relevants bytes and the \0. */
#define FONT_FORMAT_PFF2_MAGIC "PFF2"
#define FONT_FORMAT_SECTION_NAMES_FILE "FILE"
#define FONT_FORMAT_SECTION_NAMES_FONT_NAME "NAME"
#define FONT_FORMAT_SECTION_NAMES_POINT_SIZE "PTSZ"
#define FONT_FORMAT_SECTION_NAMES_WEIGHT "WEIG"
#define FONT_FORMAT_SECTION_NAMES_MAX_CHAR_WIDTH "MAXW"
#define FONT_FORMAT_SECTION_NAMES_MAX_CHAR_HEIGHT "MAXH"
#define FONT_FORMAT_SECTION_NAMES_ASCENT "ASCE"
#define FONT_FORMAT_SECTION_NAMES_DESCENT "DESC"
#define FONT_FORMAT_SECTION_NAMES_CHAR_INDEX "CHIX"
#define FONT_FORMAT_SECTION_NAMES_DATA "DATA"
#define FONT_FORMAT_SECTION_NAMES_FAMILY "FAMI"
#define FONT_FORMAT_SECTION_NAMES_SLAN "SLAN"
#endif /* ! GRUB_FONT_FORMAT_HEADER */
@@ -0,0 +1,131 @@
/* 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_int64_t mtime;
grub_uint64_t inode;
};
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_int64_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);
#endif /* ! GRUB_FS_HEADER */

Some files were not shown because too many files have changed in this diff Show More