2008-07-17 Bean <bean123ch@gmail.com>
* conf/i386/efi.rmk (pkglib_MODULES): add pci.mod and lspci.mod. (appleldr_mod_SOURCE): New variavle. (appleldr_mod_CFLAGS): Likewise. (appleldr_mod_LDFLAGS): Likewise. (pci_mod_SOURCES): Likewise. (pci_mod_CFLAGS): Likewise. (pci_mod_LDFLAGS): Likewise. (lspci_mod_SOURCES): Likewise. (lspci_mod_CFLAGS): Likewise. (lspci_mod_LDFLAGS): Likewise. * conf/x86_64-efi.rmk: New file. * disk/efi/efidisk.c (grub_efidisk_read): Wrap efi calls with efi_call_N macro. (grub_efidisk_write): Likewise. * include/efi/api.h (efi_call_0): New macro. (efi_call_1): Likewise. (efi_call_2): Likewise. (efi_call_3): Likewise. (efi_call_4): Likewise. (efi_call_5): Likewise. (efi_call_6): Likewise. * include/grub/efi/chainloader.h (grub_chainloader_cmd): Rename to grub_rescue_cmd_chainloader. * include/grub/efi/pe32.h (GRUB_PE32_MACHINE_X86_64): New macro. (grub_pe32_optional_header): Change some fields based on i386 or x86_64 platform. (GRUB_PE32_PE32_MAGIC): Likewise. * include/grub/efi/uga_draw.h: New file. * include/grub/elf.h (STN_ABS): New constant. (R_X86_64_NONE): Relocation constant for x86_64. (R_X86_64_64): Likewise. (R_X86_64_PC32): Likewise. (R_X86_64_GOT32): Likewise. (R_X86_64_PLT32): Likewise. (R_X86_64_COPY): Likewise. (R_X86_64_GLOB_DAT): Likewise. (R_X86_64_JUMP_SLOT): Likewise. (R_X86_64_RELATIVE): Likewise. (R_X86_64_GOTPCREL): Likewise. (R_X86_64_32): Likewise. (R_X86_64_32S): Likewise. (R_X86_64_16): Likewise. (R_X86_64_PC16): Likewise. (R_X86_64_8): Likewise. (R_X86_64_PC8): Likewise. * include/grub/i386/efi/pci.h: New file. * include/grub/i386/linux.h (GRUB_LINUX_EFI_SIGNATURE): Change it value based on platform. (GRUB_LINUX_EFI_SIGNATURE_0204): New constant. (GRUB_E820_RAM): Likewise. (GRUB_E820_RESERVED): Likewise. (GRUB_E820_ACPI): Likewise. (GRUB_E820_NVS): Likewise. (GRUB_E820_EXEC_CODE): Likewise. (GRUB_E820_MAX_ENTRY): Likewise. (grub_e820_mmap): New structure. (linux_kernel_header): Change the efi field according to different kernel version, also field from linux_kernel_header. * include/grub/kernel.h (grub_module_info): Add padding for x86_64. * include/grub/pci.h (GRUB_PCI_ADDR_SPACE_MASK): New constant. (GRUB_PCI_ADDR_SPACE_MEMORY): Likewise. (GRUB_PCI_ADDR_SPACE_IO): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_MASK): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_32): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_1M): Likewise. (GRUB_PCI_ADDR_MEM_TYPE_64): Likewise. (GRUB_PCI_ADDR_MEM_PREFETCH): Likewise. (GRUB_PCI_ADDR_MEM_MASK): Likewise. (GRUB_PCI_ADDR_IO_MASK): Likewise. * include/grub/x86_64/efi/kernel.h: New file. * include/grub/x86_64/efi/loader.h: Likewise. * include/grub/x86_64/efi/machine.h: Likewise. * include/grub/x86_64/efi/pci.h: Likewise. * include/grub/x86_64/efi/time.h: Likewise. * include/grub/x86_64/linux.h: Likewise. * include/grub/x86_64/setjmp.h: Likewise. * include/grub/x86_64/time.h: Likewise. * include/grub/x86_64/types.h: Likewise. * kern/dl.c (GRUB_CPU_SIZEOF_VOID_P): Changed to GRUB_TARGET_SIZEOF_VOID_P. * kern/efi/efi.c (grub_efi_locate_protocol): Wrap efi calls. (grub_efi_locate_handle): Likewise. (grub_efi_open_protocol): Likewise. (grub_efi_set_text_mode): Likewise. (grub_efi_stall): Likewise. (grub_exit): Likewise. (grub_reboot): Likewise. (grub_halt): Likewise. (grub_efi_exit_boot_services): Likewise. (grub_get_rtc): Likewise. * kern/efi/mm.c (MEMORY_MAP_SIZE): Change to 0x3000 for new models. (GRUB_CPU_SIZEOF_VOID_P): Changed to GRUB_TARGET_SIZEOF_VOID_P. (grub_efi_allocate_pages): Wrap efi calls. (grub_efi_free_pages): Wrap efi calls. (grub_efi_get_memory_map): Wrap efi calls. * kern/x86_64/dl.c: New file. * kern/x86_64/efi/callwrap.S: Likewise. * kern/x86_64/efi/startup.S: Likewise. * loader/efi/appleloader.c: Likewise. * loader/efi/chainloader.c (cmdline): New variable. (grub_chainloader_unload): Wrap efi calls. (grub_chainloader_boot): Likewise. (grub_rescue_cmd_chainloader): Wrap efi calls, handle command line. * loader/efi/chainloader_normal.c (chainloader_command): Change grub_chainloader_cmd to grub_rescue_cmd_chainloader, pass command line. * loader/i386/efi/linux.c (allocate_pages): Change allocation method. (grub_e820_add_region): New function. (grub_linux_boot): Construct e820 map from efi map, handle x86_64 booting. (grub_find_video_card): New function. (grub_linux_setup_video): New function. (grub_rescue_cmd_linux): Probe for video information. * normal/x86_64/setjmp.S: New file. * term/efi/console.c (map_char): New function. (grub_console_putchar): Map unicode char. (grub_console_checkkey): Wrap efi calls. (grub_console_getkey): Likewise. (grub_console_getwh): Likewise. (grub_console_gotoxy): Likewise. (grub_console_cls): Likewise. (grub_console_setcolorstate): Likewise. (grub_console_setcursor): Likewise. * util/i386/efi/grub-mkimage.c: Add support for x86_64.
This commit is contained in:
parent
ef29405511
commit
2001169405
39 changed files with 3960 additions and 309 deletions
19
include/grub/i386/efi/pci.h
Normal file
19
include/grub/i386/efi/pci.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <grub/i386/pc/pci.h>
|
|
@ -44,14 +44,44 @@
|
|||
#define GRUB_LINUX_SETUP_MOVE_SIZE 0x9100
|
||||
#define GRUB_LINUX_CL_MAGIC 0xA33F
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
#define GRUB_LINUX_EFI_SIGNATURE \
|
||||
('E' << 24 | 'F' << 16 | 'I' << 8 | 'L')
|
||||
('4' << 24 | '6' << 16 | 'L' << 8 | 'E')
|
||||
|
||||
#else
|
||||
|
||||
#define GRUB_LINUX_EFI_SIGNATURE \
|
||||
('2' << 24 | '3' << 16 | 'L' << 8 | 'E')
|
||||
|
||||
#endif
|
||||
|
||||
#define GRUB_LINUX_EFI_SIGNATURE_0204 \
|
||||
('L' << 24 | 'I' << 16 | 'F' << 8 | 'E')
|
||||
|
||||
#define GRUB_LINUX_OFW_SIGNATURE \
|
||||
(' ' << 24 | 'W' << 16 | 'F' << 8 | 'O')
|
||||
|
||||
#ifndef ASM_FILE
|
||||
|
||||
#define GRUB_E820_RAM 1
|
||||
#define GRUB_E820_RESERVED 2
|
||||
#define GRUB_E820_ACPI 3
|
||||
#define GRUB_E820_NVS 4
|
||||
#define GRUB_E820_EXEC_CODE 5
|
||||
|
||||
#define GRUB_E820_MAX_ENTRY 128
|
||||
|
||||
struct grub_e820_mmap
|
||||
{
|
||||
grub_uint64_t addr;
|
||||
grub_uint64_t size;
|
||||
grub_uint32_t type;
|
||||
} __attribute__((packed));
|
||||
|
||||
#define GRUB_VIDEO_TYPE_VLFB 0x23 /* VESA VGA in graphic mode */
|
||||
#define GRUB_VIDEO_TYPE_EFI 0x70
|
||||
|
||||
/* For the Linux/i386 boot protocol version 2.03. */
|
||||
struct linux_kernel_header
|
||||
{
|
||||
|
@ -164,26 +194,74 @@ struct linux_kernel_params
|
|||
grub_uint32_t ofw_cif_handler; /* b8 */
|
||||
grub_uint32_t ofw_idt; /* bc */
|
||||
|
||||
grub_uint8_t padding7[0x1c0 - 0xc0];
|
||||
|
||||
grub_uint32_t efi_signature; /* 1c0 */
|
||||
grub_uint32_t efi_system_table; /* 1c4 */
|
||||
grub_uint32_t efi_mem_desc_size; /* 1c8 */
|
||||
grub_uint32_t efi_mem_desc_version; /* 1cc */
|
||||
grub_uint32_t efi_mmap; /* 1d0 */
|
||||
grub_uint32_t efi_mmap_size; /* 1d4 */
|
||||
|
||||
grub_uint8_t padding8[0x1e0 - 0x1d8];
|
||||
grub_uint8_t padding7[0x1b8 - 0xc0];
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
grub_uint32_t efi_system_table; /* 1b8 */
|
||||
grub_uint32_t padding7_1; /* 1bc */
|
||||
grub_uint32_t efi_signature; /* 1c0 */
|
||||
grub_uint32_t efi_mem_desc_size; /* 1c4 */
|
||||
grub_uint32_t efi_mem_desc_version; /* 1c8 */
|
||||
grub_uint32_t efi_mmap_size; /* 1cc */
|
||||
grub_uint32_t efi_mmap; /* 1d0 */
|
||||
} v0204;
|
||||
struct
|
||||
{
|
||||
grub_uint32_t padding7_1; /* 1b8 */
|
||||
grub_uint32_t padding7_2; /* 1bc */
|
||||
grub_uint32_t efi_signature; /* 1c0 */
|
||||
grub_uint32_t efi_system_table; /* 1c4 */
|
||||
grub_uint32_t efi_mem_desc_size; /* 1c8 */
|
||||
grub_uint32_t efi_mem_desc_version; /* 1cc */
|
||||
grub_uint32_t efi_mmap; /* 1d0 */
|
||||
grub_uint32_t efi_mmap_size; /* 1d4 */
|
||||
grub_uint32_t efi_system_table_hi; /* 1d8 */
|
||||
grub_uint32_t efi_mmap_hi; /* 1dc */
|
||||
} v0206;
|
||||
};
|
||||
|
||||
grub_uint32_t alt_mem; /* 1e0 */
|
||||
|
||||
grub_uint8_t padding9[0x1e8 - 0x1e4];
|
||||
grub_uint8_t padding8[0x1e8 - 0x1e4];
|
||||
|
||||
grub_uint32_t mmap_size; /* 1e8 */
|
||||
|
||||
grub_uint8_t padding10[0x1ff - 0x1ec];
|
||||
grub_uint8_t padding9[0x1f1 - 0x1ec];
|
||||
|
||||
grub_uint8_t setup_sects; /* The size of the setup in sectors */
|
||||
grub_uint16_t root_flags; /* If the root is mounted readonly */
|
||||
grub_uint16_t syssize; /* obsolete */
|
||||
grub_uint16_t swap_dev; /* obsolete */
|
||||
grub_uint16_t ram_size; /* obsolete */
|
||||
grub_uint16_t vid_mode; /* Video mode control */
|
||||
grub_uint16_t root_dev; /* Default root device number */
|
||||
|
||||
grub_uint8_t padding10; /* 1fe */
|
||||
grub_uint8_t ps_mouse; /* 1ff */
|
||||
|
||||
grub_uint16_t jump; /* Jump instruction */
|
||||
grub_uint32_t header; /* Magic signature "HdrS" */
|
||||
grub_uint16_t version; /* Boot protocol version supported */
|
||||
grub_uint32_t realmode_swtch; /* Boot loader hook */
|
||||
grub_uint16_t start_sys; /* The load-low segment (obsolete) */
|
||||
grub_uint16_t kernel_version; /* Points to kernel version string */
|
||||
grub_uint8_t type_of_loader; /* Boot loader identifier */
|
||||
grub_uint8_t loadflags; /* Boot protocol option flags */
|
||||
grub_uint16_t setup_move_size; /* Move to high memory size */
|
||||
grub_uint32_t code32_start; /* Boot loader hook */
|
||||
grub_uint32_t ramdisk_image; /* initrd load address */
|
||||
grub_uint32_t ramdisk_size; /* initrd size */
|
||||
grub_uint32_t bootsect_kludge; /* obsolete */
|
||||
grub_uint16_t heap_end_ptr; /* Free memory after setup end */
|
||||
grub_uint16_t pad1; /* Unused */
|
||||
grub_uint32_t cmd_line_ptr; /* Points to the kernel command line */
|
||||
|
||||
grub_uint8_t pad2[164]; /* 22c */
|
||||
struct grub_e820_mmap e820_map[GRUB_E820_MAX_ENTRY]; /* 2d0 */
|
||||
|
||||
} __attribute__ ((packed));
|
||||
#endif /* ! ASM_FILE */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue