aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2011-08-31 23:41:57 +0100
committerMatt Fleming <matt.fleming@intel.com>2011-08-31 23:41:57 +0100
commit44a85ccecd5e8aa5274f4366a6addd9852eead06 (patch)
tree53ce8b7108348f9e83b3dcb0cb4e38cc728ce895
parent78864aa9a5f5f662adea00a219a61aff1841de66 (diff)
parent262083901cb8b7472548cea6f1ed12d8107dc067 (diff)
downloadefilinux-44a85ccecd5e8aa5274f4366a6addd9852eead06.tar.gz
Merge branch 'next'
-rw-r--r--Makefile3
-rw-r--r--loaders/bzimage/bzimage.c50
-rw-r--r--loaders/bzimage/i386.h10
-rw-r--r--malloc.c6
4 files changed, 43 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 2499ec3..3ddf8b9 100644
--- a/Makefile
+++ b/Makefile
@@ -54,7 +54,8 @@ LDSCRIPT=$(LIBDIR)/gnuefi/elf_$(ARCH)_efi.lds
CFLAGS=-I. -I/usr/include/efi -I/usr/include/efi/$(ARCH) \
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
-Wall -Ifs/ -Iloaders/ -D$(ARCH) -Werror
-LDFLAGS=-T $(LDSCRIPT) -Bsymbolic -shared -nostdlib -L$(LIBDIR) $(CRT0)
+LDFLAGS=-T $(LDSCRIPT) -Bsymbolic -shared -nostdlib -znocombreloc \
+ -L$(LIBDIR) $(CRT0)
IMAGE=efilinux.efi
OBJS = entry.o malloc.o
diff --git a/loaders/bzimage/bzimage.c b/loaders/bzimage/bzimage.c
index bf4aa35..054df4d 100644
--- a/loaders/bzimage/bzimage.c
+++ b/loaders/bzimage/bzimage.c
@@ -56,7 +56,7 @@ EFI_STATUS
load_kernel(EFI_HANDLE image, CHAR16 *name, char *cmdline)
{
UINTN map_size, _map_size, map_key;
- EFI_PHYSICAL_ADDRESS kernel_start;
+ EFI_PHYSICAL_ADDRESS kernel_start, addr;
struct boot_params *boot_params;
EFI_MEMORY_DESCRIPTOR *map_buf;
struct e820_entry *e820_map;
@@ -137,7 +137,7 @@ load_kernel(EFI_HANDLE image, CHAR16 *name, char *cmdline)
/* Make sure the initrd string is valid */
if (*initrd++ == '=') {
CHAR16 filename[MAX_FILENAME], *n;
- struct file *file;
+ struct file *rdfile;
char *o, *p;
UINT64 size;
void *rd;
@@ -150,31 +150,32 @@ load_kernel(EFI_HANDLE image, CHAR16 *name, char *cmdline)
*n = *o;
*n = '\0';
- err = file_open(filename, &file);
+ err = file_open(filename, &rdfile);
if (err != EFI_SUCCESS)
goto out;
- file_size(file, &size);
- err = emalloc(size, 1, (EFI_PHYSICAL_ADDRESS *)&rd);
+ file_size(rdfile, &size);
+ err = emalloc(size, 1, &addr);
if (err != EFI_SUCCESS) {
- file_close(file);
+ file_close(rdfile);
goto out;
}
+ rd = (void *)(UINTN)addr;
- if ((UINT32)(UINT64)rd > buf->hdr.ramdisk_max) {
+ if ((UINTN)rd > buf->hdr.ramdisk_max) {
Print(L"ramdisk address is too high!\n");
- efree((EFI_PHYSICAL_ADDRESS)rd, size);
- file_close(file);
+ efree((UINTN)rd, size);
+ file_close(rdfile);
goto out;
}
- err = file_read(file, &size, rd);
- file_close(file);
+ err = file_read(rdfile, (UINTN *)&size, rd);
+ file_close(rdfile);
if (err != EFI_SUCCESS)
goto out;
- buf->hdr.ramdisk_start = (UINT32)(UINT64)rd;
+ buf->hdr.ramdisk_start = (UINT32)(UINTN)rd;
buf->hdr.ramdisk_len = size;
}
} else {
@@ -182,7 +183,7 @@ load_kernel(EFI_HANDLE image, CHAR16 *name, char *cmdline)
buf->hdr.ramdisk_len = 0;
}
- buf->hdr.cmd_line_ptr = (UINT32)(UINT64)cmdline;
+ buf->hdr.cmd_line_ptr = (UINT32)(UINTN)cmdline;
buf->hdr.cmdline_size = strlen(cmdline);
memset((char *)&buf->screen_info, 0x0, sizeof(buf->screen_info));
@@ -204,10 +205,12 @@ load_kernel(EFI_HANDLE image, CHAR16 *name, char *cmdline)
*
* Max kernel size is 8MB
*/
- err = emalloc(16384, 1, (EFI_PHYSICAL_ADDRESS *)&boot_params);
+ err = emalloc(16384, 1, &addr);
if (err != EFI_SUCCESS)
goto out;
+ boot_params = (struct boot_params *)(UINTN)addr;
+
memset((void *)boot_params, 0x0, 16384);
/* Copy first two sectors to boot_params */
@@ -246,10 +249,11 @@ load_kernel(EFI_HANDLE image, CHAR16 *name, char *cmdline)
again:
_map_size = map_size;
- err = emalloc(map_size, 1, (EFI_PHYSICAL_ADDRESS *)&map_buf);
+ err = emalloc(map_size, 1, &addr);
if (err != EFI_SUCCESS)
goto out;
+ map_buf = (EFI_MEMORY_DESCRIPTOR *)(UINTN)addr;
size = 0x800000;
err = emalloc(size, buf->hdr.kernel_alignment, &kernel_start);
if (err != EFI_SUCCESS)
@@ -262,15 +266,15 @@ again:
*
* Print a warning and hope for the best.
*/
- if (kernel_start < (EFI_PHYSICAL_ADDRESS)boot_params ||
- kernel_start < (EFI_PHYSICAL_ADDRESS)map_buf ||
- kernel_start < (EFI_PHYSICAL_ADDRESS)gdt.base)
+ if (kernel_start < (UINTN)boot_params ||
+ kernel_start < (UINTN)map_buf ||
+ kernel_start < (UINTN)gdt.base)
Print(L"Warning: kernel_start is too low.\n");
/*
* Read the rest of the kernel image.
*/
- err = file_read(file, &size, (void *)kernel_start);
+ err = file_read(file, &size, (void *)(UINTN)kernel_start);
if (err != EFI_SUCCESS)
goto out;
@@ -294,7 +298,7 @@ again:
* call to memory_map().
*/
efree(kernel_start, 0x800000);
- efree((EFI_PHYSICAL_ADDRESS)map_buf, _map_size);
+ efree((UINTN)map_buf, _map_size);
file_set_position(file, (UINT64)nr_setup_secs * 512);
goto again;
}
@@ -309,13 +313,15 @@ again:
goto out;
efi = &boot_params->efi_info;
- efi->efi_systab = (UINT32)(UINT64)sys_table;
+ efi->efi_systab = (UINT32)(UINTN)sys_table;
efi->efi_memdesc_size = desc_size;
efi->efi_memdesc_version = desc_version;
- efi->efi_memmap = (UINT32)(UINT64)map_buf;
+ efi->efi_memmap = (UINT32)(UINTN)map_buf;
efi->efi_memmap_size = map_size;
+#ifdef x86_64
efi->efi_systab_hi = (unsigned long)sys_table >> 32;
efi->efi_memmap_hi = (unsigned long)map_buf >> 32;
+#endif
memcpy((char *)&efi->efi_loader_signature,
EFI_LOADER_SIGNATURE, sizeof(UINT32));
diff --git a/loaders/bzimage/i386.h b/loaders/bzimage/i386.h
index 367f426..3199a02 100644
--- a/loaders/bzimage/i386.h
+++ b/loaders/bzimage/i386.h
@@ -36,4 +36,14 @@
#define EFI_LOADER_SIGNATURE "EL32"
+static inline void kernel_jump(EFI_PHYSICAL_ADDRESS kernel_start,
+ struct boot_params *boot_params)
+{
+ asm volatile ("cli \n"
+ "movl %0, %%esi \n"
+ "movl %1, %%ecx \n"
+ "jmp *%%ecx \n"
+ :: "m" (boot_params), "m" (kernel_start));
+}
+
#endif /* __I386_H__ */
diff --git a/malloc.c b/malloc.c
index a4138db..8f2b18c 100644
--- a/malloc.c
+++ b/malloc.c
@@ -47,7 +47,7 @@ EFI_STATUS emalloc(UINTN size, UINTN align, EFI_PHYSICAL_ADDRESS *addr)
{
UINTN map_size, map_key, desc_size;
EFI_MEMORY_DESCRIPTOR *map_buf;
- EFI_PHYSICAL_ADDRESS d, map_end;
+ UINTN d, map_end;
UINT32 desc_version;
EFI_STATUS err;
UINTN nr_pages = EFI_SIZE_TO_PAGES(size);
@@ -57,8 +57,8 @@ EFI_STATUS emalloc(UINTN size, UINTN align, EFI_PHYSICAL_ADDRESS *addr)
if (err != EFI_SUCCESS)
goto fail;
- d = (EFI_PHYSICAL_ADDRESS)map_buf;
- map_end = (EFI_PHYSICAL_ADDRESS)map_buf + map_size;
+ d = (UINTN)map_buf;
+ map_end = (UINTN)map_buf + map_size;
for (; d < map_end; d += desc_size) {
EFI_MEMORY_DESCRIPTOR *desc;