Visual Studio: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
m →‎Intrinsics: Fixed a typo in the example code given
→‎Bootloader Stuff:: Multiboot in VC++
Line 157: Line 157:


Another option is to use a separate linker such as [[WLink]] with a linker script such as the one found on the [[Watcom]] page.
Another option is to use a separate linker such as [[WLink]] with a linker script such as the one found on the [[Watcom]] page.

==== Multiboot ====
To be booted by GRUB, you can make your kernel multiboot. THis involves the embedding of a multiboot header in the first 8K of the image.
This can be done as follows:
<source lang="cpp">
//Entry point goes here

//The good ol' multiboot header
#pragma pack(push,1)
struct MULTIBOOT_HEADER {
uint32_t magic;
uint32_t flags;
uint32_t checksum;
uint32_t header_addr;
uint32_t load_addr;
uint32_t load_end_addr;
uint32_t bss_end_addr;
uint32_t entry_addr;
};
#pragma pack(pop)

#pragma code_seg(".a")
__declspec(align(4)) MULTIBOOT_HEADER header {
0x1BADB002,
0x10003,
-(0x1BADB002+0x10003),
(uint32_t)&header - BASE_ADDR + LOADBASE,
LOAD_BASE,
0,
0,
(uint32_t)&entry - BASE_ADDR + LOADBASE
};
</source>


=== The Rebase Utility: ===
=== The Rebase Utility: ===