fix: coding style

Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
This commit is contained in:
Julien CLEMENT 2021-07-12 17:55:13 +02:00
parent 7178dbb6a7
commit 3e881a6f33
11 changed files with 924 additions and 924 deletions

@ -24,32 +24,32 @@
#include "multiboot.h" #include "multiboot.h"
#define HEADER_FLAGS (MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO) #define HEADER_FLAGS (MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO)
#define STACK_SIZE 8192 #define STACK_SIZE 8192
.section .multiboot .section .multiboot
.type multiboot_header, @object .type multiboot_header, @object
multiboot_header: multiboot_header:
.align MULTIBOOT_HEADER_ALIGN .align MULTIBOOT_HEADER_ALIGN
.long MULTIBOOT_HEADER_MAGIC .long MULTIBOOT_HEADER_MAGIC
.long HEADER_FLAGS .long HEADER_FLAGS
.long -(MULTIBOOT_HEADER_MAGIC + HEADER_FLAGS) .long -(MULTIBOOT_HEADER_MAGIC + HEADER_FLAGS)
.size multiboot_header, . - multiboot_header .size multiboot_header, . - multiboot_header
.section .text .section .text
.global k_entry .global k_entry
.type k_entry, @function .type k_entry, @function
k_entry: k_entry:
lea end_stack, %esp lea end_stack, %esp
push %ebx /* multiboot info */ push %ebx /* multiboot info */
push %eax /* magic */ push %eax /* magic */
call k_main /* kernel entry point */ call k_main /* kernel entry point */
.Lend: .Lend:
jmp .Lend jmp .Lend
.size k_entry, . - k_entry .size k_entry, . - k_entry
.section .bss .section .bss
stack: stack:
.space STACK_SIZE .space STACK_SIZE
.align 16 .align 16
end_stack: end_stack:
.global end_stack .global end_stack

806
k/elf.h

File diff suppressed because it is too large Load Diff

18
k/io.h

@ -5,30 +5,30 @@
static inline void outb(u16 port, u8 val) static inline void outb(u16 port, u8 val)
{ {
asm volatile ("outb %0, %1" : /* No output */ : "a"(val), "d"(port)); asm volatile ("outb %0, %1" : /* No output */ : "a"(val), "d"(port));
} }
static inline u8 inb(u16 port) static inline u8 inb(u16 port)
{ {
u8 res; u8 res;
asm volatile ("inb %1, %0" : "=&a"(res) : "d"(port)); asm volatile ("inb %1, %0" : "=&a"(res) : "d"(port));
return res; return res;
} }
static inline void outw(u16 port, u16 val) static inline void outw(u16 port, u16 val)
{ {
asm volatile ("outw %0, %1" : /* No output */ : "a"(val), "d"(port)); asm volatile ("outw %0, %1" : /* No output */ : "a"(val), "d"(port));
} }
static inline u16 inw(u16 port) static inline u16 inw(u16 port)
{ {
u16 res; u16 res;
asm volatile ("inw %1, %0" : "=&a"(res) : "d"(port)); asm volatile ("inw %1, %0" : "=&a"(res) : "d"(port));
return res; return res;
} }
#endif /* !IO_H_ */ #endif /* !IO_H_ */

18
k/k.c

@ -28,16 +28,16 @@
void k_main(unsigned long magic, multiboot_info_t *info) void k_main(unsigned long magic, multiboot_info_t *info)
{ {
(void)magic; (void)magic;
(void)info; (void)info;
char star[4] = "|/-\\"; char star[4] = "|/-\\";
char *fb = (void *)0xb8000; char *fb = (void *)0xb8000;
for (unsigned i = 0; ; ) { for (unsigned i = 0; ; ) {
*fb = star[i++ % 4]; *fb = star[i++ % 4];
} }
for (;;) for (;;)
asm volatile ("hlt"); asm volatile ("hlt");
} }

