Code: Select all
# Define the contnts of the Multiboot Header
.set MAGIC, 0xE85250D6
.set ARCH, 0
.set LENGTH, (multiboot_header_end - multiboot_header)
.set CHECKSUM, -(MAGIC + ARCH + LENGTH)
# Store the contents of the Multiboot header at the beginning of the file.
.section .multiboot
.align 8 # Align the section on the 64-bit boundary.
multiboot_header:
.long MAGIC
.long ARCH
.long LENGTH
.long CHECKSUM
multiboot_info_req:
.short 1
.short 0
.long (multiboot_info_req_end - multiboot_info_req)
.long 4
.long 6
multiboot_info_req_end:
.short 0
.short 0
.long 8
multiboot_header_end:
Code: Select all
#include <sys/sys.h>
#include <sys/multiboot2.h>
#include <kernel/tty.h>
#include <libc/stdio.h>
#include <stdint.h>
struct multiboot2_data {
multiboot_uint32_t totalSize;
multiboot_uint32_t reserved;
struct multiboot_tag_basic_meminfo memInfo;
struct multiboot_tag_mmap mmapInfo;
};
extern "C" void _main(struct multiboot2_data* mbd) {
gdt_install();
idt_install();
terminal_initialize();
terminal_writestring("Hello World! \n");
struct multiboot_tag_basic_meminfo memInfo = mbd->memInfo;
printf("Lower Memory: %x\n", memInfo.mem_lower);
printf("Version: 0.0.0.1d\n");
for(;;);
}
edit: And yes, I did remember to push %ebx.