How To Make Efi Bootloader |
|
|

Mar 6 2011, 08:03 PM

- Advanced Member
- Group: Staff
- Posts: 109
QUOTE (Slice @ Mar 6 2011, 08:53 PM)

CODE
toggle among different CPU architectures
???
It means at build time, it picks the right binary to include in the FV (Efildr).
Check the Fat.inf file to understand.

Mar 7 2011, 07:01 AM




- Advanced Member
- Group: Developer
- Posts: 5,589
QUOTE (Kabyl @ Mar 7 2011, 12:03 AM)

It means at build time, it picks the right binary to include in the FV (Efildr).
Check the Fat.inf file to understand.
Yes, I understood.
Now I try to create MinGW-gcc-4.4.1 as 4.3.0 was unsuccessful.
Don't know how can I compiled Duet without it.
Follow
this guide.

Mar 7 2011, 09:05 AM




- Advanced Member
- Group: Developer
- Posts: 5,589
QUOTE (Kabyl @ Mar 6 2011, 08:57 PM)

Actually I did, it's the other way around

I was talking about boot1h which can be used on HFS+.
You can skip Start32 in this case.
It is not clear for me. Can we comment out
call ReadFile?
CODE
# Read Efildr
popw %cx
# cx = Start Cluster of Efildr -> BS.com has filled already
# ES:DI = 2000:0, first cluster will be read again
xorw %di, %di # di = 0
movw $0x2000, %ax
movw %ax, %es
call ReadFile
movw %cs, %ax
movw %ax, %cs:JumpSegment
JumpFarInstruction:
.byte 0xea
JumpOffset:
.word 0x200
JumpSegment:
.word 0x2000

Mar 7 2011, 09:30 AM

- Advanced Member
- Group: Staff
- Posts: 109
QUOTE (Slice @ Mar 7 2011, 10:05 AM)

It is not clear for me. Can we comment out
call ReadFile?
CODE
# Read Efildr
popw %cx
# cx = Start Cluster of Efildr -> BS.com has filled already
# ES:DI = 2000:0, first cluster will be read again
xorw %di, %di # di = 0
movw $0x2000, %ax
movw %ax, %es
call ReadFile
movw %cs, %ax
movw %ax, %cs:JumpSegment
JumpFarInstruction:
.byte 0xea
JumpOffset:
.word 0x200
JumpSegment:
.word 0x2000
It seems boot1h does load our /boot at the same JumpSegment (0x2000), and jumps to JumpOffset (0x200) which is what we want!
And Start32 should be kept since it has some coded needed later by Efildr.
So according to the above, boot1h should be able to load Efildr if it finds it at /boot. Did you try?

Mar 7 2011, 04:11 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
QUOTE (Kabyl @ Mar 7 2011, 01:30 PM)

It seems boot1h does load our /boot at the same JumpSegment (0x2000), and jumps to JumpOffset (0x200) which is what we want!
And Start32 should be kept since it has some coded needed later by Efildr.
So according to the above, boot1h should be able to load Efildr if it finds it at /boot. Did you try?
Going to try.
I was trying to create mingw-gcc. Still no success. Binutils yes, gcc - no. Have you ready binaries?
First. I was trying with gcc-4.3.0. Dublicate symbols.
gcc-4.4.1.
CODE
Undefined symbols:
"_cpp_define_formatted", referenced from:
_c_cpp_builtins in c-cppbuiltin.o
_c_cpp_builtins in c-cppbuiltin.o
_c_cpp_builtins in c-cppbuiltin.o
_c_cpp_builtins in c-cppbuiltin.o
"_ht_purge", referenced from:
_ggc_purge_stringpool in libbackend.a(stringpool.o)
Strange, but it can be compiled out of the build script. But I am not sure in the result.
And how did I compile Duet having no mingw-gcc?

Mar 7 2011, 04:29 PM

- Advanced Member
- Group: Staff
- Posts: 109
QUOTE (Slice @ Mar 7 2011, 05:11 PM)

Going to try.
I was trying to create mingw-gcc. Still no success. Binutils yes, gcc - no. Have you ready binaries?
First. I was trying with gcc-4.3.0. Dublicate symbols.
gcc-4.4.1.
CODE
Undefined symbols:
"_cpp_define_formatted", referenced from:
_c_cpp_builtins in c-cppbuiltin.o
_c_cpp_builtins in c-cppbuiltin.o
_c_cpp_builtins in c-cppbuiltin.o
_c_cpp_builtins in c-cppbuiltin.o
"_ht_purge", referenced from:
_ggc_purge_stringpool in libbackend.a(stringpool.o)
Strange, but it can be compiled out of the build script. But I am not sure in the result.
And how did I compile Duet having no mingw-gcc?

I saved build instructions in file, but it's on my PC at home, so I'll try to find it and post it later.

Mar 7 2011, 05:00 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
QUOTE (Kabyl @ Mar 7 2011, 01:30 PM)

