Skip to contentSkip to conversation

ELF64 and changelog and 4Gb

PATCH Ruslan Nikolaev 3 participants 3 messages Jul 19, 2005 – Jul 21, 2005

lore
Share & tools
lore
#0 lore raw
Quoted 1 line

I agree. This is more readable.

I can change it of course... But it is not so bad:

1. if elf class == 64 => using ELF64 validate & loading code

2. else:

- validate header by grub_dl_check_header(). Function grub_dl_check_header() also will check that elf class is 32-bit.

and so on...

I'm very busy now, but if you want I can update code... As for me I think that is no need to check elf class twice (small optimization).

Quoted 2 lines

Could you provide us detailed information? What information is passed precisely?

Ok... But first I have a question about grub2. Does it really provide "mmap" information for OS as multiboot defined or memory size only?

As for 4Gb limit:

1. Memory size variable is a 32-bit. It measures in bytes => max 4Gb. When it passes to OS it converts to KB measuring but it's still truncated to 4Gb.

2. You can see the following code in file "init.c":

/* Ignore >4GB. */
if (entry->addr <= 0xFFFFFFFF && entry->type == 1)
{
grub_addr_t addr;
grub_size_t len;

addr = (grub_addr_t) entry->addr;
len = ((addr + entry->len > 0xFFFFFFFF)
? 0xFFFFFFFF - addr
: (grub_size_t) entry->len);
add_mem_region (addr, len);
}

Memory regions addr and len also is a 32-bit when BIOS provides it as a 64-bit numbers.

Of course I can be wrong because I don't know grub code very well.

New ChangeLog:

2005-07-17 Ruslan Nikolaev <[email protected]>

* multiboot.c (grub_rescue_cmd_multiboot): using ELF64 loading code if ELF CLASS is a 64-bit and CPU CLASS is X86_64

Signature · 3 lines
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
#1 lore raw
Quoted 3 lines · Ruslan Nikolaev
Quoted 1 line

I agree. This is more readable.

I can change it of course... But it is not so bad:

Well, I think the problem is that there is no meaning to use a union here, and it makes the function too long.

Quoted 2 lines

Ok... But first I have a question about grub2. Does it really provide "mmap" information for OS as multiboot defined or memory size only?

As this is written in the comment, this is not implemented yet.

Quoted 5 lines

As for 4Gb limit:

1. Memory size variable is a 32-bit. It measures in bytes => max 4Gb. When it passes to OS it converts to KB measuring but it's still truncated to 4Gb.

But this itself is not a bug really. Because mem_upper is the size of a contiguous region starting from 1MB, and every BIOS has one or more memory holes before 4GB.

Well, there is a 4GB limit. We must implement memory map passing.

Quoted 4 lines

2005-07-17 Ruslan Nikolaev <[email protected]>

* multiboot.c (grub_rescue_cmd_multiboot): using ELF64 loading code if ELF CLASS is a 64-bit and CPU CLASS is X86_64

Please look at the examples carefully. The rule is the same as C comments:

Also, please write complete sentences and capitalize the first word. If a lower-case identifier comes at the beginning of a sentence, don't capitalize it! Changing the spelling makes it a different identifier. If you don't like starting a sentence with a lower case letter, write the sentence differently (e.g., “The identifier lower-case is ...”).

Okuji

#2 lore raw
In reply to Ruslan Nikolaev
Quoted 10 lines · Ruslan Nikolaev
Quoted 1 line

I agree. This is more readable.

I can change it of course... But it is not so bad:

1. if elf class == 64 => using ELF64 validate & loading code

2. else:

- validate header by grub_dl_check_header(). Function grub_dl_check_header() also will check that elf class is 32-bit.

The important thing to remember is that GRUB support more machines than the PC and other loaders than just multiboot. So having a ELF32 and ELF64 loader like Hollis suggested would be the right thing to do. It will mean more shared code and a clean solution.

Thanks,
Marco