| It is currently Thu Sep 09, 2010 4:50 am |
|
All times are UTC |
Moderator: Andyhhp
|
Page 1 of 1 |
[ 10 posts ] |
| Print view | Previous topic | Next topic |
| Author | Message |
|---|---|
|
Joined: Sun Jan 24, 2010 2:20 pm Posts: 23 |
I hope I'm not asking you kind folks too many questions, and I hope it's not (for some reason) inappropriate to repost something from another forums.
Perhaps I celebrated too soon about my PE kernel and being "multiboot compliant". I thought everything was ok, and as far as I could originally tell it was. Grub booted the kernel with ease, and my kernel obviously had control of the system. So, I played around a bit and got it to clear the screen, change colors, print a couple chars to the screen, etc, and figured it was time to move on to some real implementations of the groundwork. Wrong. I soon discovered my basic I/O implementation was giving horrible results. If, let's say, I tried to print char* teststring = "Hello from the kernel!"; I would get some random junk like: sdf9087=!@^y654%$P .... (there was a LOT more, covering several lines, lol) So I wonder what the heck is wrong. I check and recheck the implementations, and can find no problems with the code. I even copy and paste them into a Win32 console application to try out, and it worked fine; as if I was using a regular standard library. THEN I become aware that only local variables actually exist at runtime. If I have a global variable and try to print it via VGA, Virtual PC again prints random junk. Mind you, at the local level inside a function printing a single character at a time works perfectly somehow. On Sun's Virtual Box, nothing is printed at all if I try to print a global char*/string. It's like they disappear into an unknown (void *). Then I got to thinking that maybe the way I've implemented the multi-boot code was bad, and causing data/resources to get chopped off during loading. So, I went to the only two online tutorials for this that I know exist: http://ksrenevasan.blogspot.com/ http://forum.osdev.org/viewtopic.php?f=1&t=21260 Following those and all their settings to the letter, I'm still plagued with the same problem. Random junk is written to the video buffer when you try to print a string, and global variables (anything outside the functions) doesn't exist at all -- and may result in more random junk. For ksrenevasan's PE/multi-boot tutorial, I discovered that changing: Code: ... dd(0x0010200F) ; load_end_addr dd(0x0010200F) ; bss_end_addr ... to: dd(0x001020FF) ; load_end_addr dd(0x001020FF) ; bss_end_addr ...Eliminates the issue with being totally unable to print an uncorrupted string. However, the same problem is still there in respect to only local variables working. I'm using Grub 0.97 and the stage2_eltorito loader, if it is of any significance. I'm going to be trying to solve this, and thoroughly (re-)reading all of the information available for both the PE format and multi-boot specifications. But I'm hoping someone at least knows what could be the issue with this or slap a bit of sense into me. Sorry for long question, but I wanted to be as clear as possible about my problem. Also, I kindly request that any suggestions to switch toolsets/formats/etc be withheld. The project is 100% 'academic' at this time, and the whole point (and requirement) is to use PE format and work in VS. ... If anyone can point me in the right direction for solving this, it may save loads of time for me. If not, I still appreciate your time! |
| Tue Feb 02, 2010 6:23 am |
|
|
Moderator
Joined: Tue Oct 23, 2007 10:05 am Posts: 311 Location: 127.0.0.1 |
What are you using to compile/link your program. You are almost certainly not formatting the .data or .r(o)data section at compile/link time, rather than getting corruption at runtime.
~Andrew _________________
|
| Tue Feb 02, 2010 4:03 pm |
|
|
Joined: Sun Jan 24, 2010 2:20 pm Posts: 23 |
Yup. I just realized further increasing the aforementioned numbers gets rid of the local vs global variable problem!
|
| Tue Feb 02, 2010 5:22 pm |
|
|
Moderator
Joined: Tue Oct 23, 2007 10:05 am Posts: 311 Location: 127.0.0.1 |
Once again, what compiler / linker are you using?
That is the most importent point. It sounds like you might not be making a "flat" file but I cant suggest anything untill I know what compiler/linker you are using. ~Andrew _________________
|
| Tue Feb 02, 2010 5:26 pm |
|
|
Joined: Sun Jan 24, 2010 2:20 pm Posts: 23 |
Oh, sorry. Visual Studio Pro 2008. Should be exactly the same as VC++ Express compiler & linker afaik.
|
| Tue Feb 02, 2010 6:00 pm |
|
|
Moderator
Joined: Tue Oct 23, 2007 10:05 am Posts: 311 Location: 127.0.0.1 |
Look in your .vsproj file.
Under <Tool Name="VCLinkerTool" you should have: BaseAddress="0x100000" //or whichever base address you choose RandomizeBaseAddress="0" FixedBaseAddress="1" Thats the first thing to check. ~Andrew _________________
|
| Tue Feb 02, 2010 6:05 pm |
|
|
Joined: Sun Jan 24, 2010 2:20 pm Posts: 23 |
Straight from the VCProj file:
Quote: BaseAddress="0x100000" RandomizedBaseAddress="0" FixedBaseAddress="1" It DOES boot and run without incident. But I'm quite convinced that something is wrong with the header itself and maybe the configuration (causing clipping/corruption of data resources on loading or even build-time). It doesn't even work if I follow those tutorials I linked to the letter. Really, I suppose that I need to get into some deeper information about the specification and get more intimate with the PE format. Then figure out how to properly make the header and build the kernel to deploy it. Another question I have now is whether or not "forcing" this PE to be multi-boot compliant is going to have any consequences/negative impacts I should be aware of. If there will be, maybe I could skirt around the issue by making a setup program in another multi-boot compliant format which then loads the kernel and executes it. Just not sure what I'll have to do to accomplish that or if it's truly necessary. Sorry, mind is racing around wildly a bit. |
| Tue Feb 02, 2010 6:26 pm |
|
|
Moderator
Joined: Tue Oct 23, 2007 10:05 am Posts: 311 Location: 127.0.0.1 |
can you post the code you used to make it multiboot complient?
_________________
|
| Tue Feb 02, 2010 6:48 pm |
|
|
Joined: Sun Jan 24, 2010 2:20 pm Posts: 23 |
I certainly can, but it will be a big space hog. First, I tried some ideas of my own, which failed. Then I tried the *exact* code and settings from these two tutorials I linked earlier:
http://ksrenevasan.blogspot.com/ http://forum.osdev.org/viewtopic.php?f=1&t=21260 I think you'll get a better idea from those links, since they list all the code and describe the settings to the T. But if you want me to post my own, exact copies for some reason, just let me know. I'm positive each test on their code was copied perfectly to the letter, including the settings. I also had my brother look at it and he agreed it's an exact copy. |
| Tue Feb 02, 2010 7:46 pm |
|
|
Joined: Sun Jan 24, 2010 2:20 pm Posts: 23 |
Yiiippeeee!
I'll be around if anyone has questions about how to do it or needs information. Thanks for all of your generous help thus far, even though you guys were a bit late on this one, heheh! Regards, |
| Thu Feb 04, 2010 3:10 pm |
|
|
Page 1 of 1 |
[ 10 posts ] |
Who is online |
Users browsing this forum: No registered users and 1 guest |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum |