Stephane Eranian 2004-02-23 08:11:30 -05:00 committed by Vincent Batts
commit fb6ce0d596
100 changed files with 20247 additions and 0 deletions

51
ia32/Makefile Normal file
View file

@ -0,0 +1,51 @@
#
# Copyright (C) 2001-2003 Hewlett-Packard Co.
# Contributed by Stephane Eranian <eranian@hpl.hp.com>
#
# This file is part of the ELILO, the EFI Linux boot loader.
#
# ELILO 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 2, or (at your option)
# any later version.
#
# ELILO 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 ELILO; see the file COPYING. If not, write to the Free
# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# Please check out the elilo.txt for complete documentation on how
# to use this program.
#
include ../Make.defaults
include ../Make.rules
TOPDIR=$(CDIR)/..
FILES=system.o config.o
TARGET=sysdeps.o
all: $(TARGET)
system.o: rmswitch.h
rmswitch.h: bin_to_h.c rmswitch.S
$(CC) -o bin_to_h bin_to_h.c
$(AS) -o rmswitch.o rmswitch.S
$(LD) -Ttext 0x0 -s --oformat binary -o rmswitch rmswitch.o
./bin_to_h <rmswitch >rmswitch.h
$(TARGET): $(FILES)
$(LD) -r -o $@ $(FILES)
clean:
$(RM) -f $(TARGET) $(FILES)
$(RM) -f bin_to_h.o bin_to_h
$(RM) -f rmswitch.h rmswitch.o rmswitch

27
ia32/bin_to_h.c Normal file
View file

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
unsigned n = 0;
int c;
printf("UINT8 rmswitch_image[] = {\n");
while ((c = getchar()) != EOF) {
printf("0x%02x,%s",
c & 0xFF,
(++n & 0x07) ? " " : "\n");
}
if (n & 0x07) {
printf("\n");
}
printf(
"};\n"
"UINTN rmswitch_size = sizeof rmswitch_image;\n");
return 0;
}

103
ia32/config.c Normal file
View file

@ -0,0 +1,103 @@
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
* Contributed by Chris Ahna <christopher.j.ahna@intel.com>
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
* ELILO 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 2, or (at your option)
* any later version.
*
* ELILO 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 ELILO; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Please check out the elilo.txt for complete documentation on how
* to use this program.
*/
#include <efi.h>
#include <efilib.h>
#include "elilo.h"
#include "config.h"
#include "private.h"
typedef struct {
UINTN legacy_free_boot;
} ia32_global_config_t;
static ia32_global_config_t ia32_gconf;
static config_option_t sysdeps_global_options[]={
{OPT_BOOL, OPT_GLOBAL, L"legacy-free", NULL, NULL, &ia32_gconf.legacy_free_boot}
};
/*
* IA-32 operations that need to be done only once and just before
* entering the main loop of the loader
* Return:
* 0 if sucessful
* -1 otherwise (will abort execution)
*/
INTN
sysdeps_preloop_actions(EFI_HANDLE dev, CHAR16 **argv, INTN argc, INTN index, EFI_HANDLE image)
{
return 0;
}
#define IA32_CMDLINE_OPTIONS L""
CHAR16 *
sysdeps_get_cmdline_opts(VOID)
{
return IA32_CMDLINE_OPTIONS;
}
INTN
sysdeps_getopt(INTN c, INTN optind, CHAR16 *optarg)
{
return -1;
}
VOID
sysdeps_print_cmdline_opts(VOID)
{
}
INTN
ia32_use_legacy_free_boot(VOID)
{
return ia32_gconf.legacy_free_boot ? 1 : 0;
}
INTN
sysdeps_register_options(VOID)
{
INTN ret;
ret = register_config_options(sysdeps_global_options,
sizeof(sysdeps_global_options)/sizeof(config_option_t),
OPTIONS_GROUP_GLOBAL);
#if 0
/* no per image options yet */
if (ret == -1 ) return ret;
ret = register_config_options(sysdeps_image_options,
sizeof(sysdeps_image_options)/sizeof(config_option_t),
OPTIONS_GROUP_IMAGE);
#endif
return ret;
}

30
ia32/private.h Normal file
View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
* ELILO 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 2, or (at your option)
* any later version.
*
* ELILO 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 ELILO; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Please check out the elilo.txt for complete documentation on how
* to use this program.
*/
#ifndef __ELILO_PRIVATE_IA32_H__
#define __ELILO_PRIVATE_IA32_H__
#endif /* __ELILO_PRIVATE_IA32_H__ */

118
ia32/rmswitch.S Normal file
View file

@ -0,0 +1,118 @@
#
# Switch from protected mode to real mode and jump to setup.S
# image located at %cx:0.
#
# This module must be placed into physical memory at 0:7C00h.
# EFI has some real mode thunking code at 2000:0h.
#
# Processor and non-maskable interrupts should be disabled
# before control is passed to this module.
#
.global _start
.code32
.text
_start:
#
# Load identity mapped GDT & real mode IDT.
# Add 7C00h to the addresses since this is linked to start
# at 0h and it is being placed at 7C00h.
#
lgdt %cs:gdt_48 + 0x7C00
lidt %cs:idt_48 + 0x7C00
#
# Turn off PG bit in CR0 and set CR3 to zero.
#
movl %cr0, %eax
andl $0x7FFFFFFF, %eax
movl %eax, %cr0
xorl %eax, %eax
movl %eax, %cr3
#
# Reload CS.
# Now we add 7B00h because we need to force the segment
# address and selector to be the same.
#
.byte 0xEA
.long pm_reload + 0x7B00
.word 0x10
pm_reload:
.code16
#
# Reload DS, ES, FS, GS & SS.
#
movw $0x18, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
#
# Switch to real mode. Clear PE bit in CR0.
#
movl %cr0, %eax
andl $0xFFFFFFFE, %eax
movl %eax, %cr0
#
# Reload CS.
#
.byte 0xEA
.word rm_reload + 0x7C00
.word 0
rm_reload:
#
# Reload SS & SP.
#
xorw %ax, %ax
movw %ax, %ss
movw $0x7BFE, %sp
#
# Start running setup.S
#
.byte 0xEA
.word 0
.word 0x9020
#
# GDT & IDT stuff for switching into real mode.
#
gdt: .word 0, 0, 0, 0 # unused (00h)
.word 0, 0, 0, 0 # dummy (08h)
.word 0xFFFF, 0x100 # code (10h)
.word 0x9A00, 0
.word 0xFFFF, 0x180 # data (18h)
.word 0x9200, 0
gdt_48: .word 0x08 * 0x400
.long gdt + 0x7C00
idt_48: .word 0x400
.long 0
#
# Be careful not to exceed 1F0h or the the bootsect.S
# parameters will be lost!
#
.end