@ -36,44 +36,44 @@ static unsigned char libvga_txt_mode_font[320 * 200];
** Registers value for graphic mode. ** Registers value for graphic mode.
*/ */
static unsigned char libvga_regs_320x200x256[] = { static unsigned char libvga_regs_320x200x256[] = {
/* MISC */ /* MISC */
0x63, 0x63,
/* SEQ */ /* SEQ */
0x03, 0x01, 0x0F, 0x00, 0x0E, 0x03, 0x01, 0x0F, 0x00, 0x0E,
/* CRTC */ /* CRTC */
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F,
0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3,
0xFF, 0xFF,
/* GC */ /* GC */
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
0xFF, 0xFF,
/* AC */ /* AC */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x41, 0x00, 0x0F, 0x00, 0x00 0x41, 0x00, 0x0F, 0x00, 0x00
}; };
/* /*
** Registers value for basic text mode. ** Registers value for basic text mode.
*/ */
static unsigned char libvga_regs_80x25xtext[] = { static unsigned char libvga_regs_80x25xtext[] = {
/* MISC */ /* MISC */
0x67, 0x67,
/* SEQ */ /* SEQ */
0x03, 0x00, 0x03, 0x00, 0x02, 0x03, 0x00, 0x03, 0x00, 0x02,
/* CRTC */ /* CRTC */
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F,
0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50, 0x00, 0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x50,
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3,
0xFF, 0xFF,
/* GC */ /* GC */
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0E, 0x00,
0xFF, 0xFF,
/* AC */ /* AC */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x0C, 0x00, 0x0F, 0x08, 0x00 0x0C, 0x00, 0x0F, 0x08, 0x00
}; };
/* /*
@ -81,171 +81,171 @@ static unsigned char libvga_regs_80x25xtext[] = {
** This palette is automatically loaded when switching to mode 13h ** This palette is automatically loaded when switching to mode 13h
*/ */
static unsigned int libvga_default_palette[256] = { static unsigned int libvga_default_palette[256] = {
0x0, 0x800000, 0x8000, 0x808000, 0x0, 0x800000, 0x8000, 0x808000,
0x80, 0x800080, 0x8080, 0xc0c0c0, 0x80, 0x800080, 0x8080, 0xc0c0c0,
0xc0dcc0, 0xa6caf0, 0x402000, 0x602000, 0xc0dcc0, 0xa6caf0, 0x402000, 0x602000,
0x802000, 0xa02000, 0xc02000, 0xe02000, 0x802000, 0xa02000, 0xc02000, 0xe02000,
0x4000, 0x204000, 0x404000, 0x604000, 0x4000, 0x204000, 0x404000, 0x604000,
0x804000, 0xa04000, 0xc04000, 0xe04000, 0x804000, 0xa04000, 0xc04000, 0xe04000,
0x6000, 0x206000, 0x406000, 0x606000, 0x6000, 0x206000, 0x406000, 0x606000,
0x806000, 0xa06000, 0xc06000, 0xe06000, 0x806000, 0xa06000, 0xc06000, 0xe06000,
0x8000, 0x208000, 0x408000, 0x608000, 0x8000, 0x208000, 0x408000, 0x608000,
0x808000, 0xa08000, 0xc08000, 0xe08000, 0x808000, 0xa08000, 0xc08000, 0xe08000,
0xa000, 0x20a000, 0x40a000, 0x60a000, 0xa000, 0x20a000, 0x40a000, 0x60a000,
0x80a000, 0xa0a000, 0xc0a000, 0xe0a000, 0x80a000, 0xa0a000, 0xc0a000, 0xe0a000,
0xc000, 0x20c000, 0x40c000, 0x60c000, 0xc000, 0x20c000, 0x40c000, 0x60c000,
0x80c000, 0xa0c000, 0xc0c000, 0xe0c000, 0x80c000, 0xa0c000, 0xc0c000, 0xe0c000,
0xe000, 0x20e000, 0x40e000, 0x60e000, 0xe000, 0x20e000, 0x40e000, 0x60e000,
0x80e000, 0xa0e000, 0xc0e000, 0xe0e000, 0x80e000, 0xa0e000, 0xc0e000, 0xe0e000,
0x40, 0x200040, 0x400040, 0x600040, 0x40, 0x200040, 0x400040, 0x600040,
0x800040, 0xa00040, 0xc00040, 0xe00040, 0x800040, 0xa00040, 0xc00040, 0xe00040,
0x2040, 0x202040, 0x402040, 0x602040, 0x2040, 0x202040, 0x402040, 0x602040,
0x802040, 0xa02040, 0xc02040, 0xe02040, 0x802040, 0xa02040, 0xc02040, 0xe02040,
0x4040, 0x204040, 0x404040, 0x604040, 0x4040, 0x204040, 0x404040, 0x604040,
0x804040, 0xa04040, 0xc04040, 0xe04040, 0x804040, 0xa04040, 0xc04040, 0xe04040,
0x6040, 0x206040, 0x406040, 0x606040, 0x6040, 0x206040, 0x406040, 0x606040,
0x806040, 0xa06040, 0xc06040, 0xe06040, 0x806040, 0xa06040, 0xc06040, 0xe06040,
0x8040, 0x208040, 0x408040, 0x608040, 0x8040, 0x208040, 0x408040, 0x608040,
0x808040, 0xa08040, 0xc08040, 0xe08040, 0x808040, 0xa08040, 0xc08040, 0xe08040,
0xa040, 0x20a040, 0x40a040, 0x60a040, 0xa040, 0x20a040, 0x40a040, 0x60a040,
0x80a040, 0xa0a040, 0xc0a040, 0xe0a040, 0x80a040, 0xa0a040, 0xc0a040, 0xe0a040,
0xc040, 0x20c040, 0x40c040, 0x60c040, 0xc040, 0x20c040, 0x40c040, 0x60c040,
0x80c040, 0xa0c040, 0xc0c040, 0xe0c040, 0x80c040, 0xa0c040, 0xc0c040, 0xe0c040,
0xe040, 0x20e040, 0x40e040, 0x60e040, 0xe040, 0x20e040, 0x40e040, 0x60e040,
0x80e040, 0xa0e040, 0xc0e040, 0xe0e040, 0x80e040, 0xa0e040, 0xc0e040, 0xe0e040,
0x80, 0x200080, 0x400080, 0x600080, 0x80, 0x200080, 0x400080, 0x600080,
0x800080, 0xa00080, 0xc00080, 0xe00080, 0x800080, 0xa00080, 0xc00080, 0xe00080,
0x2080, 0x202080, 0x402080, 0x602080, 0x2080, 0x202080, 0x402080, 0x602080,
0x802080, 0xa02080, 0xc02080, 0xe02080, 0x802080, 0xa02080, 0xc02080, 0xe02080,
0x4080, 0x204080, 0x404080, 0x604080, 0x4080, 0x204080, 0x404080, 0x604080,
0x804080, 0xa04080, 0xc04080, 0xe04080, 0x804080, 0xa04080, 0xc04080, 0xe04080,
0x6080, 0x206080, 0x406080, 0x606080, 0x6080, 0x206080, 0x406080, 0x606080,
0x806080, 0xa06080, 0xc06080, 0xe06080, 0x806080, 0xa06080, 0xc06080, 0xe06080,
0x8080, 0x208080, 0x408080, 0x608080, 0x8080, 0x208080, 0x408080, 0x608080,
0x808080, 0xa08080, 0xc08080, 0xe08080, 0x808080, 0xa08080, 0xc08080, 0xe08080,
0xa080, 0x20a080, 0x40a080, 0x60a080, 0xa080, 0x20a080, 0x40a080, 0x60a080,
0x80a080, 0xa0a080, 0xc0a080, 0xe0a080, 0x80a080, 0xa0a080, 0xc0a080, 0xe0a080,
0xc080, 0x20c080, 0x40c080, 0x60c080, 0xc080, 0x20c080, 0x40c080, 0x60c080,
0x80c080, 0xa0c080, 0xc0c080, 0xe0c080, 0x80c080, 0xa0c080, 0xc0c080, 0xe0c080,
0xe080, 0x20e080, 0x40e080, 0x60e080, 0xe080, 0x20e080, 0x40e080, 0x60e080,
0x80e080, 0xa0e080, 0xc0e080, 0xe0e080, 0x80e080, 0xa0e080, 0xc0e080, 0xe0e080,
0xc0, 0x2000c0, 0x4000c0, 0x6000c0, 0xc0, 0x2000c0, 0x4000c0, 0x6000c0,
0x8000c0, 0xa000c0, 0xc000c0, 0xe000c0, 0x8000c0, 0xa000c0, 0xc000c0, 0xe000c0,
0x20c0, 0x2020c0, 0x4020c0, 0x6020c0, 0x20c0, 0x2020c0, 0x4020c0, 0x6020c0,
0x8020c0, 0xa020c0, 0xc020c0, 0xe020c0, 0x8020c0, 0xa020c0, 0xc020c0, 0xe020c0,
0x40c0, 0x2040c0, 0x4040c0, 0x6040c0, 0x40c0, 0x2040c0, 0x4040c0, 0x6040c0,
0x8040c0, 0xa040c0, 0xc040c0, 0xe040c0, 0x8040c0, 0xa040c0, 0xc040c0, 0xe040c0,
0x60c0, 0x2060c0, 0x4060c0, 0x6060c0, 0x60c0, 0x2060c0, 0x4060c0, 0x6060c0,
0x8060c0, 0xa060c0, 0xc060c0, 0xe060c0, 0x8060c0, 0xa060c0, 0xc060c0, 0xe060c0,
0x80c0, 0x2080c0, 0x4080c0, 0x6080c0, 0x80c0, 0x2080c0, 0x4080c0, 0x6080c0,
0x8080c0, 0xa080c0, 0xc080c0, 0xe080c0, 0x8080c0, 0xa080c0, 0xc080c0, 0xe080c0,
0xa0c0, 0x20a0c0, 0x40a0c0, 0x60a0c0, 0xa0c0, 0x20a0c0, 0x40a0c0, 0x60a0c0,
0x80a0c0, 0xa0a0c0, 0xc0a0c0, 0xe0a0c0, 0x80a0c0, 0xa0a0c0, 0xc0a0c0, 0xe0a0c0,
0xc0c0, 0x20c0c0, 0x40c0c0, 0x60c0c0, 0xc0c0, 0x20c0c0, 0x40c0c0, 0x60c0c0,
0x80c0c0, 0xa0c0c0, 0xfffbf0, 0xa0a0a4, 0x80c0c0, 0xa0c0c0, 0xfffbf0, 0xa0a0a4,
0x808080, 0xff0000, 0xff00, 0xffff00, 0x808080, 0xff0000, 0xff00, 0xffff00,
0xff, 0xff00ff, 0xffff, 0xffffff 0xff, 0xff00ff, 0xffff, 0xffffff
}; };
static void libvga_write_regs(unsigned char *regs) static void libvga_write_regs(unsigned char *regs)
{ {
unsigned int i; unsigned int i;
unsigned int a; unsigned int a;
/* write the MISC register */ /* write the MISC register */
outb(VGA_MISC_WRITE, *regs); outb(VGA_MISC_WRITE, *regs);
regs++; regs++;
/* write SEQ registers */ /* write SEQ registers */
for (i = 0; i < VGA_NUM_SEQ_REGS; i++) { for (i = 0; i < VGA_NUM_SEQ_REGS; i++) {
outb(VGA_SEQ_INDEX, i); outb(VGA_SEQ_INDEX, i);
outb(VGA_SEQ_DATA, *regs); outb(VGA_SEQ_DATA, *regs);
regs++; regs++;
} }
/* write CRTC registers */ /* write CRTC registers */
outb(VGA_CRTC_INDEX, 0x03); outb(VGA_CRTC_INDEX, 0x03);
a = inb(VGA_CRTC_DATA); a = inb(VGA_CRTC_DATA);
outb(VGA_CRTC_DATA, a | 0x80); outb(VGA_CRTC_DATA, a | 0x80);
outb(VGA_CRTC_INDEX, 0x11); outb(VGA_CRTC_INDEX, 0x11);
a = inb(VGA_CRTC_DATA); a = inb(VGA_CRTC_DATA);
outb(VGA_CRTC_DATA, a & ~0x80); outb(VGA_CRTC_DATA, a & ~0x80);
regs[0x03] |= 0x80; regs[0x03] |= 0x80;
regs[0x11] &= ~0x80; regs[0x11] &= ~0x80;
for (i = 0; i < VGA_NUM_CRTC_REGS; i++) { for (i = 0; i < VGA_NUM_CRTC_REGS; i++) {
outb(VGA_CRTC_INDEX, i); outb(VGA_CRTC_INDEX, i);
outb(VGA_CRTC_DATA, *regs); outb(VGA_CRTC_DATA, *regs);
regs++; regs++;
} }
/* write GC registers */ /* write GC registers */
for (i = 0; i < VGA_NUM_GC_REGS; i++) { for (i = 0; i < VGA_NUM_GC_REGS; i++) {
outb(VGA_GC_INDEX, i); outb(VGA_GC_INDEX, i);
outb(VGA_GC_DATA, *regs); outb(VGA_GC_DATA, *regs);
regs++; regs++;
} }
/* write AC registers */ /* write AC registers */
inb(VGA_INSTAT_READ); inb(VGA_INSTAT_READ);
for (i = 0; i < VGA_NUM_AC_REGS; i++) { for (i = 0; i < VGA_NUM_AC_REGS; i++) {
outb(VGA_AC_INDEX, i); outb(VGA_AC_INDEX, i);
outb(VGA_AC_WRITE, *regs); outb(VGA_AC_WRITE, *regs);
regs++; regs++;
} }
inb(VGA_INSTAT_READ); inb(VGA_INSTAT_READ);
outb(VGA_AC_INDEX, 0x20); outb(VGA_AC_INDEX, 0x20);
/* write the default palette to the DAC */ /* write the default palette to the DAC */
outb(VGA_DAC_MASK, 0xFF); outb(VGA_DAC_MASK, 0xFF);
libvga_set_palette(libvga_default_palette, array_size(libvga_default_palette)); libvga_set_palette(libvga_default_palette, array_size(libvga_default_palette));
} }
void libvga_set_palette(unsigned int *new_palette, size_t size) void libvga_set_palette(unsigned int *new_palette, size_t size)
{ {
outb(VGA_DAC_WRITE_INDEX, 0); outb(VGA_DAC_WRITE_INDEX, 0);
for (size_t i = 0; i < size; i++) { for (size_t i = 0; i < size; i++) {
outb(VGA_DAC_DATA, ((new_palette[i] >> 16) >> 2) & 0xFF); outb(VGA_DAC_DATA, ((new_palette[i] >> 16) >> 2) & 0xFF);
outb(VGA_DAC_DATA, ((new_palette[i] >> 8) >> 2) & 0xFF); outb(VGA_DAC_DATA, ((new_palette[i] >> 8) >> 2) & 0xFF);
outb(VGA_DAC_DATA, ((new_palette[i]) >> 2) & 0xFF); outb(VGA_DAC_DATA, ((new_palette[i]) >> 2) & 0xFF);
} }
} }
char *libvga_get_framebuffer(void) char *libvga_get_framebuffer(void)
{ {
unsigned int mmap_select; unsigned int mmap_select;
outb(VGA_GC_INDEX, 6); outb(VGA_GC_INDEX, 6);
mmap_select = inb(VGA_GC_DATA); mmap_select = inb(VGA_GC_DATA);
mmap_select >>= 2; mmap_select >>= 2;
mmap_select &= 3; mmap_select &= 3;
switch (mmap_select) { switch (mmap_select) {
case 0: case 0:
case 1: case 1:
return (char *)0xA0000; return (char *)0xA0000;
case 2: case 2:
return (char *)0xB0000; return (char *)0xB0000;
case 3: case 3:
return (char *)0xB8000; return (char *)0xB8000;
} }
return (char *)0; return (char *)0;
} }
void libvga_switch_mode13h(void) void libvga_switch_mode13h(void)
{ {
libvga_write_regs(libvga_regs_320x200x256); libvga_write_regs(libvga_regs_320x200x256);
// plane 2 is now map in the memory, save it // plane 2 is now map in the memory, save it
char *vram = libvga_get_framebuffer(); char *vram = libvga_get_framebuffer();
for (size_t i = 0; i < array_size(libvga_txt_mode_font); i++) for (size_t i = 0; i < array_size(libvga_txt_mode_font); i++)
libvga_txt_mode_font[i] = vram[i]; libvga_txt_mode_font[i] = vram[i];
} }
void libvga_switch_mode3h(void) void libvga_switch_mode3h(void)
{ {
// restore the VGA plane 2 to the text font // restore the VGA plane 2 to the text font
char *vram = libvga_get_framebuffer(); char *vram = libvga_get_framebuffer();
for (size_t i = 0; i < array_size(libvga_txt_mode_font); i++) for (size_t i = 0; i < array_size(libvga_txt_mode_font); i++)
vram[i] = libvga_txt_mode_font[i]; vram[i] = libvga_txt_mode_font[i];
libvga_write_regs(libvga_regs_80x25xtext); libvga_write_regs(libvga_regs_80x25xtext);
} }

