Sorry to bother again, why can't i write anything to the VGA

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.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Sorry to bother again, why can't i write anything to the VGA

Post by NeonLightions »

Hi,
Like the title. Can you help me? I'm getting crazy with it.
Here is my repo: https://github.com/NeonLightions/Amore-OS-x64
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Sorry to bother again, why can't i write anything to the

Post by Octocontrabass »

You're building 64-bit code but you never switch the CPU to 64-bit mode.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Octocontrabass wrote:You're building 64-bit code but you never switch the CPU to 64-bit mode.
Yes, I just haven't switched to 64-bit mode yet. But can I call C function before I switch to 64-bit mode?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Sorry to bother again, why can't i write anything to the

Post by Octocontrabass »

Only if you compile said C function into 32-bit code.

It's better to just switch the CPU to 64-bit mode. Don't waste your time trying to mix 32-bit and 64-bit code.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Octocontrabass wrote:Only if you compile said C function into 32-bit code.

It's better to just switch the CPU to 64-bit mode. Don't waste your time trying to mix 32-bit and 64-bit code.
OK, I will notice that. Thank you.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Octocontrabass wrote:Only if you compile said C function into 32-bit code.

It's better to just switch the CPU to 64-bit mode. Don't waste your time trying to mix 32-bit and 64-bit code.
Hi,
I have entered long mode, but I still can't write anything to VGA buffer. Can you help me? I have updated repo, you can check on there. Thank you.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Sorry to bother again, why can't i write anything to the

Post by Octocontrabass »

What does it do instead of writing to the VGA buffer? Triple fault and reboot? Looking at the code, it should triple fault and reboot.

This isn't going to work.

Neither will this.

And while I'm at it, EAX and EBX don't contain the Multiboot2 magic number or pointer to the Multiboot2 information at this point.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Octocontrabass wrote:What does it do instead of writing to the VGA buffer? Triple fault and reboot? Looking at the code, it should triple fault and reboot.

This isn't going to work.

Neither will this.

And while I'm at it, EAX and EBX don't contain the Multiboot2 magic number or pointer to the Multiboot2 information at this point.
So what should I do to map 2 MiB pages? I followed Philipp's tutorial, but with GAS syntax.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Sorry to bother again, why can't i write anything to the

Post by Octocontrabass »

You should fix your AT&T syntax. You forgot the $ prefix, so the assembler will interpret those labels as memory operands instead of immediate operands.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Octocontrabass wrote:You should fix your AT&T syntax. You forgot the $ prefix, so the assembler will interpret those labels as memory operands instead of immediate operands.
I have done like what you said. But it still triple fault.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Sorry to bother again, why can't i write anything to the

Post by Octocontrabass »

Maybe you should use a debugger and see if you can spot the problem that way? It'll probably be faster than asking here.

I think you're missing an instruction.
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Octocontrabass wrote:Maybe you should use a debugger and see if you can spot the problem that way? It'll probably be faster than asking here.

I think you're missing an instruction.
How stupid am I? I forgot to copy %eax back to %cr4, thank you! Now it's working normal. Sorry to bother you
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Hi,
After I fixed stupid bug (sorry to bother), there's more bug in my project. In kernel/video/vga/vga.c, there's a bug in __clrscr() but I can't find out what. Can anyone help me?
NeonLightions
Member
Member
Posts: 102
Joined: Wed Oct 20, 2021 6:00 pm
Location: Paraguay

Re: Sorry to bother again, why can't i write anything to the

Post by NeonLightions »

Thanks, another question: I can't write text with color, how may I fix it?
Post Reply