writing 64bit kernel using c++ !
writing 64bit kernel using c++ !
hello everyone
*what steps required to write & compile 64bit kernel using c++ suppose i will write all from scratch ,bootloader,entering long mode and loading the kernel how to compile and link c++ against asm code,command line options ,ld script?
*what about the model i use in c++ coding i want to use LP64 how to use it?
= i read the tutorial about writing 64bit kernel and doing kernel in c++ but i couldnt get them all together
thnx for ur time !
*what steps required to write & compile 64bit kernel using c++ suppose i will write all from scratch ,bootloader,entering long mode and loading the kernel how to compile and link c++ against asm code,command line options ,ld script?
*what about the model i use in c++ coding i want to use LP64 how to use it?
= i read the tutorial about writing 64bit kernel and doing kernel in c++ but i couldnt get them all together
thnx for ur time !
Re: writing 64bit kernel using c++ !
thnx for reply but i did search google,wiki but found nothing i dont want to know how to code but how to compile link c++ 64bit code with the 32bit code of my bootstrab+kernel also how to choose the model LP64?
thnx
thnx
Re: writing 64bit kernel using c++ !
LP64 is the default for gcc. So if you use gcc there is nothing to do. Build your cross-compiler and it will work.
You should write your code, including your kernel, in such a way that it is portable between data models. This basically means don't rely on the size of integer types and don't cast pointers to and from ints.
You should write your code, including your kernel, in such a way that it is portable between data models. This basically means don't rely on the size of integer types and don't cast pointers to and from ints.
If a trainstation is where trains stop, what is a workstation ?
Re: writing 64bit kernel using c++ !
That's because you can't. Look up long mode in the wiki, I think you have your ideas mixed up about compatibility.weezo wrote:thnx for reply but i did search google,wiki but found nothing i dont want to know how to code but how to compile link c++ 64bit code with the 32bit code of my bootstrab+kernel also how to choose the model LP64?
thnx
Re: writing 64bit kernel using c++ !
You have to specify that your 32bit code be put in a amd64 elf object file, which is opposite the default. Just specify args to the linker telling it to link it as "elf64-x86-64". That should be all.
Re: writing 64bit kernel using c++ !
My solution for that is to typedef an integral type for physical and virtual offsets. One typedef assures that a * will fit into the integer type, and I get the safety of 1 to 1 "pointer" arithmetic without GCC void* extensions.gerryg400 wrote:You should write your code, including your kernel, in such a way that it is portable between data models. This basically means don't rely on the size of integer types and don't cast pointers to and from ints.
Re: writing 64bit kernel using c++ !
I use uintptr_t. You can set and clear bits (like the paging bits) without casting.
If a trainstation is where trains stop, what is a workstation ?
Re: writing 64bit kernel using c++ !
Won't all go to hell when and if you decide to use PAE?gerryg400 wrote:I use uintptr_t. You can set and clear bits (like the paging bits) without casting.
Re: writing 64bit kernel using c++ !
You forgot to mention it's true only for some targets, but not for others.gerryg400 wrote:LP64 is the default for gcc.
Re: writing 64bit kernel using c++ !
True. I assumed it was a PC because the OP called 64bit mode long mode.Fanael wrote:You forgot to mention it's true only for some targets, but not for others.gerryg400 wrote:LP64 is the default for gcc.
If a trainstation is where trains stop, what is a workstation ?
Re: writing 64bit kernel using c++ !
You're correct. uintptr_t is not really suitable for physical addresses. Scratch my comment about paging bits.TylerAnon wrote:Won't all go to hell when and if you decide to use PAE?gerryg400 wrote:I use uintptr_t. You can set and clear bits (like the paging bits) without casting.
If a trainstation is where trains stop, what is a workstation ?
Re: writing 64bit kernel using c++ !
Even on x86-64 LP64 is not always the default, see e.g. x86_64-w64-mingw32 (or however the Win64 MinGW target is called).gerryg400 wrote:True. I assumed it was a PC because the OP called 64bit mode long mode.Fanael wrote:You forgot to mention it's true only for some targets, but not for others.gerryg400 wrote:LP64 is the default for gcc.
Re: writing 64bit kernel using c++ !
Yeah, they're defined by the OS. Belive me or not, there really are people who use executable and object file formats other than ELF for their systems. If they use PE, the can either use Win64 MinGW target or (the "proper" way) port the compiler so they'll have their own target. In the former case, they'll get LLP64 model.berkus wrote:Data models are mostly defined by the OS used. Many compilers stick to LP64 model, but mingw most probably would stick to Windows LLP64 model just because it's the default for target OS.
But it's not that important, really - my point was that LP64 is not necessarily default. Nothing more.
Re: writing 64bit kernel using c++ !
Okay, I give up. 不正確でした。Fanael wrote:Even on x86-64 LP64 is not always the default, see e.g. x86_64-w64-mingw32 (or however the Win64 MinGW target is called).gerryg400 wrote:True. I assumed it was a PC because the OP called 64bit mode long mode.Fanael wrote: You forgot to mention it's true only for some targets, but not for others.
If a trainstation is where trains stop, what is a workstation ?