@ -26,28 +26,28 @@
#include <stddef.h> #include <stddef.h>
#define VGA_AC_INDEX 0x3C0 #define VGA_AC_INDEX 0x3C0
#define VGA_AC_WRITE 0x3C0 #define VGA_AC_WRITE 0x3C0
#define VGA_AC_READ 0x3C1 #define VGA_AC_READ 0x3C1
#define VGA_MISC_WRITE 0x3C2 #define VGA_MISC_WRITE 0x3C2
#define VGA_SEQ_INDEX 0x3C4 #define VGA_SEQ_INDEX 0x3C4
#define VGA_SEQ_DATA 0x3C5 #define VGA_SEQ_DATA 0x3C5
#define VGA_DAC_MASK 0x3C6 #define VGA_DAC_MASK 0x3C6
#define VGA_DAC_READ_INDEX 0x3C7 #define VGA_DAC_READ_INDEX 0x3C7
#define VGA_DAC_WRITE_INDEX 0x3C8 #define VGA_DAC_WRITE_INDEX 0x3C8
#define VGA_DAC_DATA 0x3C9 #define VGA_DAC_DATA 0x3C9
#define VGA_MISC_READ 0x3CC #define VGA_MISC_READ 0x3CC
#define VGA_GC_INDEX 0x3CE #define VGA_GC_INDEX 0x3CE
#define VGA_GC_DATA 0x3CF #define VGA_GC_DATA 0x3CF
#define VGA_CRTC_INDEX 0x3D4 #define VGA_CRTC_INDEX 0x3D4
#define VGA_CRTC_DATA 0x3D5 #define VGA_CRTC_DATA 0x3D5
#define VGA_INSTAT_READ 0x3DA #define VGA_INSTAT_READ 0x3DA
#define VGA_NUM_SEQ_REGS 5 #define VGA_NUM_SEQ_REGS 5
#define VGA_NUM_CRTC_REGS 25 #define VGA_NUM_CRTC_REGS 25
#define VGA_NUM_GC_REGS 9 #define VGA_NUM_GC_REGS 9
#define VGA_NUM_AC_REGS 21 #define VGA_NUM_AC_REGS 21
void libvga_set_palette(unsigned int *new_palette, size_t size); void libvga_set_palette(unsigned int *new_palette, size_t size);
@ -57,4 +57,4 @@ void libvga_switch_mode13h(void);
void libvga_switch_mode3h(void); void libvga_switch_mode3h(void);
#endif /* !LIBVGA_H */ #endif /* !LIBVGA_H */

