i've just started trying to get some initial bootable kernel working via visual studio.
Im using grub as my boot loader, and i've followed the blog here:
http://ksrenevasan.blogspot.com/2005/10 ... using.html
i tried to boot the resulting exe in VMWare, and it error'ed something about a kernel stack fault.
So, i'm guessing it is one of my linker of compiler settings, not sure which though:
additional linker settings:
/Gd /Fm /TC
additional compiler settings:
/safeseh:no /filealign:0x1000 /base:0x100000 /map:Kernel.map /entry:__multiboot_entry__ /nodefaultlib:libc /subsystem:console
ideas?
visual studio - compiling and running kernel
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Can I make a point here?
I understand where you are coming from, you've dished out an insane amount of money for Visual Studio (and it's worth almost every cent). BUT... It was designed for the sole purpose of developing applications for Windows. AFAIK it is still possible to develop kernels in Visual Studio, but very difficult.
I suggest you use GCC.
I understand where you are coming from, you've dished out an insane amount of money for Visual Studio (and it's worth almost every cent). BUT... It was designed for the sole purpose of developing applications for Windows. AFAIK it is still possible to develop kernels in Visual Studio, but very difficult.
I suggest you use GCC.
- Kevin McGuire
- Member
- Posts: 843
- Joined: Tue Nov 09, 2004 12:00 am
- Location: United States
- Contact:
Just break the .text, .data, and I feel like it was one other section out by writting a MSDOS stub and handing it to the MSVC linker with the /STUB option. Just like a little mini boot loader, but it will be in protected mode when it runs.
Use a AOUT kludge for the multi boot header with the entry set two bytes after the MSDOS stub signature so that GRUB load the entire image with the PE32 and DLL header intact for the stub to relocate with.
You can even use the .reloc section. I think MSVC supports compiling to all sorts of processor architectures.
Microsoft Visual C++ Express Edition is free.
Use a AOUT kludge for the multi boot header with the entry set two bytes after the MSDOS stub signature so that GRUB load the entire image with the PE32 and DLL header intact for the stub to relocate with.
You can even use the .reloc section. I think MSVC supports compiling to all sorts of processor architectures.
Microsoft Visual C++ Express Edition is free.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Well, yeah... I use C++ Express Edition. I also have a copy of Visual Studio from back in '98...
IIRC the STUB option is to let you put in some code to run if MS-DOS can't run the program (ie. "The program you are trying to run cannot be run in MS-DOS mode"). Kevin McGuire is right - maybe if you put in some code there?
IIRC the STUB option is to let you put in some code to run if MS-DOS can't run the program (ie. "The program you are trying to run cannot be run in MS-DOS mode"). Kevin McGuire is right - maybe if you put in some code there?
- Kevin McGuire
- Member
- Posts: 843
- Joined: Tue Nov 09, 2004 12:00 am
- Location: United States
- Contact:
I know it works, because I did it a year or two ago. It actually worked quite well and I did not see any limitation to it except the extra step of having to relocate the sections appropriately.
There is another guy somewhere around this forum that is doing the same. He might be able to help out since I do not have MSVC handy to play with.
- Only Linux installed.
You just have to read the specification for the PE32 and PE32DLL header's in the image. Walk the fields until you find the sections. Then load each one where it specifies the virtual address. I think MSVC will not link a image lower than sixteen megabyte. Never the less I like to load my kernel at least above the sixteen megabyte mark any way.
Some people use a rebase utility, but I think it might be a waste of time when you can just load it above the sixteen megabyte mark.
The tutorial he has in the first post will work too, but it has some drawbacks I think. I am no expert on the tutorial he is using above.
I found the thread were I posted the zip containing the MSVC project zipped up where all you had to do was open it and start writing the kernel, but somehow the forum transfer went bad and dropped the file.
http://www.osdev.org/phpBB2/viewtopic.p ... 0&start=15
There is another guy somewhere around this forum that is doing the same. He might be able to help out since I do not have MSVC handy to play with.
- Only Linux installed.
You just have to read the specification for the PE32 and PE32DLL header's in the image. Walk the fields until you find the sections. Then load each one where it specifies the virtual address. I think MSVC will not link a image lower than sixteen megabyte. Never the less I like to load my kernel at least above the sixteen megabyte mark any way.
Some people use a rebase utility, but I think it might be a waste of time when you can just load it above the sixteen megabyte mark.
The tutorial he has in the first post will work too, but it has some drawbacks I think. I am no expert on the tutorial he is using above.
I found the thread were I posted the zip containing the MSVC project zipped up where all you had to do was open it and start writing the kernel, but somehow the forum transfer went bad and dropped the file.
http://www.osdev.org/phpBB2/viewtopic.p ... 0&start=15
-
- Posts: 3
- Joined: Sun Feb 25, 2007 4:56 am
Hi supagu,
im also writting multiboot kernel in MSVC..
but instead of writting multiboot header in code i have written a utility to make any pe executable multiboot compliant but they are certain restrictions.
1) Image Base == 0x100000
2) File Alignment == Section Alignment == 0x1000
3) Image must not be linked with any os dependent libraries
i.e. Standard C Library.
Image entry point must be of type
void ldr_main(multiboot_info* mb_info,unsigned long magic);
use these linker options for MSVC
add postbuild step in ur project like this
change kernel.exe to output file of linker
im attaching mbtool.exe with this thread.
hope this helps.
regards
Sidhant
im also writting multiboot kernel in MSVC..
but instead of writting multiboot header in code i have written a utility to make any pe executable multiboot compliant but they are certain restrictions.
1) Image Base == 0x100000
2) File Alignment == Section Alignment == 0x1000
3) Image must not be linked with any os dependent libraries
i.e. Standard C Library.
Image entry point must be of type
void ldr_main(multiboot_info* mb_info,unsigned long magic);
Code: Select all
additional linker settings:
/Gd /Fm /TC
additional compiler settings:
/safeseh:no /filealign:0x1000 /base:0x100000 /map:Kernel.map /entry:ldr_main /nodefaultlib:libc /subsystem:console
add postbuild step in ur project like this
Code: Select all
mbtool.exe kernel.exe
im attaching mbtool.exe with this thread.
hope this helps.
regards
Sidhant
- Attachments
-
- mbtool.zip
- (7.83 KiB) Downloaded 79 times