It seems boot1h does load our /boot at the same JumpSegment (0x2000), and jumps to JumpOffset (0x200) which is what we want!
And Start32 should be kept since it has some coded needed later by Efildr.
So according to the above, boot1h should be able to load Efildr if it finds it at /boot. Did you try?
Doesn't start, just blinking cursor at upper corner.

Mar 7 2011, 06:31 PM

- Advanced Member
- Group: Staff
- Posts: 109
Can't find where I saved the instructions

but you can use MacPorts or download from
http://crossgcc.rts-software.org/doku.php only 32bit, though.

Mar 7 2011, 06:47 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
Strange, but I repeat success.
Reboot.
Do step by step instructions from posts 2,3 except building tools. OK! Duet is compiled.
It seems for XCODE32 target mingw-gcc is not needed, just create binutils.
Now I can modify Duet.
TODO:
1. HFS+ support.
2. DSDT.aml load and apply.
3. SMBIOS corrections to Apple's values.
4. Correct FSBFrequency.
5. AppleSim (bootservices?)
And so on...

Mar 7 2011, 10:20 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
HFS+ support.I take VirtualBox sources and look into VBoxFsDxe. It supports FAT, HFS+, ISO9660 file system. But it connected to VirtualBox function.
And as I see Duet has no hardware implementation for ReadDisk required by VBox function.
CODE
/**
* FSW interface function to read data blocks. This function is called by the FSW core
* to read a block of data from the device. The buffer is allocated by the core code.
*/
fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)vol->host_data;
FSW_MSG_DEBUGV((FSW_MSGSTR("fsw_efi_read_block: %d (%d)\n"), phys_bno, vol->phys_blocksize));
// read from disk
Status = Volume->DiskIo->ReadDisk(Volume->DiskIo, Volume->MediaId,
(UINT64)phys_bno * vol->phys_blocksize,
vol->phys_blocksize,
buffer);
Volume->LastIOStatus = Status;
if (EFI_ERROR(Status))
return FSW_IO_ERROR;
return FSW_SUCCESS;
}
It should be INT13, and its address places into dispatch table.

Mar 8 2011, 08:10 AM




- Advanced Member
- Group: Developer
- Posts: 5,589
About rEFIt
CODE
Volume->OSName = L"Linux";
} else if....
Volume->OSName = L"FreeBSD";
} else if ....
Volume->OSName = L"NetBSD";
} else if ....
Volume->OSName = L"Windows";
} else if ....
Volume->OSName = L"eComStation";
} else if ...
Volume->OSName = L"BeOS";
} else if (....
Volume->OSName = L"ZETA";
} else if ....
Volume->OSName = L"Haiku";
Any, but MacOSX

Mar 8 2011, 10:21 AM

- Initiate
- Group: Comrade
- Posts: 21
QUOTE (Slice @ Mar 7 2011, 07:01 AM)

Yes, I understood.
Now I try to create MinGW-gcc-4.4.1 as 4.3.0 was unsuccessful.
Don't know how can I compiled Duet without it.
Follow
this guide.Hi Slice.
You can cross-compile gcc 4.3 on 10.6 by patching Make-lang.in in gcc/cp source folder. Remove tree-inline.o from line 73, delete your existing build folder and your'e good to go with the re-compile. I have compiled 32 and 64-bit versions successfully using the tutorial you gave earlier
Asus Maximus IV Gene-Z, i3770K@3.5GHz, 8Gb RAM, 10.8 via Clover, modded bios 3402 with AICPUPM fix and HFSPlus/OsxAptioDrv/FatBinaryDrv built-in

Mar 8 2011, 05:01 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
QUOTE (dgsga @ Mar 8 2011, 02:21 PM)

Hi Slice.
You can cross-compile gcc 4.3 on 10.6 by patching Make-lang.in in gcc/cp source folder. Remove tree-inline.o from line 73, delete your existing build folder and your'e good to go with the re-compile. I have compiled 32 and 64-bit versions successfully using the tutorial you gave earlier
Thank you for the contribution.
As I found new gcc is not needed. Duet can be compiled with Apple's gcc + mtoc.
Going forward. We have to make Duet better then Chameleon.

Mar 8 2011, 05:55 PM

- Advanced Member
- Group: Staff
- Posts: 109
QUOTE (Slice @ Mar 7 2011, 07:47 PM)

TODO:
1. HFS+ support.
2. DSDT.aml load and apply.
3. SMBIOS corrections to Apple's values.
4. Correct FSBFrequency.
5. AppleSim (bootservices?)
And so on...
I would rearrange the priorities like this:
1: HFS+
2: Fat binary support (Apple specific).
3: FSBFrequency.
This
should be enough to boot OS X, assuming you have your "extra" KEXTs in /S/L/E (the right place).
4: SMBIOS corrections (this one could be even necessary, we shall see).
5: Alternative ACPI tables.
6: device-properties.
7: Preloading KEXTs or MKEXT (this helps ease installing from a retail DVD).
QUOTE (Slice @ Mar 7 2011, 11:20 PM)