@ -7,27 +7,27 @@
void list_init(struct list *list) void list_init(struct list *list)
{ {
list->prev = list; list->prev = list;
list->next = list; list->next = list;
} }
void list_insert(struct list *list, struct list *elm) void list_insert(struct list *list, struct list *elm)
{ {
elm->prev = list; elm->prev = list;
elm->next = list->next; elm->next = list->next;
list->next = elm; list->next = elm;
elm->next->prev = elm; elm->next->prev = elm;
} }
void list_remove(struct list *elm) void list_remove(struct list *elm)
{ {
elm->prev->next = elm->next; elm->prev->next = elm->next;
elm->next->prev = elm->prev; elm->next->prev = elm->prev;
elm->next = NULL; elm->next = NULL;
elm->prev = NULL; elm->prev = NULL;
} }
int list_empty(const struct list *list) int list_empty(const struct list *list)
{ {
return list->next == list; return list->next == list;
} }

@ -9,8 +9,8 @@
*/ */
struct list { struct list {
struct list *prev; struct list *prev;
struct list *next; struct list *next;
}; };
void list_init(struct list *list); void list_init(struct list *list);
@ -18,24 +18,24 @@ void list_insert(struct list *list, struct list *elm);
void list_remove(struct list *elm); void list_remove(struct list *elm);
int list_empty(const struct list *list); int list_empty(const struct list *list);
#define container_of(ptr, type, member) \ #define container_of(ptr, type, member) \
(__typeof__(type) *)((char *)(ptr) - \ (__typeof__(type) *)((char *)(ptr) - \
offsetof(__typeof__(type), member)) offsetof(__typeof__(type), member))
#define list_first_entry(head, pos, member) \ #define list_first_entry(head, pos, member) \
container_of((head)->next, __typeof__(*pos), member) container_of((head)->next, __typeof__(*pos), member)
#define list_for_each(pos, head, member) \ #define list_for_each(pos, head, member) \
for (pos = 0, pos = list_first_entry(head, pos, member); \ for (pos = 0, pos = list_first_entry(head, pos, member); \
&pos->member != (head); \ &pos->member != (head); \
pos = list_first_entry(&pos->member, pos, member)) pos = list_first_entry(&pos->member, pos, member))
#define list_for_each_safe(pos, tmp, head, member) \ #define list_for_each_safe(pos, tmp, head, member) \
for (pos = 0, tmp = 0, \ for (pos = 0, tmp = 0, \
pos = list_first_entry(head, pos, member), \ pos = list_first_entry(head, pos, member), \
tmp = list_first_entry(&pos->member, tmp, member); \ tmp = list_first_entry(&pos->member, tmp, member); \
&pos->member != (head); \ &pos->member != (head); \
pos = tmp, \ pos = tmp, \
tmp = list_first_entry(&pos->member, tmp, member)) tmp = list_first_entry(&pos->member, tmp, member))
#endif /* LIST_H */ #endif /* LIST_H */

