Page 2 of 2
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 8:34 am
by mrfrustrationman
Octocontrabass wrote:Code: Select all
objcopy -O binary -j .text kernel\kernel.out kernel\kernel.bin
Strings are usually stored in the .rodata section, but you're discarding everything except the .text section. Any particular reason you use objcopy here instead of passing "--oformat binary" to ld like the tutorial does?
if you mean using the "--oformat binary" in the ld cmd, it doesn't work, it gives the following error: "ld cannot perform pe operations on non pe output file 'kernel.bin'", and how do i include the .rodata section too?
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 8:46 am
by MichaelPetch
One other issue I see is that when you use objcopy you tell it to only include the `.text` section in the resulting binary. So if you properly link with `-Ttext 0x1000` nothing in any of your other sections will be emitted and likely that includes the string you want to print. Any reason you don't do:
Code: Select all
objcopy -O binary kernel\kernel.out kernel\kernel.bin
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 8:49 am
by MichaelPetch
It should be noted that for native windows applications (which is what your MinGW tool chain is generating) the read only data section is actually called .rdata instead of .rodata and it can be a number of sections that start with `.rdata` so it is more like `.rdata*`
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 8:49 am
by mrfrustrationman
MichaelPetch wrote:One other issue I see is that when you use objcopy you tell it to only include the `.text` section in the resulting binary. So if you properly link with `-Ttext 0x1000` nothing in any of your other sections will be emitted and likely that includes the string you want to print. Any reason you don't do:
Code: Select all
objcopy -O binary kernel\kernel.out kernel\kernel.bin
It worked!!! Thanks! It was the objcopy, this was giving me a headache since saturday!
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 8:56 am
by Octocontrabass
You might have an easier time if you use a proper cross-compiler, like everyone else does.
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
If you're not using Windows 10, or if you want something slightly more "native" to Windows, try
MSYS2. (The Windows version of QEMU works here.)
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 9:12 am
by MichaelPetch
Octocontrabass wrote:You might have an easier time if you use a proper cross-compiler, like everyone else does.
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
. I agree with you on the cross compiler. I had commented about that on Stackoverflow where this question was cross posted.
Getting X Windows working on WSL isn't too difficult. Download Xming X11 server from:
https://sourceforge.net/projects/xming/ . Then launch into a WSL prompt and modify ~/.bashrc by adding this line to the bottom:
. Exit out of the WSL shell and relaunch it. Then all you need to do is make sure the XMing server is running and the X11 output from WSL should appear. qemu should work as expected.
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 9:31 am
by mrfrustrationman
MichaelPetch wrote:Octocontrabass wrote:You might have an easier time if you use a proper cross-compiler, like everyone else does.
If you're using Windows 10, you might try installing WSL and build a cross-compiler there. (But it's tricky to get QEMU to launch from a build script, since you'd need to set up GUI support.)
. I agree with you on the cross compiler. I had commented about that on Stackoverflow where this question was cross posted.
Getting X Windows working on WSL isn't too difficult. Download Xming X11 server from:
https://sourceforge.net/projects/xming/ . Then launch into a WSL prompt and modify ~/.bashrc by adding this line to the bottom:
. Exit out of the WSL shell and relaunch it. Then all you need to do is make sure the XMing server is running and the X11 output from WSL should appear. qemu should work as expected.
Wich stackoverflow question? I posted this just here...
Re: My VGA driver prints garbage on screen
Posted: Mon Jun 15, 2020 10:05 am
by MichaelPetch
mrfrustrationman wrote:Wich stackoverflow question? I posted this just here...
I happened to ask if you were one in the same on the Stackoverflow question, but didn't get a response there. That question uses the same tutorial and had a problem with printing using the same vga driver, uses MinGW and BOCHS on Windows. That question was here:
https://stackoverflow.com/questions/623 ... y#62378540 . The output they were getting is an identical screenshot as to the one you posted here:
https://prnt.sc/szpyzt
Sorry if you are not the same person - you have my apologies. It is pretty coincidental that two users ask nearly the identical question in 48 hours. Maybe this is for a course and it was a classmate?
Re: My VGA driver prints garbage on screen
Posted: Wed Jun 17, 2020 5:52 pm
by asos
You can execute regular windows .exe programs through WSL, including both Bochs and QEMU. You just have to point to its path on the C: drive i.e
$> /mnt/c/Program\ Files/qemu/qemu-system-i386.exe -s -S -kernel myos.bin
So no need to try and get X to work