mmap support and x86_64 CPU detection
PATCH 1/1 mmap support and x86_64 CPU detection
Hi!
I made a patch. Now you can use MMAP for multiboot and also during loading ELF64 (x86_64) check for x86_64 performs. I've tested it with gnu sample from multiboot.html.
You can say that it will be better to have separte cpuid feauture detection function, but please note that some 486 processor needs kludge code for CPUID detection while it always works for x86_64. Briefly: some 486 processor actually has CPUID but this code says that they don't (they need kludge code for detection). => In that case I think that it is clear to have CPUID detection within grub_x86_64_cpu function :)
P.S. It seems that grub_disk_read works (at least for grub-1.90 version) works incorrectly when you specify 0 as read data size. It returns something strange. This bug for both ext2 and dos. I've found this bug when tried to load multiboot file (it fails in one place). I comment readed data size checking (just for testing my patch).
ChangeLog:
ChangeLog:
2005-08-13 Ruslan Nikolaev <[email protected]>
* kern/i386/pc/startup.S (grub_x86_64_cpu): New function.
* loader/i386/pc/multiboot.c (grub_multiboot_mmap): New function. (grub_load_elf64): Make sure that we have deal with x86_64 CPU. (grub_rescue_cmd_multiboot): Added mmap support.
* include/grub/i386/pc/init.h: Function grub_get_mmap_entry is exportable now.
* include/grub/i386/pc/loader.h: Added prototype for grub_x86_64_cpu.
PATCH:
include/grub/i386/pc/init.h 2005-08-13 22:35:59.000000000 +0000 renamed from include/grub/i386/pc/init.h 2005-01-31 21:40:25.000000000 +0000 +1 -1
@@ -48,7 +48,7 @@ /* Get a memory map entry. Return next continuation value. Zero means the end. */ -grub_uint32_t grub_get_mmap_entry (struct grub_machine_mmap_entry *entry, +grub_uint32_t EXPORT_FUNC (grub_get_mmap_entry) (struct grub_machine_mmap_entry *entry, grub_uint32_t cont); /* Turn on/off Gate A20. */
include/grub/i386/pc/loader.h 2005-08-13 14:55:23.000000000 +0000 renamed from include/grub/i386/pc/loader.h 2004-09-12 12:20:52.000000000 +0000 +1 -0
@@ -38,6 +38,7 @@ void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry, struct grub_multiboot_info *mbi) __attribute__ ((noreturn)); +int EXPORT_FUNC(grub_x86_64_cpu) (void); /* It is necessary to export these functions, because normal mode commands reuse rescue mode commands. */
kern/i386/pc/startup.S 2005-08-13 22:50:34.000000000 +0000 renamed from kern/i386/pc/startup.S 2005-08-06 15:40:00.000000000 +0000 +29 -0
@@ -1684,3 +1684,32 @@ popl %ebx popl %ebp ret + +/* + * int grub_x86_64_cpu (void) + */ +FUNCTION(grub_x86_64_cpu) + pushf /* Save EFLAGS */ + pushf + popl %eax + xorl $0x200000, %eax /* Change ID(21) bit */ + pushl %eax + popf + pushf + popl %edx + popf /* Restore EFLAGS */ + xorl %edx, %eax + jnz 1f + movl $0x80000000, %eax /* Does CPU supports any function > 0x80000000? */ + cpuid + cmpl $0x80000000, %eax + jbe 1f + movl $0x80000001, %eax /* Does CPU supports long mode? */ + cpuid + xorl %eax, %eax + btl $29, %edx + jc 2f +1: + movl $0xFFFFFFFF, %eax +2: + ret
loader/i386/pc/multiboot.c 2005-08-14 04:44:32.282230288 +0000 renamed from loader/i386/pc/multiboot.c 2005-07-31 15:56:54.000000000 +0000 +88 -2
136 lines not on this page · raw message
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com