@ -12,256 +12,256 @@ static void *__cache_alloc(struct cache *cache, int in_extend);
static void cache_initialize(struct cache *c, void *p, size_t sz, size_t bsize) static void cache_initialize(struct cache *c, void *p, size_t sz, size_t bsize)
{ {
list_init(&c->freelist); list_init(&c->freelist);
list_init(&c->caches); list_init(&c->caches);
c->base = p; c->base = p;
c->size = sz; c->size = sz;
c->bsize = bsize; c->bsize = bsize;
for (size_t i = 0; i < sz / bsize; ++i) { for (size_t i = 0; i < sz / bsize; ++i) {
struct list *l = (struct list *)((char *) p + i * bsize); struct list *l = (struct list *)((char *) p + i * bsize);
list_init(l); list_init(l);
list_insert(c->freelist.prev, l); list_insert(c->freelist.prev, l);
} }
} }
static void cache_extend(struct cache *old, void *p, size_t sz, size_t bsize, int in_extend) static void cache_extend(struct cache *old, void *p, size_t sz, size_t bsize, int in_extend)
{ {
struct cache *c = __cache_alloc(metadata_cache, in_extend); struct cache *c = __cache_alloc(metadata_cache, in_extend);
cache_initialize(c, p, sz, bsize); cache_initialize(c, p, sz, bsize);
list_insert(old->caches.prev, &c->caches); list_insert(old->caches.prev, &c->caches);
} }
struct cache *cache_new(void *base, size_t nmemb, size_t bsize) struct cache *cache_new(void *base, size_t nmemb, size_t bsize)
{ {
struct cache *c = cache_alloc(metadata_cache); struct cache *c = cache_alloc(metadata_cache);
cache_initialize(c, base, nmemb * bsize, bsize); cache_initialize(c, base, nmemb * bsize, bsize);
return c; return c;
} }
static size_t freelist_size(struct cache *cache) static size_t freelist_size(struct cache *cache)
{ {
if (list_empty(&cache->freelist)) if (list_empty(&cache->freelist))
return 0; return 0;
size_t len = 1; size_t len = 1;
struct list *l = cache->freelist.next; struct list *l = cache->freelist.next;
for (; l != &cache->freelist; l = l->next) { for (; l != &cache->freelist; l = l->next) {
len++; len++;
} }
return len; return len;
} }
static size_t cache_remaining(struct cache *cache) static size_t cache_remaining(struct cache *cache)
{ {
size_t len = freelist_size(cache); size_t len = freelist_size(cache);
struct cache *c; struct cache *c;
list_for_each(c, &cache->caches, caches) { list_for_each(c, &cache->caches, caches) {
len += freelist_size(c); len += freelist_size(c);
} }
return len; return len;
} }
static void *__cache_alloc(struct cache *cache, int in_extend) static void *__cache_alloc(struct cache *cache, int in_extend)
{ {
try_alloc: try_alloc:
if (!list_empty(&cache->freelist)) { if (!list_empty(&cache->freelist)) {
struct list *l = cache->freelist.next; struct list *l = cache->freelist.next;
list_remove(l); list_remove(l);
return (void *)l; return (void *)l;
} }
struct cache *c; struct cache *c;
list_for_each(c, &cache->caches, caches) { list_for_each(c, &cache->caches, caches) {
if (!list_empty(&c->freelist)) { if (!list_empty(&c->freelist)) {
return cache_alloc(c); return cache_alloc(c);
} }
} }
if (cache_remaining(metadata_cache) <= 2 && !in_extend) { if (cache_remaining(metadata_cache) <= 2 && !in_extend) {
void *p = __memory_reserve_ex(0, metadata_cache->size, 1); void *p = __memory_reserve_ex(0, metadata_cache->size, 1);
cache_extend(metadata_cache, p, cache_extend(metadata_cache, p,
metadata_cache->size, metadata_cache->size,
metadata_cache->bsize, 1); metadata_cache->bsize, 1);
} }
void *p = memory_reserve(c->size); void *p = memory_reserve(c->size);
cache_extend(c, p, c->size, c->bsize, 0); cache_extend(c, p, c->size, c->bsize, 0);
goto try_alloc; goto try_alloc;
} }
void *cache_alloc(struct cache *cache) void *cache_alloc(struct cache *cache)
{ {
return __cache_alloc(cache, 0); return __cache_alloc(cache, 0);
} }
static int cache_try_free(struct cache *cache, void *ptr) static int cache_try_free(struct cache *cache, void *ptr)
{ {
if ((size_t)cache->base <= (size_t)ptr if ((size_t)cache->base <= (size_t)ptr
&& (size_t)cache->base + cache->size > (size_t)ptr) { && (size_t)cache->base + cache->size > (size_t)ptr) {
list_init(ptr); list_init(ptr);
list_insert(&cache->freelist, ptr); list_insert(&cache->freelist, ptr);
return 1; return 1;
} }
return 0; return 0;
} }
void cache_free(struct cache *cache, void *ptr) void cache_free(struct cache *cache, void *ptr)
{ {
if (cache_try_free(cache, ptr)) { if (cache_try_free(cache, ptr)) {
return; return;
} }
struct cache *c; struct cache *c;
list_for_each(c, &cache->caches, caches) { list_for_each(c, &cache->caches, caches) {
if (cache_try_free(c, ptr)) { if (cache_try_free(c, ptr)) {
return; return;
} }
} }
/* FIXME: handle the case when the pointer does not belong to the cache */ /* FIXME: handle the case when the pointer does not belong to the cache */
} }
static void memory_initialize(struct memory_map *m, static void memory_initialize(struct memory_map *m,
unsigned addr, unsigned size, int type) unsigned addr, unsigned size, int type)
{ {
list_init(&m->list); list_init(&m->list);
m->base_addr = addr; m->base_addr = addr;
m->size = size; m->size = size;
m->type = type; m->type = type;
} }
void memory_dump() void memory_dump()
{ {
struct memory_map *m; struct memory_map *m;
list_for_each(m, &memory_map, list) { list_for_each(m, &memory_map, list) {
printf("{.base_addr=%p, .length=0x%x, .type=%u}\n", printf("{.base_addr=%p, .length=0x%x, .type=%u}\n",
m->base_addr, m->size, m->type); m->base_addr, m->size, m->type);
} }
} }
extern void *_end[]; /* kernel data end address */ extern void *_end[]; /* kernel data end address */
#define BASE_METADATA_CACHE_NMEMB 10 #define BASE_METADATA_CACHE_NMEMB 10
void memory_init(multiboot_info_t *info) void memory_init(multiboot_info_t *info)
{ {
unsigned int last_loaded_addr = info->mods_count unsigned int last_loaded_addr = info->mods_count
? ((multiboot_module_t *)info->mods_addr)[info->mods_count - 1].mod_end ? ((multiboot_module_t *)info->mods_addr)[info->mods_count - 1].mod_end
: 0; : 0;
if (last_loaded_addr < (u32)_end) { if (last_loaded_addr < (u32)_end) {
last_loaded_addr = (u32)_end; /* XXX: needs to align up */ last_loaded_addr = (u32)_end; /* XXX: needs to align up */
} }
/* take the first good memory region */ /* take the first good memory region */
unsigned int reservation_addr = last_loaded_addr; unsigned int reservation_addr = last_loaded_addr;
unsigned int reservation_len = (BASE_METADATA_CACHE_NMEMB + 1) * sizeof(struct cache); unsigned int reservation_len = (BASE_METADATA_CACHE_NMEMB + 1) * sizeof(struct cache);
unsigned int num_mem_zone = info->mmap_length / sizeof(multiboot_memory_map_t); unsigned int num_mem_zone = info->mmap_length / sizeof(multiboot_memory_map_t);
metadata_cache = (void *)reservation_addr; metadata_cache = (void *)reservation_addr;
cache_initialize(metadata_cache, metadata_cache + 1, BASE_METADATA_CACHE_NMEMB * sizeof(struct cache), cache_initialize(metadata_cache, metadata_cache + 1, BASE_METADATA_CACHE_NMEMB * sizeof(struct cache),
sizeof(struct cache)); sizeof(struct cache));
memory_map_cache = cache_new((void *)(reservation_addr + reservation_len), memory_map_cache = cache_new((void *)(reservation_addr + reservation_len),
num_mem_zone * 2, sizeof(struct memory_map)); num_mem_zone * 2, sizeof(struct memory_map));
reservation_len += num_mem_zone * 2 * sizeof(struct memory_map); reservation_len += num_mem_zone * 2 * sizeof(struct memory_map);
multiboot_memory_map_t *map = (void *)info->mmap_addr; multiboot_memory_map_t *map = (void *)info->mmap_addr;
for (size_t i = 0; i < num_mem_zone; ++i) { for (size_t i = 0; i < num_mem_zone; ++i) {
struct memory_map *m = cache_alloc(memory_map_cache); struct memory_map *m = cache_alloc(memory_map_cache);
memory_initialize(m, (u32)map[i].addr, (u32)map[i].len, memory_initialize(m, (u32)map[i].addr, (u32)map[i].len,
map[i].type - 1); map[i].type - 1);
list_insert(memory_map.prev, &m->list); list_insert(memory_map.prev, &m->list);
} }
/* reserve all low memory to avoid overwriting grub data */ /* reserve all low memory to avoid overwriting grub data */
memory_reserve_ex(0, info->mem_lower * 1024); memory_reserve_ex(0, info->mem_lower * 1024);
/* reserve kernel and fs data */ /* reserve kernel and fs data */
memory_reserve_ex(0x100000, last_loaded_addr - 0x100000); memory_reserve_ex(0x100000, last_loaded_addr - 0x100000);
/* reserve initial cache datas */ /* reserve initial cache datas */
memory_reserve_ex(reservation_addr, reservation_len); memory_reserve_ex(reservation_addr, reservation_len);
} }
static void *memory_split(struct memory_map *m, size_t size) static void *memory_split(struct memory_map *m, size_t size)
{ {
struct memory_map *t = cache_alloc(memory_map_cache); struct memory_map *t = cache_alloc(memory_map_cache);
memory_initialize(t, m->base_addr, size, 2); memory_initialize(t, m->base_addr, size, 2);
list_insert(m->list.prev, &t->list); list_insert(m->list.prev, &t->list);
m->size -= size; m->size -= size;
m->base_addr += size; m->base_addr += size;
return (void *)t->base_addr; return (void *)t->base_addr;
} }
static void *__memory_reserve_ex(unsigned int base_addr, size_t size, int in_extend) static void *__memory_reserve_ex(unsigned int base_addr, size_t size, int in_extend)
{ {
if (cache_remaining(memory_map_cache) <= 2 && !in_extend) { if (cache_remaining(memory_map_cache) <= 2 && !in_extend) {
void *p = __memory_reserve_ex(0, 10 * sizeof(struct cache), 1); void *p = __memory_reserve_ex(0, 10 * sizeof(struct cache), 1);
cache_extend(memory_map_cache, p, 10 * sizeof(struct cache), cache_extend(memory_map_cache, p, 10 * sizeof(struct cache),
sizeof(struct cache), 0); sizeof(struct cache), 0);
} }
struct memory_map *m; struct memory_map *m;
list_for_each(m, &memory_map, list) { list_for_each(m, &memory_map, list) {
if (m->type) if (m->type)
continue; continue;
if (!base_addr && m->size >= size) { if (!base_addr && m->size >= size) {
if (m->size == size) { if (m->size == size) {
m->type = 2; m->type = 2;
return (void *)m->base_addr; return (void *)m->base_addr;
} }
return memory_split(m, size); return memory_split(m, size);
} else if (base_addr >= m->base_addr && base_addr < m->base_addr + m->size) { } else if (base_addr >= m->base_addr && base_addr < m->base_addr + m->size) {
if (base_addr + size >= m->base_addr + m->size) { if (base_addr + size >= m->base_addr + m->size) {
return NULL; return NULL;
} }
unsigned first_size = base_addr - m->base_addr; unsigned first_size = base_addr - m->base_addr;
if (first_size) { if (first_size) {
memory_split(m, first_size); memory_split(m, first_size);
return memory_reserve_ex(base_addr, size); return memory_reserve_ex(base_addr, size);
} }
return memory_split(m, size); return memory_split(m, size);
} }
} }
return NULL; return NULL;
} }
void *memory_reserve_ex(unsigned int base_addr, size_t size) void *memory_reserve_ex(unsigned int base_addr, size_t size)
{ {
return __memory_reserve_ex(base_addr, size, 0); return __memory_reserve_ex(base_addr, size, 0);
} }
void *memory_reserve(size_t size) void *memory_reserve(size_t size)
{ {
return memory_reserve_ex(0, size); return memory_reserve_ex(0, size);
} }
void memory_release(void *ptr) void memory_release(void *ptr)
{ {
struct memory_map *m; struct memory_map *m;
list_for_each(m, &memory_map, list) { list_for_each(m, &memory_map, list) {
if (m->base_addr == (unsigned int)ptr) { if (m->base_addr == (unsigned int)ptr) {
m->type = 0; m->type = 0;
/* FIXME: need to merge free blocks */ /* FIXME: need to merge free blocks */
return; return;
} }
} }
} }

@ -5,10 +5,10 @@
#include "multiboot.h" #include "multiboot.h"
struct memory_map { struct memory_map {
struct list list; struct list list;
unsigned int base_addr; unsigned int base_addr;
unsigned int size; unsigned int size;
int type; int type;
}; };
void memory_dump(); void memory_dump();
@ -18,11 +18,11 @@ void *memory_reserve_ex(unsigned int base_addr, size_t size);
void memory_release(void *ptr); void memory_release(void *ptr);
struct cache { struct cache {
struct list freelist; struct list freelist;
struct list caches; struct list caches;
void *base; void *base;
size_t size; size_t size;
size_t bsize; size_t bsize;
}; };
struct cache *cache_new(void *base, size_t nmemb, size_t bsize); struct cache *cache_new(void *base, size_t nmemb, size_t bsize);

@ -97,164 +97,164 @@ typedef unsigned int multiboot_uint32_t;
typedef unsigned long long multiboot_uint64_t; typedef unsigned long long multiboot_uint64_t;
struct multiboot_header { struct multiboot_header {
/* Must be MULTIBOOT_MAGIC - see above. */ /* Must be MULTIBOOT_MAGIC - see above. */
multiboot_uint32_t magic; multiboot_uint32_t magic;
/* Feature flags. */ /* Feature flags. */
multiboot_uint32_t flags; multiboot_uint32_t flags;
/* The above fields plus this one must equal 0 mod 2^32. */ /* The above fields plus this one must equal 0 mod 2^32. */
multiboot_uint32_t checksum; multiboot_uint32_t checksum;
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
multiboot_uint32_t header_addr; multiboot_uint32_t header_addr;
multiboot_uint32_t load_addr; multiboot_uint32_t load_addr;
multiboot_uint32_t load_end_addr; multiboot_uint32_t load_end_addr;
multiboot_uint32_t bss_end_addr; multiboot_uint32_t bss_end_addr;
multiboot_uint32_t entry_addr; multiboot_uint32_t entry_addr;
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
multiboot_uint32_t mode_type; multiboot_uint32_t mode_type;
multiboot_uint32_t width; multiboot_uint32_t width;
multiboot_uint32_t height; multiboot_uint32_t height;
multiboot_uint32_t depth; multiboot_uint32_t depth;
}; };
/* The symbol table for a.out. */ /* The symbol table for a.out. */
struct multiboot_aout_symbol_table { struct multiboot_aout_symbol_table {
multiboot_uint32_t tabsize; multiboot_uint32_t tabsize;
multiboot_uint32_t strsize; multiboot_uint32_t strsize;
multiboot_uint32_t addr; multiboot_uint32_t addr;
multiboot_uint32_t reserved; multiboot_uint32_t reserved;
}; };
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
/* The section header table for ELF. */ /* The section header table for ELF. */
struct multiboot_elf_section_header_table { struct multiboot_elf_section_header_table {
multiboot_uint32_t num; multiboot_uint32_t num;
multiboot_uint32_t size; multiboot_uint32_t size;
multiboot_uint32_t addr; multiboot_uint32_t addr;
multiboot_uint32_t shndx; multiboot_uint32_t shndx;
}; };
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
struct multiboot_info { struct multiboot_info {
/* Multiboot info version number */ /* Multiboot info version number */
multiboot_uint32_t flags; multiboot_uint32_t flags;
/* Available memory from BIOS */ /* Available memory from BIOS */
multiboot_uint32_t mem_lower; multiboot_uint32_t mem_lower;
multiboot_uint32_t mem_upper; multiboot_uint32_t mem_upper;
/* "root" partition */ /* "root" partition */
multiboot_uint32_t boot_device; multiboot_uint32_t boot_device;
/* Kernel command line */ /* Kernel command line */
multiboot_uint32_t cmdline; multiboot_uint32_t cmdline;
/* Boot-Module list */ /* Boot-Module list */
multiboot_uint32_t mods_count; multiboot_uint32_t mods_count;
multiboot_uint32_t mods_addr; multiboot_uint32_t mods_addr;
union { union {
multiboot_aout_symbol_table_t aout_sym; multiboot_aout_symbol_table_t aout_sym;
multiboot_elf_section_header_table_t elf_sec; multiboot_elf_section_header_table_t elf_sec;
} u; } u;
/* Memory Mapping buffer */ /* Memory Mapping buffer */
multiboot_uint32_t mmap_length; multiboot_uint32_t mmap_length;
multiboot_uint32_t mmap_addr; multiboot_uint32_t mmap_addr;
/* Drive Info buffer */ /* Drive Info buffer */
multiboot_uint32_t drives_length; multiboot_uint32_t drives_length;
multiboot_uint32_t drives_addr; multiboot_uint32_t drives_addr;
/* ROM configuration table */ /* ROM configuration table */
multiboot_uint32_t config_table; multiboot_uint32_t config_table;
/* Boot Loader Name */ /* Boot Loader Name */
multiboot_uint32_t boot_loader_name; multiboot_uint32_t boot_loader_name;
/* APM table */ /* APM table */
multiboot_uint32_t apm_table; multiboot_uint32_t apm_table;
/* Video */ /* Video */
multiboot_uint32_t vbe_control_info; multiboot_uint32_t vbe_control_info;
multiboot_uint32_t vbe_mode_info; multiboot_uint32_t vbe_mode_info;
multiboot_uint16_t vbe_mode; multiboot_uint16_t vbe_mode;
multiboot_uint16_t vbe_interface_seg; multiboot_uint16_t vbe_interface_seg;
multiboot_uint16_t vbe_interface_off; multiboot_uint16_t vbe_interface_off;
multiboot_uint16_t vbe_interface_len; multiboot_uint16_t vbe_interface_len;
multiboot_uint64_t framebuffer_addr; multiboot_uint64_t framebuffer_addr;
multiboot_uint32_t framebuffer_pitch; multiboot_uint32_t framebuffer_pitch;
multiboot_uint32_t framebuffer_width; multiboot_uint32_t framebuffer_width;
multiboot_uint32_t framebuffer_height; multiboot_uint32_t framebuffer_height;
multiboot_uint8_t framebuffer_bpp; multiboot_uint8_t framebuffer_bpp;
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 #define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 #define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 #define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
multiboot_uint8_t framebuffer_type; multiboot_uint8_t framebuffer_type;
union { union {
struct { struct {
multiboot_uint32_t framebuffer_palette_addr; multiboot_uint32_t framebuffer_palette_addr;
multiboot_uint16_t framebuffer_palette_num_colors; multiboot_uint16_t framebuffer_palette_num_colors;
}; };
struct { struct {
multiboot_uint8_t framebuffer_red_field_position; multiboot_uint8_t framebuffer_red_field_position;
multiboot_uint8_t framebuffer_red_mask_size; multiboot_uint8_t framebuffer_red_mask_size;
multiboot_uint8_t framebuffer_green_field_position; multiboot_uint8_t framebuffer_green_field_position;
multiboot_uint8_t framebuffer_green_mask_size; multiboot_uint8_t framebuffer_green_mask_size;
multiboot_uint8_t framebuffer_blue_field_position; multiboot_uint8_t framebuffer_blue_field_position;
multiboot_uint8_t framebuffer_blue_mask_size; multiboot_uint8_t framebuffer_blue_mask_size;
}; };
}; };
}; };
typedef struct multiboot_info multiboot_info_t; typedef struct multiboot_info multiboot_info_t;
struct multiboot_color { struct multiboot_color {
multiboot_uint8_t red; multiboot_uint8_t red;
multiboot_uint8_t green; multiboot_uint8_t green;
multiboot_uint8_t blue; multiboot_uint8_t blue;
}; };
struct multiboot_mmap_entry { struct multiboot_mmap_entry {
multiboot_uint32_t size; multiboot_uint32_t size;
multiboot_uint64_t addr; multiboot_uint64_t addr;
multiboot_uint64_t len; multiboot_uint64_t len;
#define MULTIBOOT_MEMORY_AVAILABLE 1 #define MULTIBOOT_MEMORY_AVAILABLE 1
#define MULTIBOOT_MEMORY_RESERVED 2 #define MULTIBOOT_MEMORY_RESERVED 2
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 #define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
#define MULTIBOOT_MEMORY_NVS 4 #define MULTIBOOT_MEMORY_NVS 4
#define MULTIBOOT_MEMORY_BADRAM 5 #define MULTIBOOT_MEMORY_BADRAM 5
multiboot_uint32_t type; multiboot_uint32_t type;
} __attribute__((packed)); } __attribute__((packed));
typedef struct multiboot_mmap_entry multiboot_memory_map_t; typedef struct multiboot_mmap_entry multiboot_memory_map_t;
struct multiboot_mod_list { struct multiboot_mod_list {
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
multiboot_uint32_t mod_start; multiboot_uint32_t mod_start;
multiboot_uint32_t mod_end; multiboot_uint32_t mod_end;
/* Module command line */ /* Module command line */
multiboot_uint32_t cmdline; multiboot_uint32_t cmdline;
/* padding to take it to 16 bytes (must be zero) */ /* padding to take it to 16 bytes (must be zero) */
multiboot_uint32_t pad; multiboot_uint32_t pad;
}; };
typedef struct multiboot_mod_list multiboot_module_t; typedef struct multiboot_mod_list multiboot_module_t;
/* APM BIOS info. */ /* APM BIOS info. */
struct multiboot_apm_info { struct multiboot_apm_info {
multiboot_uint16_t version; multiboot_uint16_t version;
multiboot_uint16_t cseg; multiboot_uint16_t cseg;
multiboot_uint32_t offset; multiboot_uint32_t offset;
multiboot_uint16_t cseg_16; multiboot_uint16_t cseg_16;
multiboot_uint16_t dseg; multiboot_uint16_t dseg;
multiboot_uint16_t flags; multiboot_uint16_t flags;
multiboot_uint16_t cseg_len; multiboot_uint16_t cseg_len;
multiboot_uint16_t cseg_16_len; multiboot_uint16_t cseg_16_len;
multiboot_uint16_t dseg_len; multiboot_uint16_t dseg_len;
}; };
#endif /* ! ASM_FILE */ #endif /* ! ASM_FILE */