wip: enable vbe
This commit is contained in:
parent
4bd4198293
commit
fb1a1bc213
6
Makefile
6
Makefile
@ -31,7 +31,7 @@ $(NAME): $(OBJ)
|
||||
$(LD) $(LDFLAGS) -o build/$(NAME).bin $(OBJ) $(LIBS)
|
||||
|
||||
run: $(NAME)
|
||||
qemu-system-i386 -kernel build/$(NAME).bin
|
||||
qemu-system-i386 -kernel build/$(NAME).bin -vga std
|
||||
|
||||
iso: $(NAME)
|
||||
mkdir -p isodir/boot/grub
|
||||
@ -41,10 +41,10 @@ iso: $(NAME)
|
||||
rm -rf isodir
|
||||
|
||||
run-iso: iso
|
||||
qemu-system-i386 -cdrom build/$(NAME).iso
|
||||
qemu-system-i386 -cdrom build/$(NAME).iso -vga std
|
||||
|
||||
debug: iso
|
||||
qemu-system-i386 -s -S build/$(NAME).iso
|
||||
qemu-system-i386 -s -S build/$(NAME).iso -vga std
|
||||
|
||||
clean:
|
||||
make -C libbozo clean
|
||||
|
@ -1,3 +1,6 @@
|
||||
menuentry "bozos" {
|
||||
multiboot /boot/bozOS.bin
|
||||
}
|
||||
set gfxmode=1024x768x32
|
||||
set gfxpayload=keep
|
||||
menuentry "bozOS" {
|
||||
multiboot /boot/bozOS.bin
|
||||
boot
|
||||
}
|
||||
|
30
src/boot.s
30
src/boot.s
@ -1,27 +1,17 @@
|
||||
# Declare constants for the multiboot header.
|
||||
.set ALIGN, 1<<0 # align loaded modules on page boundaries
|
||||
.set MEMINFO, 1<<1 # provide memory map
|
||||
.set MAGIC, 0xE85250D6 # 'magic number' lets bootloader find the header
|
||||
.set ARCHITECTURE, 0
|
||||
.set ALIGN, 1<<0 # align loaded modules on page boundaries
|
||||
.set MEMINFO, 1<<1 # provide memory map
|
||||
.set VIDEOMODE, 1<<2 # provide memory map
|
||||
.set FLAGS, ALIGN | MEMINFO | VIDEOMODE # this is the Multiboot 'flag' field
|
||||
.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header
|
||||
.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot
|
||||
|
||||
# Declare a multiboot header that marks the program as a kernel.
|
||||
.section .multiboot.data, "aw"
|
||||
header_start:
|
||||
# HEADER
|
||||
.long MAGIC
|
||||
.long ARCHITECTURE
|
||||
.long header_end - header_start
|
||||
.long 0x100000000 - (MAGIC + (header_end - header_start))
|
||||
|
||||
#TAGS:
|
||||
|
||||
|
||||
# END TAG
|
||||
.align 8
|
||||
.int 0 # type
|
||||
.int 0 # flag
|
||||
.long 8 # size
|
||||
header_end:
|
||||
.align 4
|
||||
.long MAGIC
|
||||
.long FLAGS
|
||||
.long CHECKSUM
|
||||
|
||||
# Allocate the initial stack.
|
||||
.section .bootstrap_stack, "aw", @nobits
|
||||
|
70
src/kernel.c
70
src/kernel.c
@ -26,50 +26,6 @@
|
||||
#error "This tutorial needs to be compiled with a ix86-elf compiler"
|
||||
#endif
|
||||
|
||||
/* Par contre je me dois d'être honnête avec toi, j'ai passé un très bon moment
|
||||
* hier soir c'était vraiment posé et tout mais j'ai pas trop ressenti de
|
||||
* feeling qui me donnerait envie de continuer dans une relation "couple" sur le
|
||||
* long terme. Je sais pas trop comment le dire sans que ça te blesse, c'est pas
|
||||
* personnel ou quoi c'est cool quand on parle et tout mais juste je ne pense
|
||||
* pas pouvoir faire marcher une relation comme celle là :( */
|
||||
/* Voilà je voulais juste te le dire pour pas que tu te mettes quelque chose en
|
||||
* tête qui n'arrivera pas, je trouve ça plus correct */
|
||||
|
||||
static void set_mem_size(multiboot_info_t *mbd, uint32_t magic)
|
||||
{
|
||||
/* Make sure the magic number matches for memory mapping */
|
||||
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
|
||||
kpanic("invalid magic number!");
|
||||
|
||||
/* Check bit 6 to see if we have a valid memory map */
|
||||
if (!(mbd->flags >> 6 & 0x1))
|
||||
kpanic("invalid memory map given by GRUB bootloader");
|
||||
|
||||
/* Loop through the memory map and display the values */
|
||||
for (uint32_t i = 0; i < mbd->mmap_length;
|
||||
i += sizeof(multiboot_memory_map_t)) {
|
||||
multiboot_memory_map_t *mmmt =
|
||||
(multiboot_memory_map_t *)(mbd->mmap_addr + i);
|
||||
/* if (mmmt->type == MULTIBOOT_MEMORY_AVAILABLE) */
|
||||
/* mem_size += mmmt->len; */
|
||||
}
|
||||
}
|
||||
|
||||
extern uint32_t boot_page_table1;
|
||||
|
||||
void get_kernel_page_used(void)
|
||||
{
|
||||
uint32_t *boot_pt = &boot_page_table1;
|
||||
size_t i = 0;
|
||||
size_t used_pages = 0;
|
||||
for (; i < 1024; i++) {
|
||||
if ((boot_pt[i] != 0) && (boot_pt[i] != (i << 12))) {
|
||||
used_pages++;
|
||||
}
|
||||
}
|
||||
kprintf("page used: %d/%d\n", used_pages, PT_SIZE);
|
||||
}
|
||||
|
||||
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
{
|
||||
terminal_initialize();
|
||||
@ -81,31 +37,5 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
"I see no way to confuse an array of 256 seg:off pairs with a "
|
||||
"complex 8*unknown quantity -byte descriptor table. -- Troy "
|
||||
"Martin 03:50, 22 March 2009 (UTC)\n");
|
||||
// PRINT_PTR(alloc_frame());
|
||||
if (false) {
|
||||
void *start = alloc_pages(1);
|
||||
int *ptr;
|
||||
uint32_t i;
|
||||
for (i = 1; (ptr = alloc_pages(PAGE_SIZE)); i++) {
|
||||
memset(ptr, i % 256, PAGE_SIZE);
|
||||
*ptr = i;
|
||||
if (i == 4096 && 0)
|
||||
break;
|
||||
}
|
||||
PRINT_UINT(i); // 32573
|
||||
for (uint32_t j = 1; j < i - 1; j++) {
|
||||
ptr = start + j * PAGE_SIZE;
|
||||
for (uint32_t k = sizeof(*ptr);
|
||||
k < PAGE_SIZE - sizeof(*ptr); k++)
|
||||
if (((uint8_t *)ptr)[k] != (j % 256))
|
||||
kprintf("cringe %u != %u\n",
|
||||
((uint8_t *)ptr)[k], j % 256);
|
||||
}
|
||||
|
||||
} else {
|
||||
while (vmalloc(10))
|
||||
;
|
||||
}
|
||||
/* vmalloc(10); */
|
||||
shell_init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user