Kernel loading from cd
Re: Kernel loading from cd
So, can anyone explain to me what i have to do to load my kernel?
Re: Kernel loading from cd
I saw this but though reliability is high. Although I use 2K boot block for CDsOwen wrote:on a CD you have a little extra space for the initial bootsrap, but you can't reliably use more than 2048 bytes.
Read: Yet again BIOSes are buggy sacks of crap
Last edited by egos on Sun Aug 15, 2010 3:52 am, edited 1 time in total.
If you have seen bad English in my words, tell me what's wrong, please.
Re: Kernel loading from cd
I'm not sure what you want to know. There is a wiki with lots of information and if you have a specific question, I'm sure someone can/will help. If you just want an instant solution to loading your kernel you can use Grub.So, can anyone explain to me what i have to do to load my kernel?
What about starting by giving us some useful information. Did you get your kernel to compile yet ? Also, I'll ask once again, How are you building the kernel ? What tools, command line etc ?
If a trainstation is where trains stop, what is a workstation ?
Re: Kernel loading from cd
I compile the kernel using mingw.
What i have to do to load the kernel from my bootloader?
I know that there are a lot of tutorials, but most of them use GRUB as bootloader and i don't want that.
Code: Select all
gcc -o kernel.o -c kernel.cpp -nostdlib -nostartfiles -nodefaultlibs
Code: Select all
ld -T linker.ld -o kernel.bin kernel.o
I know that there are a lot of tutorials, but most of them use GRUB as bootloader and i don't want that.
Re: Kernel loading from cd
If you are using C++, kernel_main must use C linkage (well must is not really correct, but it makes things a lot easier) if you are planning to call it from Assembly (not sure if LD would complain about that though when you're only using one C++ source file).
If that doesn't fix it, "Cannot find entry point" issue is usually fixed by placing [SECTION .text] at the top of the multiboot header, but seeing as your kernel is only one C++ source file, that's going to be a bit harder (maybe GCC's __attribute__ may work).
Other common mistakes are forgetting to add some arguments to the command line. I see your source file is C++, if you're completely new, it may be better to get C working first and then build upon that. C++ brings a couple of other things that you need to consider (e.g. calling constructors/destructors, exception handling, ...).
If that doesn't fix it, "Cannot find entry point" issue is usually fixed by placing [SECTION .text] at the top of the multiboot header, but seeing as your kernel is only one C++ source file, that's going to be a bit harder (maybe GCC's __attribute__ may work).
Other common mistakes are forgetting to add some arguments to the command line. I see your source file is C++, if you're completely new, it may be better to get C working first and then build upon that. C++ brings a couple of other things that you need to consider (e.g. calling constructors/destructors, exception handling, ...).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: Kernel loading from cd
What executable format is your kernel.bin ? Is it actually a flat binary ? Or a format like ELF or PE exe that needs to be parsed ?
If a trainstation is where trains stop, what is a workstation ?
Re: Kernel loading from cd
You have enough space in the 2k bootspace on an CD. Use the ATAPI driver shown in the wiki and this certainly will work for you.
Re: Kernel loading from cd
kernel.bin starts with MZ, i think is a PE.
Re: Kernel loading from cd
Okay, so that's a problem. If you just want to load the file and jmp into it, it will need to be a flat binary. I've not used mingw but I imagine there is a linker option for that.
If a trainstation is where trains stop, what is a workstation ?
Re: Kernel loading from cd
I prefer to use own boot loader with no emulation but it is not most easy way. Maybe grub will better for you.Payn3 wrote:So, can anyone explain to me what i have to do to load my kernel?
If you have seen bad English in my words, tell me what's wrong, please.
Re: Kernel loading from cd
Well, but we may think about this. You must know. It could be PE, original MZ or actually NE or LE.Payn3 wrote:kernel.bin starts with MZ, i think is a PE.
Last edited by egos on Sun Aug 15, 2010 4:50 am, edited 1 time in total.
If you have seen bad English in my words, tell me what's wrong, please.
Re: Kernel loading from cd
If I put OUTPUT_FORMAT("binary") in the linker.ld i get
ld: cannot perform PE operations on non PE output file 'kernel.bin'.
Re: Kernel loading from cd
Remove from script PE directives.
If you have seen bad English in my words, tell me what's wrong, please.
Re: Kernel loading from cd
Remove the ENTRY directive. You won't need it. Your entry address will be at a known offset in the binary file that you choose.
Last edited by gerryg400 on Sun Aug 15, 2010 5:06 am, edited 1 time in total.
If a trainstation is where trains stop, what is a workstation ?
Re: Kernel loading from cd
I removed the entry directive, but the output file still starts with the MZ. And if i put the again the OUTPUT_FORMAT directive, but without ENTRY i get the same error.
ld: cannot perform PE operations on non PE output file 'kernel.bin'.
ld: cannot perform PE operations on non PE output file 'kernel.bin'.
Code: Select all
SECTIONS{
. = 0x00100000;
.text :{
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.data ALIGN (0x1000) : {
*(.data)
}
.bss : {
sbss = .;
*(COMMON)
*(.bss)
ebss = .;
}
}
Code: Select all
OUTPUT_FORMAT("binary")
SECTIONS{
. = 0x00100000;
.text :{
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.data ALIGN (0x1000) : {
*(.data)
}
.bss : {
sbss = .;
*(COMMON)
*(.bss)
ebss = .;
}
}