Write to 0xB8000 does't work

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

Oup sorry i would said 4kb. Ok if i understand, ALIGN 4096 it a good think only if i use the paging system in pMode. If i dontuse it i can use a différent number and more that number is smal better is the memory speed. When I said ELF is the same as PE I would say if ELF is a executable as PE and not if ELF is 100% like PE. And if I was under Window, canI use ELF to build my kernel ?
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: Write to 0xB8000 does't work

Post by gzaloprgm »

spiner900 wrote:If i dontuse it i can use a différent number and more that number is smal better is the memory speed.
You can just eliminate the align line if you don't plan using paging / mapping kernel sections as RO, etc. If you delete it it wont be faster, the kernel will be smaller (in size).
When I said ELF is the same as PE I would say if ELF is a executable as PE and not if ELF is 100% like PE. And if I was under Window, canI use ELF to build my kernel ?
ELF in a kernel is only useful if you are using a bootloader which supports it (ie: GRUB) or when you want your OS to load applications, in which you can compile them as ELF and load them.

If you want to use ELF to build your kernel, you will probably need to make a cross-compiler (Check the wiki for more info).

Cheers,
gzaloprgm
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

Ok but now I want my kernel in a plain binary file, but i have to use ELF object to get it in 32 bit. Is there a other way ?
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: Write to 0xB8000 does't work

Post by gzaloprgm »

Yes, you can try compiling as a 32 bit COFF and then using a tool such as objdump to convert it to a plain binary file.
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
spiner900
Member
Member
Posts: 26
Joined: Mon Mar 09, 2009 10:47 am

Re: Write to 0xB8000 does't work

Post by spiner900 »

ok thanks !
JohnnyTheDon
Member
Member
Posts: 524
Joined: Sun Nov 09, 2008 2:55 am
Location: Pennsylvania, USA

Re: Write to 0xB8000 does't work

Post by JohnnyTheDon »

gzaloprgm wrote:Yes, you can try compiling as a 32 bit COFF and then using a tool such as objdump to convert it to a plain binary file.
Or you could take the normal elf32 and use objcopy. And if I remember correctly, COFF is a relocatable object format and not a finished excecutable format.
If i dontuse it i can use a différent number and more that number is smal better is the memory speed.
Smaller isn't better, more aligned is better. Accessing a multibyte variable is faster on boundaries evenly divisible by the size of the value. So 32-bit variables should be aligned to 4 bytes, 64-bit to 8 bytes, 128-bit to 16, etc. I said 16 because thats typically the biggest data size you will see.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Re: Write to 0xB8000 does't work

Post by quok »

JohnnyTheDon wrote:
gzaloprgm wrote:Yes, you can try compiling as a 32 bit COFF and then using a tool such as objdump to convert it to a plain binary file.
Or you could take the normal elf32 and use objcopy. And if I remember correctly, COFF is a relocatable object format and not a finished excecutable format.
I really don't see what's wrong with letting LD do the conversion to a flat binary for you. Something like the following should work fine, and I find it just as easy (if not easier, since it requires less steps) than using objcopy.

Code: Select all

ld --oformat binary -Ttext 0x0 -o kernel.bin kernel.o startup.o ...
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Write to 0xB8000 does't work

Post by neon »

Only question I have is why one would want a plain binary kernel anyways. I do not see any benefit of it.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Write to 0xB8000 does't work

Post by Combuster »

neon wrote:Only question I have is why one would want a plain binary kernel anyways. I do not see any benefit of it.
Much easier to load by a custom bootloader
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Write to 0xB8000 does't work

Post by neon »

Much easier to load by a custom bootloader
True. Easier is not always better though.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply