Page 1 of 2

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

Posted: Sun Dec 12, 2021 5:38 pm
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

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

Posted: Sun Dec 12, 2021 6:18 pm
by Octocontrabass
You're building 64-bit code but you never switch the CPU to 64-bit mode.

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

Posted: Sun Dec 12, 2021 6:19 pm
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?

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

Posted: Sun Dec 12, 2021 6:24 pm
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.

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

Posted: Sun Dec 12, 2021 6:28 pm
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.

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

Posted: Mon Dec 13, 2021 7:03 am
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.

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

Posted: Mon Dec 13, 2021 10:07 am
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.

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

Posted: Mon Dec 13, 2021 6:31 pm
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.

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

Posted: Mon Dec 13, 2021 8:03 pm
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.

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

Posted: Tue Dec 14, 2021 2:16 am
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.

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

Posted: Tue Dec 14, 2021 9:40 am
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.

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

Posted: Tue Dec 14, 2021 5:30 pm
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

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

Posted: Thu Dec 16, 2021 8:07 pm
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?

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

Posted: Thu Dec 16, 2021 8:33 pm
by Octocontrabass

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

Posted: Fri Dec 17, 2021 1:34 am
by NeonLightions
Thanks, another question: I can't write text with color, how may I fix it?