440
ia32/sysdeps.h Normal file
View file

@ -0,0 +1,440 @@
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
* Contributed by Mike Johnston <johnston@intel.com>
* Contributed by Chris Ahna <christopher.j.ahna@intel.com>
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
* ELILO 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 2, or (at your option)
* any later version.
*
* ELILO 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 ELILO; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Please check out the elilo.txt for complete documentation on how
* to use this program.
*/
/*
* This file is used to define all the IA32-specific data structures
* and constant used by the generic ELILO
*/
#ifndef __ELILO_SYSDEPS_IA32_H__
#define __ELILO_SYSDEPS_IA32_H__
#define ELILO_ARCH "IA-32" /* ASCII string */
/* for now use library versions */
#define Memset(a,v,n) SetMem((a),(n),(v))
#define Memcpy(a,b,n) CopyMem((a),(b),(n))
/*
* This version must match the one in the kernel.
*
* This table was put together using information from the
* following Linux kernel source files:
* linux/include/tty.h
* linux/arch/i386/kernel/setup.c
* linux/arch/i386/boot/bootsect.S
* linux/arch/i386/boot/setup.S
* linux/arch/i386/boot/video.S
*
* New fields in this structure for EFI and ELILO are:
* efi_loader_sig
* efi_st_addr
*
* A new bit, LDRFLAG_BOOT_PARAM_RELOC, in the loader_flags
* field is also defined in this file.
*/
typedef struct efi_ia32_boot_params {
UINT32 size;
UINT32 command_line;
UINT32 efi_sys_tbl;
UINT32 efi_mem_map;
UINT32 efi_mem_map_size;
UINT32 efi_mem_desc_size;
UINT32 efi_mem_desc_version;
UINT32 initrd_start;
UINT32 initrd_size;
UINT32 loader_start;
UINT32 loader_size;
UINT32 kernel_start;
UINT32 kernel_size;
UINT16 num_cols;
UINT16 num_rows;
UINT16 orig_x;
UINT16 orig_y;
} efi_ia32_boot_params_t;
extern efi_ia32_boot_params_t efi_ia32_bp;
#pragma pack(1)
typedef union ia32_boot_params {
UINT8 raw[0x2000];
struct {
/* Cursor position before passing control to kernel. */
/* 0x00 */ UINT8 orig_cursor_col; /* LDR */
/* 0x01 */ UINT8 orig_cursor_row; /* LDR */
/* Available contiguous extended memory in KB. */
/* 0x02 */ UINT16 ext_mem_k; /* LDR */
/* Video page, mode and screen width before passing control to kernel. */
/* 0x04 */ UINT16 orig_video_page; /* LDR */
/* 0x06 */ UINT8 orig_video_mode; /* LDR */
/* 0x07 */ UINT8 orig_video_cols; /* LDR */
/* 0x08 */ UINT16 unused_1; /* unused */
/* %%TBD */
/* 0x0A */ UINT16 orig_ega_bx; /* LDR */
/* 0x0C */ UINT16 unused_2; /* unused */
/* Screen height before passing control to kernel. */
/* 0x0E */ UINT8 orig_video_rows; /* LDR */
/* %%TBD */
/* 0x0F */ UINT8 is_vga; /* LDR */
/* 0x10 */ UINT16 orig_video_points; /* LDR */
/* %%TBD */
/* 0x12 */ UINT16 lfb_width; /* LDR */
/* 0x14 */ UINT16 lfb_height; /* LDR */
/* 0x16 */ UINT16 lfb_depth; /* LDR */
/* 0x18 */ UINT32 lfb_base; /* LDR */
/* 0x1C */ UINT32 lfb_size; /* LDR */
/* Offset of command line (from start of ia32_boot_param struct). */
/* The command line magik number must be set for the kernel setup */
/* code to use the command line offset. */
/* 0x20 */ UINT16 cmdline_magik; /* LDR */
#define CMDLINE_MAGIK 0xA33F
/* 0x22 */ UINT16 cmdline_offset; /* LDR */
/* %%TBD */
/* 0x24 */ UINT16 lfb_line_len; /* LDR */
/* %%TBD */
/* 0x26 */ UINT8 lfb_red_size; /* LDR */
/* 0x27 */ UINT8 lfb_red_pos; /* LDR */
/* 0x28 */ UINT8 lfb_green_size; /* LDR */
/* 0x29 */ UINT8 lfb_green_pos; /* LDR */
/* 0x2A */ UINT8 lfb_blue_size; /* LDR */
/* 0x2B */ UINT8 lfb_blue_pos; /* LDR */
/* 0x2C */ UINT8 lfb_rsvd_size; /* LDR */
/* 0x2D */ UINT8 lfb_rsvd_pos; /* LDR */
/* %%TBD */
/* 0x2E */ UINT16 vesa_seg; /* LDR */
/* 0x30 */ UINT16 vesa_off; /* LDR */
/* %%TBD */
/* 0x32 */ UINT16 lfb_pages; /* LDR */
/* 0x34 */ UINT8 lfb_reserved[0x0C]; /* reserved */
/* %%TBD */
/* 0x40 */ UINT16 apm_bios_ver; /* LDR */
#define NO_APM_BIOS 0x0000
/* %%TBD */
/* 0x42 */ UINT16 bios_code_seg; /* LDR */
/* 0x44 */ UINT32 bios_entry_point; /* LDR */
/* 0x48 */ UINT16 bios_code_seg16; /* LDR */
/* 0x4A */ UINT16 bios_data_seg; /* LDR */
/* %%TBD */
/* 0x4C */ UINT16 apm_bios_flags; /* LDR */
#define NO_32BIT_APM_MASK 0xFFFD
/* %%TBD */
/* 0x4E */ UINT32 bios_code_len; /* LDR */
/* 0x52 */ UINT16 bios_data_len; /* LDR */
/* 0x54 */ UINT8 unused_3[0x2C]; /* unused */
/* %%TBD */
/* 0x80 */ UINT8 hd0_info[0x10]; /* LDR */
/* 0x90 */ UINT8 hd1_info[0x10]; /* LDR */
/* %%TBD */
/* 0xA0 */ UINT16 mca_info_len; /* LDR */
/* 0xA2 */ UINT8 mca_info_buf[0x10]; /* LDR */
/* 0xB2 */ UINT8 unused_4[0x10E]; /* unused */
/* EFI boot loader signature. */
/* 0x1C0 */ UINT8 efi_loader_sig[4]; /* LDR */
#define EFI_LOADER_SIG "EFIL"
/* Address of the EFI system table. */
/* 0x1C4 */ UINT32 efi_sys_tbl; /* LDR */
/* EFI memory descriptor size. */
/* 0x1C8 */ UINT32 efi_mem_desc_size; /* LDR */
/* EFI memory descriptor version. */
/* 0x1CC */ UINT32 efi_mem_desc_ver; /* LDR */
/* Address & size of EFI memory map. */
/* 0x1D0 */ UINT32 efi_mem_map; /* LDR */
/* 0x1D4 */ UINT32 efi_mem_map_size; /* LDR */
/* Address & size of loader. */
/* 0x1D8 */ UINT32 loader_start; /* LDR */
/* 0x1DC */ UINT32 loader_size; /* LDR */
/* Available contiguous extended memory in KB. */
/* 0x1E0 */ UINT32 alt_mem_k; /* LDR */
/* 0x1E4 */ UINT8 unused_5[0x0D]; /* unused */
/* Size of setup code in sectors (1 sector == 512 bytes). */
/* 0x1F1 */ UINT8 setup_sectors; /* BLD */
/* %%TBD */
/* 0x1F2 */ UINT16 mount_root_rdonly; /* BLD */
/* %%TBD */
/* 0x1F4 */ UINT16 sys_size; /* BLD */
/* %%TBD */
/* 0x1F6 */ UINT16 swap_dev; /* BLD */
/* %%TBD */
/* 0x1F8 */ UINT16 ramdisk_flags; /* BLD */
#define RAMDISK_PROMPT 0x8000
#define RAMDISK_LOAD 0x4000
/* %%TBD */
/* 0x1FA */ UINT16 video_mode_flag; /* BLD */
/* %%TBD */
/* 0x1FC */ UINT16 orig_root_dev; /* BLD */
/* 0x1FE */ UINT8 unused_6; /* unused */
/* %%TBD */
/* 0x1FF */ UINT8 aux_dev_info; /* LDR */
#define NO_MOUSE 0x00
#define FOUND_MOUSE 0xAA
/* Jump past setup data (not used in EFI). */
/* 0x200 */ UINT16 jump; /* BLD */
/* Setup data signature. */
/* 0x202 */ UINT8 setup_sig[4]; /* BLD */
#define SETUP_SIG "HdrS"
/* %%TBD */
/* 0x206 */ UINT8 hdr_minor; /* BLD */
/* 0x207 */ UINT8 hdr_major; /* BLD */
/* %%TBD */
/* 0x208 */ UINT32 rm_switch; /* LDD */
/* %%TBD */
/* 0x20C */ UINT16 start_sys_seg; /* BLD */
/* %%TBD */
/* 0x20E */ UINT16 kernel_verstr_offset; /* BLD */
/* Loader type & version. */
/* 0x210 */ UINT8 loader_type; /* LDR */
#define LDRTYPE_ELILO 0x50 /* 5?h == elilo */
/* ?0h == revision */
/* 0x211 */ UINT8 loader_flags; /* BLD and LDR */
#define LDRFLAG_CAN_USE_HEAP 0x80
#define LDRFLAG_BOOT_PARAM_RELOC 0x40
/* %%TBD */
/* 0x212 */ UINT16 setup_move_size; /* BLD */
/* %%TBD */
/* 0x214 */ UINT32 kernel_start; /* LDR */
/* %%TBD */
/* 0x218 */ UINT32 initrd_start; /* LDR */
/* 0x21C */ UINT32 initrd_size; /* LDR */
/* %%TBD */
/* 0x220 */ UINT32 bootsect_helper; /* BLD */
/* %%TBD */
/* 0x224 */ UINT16 heap_end_ptr; /* LDR */
/* %%TBD */
/* 0x226 */ UINT32 base_mem_size; /* LDR */
} s;
} boot_params_t;
#pragma pack()
/*
* The stuff below here is for jumping to the kernel.
*/
/*
* Some macros to copy and set memory after EFI has been
* stopped.
*/
#define MEMCPY(to, from, cnt) { \
UINT8 *t = (UINT8 *)(to); \
UINT8 *f = (UINT8 *)(from); \
UINTN n = cnt; \
if (t && f && n) { \
while (n--) { \
*t++ = *f++; \
} \
} \
}
#define MEMSET(ptr, size, val) { \
UINT8 *p = (UINT8 *)(ptr); \
UINTN n = (UINTN)(size); \
UINT8 v = (UINT8)(val); \
if (p && n) { \
while (n--) { \
*p++ = v; \
} \
} \
}
/*
* Descriptor table pointer format.
*/
#pragma pack(1)
typedef struct {
UINT16 limit;
UINT32 base;
} dt_addr_t;
#pragma pack()
extern UINTN high_base_mem;
extern UINTN high_ext_mem;
extern boot_params_t *param_start;
extern UINTN param_size;
extern VOID *kernel_start;
extern UINTN kernel_size;
extern VOID *initrd_start;
extern UINTN initrd_size;
extern dt_addr_t gdt_addr;
extern dt_addr_t idt_addr;
extern UINT16 init_gdt[];
extern UINTN sizeof_init_gdt;
extern UINT8 rmswitch_image[];
extern UINTN rmswitch_size;
extern INTN ia32_use_legacy_free_boot();
/*
* How to jump to kernel code
*/
static inline void
start_kernel(VOID *kentry, boot_params_t *bp)
{
/*
* Disable interrupts.
*/
asm volatile ( "cli" : : );
/*
* Relocate initrd, if present.
*/
if (bp->s.initrd_start) {
/* %%TBD */
MEMCPY(15 * 1024 * 1024, bp->s.initrd_start, bp->s.initrd_size);
bp->s.initrd_start = 15 * 1024 * 1024;
}
/*
* Copy boot sector, setup data and command line
* to final resting place. We need to copy
* BOOT_PARAM_MEMSIZE bytes.
*/
MEMCPY(high_base_mem, bp, 0x4000);
/*
* initialize efi ia32 boot params and place them at 1kb up from
* the start of the boot command line param. This results in the
* efi ia32 boot params to be copied to 0x00104c00. See bootparams.c
* for details on how this is arranged. EFI enabled
* kernels will look for the efi boot params here to know if the
* kernel is booting on an EFI platform or legacy BIOS based platfrom
*/
efi_ia32_bp.initrd_start = bp->s.initrd_start;
efi_ia32_bp.initrd_size = bp->s.initrd_size;
MEMCPY(high_base_mem + 0x4000 - 0x0400, &efi_ia32_bp, sizeof(efi_ia32_bp));
/*
* Initialize Linux GDT.
*/
MEMSET(gdt_addr.base, gdt_addr.limit, 0);
MEMCPY(gdt_addr.base, init_gdt, sizeof_init_gdt);
if (! ia32_use_legacy_free_boot()) {
/*
* Copy our real mode transition code to 0x7C00.
*/
MEMCPY(0x7C00, rmswitch_image, rmswitch_size);
asm volatile ( "movl $0x7C00, %%ebx" : : );
asm volatile ( "jmp *%%ebx" : : );
}
/*
* Load descriptor table pointers.
*/
asm volatile ( "lidt %0" : : "m" (idt_addr) );
asm volatile ( "lgdt %0" : : "m" (gdt_addr) );
/*
* ebx := 0 (%%TBD - do not know why, yet)
* ecx := kernel entry point
* esi := address of boot sector and setup data
*/
asm volatile ( "movl %0, %%esi" : : "m" (high_base_mem) );
asm volatile ( "movl %0, %%ecx" : : "m" (kentry) );
asm volatile ( "xorl %%ebx, %%ebx" : : );
/*
* Jump to kernel entry point.
*/
asm volatile ( "jmp *%%ecx" : : );
}
typedef struct sys_img_options {
UINT8 nothing_yet;
} sys_img_options_t;
#endif /* __ELILO_SYSDEPS_IA32_H__ */

