aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2011-11-10Find crt0 and the LD script automaticallydvhartDarren Hart1-2/+3
gnuefi doesn't install crt0 and the ld script to a gnuefi directory by default, but some distributions stick it there. Use find via a shell command to take the last matching file for each of CRT0 and LDSCRIPT. This avoids forcing the caller to duplicate the script generating the ARCH variable used throughout the Makefile. Signed-off-by: Darren Hart <dvhart@linux.intel.com> CC: Matt Fleming <matt.fleming@intel.com>
2011-11-08Make the efi include dir configurableDarren Hart1-1/+3
When crosscompiling, it's common to need to specify a different include dir location. Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2011-10-13efilinux 0.9Matt Fleming1-1/+1
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-09-22Makefile: Allow CRT0 and LDSCRIPT to be overriddenMatt Fleming1-2/+2
Different distributions have a habit of installing the gnu-efi crt0 and ldscripts in various locations on the file system. Until efilinux gets autoconf support allow the user to override $CRT0 and $LDSCRIPT. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-09-22Makefile: Make cross-building possibleMatt Fleming1-4/+11
Add support for building ia32 efilinux on an x86-64 host. Cross-building can be turned on by specifying $ARCH when building efilinux, e.g. (assuming an x86-64 host) $ make ARCH=ia32 Also, delete $MACHINE from the Makefile and use $ARCH instead as ARCH seems to be more commonly used for specifying the target architecture; gnu-efi uses $ARCH for example. Note that $(CFLAGS) is now passed to $(CC) when looking up the path for libgcc.a, $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) This change is required because if we're cross-building $(CFLAGS) will include -m32, which makes -print-libgcc-file-name return the filename of the 32-bit version of libgcc.a, not the host's version. Reported-by: Darren Hart <dvhart@linux.intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-09-22bzimage: Multiple initrds supportMatt Fleming1-58/+116
Previously we only parsed one initrd= argument from the command line, but the linux kernel can handle multiple initrds. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-31Merge branch 'next'Matt Fleming4-26/+43
2011-08-26efilinux: Fix memory leaks in the error pathMatt Fleming4-9/+26
We leak a few chunks of memory if we take the error path in efi_main(). Be sure to free the memory and clean up the file handles in fs_exit(). Now that the caller of load_image() calls fs_exit() in the error path we don't need to do it in the bzImage code (the kernel will reclaim 'fs_devices' anyway if it loads successfully), but we do need to be sure to close any open file handles. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-25efilinux: malloc() size is too small for filenameMatt Fleming1-8/+20
We should be using sizeof() to figure out how large the buffer needs to be because the buffer does not hold an array of bytes, rather it's an array of CHAR16, which is actually 2 bytes. While I'm here cleanup the error path so that we free() '*name' and '*cmdline' in case of failure. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-25fs: Don't copy junk from locate_handle() bufferMatt Fleming1-7/+27
Currently if we have more than one handle that supports FileSystemProtocol we'll copy junk from 'fs_devices' when passing the arguments to handle_protocol(). This is because we're using an incorrect data type for the buffer filled out by locate_handle() - it returns an array of EFI_HANDLE, not an array of struct fs_device's. Instead use a temporary buffer to store the list of EFI_HANDLE's and copy them individually to fs_devices[].handle. Also, this is a good opportunity to clean up the error path in fs_init() so no longer leak open handles and 'fs_devices'. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-22protocol.h: Remove unused locate_protocol()Matt Fleming1-13/+0
locate_protocol() has never been used by efilinux and results in the following build error when compiled with gnu-efi <= 3.0i, In file included from entry.c:38:0: protocol.h: In function 'locate_protocol': protocol.h:62:31: error: 'EFI_BOOT_SERVICES' has no member named 'LocateProtocol' Reported-by: KESHAV P.R. <skodabenz@gmail.com> Reported-by: Metatech <metatechbe@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18efilinux: i386 kernel_jump()Matt Fleming1-0/+10
Add an implementation of kernel_jump() for i386. This was all the architecture specific code that was needed to get efilinux booting on i386. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18bzimage: Cast file_read() argument to avoid warningMatt Fleming1-1/+1
The following warning appears when compiling for i386, loaders/bzimage/bzimage.c: In function ‘load_kernel’: loaders/bzimage/bzimage.c:172:4: error: passing argument 2 of ‘file_read’ from incompatible pointer type fs/fs.h:63:1: note: expected ‘UINTN *’ but argument is of type ‘UINT64 *’ Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18bzimage: Only set efi_*_hi for x86-64Matt Fleming1-0/+2
It doesn't make sense to set efi_systab_hi or efi_memmap_hi for i386 because the 32-bit addresses fit in efi_systab and efi_memmap. Also, shifting the systab and memmap pointers results in the following warnings, loaders/bzimage/bzimage.c:324:2: error: right shift count >= width of type loaders/bzimage/bzimage.c:325:2: error: right shift count >= width of type Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18bzimage: Use UINTN to cast from pointer to integerMatt Fleming1-11/+11
The following warnings appear when compiling for i386, cc1: warnings being treated as errors loaders/bzimage/bzimage.c: In function ‘load_kernel’: loaders/bzimage/bzimage.c:165:16: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:167:11: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:178:37: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:186:34: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:275:21: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:276:21: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:277:21: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:283:31: error: cast to pointer from integer of different size loaders/bzimage/bzimage.c:307:10: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:319:28: error: cast from pointer to integer of different size loaders/bzimage/bzimage.c:322:28: error: cast from pointer to integer of different size Use UINTN which maps to unsigned long and works for i386 and x86-64. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18malloc: Use UINTN instead of EFI_PHYSICAL_ADDRESS for castsMatt Fleming1-3/+3
EFI_PHYSICAL_ADDRESS is a 64-bit data type, which when used to cast to a 32-bit pointer leads to the following warnings, cc1: warnings being treated as errors malloc.c: In function ‘emalloc’: malloc.c:60:6: error: cast from pointer to integer of different size malloc.c:61:12: error: cast from pointer to integer of different size malloc.c:67:10: error: cast to pointer from integer of different size UINTN is a much more logical choice for this cast because it maps to unsigned long, which will Do The Right Thing for both i386 and x86-64. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18bzimage: Fix typecast bug on i386Matt Fleming1-4/+8
Before 32-bit support we were playing fast and loose with casts. The problem was that we were casting away legimate warnings, such as the compiler telling us that the value it was storing into a variable to was too big to fit. emalloc() was a prime example, in various places we passed a pointer to a pointer as the third argument to emalloc which has type EFI_PHYSICALL_ADDRESS *, where EFI_PHYSICAL_ADDRESS is a 64-bit type, like so, emalloc(UINTN size, UINTN align, EFI_PHYSICAL_ADDRESS *addr) Then inside emalloc() we do, *addr = aligned; On 64-bit this is fine because, sizeof(void *) == sizeof(EFI_PHYSICAL_ADDRESS) but if we have a 32-bit pointer we attempt to store a 64-bit value into a 32-bit data type. This led to stack corruption when we passed the address of a pointer on the stack to emalloc(). Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18bzimage: Rename shadow variable 'file'Matt Fleming1-7/+7
We currently have two 'file' variables in load_kernel(), and the outermost variable is live across the inner one. Rename the innermost variable to 'rdfile' since it's used for initrd's. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-18Makefile: Add -znocombreloc to LDFLAGSMatt Fleming1-1/+2
This seems to be required in order for i386 to boot. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-10bzimage: Fix EFI to e820 memory type mappingMatt Fleming1-2/+2
Fix the memory types of EfiRuntimeServicesCode and EfiUnusableMemory which should be E820_RESERVED and E820_UNUSABLE respectively. Reported-by: Maarten Lankhorst <m.b.lankhorst@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-10bzimage: Don't call Print() after ExitBootServices()Matt Fleming1-3/+0
It is not safe to call Print() after ExitBootServices() because Print() may allocate memory, which isn't allowed once the boot services have exited. Maarten observed that calling Print() after boot services have exited caused his machine to reboot. Reported-by: Maarten Lankhorst <m.b.lankhorst@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-09bzimage: Merge memory typesMaarten Lankhorst1-6/+11
Fix failure to boot because of >128 e820 entries Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-08-08fs: Add device numbers as synonyms for full device pathsMaarten Lankhorst1-7/+27
Here's a patch to accept 0:\vmlinuz initrd=0:\initrd.img and zap the case sensitivity when looking up device paths. The device numbers correspond to the position of the device in the efilinux -l list. I alter 'name' in file_open, but it seems nothing else requires it anyhow, so I didn't see a need to copy or revert it. Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2011-07-28efilinux: Release 0.8Matt Fleming2-2/+5
Version numbers are useful for bug reports so the user knows which version to report bugs against. Start at version 0.8 because 32-bit support is planned for 0.9 with 1.0 being released after a thorough round of testing. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux: Add .gitignore fileMatt Fleming1-0/+6
Cut down on the noise of 'git status' and ignore build objects. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux: Free memory mapMatt Fleming1-0/+1
After we've printed the entries in the memory map we can free it. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux.h: Delete unused function, num_pages()Matt Fleming1-11/+0
This function isn't used, and gnu-efi already provides EFI_SIZE_TO_PAGES() for converting from a size in bytes to pages. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux: Add docbook comments for exit_boot_servicesMatt Fleming1-1/+7
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28Makefile: Turn on -WerrorMatt Fleming1-1/+1
It's all too easy to miss important warnings if they don't cause the compiler to error. One really important warning is missing function declarations - if the function cannot be resolved at runtime by the EFI loader then efilinux will silently fail to load and run. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28protocol.h: Add locate_protocol()Matt Fleming1-0/+13
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux: Add loader infrastructure and bzImage supportMatt Fleming10-4/+945
This patch provides the necessary glue to load binary files and transfer execution to them. Currently, we only support the Linux kernel bzImage format but other formats should be trivial to handle later. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28stdlib.h: Add implementation of strstrMatt Fleming1-0/+20
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28emalloc: Introduce an allocate with alignment capabilityMatt Fleming2-0/+84
When loading a linux kernel we need to be able to allocate memory with a strict alignment. This isn't possible with the current malloc implementation, so provide a new emalloc() function that takes an alignment as an argument. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28stdlib.h: Add strlen implementationMatt Fleming1-0/+12
While gnu-efi provides a strlen implementation for Unicode strings, we also need one for char *. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28Makefile: Add $(ARCH) macro to CFLAGSMatt Fleming1-1/+1
Pass -D$(ARCH) to $(CFLAGS) so that we can make architecture-specific decisions about which code fragments to include. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux: Parse load optionsMatt Fleming1-3/+115
efilinux expects to be called with the path of a kernel as its only argument. If an argument is present, parse it and pass it to the loader as the file to load and execute. If no arguments are present display the proper syntax for calling efilinux. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-28efilinux: File supportMatt Fleming5-3/+398
Files are managed via 'struct file', which allows us to hide the details necessary for accessing the file via the firmware, e.g. all the handles. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-22efilinux: Make print_memory_map() call memory_map()Matt Fleming1-11/+14
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-22efilinux: Correct the type of descr_versionMatt Fleming2-2/+2
descr_version should be UINT32, not UINTN. This obviously makes a difference on x86-64 where UINT32 is 32-bits and UINTN is 64-bits. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-22efilinux: Pass correct size to exit()Matt Fleming2-2/+2
The @size argument to exit() should be the size, in bytes, of @reason. Previously we were passing whatever value was left in 'size' in efi_main(). We should instead be passing ERROR_STRING_LENGTH because that is the size of the allocation holding @reason. Also, cleanup a typo in the documentation for exit() where the explanation of the @size argument referred to a nonexistent @data argument. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-22efilinux: Extract code for getting memory mapMatt Fleming1-31/+60
In the future there will be multiple call sites for this code, e.g. whenever someone calls print_memory_map() and also when we call exit_boot_services(). Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21stdlib.h: Add prototype for free()Matt Fleming1-0/+1
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21Makefile: Add -Wall to CFLAGSMatt Fleming1-1/+2
Being informed of all warnings is really useful, so turn this feature on. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21stdlib.h: Add memset and memcpyMatt Fleming1-0/+16
Add a simple implementation of these standard library functions. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21efilinux: malloc supportMatt Fleming3-1/+69
Provide a malloc implementation with the same prototype as the standard C library. This implementation is a wrapper around allocate_pool() and allocates from the EfiLoaderData runtime pool. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21efilinux.h: Expand the allocate_pages() commentMatt Fleming1-0/+3
Explain how @memory is used when when @atype is AllocateAddress. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21efilinux: Move the services and system tables into entry.cMatt Fleming2-22/+14
We only need to allocate space for the services and system table data structures once, so allocate space in entry.c. Currently, space will be allocated in every object file that includes efilinux.h. What's worse is that we only initialise the data objects allocated in entry.c via register_table(), all other object files will operate on uninitialised tables. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-07-21Makefile: Build in a -ffreestanding environmentMatt Fleming1-1/+1
Tell GCC that we're compiling in a freestanding environment, e.g. one in which standard libraries do not exist and in which GCC should not use builtin functions. This allows us to reuse some of the common function names, such as exit(), but with our own implementation. Turning off builtin functions also stops warnings like the following from being emitted, efilinux.h:187:1: warning: conflicting types for built-in function ‘exit’ Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-05-23efilinux.h: Fix compiler warning for CheckCrc()Matt Fleming1-1/+1
Pass the correct member (->Hdr) of the system table to CheckCrc() and fix the following warning, efilinux.h: In function ‘register_table’: efilinux.h:62:2: warning: passing argument 2 of ‘CheckCrc’ from incompatible pointer type /usr/include/efi/efilib.h:155:1: note: expected ‘struct EFI_TABLE_HEADER *’ but argument is of type ‘struct EFI_SYSTEM_TABLE *’ Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-05-11efilinux: Switch to 3-clause BSD licenseMatt Fleming3-41/+83
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-03-11Makefile: Allow buildling for ia32Matt Fleming1-5/+16
Extract all the architecture-specific options and infer which architecture we're building from $(CC) -dumpmachine. Currently, only x86-64 and ia32 are supported, but it would be trivial to add ia64 support. Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
2011-03-07Welcome to efilinux!Matt Fleming4-0/+415
This is the initial commit and we're just laying the ground work for the project. We can produce a .efi executable for use with UEFI firmware, but currently all that efilinux does is dump the memory map to the console and exit. Happy Hacking! Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>