HFS+ support.I take VirtualBox sources and look into VBoxFsDxe. It supports FAT, HFS+, ISO9660 file system. But it connected to VirtualBox function.
And as I see Duet has no hardware implementation for ReadDisk required by VBox function.
CODE
/**
* FSW interface function to read data blocks. This function is called by the FSW core
* to read a block of data from the device. The buffer is allocated by the core code.
*/
fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer)
{
EFI_STATUS Status;
FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)vol->host_data;
FSW_MSG_DEBUGV((FSW_MSGSTR("fsw_efi_read_block: %d (%d)\n"), phys_bno, vol->phys_blocksize));
// read from disk
Status = Volume->DiskIo->ReadDisk(Volume->DiskIo, Volume->MediaId,
(UINT64)phys_bno * vol->phys_blocksize,
vol->phys_blocksize,
buffer);
Volume->LastIOStatus = Status;
if (EFI_ERROR(Status))
return FSW_IO_ERROR;
return FSW_SUCCESS;
}
It should be INT13, and its address places into dispatch table.
If that doesn't work, then the HFS+ driver isn't written according to specs, it might be a way for a hack to load extra KEXTs.
I believe it can be made to work with little modifications.
QUOTE (Slice @ Mar 8 2011, 06:01 PM)

As I found new gcc is not needed. Duet can be compiled with Apple's gcc + mtoc.
I assume since the errors come from compiling .S (assembly) files, binutils would be enough.
UnixPkg builds and works fine, probably also an easier way to test boot.efi (?)
QUOTE
Going forward. We have to make Duet better then Chameleon.
Porting features should be easy, the issue is getting DUET to work better on BIOS-based PCs.

Mar 8 2011, 06:17 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
Did you know any way to start Shell.efi without booting with Efildr? I still have no any working Efildr20.
So for me first problem is making working boot.
About FAT binary you means
this info? VBoxPECoffLib
And about HFS+
QUOTE
The Apple EFI firmware understands the HFS+ filesystem format, in addition to the FAT filesystem format mandated by the EFI specification

Mar 9 2011, 08:16 PM




- Advanced Member
- Group: Developer
- Posts: 5,589
Check the compilation is successful
DSC00069.png ( 683.73K )
Number of downloads: 91

Mar 10 2011, 11:13 AM




- Advanced Member
- Group: Developer
- Posts: 5,589
QUOTE (Kabyl @ Mar 8 2011, 09:55 PM)

I would rearrange the priorities like this:
1: HFS+
2: Fat binary support (Apple specific).
3: FSBFrequency.
This should be enough to boot OS X, assuming you have your "extra" KEXTs in /S/L/E (the right place).
4: SMBIOS corrections (this one could be even necessary, we shall see).
5: Alternative ACPI tables.
6: device-properties.
7: Preloading KEXTs or MKEXT (this helps ease installing from a retail DVD).
Porting features should be easy, the issue is getting DUET to work better on BIOS-based PCs.
Continue TODO list after some testing.
8. This bootloader works only on one of my computers. Hardware dependencies?
9. efivar.bin has own format. It is better to make it compatible with nvram utility to have a possibility save changes from OSX as I did with NVRAM.dylib.
bless and StartupDisk.prefPane save into DeviceTree, and we want to use this info after reboot. Not sure if EfiRuntime do the work.
10. Correct memory detect. Now I see 0Mb.
11. Correct UUIDs to Apple's one?
12. FakeSMC.efi DRV F46998C9-DD30-4C64-966C-E17777B2568A

Mar 10 2011, 12:18 PM


- Initiate
- Group: Comrade
- Posts: 14
QUOTE (Slice @ Mar 6 2011, 03:33 AM)

VMWare no sources but VirtualBox by Oracle - yes! Including HFS+.
Yes, I was looking at that too. Also, downloaded it.
Net...
Again, your a few days ahead of me.

Mar 10 2011, 12:31 PM


- Initiate
- Group: Comrade
- Posts: 14
QUOTE (Slice @ Mar 8 2011, 01:17 PM)

Did you know any way to start Shell.efi without booting with Efildr? I still have no any working Efildr20.
So for me first problem is making working boot.
About FAT binary you means
this info? VBoxPECoffLib
And about HFS+
How about setting it up as a floppy ram disk. So, instead of the next boot stage being EfiLdr on the hard drive. It would be a floppy ram disk A:
Then you can pre-stage before running EfiLdr.
here is an example of this in the source code. GnuGenBootSector.c // Process floppy disk
I've also been looking at the source code for GRUB 2 with EFI to get some ideas down...
Net...
This post has been edited by NetBoot: Mar 10 2011, 12:33 PM

Mar 10 2011, 01:10 PM

- Advanced Member
- Group: Staff
- Posts: 109
QUOTE (Slice @ Mar 10 2011, 12:13 PM)

12. FakeSMC.efi DRV F46998C9-DD30-4C64-966C-E17777B2568A
I haven't checked the above GUID, could you provide more information about it?
If this is the SmcProtocol, then I don't see a use for it.