798
ia32/system.c Normal file
View file

@ -0,0 +1,798 @@
/*
* Copyright (C) 2001-2003 Hewlett-Packard Co.
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
* Contributed by Mike Johnston <johnston@intel.com>
* Contributed by Chris Ahna <christopher.j.ahna@intel.com>
*
* This file is part of the ELILO, the EFI Linux boot loader.
*
* ELILO 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 2, or (at your option)
* any later version.
*
* ELILO 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 ELILO; see the file COPYING. If not, write to the Free
* Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Please check out the elilo.txt for complete documentation on how
* to use this program.
*/
/*
* this file contains all the IA-32 specific code expected by generic loader
*/
#include <efi.h>
#include <efilib.h>
#include "elilo.h"
#include "loader.h"
#include "rmswitch.h"
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* extern loader_ops_t plain_loader, gzip_loader; */
efi_ia32_boot_params_t efi_ia32_bp;
/*
* Descriptor table base addresses & limits for Linux startup.
*/
dt_addr_t gdt_addr = { 0x800, 0x94000 };
dt_addr_t idt_addr = { 0, 0 };
/*
* Initial GDT layout for Linux startup.
*/
UINT16 init_gdt[] = {
/* gdt[0]: dummy */
0, 0, 0, 0,
/* gdt[1]: unused */
0, 0, 0, 0,
/* gdt[2]: code */
0xFFFF, /* 4Gb - (0x100000*0x1000 = 4Gb) */
0x0000, /* base address=0 */
0x9A00, /* code read/exec */
0x00CF, /* granularity=4096, 386 (+5th nibble of limit) */
/* gdt[3]: data */
0xFFFF, /* 4Gb - (0x100000*0x1000 = 4Gb) */
0x0000, /* base address=0 */
0x9200, /* data read/write */
0x00CF, /* granularity=4096, 386 (+5th nibble of limit) */
};
UINTN sizeof_init_gdt = sizeof init_gdt;
/*
* Highest available base memory address.
*
* For traditional kernels and loaders this is always at 0x90000.
* For updated kernels and loaders this is computed by taking the
* highest available base memory address and rounding down to the
* nearest 64 kB boundary and then subtracting 64 kB.
*
* A non-compressed kernel is automatically assumed to be an updated
* kernel. A compressed kernel that has bit 6 (0x40) set in the
* loader_flags field is also assumed to be an updated kernel.
*/
UINTN high_base_mem = 0x90000;
/*
* Highest available extended memory address.
*
* This is computed by taking the highest available extended memory
* address and rounding down to the nearest EFI_PAGE_SIZE (usually
* 4 kB) boundary. The ia32 Linux kernel can only support up to
* 2 GB (AFAIK).
*/
UINTN high_ext_mem = 32 * 1024 * 1024;
/*
* Starting location and size of runtime memory blocks.
*/
boot_params_t *param_start = NULL;
UINTN param_size = 0;
VOID *kernel_start = (VOID *)0x100000; /* 1M */
UINTN kernel_size = 0x200000; /* 2M (largest x86 kernel image) */
VOID *initrd_start = NULL;
UINTN initrd_size = 0;
/*
* Boot parameters can be relocated if TRUE.
* Boot parameters must be placed at 0x90000 if FALSE.
*
* This will be set to TRUE if bit 6 (0x40) is set in the loader_flags
* field in a compressed x86 boot format kernel. This will also be set
* to TRUE if the kernel is an uncompressed ELF32 image.
*
* To remote boot w/ the universal network driver and a 16-bit UNDI
* this must be set to TRUE.
*/
BOOLEAN can_reloc_boot_params = FALSE;
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static INTN
probe_bzImage_boot(CHAR16 *kname)
{
EFI_STATUS efi_status;
UINTN size;
fops_fd_t fd;
UINT8 bootsect[512];
DBG_PRT((L"probe_bzImage_boot()\n"));
if (!kname) {
ERR_PRT((L"kname == %xh", kname));
free_kmem();
return -1;
}
/*
* Open kernel image.
*/
DBG_PRT((L"opening %s...\n", kname));
efi_status = fops_open(kname, &fd);
if (EFI_ERROR(efi_status)) {
ERR_PRT((L"Could not open %s.", kname));
free_kmem();
return -1;
}
/*
* Read boot sector.
*/
DBG_PRT((L"\nreading boot sector...\n"));
size = sizeof bootsect;
efi_status = fops_read(fd, bootsect, &size);
if (EFI_ERROR(efi_status) || size != sizeof bootsect) {
ERR_PRT((L"Could not read boot sector from %s.", kname));
fops_close(fd);
free_kmem();
return -1;
}
/*
* Verify boot sector signature.
*/
if (bootsect[0x1FE] != 0x55 || bootsect[0x1FF] != 0xAA) {
ERR_PRT((L"%s is not a bzImage kernel image.\n", kname));
fops_close(fd);
free_kmem();
return -1;
}
/*
* Check for out of range setup data size.
* Will almost always be 7, but we will accept 1 to 64.
*/
DBG_PRT((L"bootsect[1F1h] == %d setup sectors\n", bootsect[0x1F1]));
if (bootsect[0x1F1] < 1 || bootsect[0x1F1] > 64) {
ERR_PRT((L"%s is not a valid bzImage kernel image.",
kname));
fops_close(fd);
free_kmem();
return -1;
}
/*
* Allocate and read setup data.
*/
DBG_PRT((L"reading setup data...\n"));
param_size = (bootsect[0x1F1] + 1) * 512;
//param_start = alloc(param_size, EfiBootServicesData);
param_start = alloc(param_size, EfiLoaderData);
DBG_PRT((L"param_size=%d param_start=%x", param_size, param_start));
if (!param_start) {
ERR_PRT((L"Could not allocate %d bytes of setup data.",
param_size));
fops_close(fd);
free_kmem();
return -1;
}
CopyMem(param_start, bootsect, sizeof bootsect);
size = param_size - 512;
efi_status = fops_read(fd, ((UINT8 *)param_start) + 512, &size);
if (EFI_ERROR(efi_status) || size != param_size - 512) {
ERR_PRT((L"Could not read %d bytes of setup data.",
param_size - 512));
free(param_start);
param_start = NULL;
param_size = 0;
fops_close(fd);
free_kmem();
return -1;
}
/*
* Check for setup data signature.
*/
{ UINT8 *c = ((UINT8 *)param_start)+514;
DBG_PRT((L"param_start(c=%x): %c-%c-%c-%c", c, (CHAR16)c[0],(CHAR16) c[1], (CHAR16)c[2], (CHAR16)c[3]));
}
if (CompareMem(((UINT8 *)param_start) + 514, "HdrS", 4)) {
ERR_PRT((L"%s does not have a setup signature.",
kname));
free(param_start);
param_start = NULL;
param_size = 0;
fops_close(fd);
free_kmem();
return -1;
}
/*
* Allocate memory for kernel.
*/
if (alloc_kmem(kernel_start, EFI_SIZE_TO_PAGES(kernel_size))) {
ERR_PRT((L"Could not allocate kernel memory."));
return -1;
} else {
VERB_PRT(3, Print(L"kernel_start: 0x%x kernel_size: %d\n", kernel_start, kernel_size));
}
/*
* Now read the rest of the kernel image into memory.
*/
DBG_PRT((L"reading kernel image...\n"));
size = kernel_size;
efi_status = fops_read(fd, kernel_start, &size);
if (EFI_ERROR(efi_status) || size < 0x10000) {
ERR_PRT((L"Error reading kernel image %s.", kname));
free(param_start);
param_start = NULL;
param_size = 0;
fops_close(fd);
free_kmem();
return -1;
}
DBG_PRT((L"kernel image read: %d bytes, %d Kbytes\n", size, size / 1024));
/*
* Boot sector, setup data and kernel image loaded.
*/
fops_close(fd);
return 0;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static INTN
load_bzImage_boot(CHAR16 *kname, kdesc_t *kd)
{
DBG_PRT((L"load_bzImage_boot()\n"));
if (!kname || !kd) {
ERR_PRT((L"kname=0x%x kd=0x%x", kname, kd));
free(param_start);
param_start = NULL;
param_size = 0;
free_kmem();
return -1;
}
kd->kstart = kd->kentry = kernel_start;
kd->kend = ((UINT8 *)kd->kstart) + kernel_size;
DBG_PRT((L"kstart=0x%x kentry=0x%x kend=0x%x\n", kd->kstart, kd->kentry, kd->kend));
return 0;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static loader_ops_t loader_bzImage_boot = {
NULL,
L"loader_bzImage_boot",
&probe_bzImage_boot,
&load_bzImage_boot
};
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
INTN
sysdeps_init(EFI_HANDLE dev)
{
DBG_PRT((L"sysdeps_init()\n"));
/*
* Register our loader(s)...
*/
loader_register(&loader_bzImage_boot);
/* loader_register(&plain_loader); */
/* loader_register(&gzip_loader); */
return 0;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
* initrd_get_addr()
* Compute a starting address for the initial RAMdisk image.
* For now, this image is placed immediately after the end of
* the kernel memory. Inside the start_kernel() code, the
* RAMdisk image will be relocated to the top of available
* extended memory.
*/
INTN
sysdeps_initrd_get_addr(kdesc_t *kd, memdesc_t *imem)
{
DBG_PRT((L"initrd_get_addr()\n"));
if (!kd || !imem) {
ERR_PRT((L"kd=0x%x imem=0x%x", kd, imem));
return -1;
}
VERB_PRT(3, Print(L"kstart=0x%x kentry=0x%x kend=0x%x\n",
kd->kstart, kd->kentry, kd->kend));
imem->start_addr = kd->kend;
VERB_PRT(3, Print(L"initrd start_addr=0x%x pgcnt=%d\n", imem->start_addr, imem->pgcnt));
return 0;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
VOID
sysdeps_free_boot_params(boot_params_t *bp)
{
mmap_desc_t md;
ZeroMem(&md, sizeof md);
md.md = (VOID *)bp->s.efi_mem_map;
free_memmap(&md);
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
* IA-32 specific boot parameters initialization routine
*/
INTN
sysdeps_create_boot_params(
boot_params_t *bp,
CHAR8 *cmdline,
memdesc_t *initrd,
UINTN *cookie)
{
mmap_desc_t mdesc;
EFI_STATUS efi_status;
UINTN rows, cols;
UINT8 row, col;
UINT8 mode;
UINT16 hdr_version;
DBG_PRT((L"fill_boot_params()\n"));
if (!bp || !cmdline || !initrd || !cookie) {
ERR_PRT((L"bp=0x%x cmdline=0x%x initrd=0x%x cookie=0x%x",
bp, cmdline, initrd, cookie));
free(param_start);
param_start = NULL;
param_size = 0;
free_kmem();
return -1;
}
/*
* Copy temporary boot sector and setup data storage to
* elilo allocated boot parameter storage. We only need
* the first two sectors (1K). The rest of the storage
* can be used by the command line.
*/
CopyMem(bp, param_start, 0x2000);
free(param_start);
param_start = NULL;
param_size = 0;
/*
* Save off our header revision information.
*/
hdr_version = (bp->s.hdr_major << 8) | bp->s.hdr_minor;
/*
* Clear out unused memory in boot sector image.
*/
bp->s.unused_1 = 0;
bp->s.unused_2 = 0;
ZeroMem(bp->s.unused_3, sizeof bp->s.unused_3);
ZeroMem(bp->s.unused_4, sizeof bp->s.unused_4);
ZeroMem(bp->s.unused_5, sizeof bp->s.unused_5);
bp->s.unused_6 = 0;
/*
* Tell kernel this was loaded by an advanced loader type.
* If this field is zero, the initrd_start and initrd_size
* fields are ignored by the kernel.
*/
bp->s.loader_type = LDRTYPE_ELILO;
/*
* Setup command line information.
*/
bp->s.cmdline_magik = CMDLINE_MAGIK;
bp->s.cmdline_offset = (UINT8 *)cmdline - (UINT8 *)bp;
/*
* Setup hard drive parameters.
* %%TBD - It should be okay to zero fill the hard drive
* info buffers. The kernel should do its own detection.
*/
ZeroMem(bp->s.hd0_info, sizeof bp->s.hd0_info);
ZeroMem(bp->s.hd1_info, sizeof bp->s.hd1_info);
#if 0
CopyMem(bp->s.hd0_info, *((VOID **)(0x41 * 4)),
sizeof bp->s.hd0_info);
CopyMem(bp->s.hd1_info, *((VOID **)(0x46 * 4)),
sizeof bp->s.hd1_info);
#endif
/*
* Memory info.
*/
bp->s.alt_mem_k = high_ext_mem / 1024;
if (bp->s.alt_mem_k <= 65535) {
bp->s.ext_mem_k = (UINT16)bp->s.alt_mem_k;
} else {
bp->s.ext_mem_k = 65535;
}
if (hdr_version < 0x0202)
bp->s.base_mem_size = high_base_mem;
/*
* Initial RAMdisk and root device stuff.
*/
DBG_PRT((L"initrd->start_addr=0x%x initrd->pgcnt=%d\n",
initrd->start_addr, initrd->pgcnt));
/* These RAMdisk flags are not needed, just zero them. */
bp->s.ramdisk_flags = 0;
if (initrd->start_addr && initrd->pgcnt) {
/* %%TBD - This will probably have to be changed. */
bp->s.initrd_start = (UINT32)initrd->start_addr;
bp->s.initrd_size = (UINT32)(initrd->pgcnt * EFI_PAGE_SIZE);
/*
* This is the RAMdisk root device for RedHat 2.2.x
* kernels (major 0x01, minor 0x00).
* %%TBD - Will this work for other distributions and
* 2.3.x and 2.4.x kernels? I do not know, yet.
*/
bp->s.orig_root_dev = 0x0100;
} else {
bp->s.initrd_start = 0;
bp->s.initrd_size = 0;
/* Do not change the root device if there is no RAMdisk. */
/* bp->s.orig_root_dev = 0; */
}
/*
* APM BIOS info.
*/
/* %%TBD - How to do Int 15h calls to get this info? */
bp->s.apm_bios_ver = NO_APM_BIOS;
bp->s.bios_code_seg = 0;
bp->s.bios_entry_point = 0;
bp->s.bios_code_seg16 = 0;
bp->s.bios_data_seg = 0;
bp->s.apm_bios_flags = 0;
bp->s.bios_code_len = 0;
bp->s.bios_data_len = 0;
/*
* MCA BIOS info (misnomer).
*/
/* %%TBD - How to do Int 15h call to get this info? */
bp->s.mca_info_len = 0;
ZeroMem(bp->s.mca_info_buf, sizeof bp->s.mca_info_buf);
/*
* Pointing device presence.
*/
/* %%TBD - How to do Int 11h call to get this info? */
bp->s.aux_dev_info = NO_MOUSE;
/*
* EFI loader signature and address of EFI system table.
*/
CopyMem(bp->s.efi_loader_sig, EFI_LOADER_SIG, 4);
bp->s.efi_sys_tbl = 0; /* %%TBD */
/*
* Kernel entry point.
*/
bp->s.kernel_start = (UINT32)kernel_start;
/*
* When changing stuff in the parameter structure compare
* the offsets of the fields with the offsets used in the
* boot sector and setup source files.
* arch/i386/boot/bootsect.S
* arch/i386/boot/setup.S
* arch/i386/kernel/setup.c
*/
#define CHECK_OFFSET(n, o, f) \
{ \
UINTN p = (UINT8 *)&bp->s.n - (UINT8 *)bp; \
UINTN q = (UINTN)(o); \
if (p != q) { \
test |= 1; \
Print(L"%20a: %3xh %3xh ", #n, p, q); \
if (*f) { \
Print(f, bp->s.n); \
} \
Print(L"\n"); \
} \
}
#define WAIT_FOR_KEY() \
{ \
EFI_INPUT_KEY key; \
while (ST->ConIn->ReadKeyStroke(ST->ConIn, &key) != EFI_SUCCESS) { \
; \
} \
}
{
UINTN test = 0;
CHECK_OFFSET(orig_cursor_col, 0x00, L"%xh");
CHECK_OFFSET(orig_cursor_row, 0x01, L"%xh");
CHECK_OFFSET(ext_mem_k, 0x02, L"%xh");
CHECK_OFFSET(orig_video_page, 0x04, L"%xh");
CHECK_OFFSET(orig_video_mode, 0x06, L"%xh");
CHECK_OFFSET(orig_video_cols, 0x07, L"%xh");
CHECK_OFFSET(orig_ega_bx, 0x0A, L"%xh");
CHECK_OFFSET(orig_video_rows, 0x0E, L"%xh");
CHECK_OFFSET(is_vga, 0x0F, L"%xh");
CHECK_OFFSET(orig_video_points, 0x10, L"%xh");
CHECK_OFFSET(lfb_width, 0x12, L"%xh");
CHECK_OFFSET(lfb_height, 0x14, L"%xh");
CHECK_OFFSET(lfb_depth, 0x16, L"%xh");
CHECK_OFFSET(lfb_base, 0x18, L"%xh");
CHECK_OFFSET(lfb_size, 0x1C, L"%xh");
CHECK_OFFSET(cmdline_magik, 0x20, L"%xh");
CHECK_OFFSET(cmdline_offset, 0x22, L"%xh");
CHECK_OFFSET(lfb_line_len, 0x24, L"%xh");
CHECK_OFFSET(lfb_red_size, 0x26, L"%xh");
CHECK_OFFSET(lfb_red_pos, 0x27, L"%xh");
CHECK_OFFSET(lfb_green_size, 0x28, L"%xh");
CHECK_OFFSET(lfb_green_pos, 0x29, L"%xh");
CHECK_OFFSET(lfb_blue_size, 0x2A, L"%xh");
CHECK_OFFSET(lfb_blue_pos, 0x2B, L"%xh");
CHECK_OFFSET(lfb_rsvd_size, 0x2C, L"%xh");
CHECK_OFFSET(lfb_rsvd_pos, 0x2D, L"%xh");
CHECK_OFFSET(vesa_seg, 0x2E, L"%xh");
CHECK_OFFSET(vesa_off, 0x30, L"%xh");
CHECK_OFFSET(lfb_pages, 0x32, L"%xh");
CHECK_OFFSET(lfb_reserved, 0x34, L"");
CHECK_OFFSET(apm_bios_ver, 0x40, L"%xh");
CHECK_OFFSET(bios_code_seg, 0x42, L"%xh");
CHECK_OFFSET(bios_entry_point, 0x44, L"%xh");
CHECK_OFFSET(bios_code_seg16, 0x48, L"%xh");
CHECK_OFFSET(bios_data_seg, 0x4A, L"%xh");
CHECK_OFFSET(apm_bios_flags, 0x4C, L"%xh");
CHECK_OFFSET(bios_code_len, 0x4E, L"%xh");
CHECK_OFFSET(bios_data_len, 0x52, L"%xh");
CHECK_OFFSET(hd0_info, 0x80, L"");
CHECK_OFFSET(hd1_info, 0x90, L"");
CHECK_OFFSET(mca_info_len, 0xA0, L"%xh");
CHECK_OFFSET(mca_info_buf, 0xA2, L"");
CHECK_OFFSET(efi_loader_sig, 0x1C0, L"'%-4.4a'");
CHECK_OFFSET(efi_sys_tbl, 0x1C4, L"%xh");
CHECK_OFFSET(efi_mem_desc_size, 0x1C8, L"%xh");
CHECK_OFFSET(efi_mem_desc_ver, 0x1CC, L"%xh");
CHECK_OFFSET(efi_mem_map, 0x1D0, L"%xh");
CHECK_OFFSET(efi_mem_map_size, 0x1D4, L"%xh");
CHECK_OFFSET(loader_start, 0x1D8, L"%xh");
CHECK_OFFSET(loader_size, 0x1DC, L"%xh");
CHECK_OFFSET(alt_mem_k, 0x1E0, L"%xh");
CHECK_OFFSET(setup_sectors, 0x1F1, L"%xh");
CHECK_OFFSET(mount_root_rdonly, 0x1F2, L"%xh");
CHECK_OFFSET(sys_size, 0x1F4, L"%xh");
CHECK_OFFSET(swap_dev, 0x1F6, L"%xh");
CHECK_OFFSET(ramdisk_flags, 0x1F8, L"%xh");
CHECK_OFFSET(video_mode_flag, 0x1FA, L"%xh");
CHECK_OFFSET(orig_root_dev, 0x1FC, L"%xh");
CHECK_OFFSET(aux_dev_info, 0x1FF, L"%xh");
CHECK_OFFSET(jump, 0x200, L"%xh");
CHECK_OFFSET(setup_sig, 0x202, L"'%-4.4a'");
CHECK_OFFSET(hdr_minor, 0x206, L"%xh");
CHECK_OFFSET(hdr_major, 0x207, L"%xh");
CHECK_OFFSET(rm_switch, 0x208, L"%xh");
CHECK_OFFSET(start_sys_seg, 0x20C, L"%xh");
CHECK_OFFSET(kernel_verstr_offset, 0x20E, L"%xh");
CHECK_OFFSET(loader_type, 0x210, L"%xh");
CHECK_OFFSET(loader_flags, 0x211, L"%xh");
CHECK_OFFSET(setup_move_size, 0x212, L"%xh");
CHECK_OFFSET(kernel_start, 0x214, L"%xh");
CHECK_OFFSET(initrd_start, 0x218, L"%xh");
CHECK_OFFSET(initrd_size, 0x21C, L"%xh");
CHECK_OFFSET(bootsect_helper, 0x220, L"%xh");
CHECK_OFFSET(heap_end_ptr, 0x224, L"%xh");
CHECK_OFFSET(base_mem_size, 0x226, L"%xh");
if (test) {
ERR_PRT((L"Boot sector and/or setup parameter alignment error."));
free_kmem();
return -1;
}
}
/*
* Get video information.
* Do this last so that any other cursor positioning done
* in the fill routine gets accounted for.
*/
efi_status = ST->ConOut->QueryMode(
ST->ConOut,
ST->ConOut->Mode->Mode,
&cols,
&rows);
if (EFI_ERROR(efi_status)) {
ERR_PRT((L"QueryMode failed. Fake it."));
mode = 3;
rows = 25;
cols = 80;
row = 24;
col = 0;
} else {
mode = (UINT8)ST->ConOut->Mode->Mode;
col = (UINT8)ST->ConOut->Mode->CursorColumn;
row = (UINT8)ST->ConOut->Mode->CursorRow;
}
bp->s.orig_cursor_col = col;
bp->s.orig_cursor_row = row;
bp->s.orig_video_page = 0;
bp->s.orig_video_mode = mode;
bp->s.orig_video_cols = (UINT8)cols;
bp->s.orig_video_rows = (UINT8)rows;
/* %%TBD - How to do Int 10h calls to get video info? */
bp->s.orig_ega_bx = 0;
bp->s.is_vga = 0;
bp->s.orig_video_points = 0;
/* %%TBD - How to do Int 10h calls to get frame buffer info? */
bp->s.lfb_width = 0;
bp->s.lfb_height = 0;
bp->s.lfb_depth = 0;
bp->s.lfb_base = 0;
bp->s.lfb_size = 0;
bp->s.lfb_line_len = 0;
bp->s.lfb_red_size = 0;
bp->s.lfb_red_pos = 0;
bp->s.lfb_green_size = 0;
bp->s.lfb_green_pos = 0;
bp->s.lfb_blue_size = 0;
bp->s.lfb_blue_pos = 0;
bp->s.lfb_rsvd_size = 0;
bp->s.lfb_rsvd_pos = 0;
bp->s.lfb_pages = 0;
bp->s.vesa_seg = 0;
bp->s.vesa_off = 0;
/*
* Get memory map description and cookie for ExitBootServices()
*/
if (get_memmap(&mdesc)) {
ERR_PRT((L"Could not get memory map."));
free_kmem();
return -1;
}
*cookie = mdesc.cookie;
bp->s.efi_mem_map = (UINTN)mdesc.md;
bp->s.efi_mem_map_size = mdesc.map_size;
bp->s.efi_mem_desc_size = mdesc.desc_size;
bp->s.efi_mem_desc_ver = mdesc.desc_version;
bp->s.efi_sys_tbl = (UINTN)systab;
/*
* my_ia32_boot_params and get ready to slap them into 0x00104c00
*/
efi_ia32_bp.size= sizeof(efi_ia32_bp);
efi_ia32_bp.command_line = (UINT32) cmdline;
efi_ia32_bp.efi_sys_tbl = bp->s.efi_sys_tbl;
efi_ia32_bp.efi_mem_map = bp->s.efi_mem_map;
efi_ia32_bp.efi_mem_map_size = bp->s.efi_mem_map_size;
efi_ia32_bp.efi_mem_desc_size = bp->s.efi_mem_desc_size;
efi_ia32_bp.efi_mem_desc_version = bp->s.efi_mem_desc_ver;
efi_ia32_bp.initrd_start = (UINTN)initrd->start_addr;
efi_ia32_bp.initrd_size = initrd->pgcnt * EFI_PAGE_SIZE;
efi_ia32_bp.loader_start = 0;
efi_ia32_bp.loader_size = 0;
efi_ia32_bp.kernel_start = bp->s.kernel_start;
efi_ia32_bp.kernel_size = kernel_size;
efi_ia32_bp.num_cols = cols;
efi_ia32_bp.num_rows = rows;
efi_ia32_bp.orig_x = col;
efi_ia32_bp.orig_y = row;
return 0;
}