[core] Fix up everything to read multiboot parameters and print them out.
This commit is contained in:
parent
3e9f4d65a7
commit
ac2a767373
5
Makefile
5
Makefile
@ -2,7 +2,7 @@ include Makefile.inc
|
||||
|
||||
DIRS = core
|
||||
|
||||
.PHONY: all clean install core
|
||||
.PHONY: all clean install core run
|
||||
|
||||
all: kernel
|
||||
|
||||
@ -12,6 +12,9 @@ install: kernel
|
||||
umount /mnt
|
||||
cp kernel /boot/toaruos-kernel
|
||||
|
||||
run: bootdisk.img
|
||||
qemu -fda bootdisk.img
|
||||
|
||||
kernel: start.o link.ld main.o core
|
||||
${LD} -T link.ld -o kernel *.o core/*.o
|
||||
|
||||
|
BIN
bootdisk.img
BIN
bootdisk.img
Binary file not shown.
@ -19,18 +19,13 @@ timer_handler(
|
||||
) {
|
||||
++timer_ticks;
|
||||
if (timer_ticks % 18 == 0) {
|
||||
ticker++;
|
||||
puts ("Tick. ");
|
||||
if (ticker % 4 == 0) { putch('|'); }
|
||||
else if(ticker % 4 == 1) { putch('/'); }
|
||||
else if(ticker % 4 == 2) { putch('-'); }
|
||||
else if(ticker % 4 == 3) { putch('\\'); }
|
||||
putch('\n');
|
||||
++ticker;
|
||||
}
|
||||
}
|
||||
|
||||
void timer_install() {
|
||||
irq_install_handler(0, timer_handler);
|
||||
timer_phase(100); /* 100Hz */
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -130,6 +130,15 @@ settextcolor(
|
||||
attrib = (backcolor << 4) | (forecolor & 0x0F);
|
||||
}
|
||||
|
||||
/*
|
||||
* resettextcolor
|
||||
* Reset the text color to white on black
|
||||
*/
|
||||
void
|
||||
resettextcolor() {
|
||||
settextcolor(15,0);
|
||||
}
|
||||
|
||||
/*
|
||||
* init_video
|
||||
* Initialize the VGA driver.
|
||||
|
41
include/multiboot.h
Normal file
41
include/multiboot.h
Normal file
@ -0,0 +1,41 @@
|
||||
#include <system.h>
|
||||
|
||||
#define MULTIBOOT_FLAG_MEM 0x001
|
||||
#define MULTIBOOT_FLAG_DEVICE 0x002
|
||||
#define MULTIBOOT_FLAG_CMDLINE 0x004
|
||||
#define MULTIBOOT_FLAG_MODS 0x008
|
||||
#define MULTIBOOT_FLAG_AOUT 0x010
|
||||
#define MULTIBOOT_FLAG_ELF 0x020
|
||||
#define MULTIBOOT_FLAG_MMAP 0x040
|
||||
#define MULTIBOOT_FLAG_CONFIG 0x080
|
||||
#define MULTIBOOT_FLAG_LOADER 0x100
|
||||
#define MULTIBOOT_FLAG_APM 0x200
|
||||
#define MULTIBOOT_FLAG_VBE 0x400
|
||||
|
||||
struct multiboot
|
||||
{
|
||||
uintptr_t flags;
|
||||
uintptr_t mem_lower;
|
||||
uintptr_t mem_upper;
|
||||
uintptr_t boot_device;
|
||||
uintptr_t cmdline;
|
||||
uintptr_t mods_count;
|
||||
uintptr_t mods_addr;
|
||||
uintptr_t num;
|
||||
uintptr_t size;
|
||||
uintptr_t addr;
|
||||
uintptr_t shndx;
|
||||
uintptr_t mmap_length;
|
||||
uintptr_t mmap_addr;
|
||||
uintptr_t drives_length;
|
||||
uintptr_t drives_addr;
|
||||
uintptr_t config_table;
|
||||
uintptr_t boot_loader_name;
|
||||
uintptr_t apm_table;
|
||||
uintptr_t vbe_control_info;
|
||||
uintptr_t vbe_mode_info;
|
||||
uintptr_t vbe_mode;
|
||||
uintptr_t vbe_interface_seg;
|
||||
uintptr_t vbe_interface_off;
|
||||
uintptr_t vbe_interface_len;
|
||||
} __attribute__((packed));
|
@ -1,10 +1,18 @@
|
||||
#ifndef __SYSTEM_H
|
||||
#define __SYSTEM_H
|
||||
|
||||
/* Types */
|
||||
|
||||
#define NULL ((void *)0UL)
|
||||
|
||||
typedef unsigned long uintptr_t;
|
||||
typedef long size_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
/* Unimportant Kernel Strings */
|
||||
#define KERNEL_UNAME "ToAruOS"
|
||||
#define KERNEL_VERSION_STRING "0.0.1"
|
||||
|
||||
|
||||
/* Kernel Main */
|
||||
extern void *memcpy(void * restrict dest, const void * restrict src, size_t count);
|
||||
@ -19,6 +27,7 @@ extern void cls();
|
||||
extern void putch(unsigned char c);
|
||||
extern void puts(char *str);
|
||||
extern void settextcolor(unsigned char forecolor, unsigned char backcolor);
|
||||
extern void resettextcolor();
|
||||
extern void init_video();
|
||||
|
||||
/* GDT */
|
||||
|
59
main.c
59
main.c
@ -1,4 +1,5 @@
|
||||
#include <system.h>
|
||||
#include <multiboot.h>
|
||||
|
||||
/*
|
||||
* memcpy
|
||||
@ -96,6 +97,10 @@ outportb(
|
||||
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
||||
}
|
||||
|
||||
/*
|
||||
* 99 Bottles of Beer on the -Wall
|
||||
* Sample kernel mode program.
|
||||
*/
|
||||
void beer() {
|
||||
int i = 99;
|
||||
while (i > 0) {
|
||||
@ -116,10 +121,10 @@ void beer() {
|
||||
}
|
||||
|
||||
/*
|
||||
* Kernel Entry Point
|
||||
* kernel entry point
|
||||
*/
|
||||
int
|
||||
main() {
|
||||
main(struct multiboot *mboot_ptr) {
|
||||
gdt_install();
|
||||
idt_install();
|
||||
isrs_install();
|
||||
@ -128,8 +133,52 @@ main() {
|
||||
timer_install();
|
||||
keyboard_install();
|
||||
init_video();
|
||||
puts("Good Morning!\n");
|
||||
beer();
|
||||
for (;;);
|
||||
/* Yes, yes, these are #define'd strings, consider this a nice test of kprintf */
|
||||
settextcolor(12,0);
|
||||
kprintf("[%s %s]\n", KERNEL_UNAME, KERNEL_VERSION_STRING);
|
||||
settextcolor(1,0);
|
||||
/* Multiboot Debug */
|
||||
kprintf("Received the following MULTIBOOT data:\n");
|
||||
settextcolor(7,0);
|
||||
kprintf("Flags: %x\t", mboot_ptr->flags);
|
||||
kprintf("Mem Lo: %x\t", mboot_ptr->mem_lower);
|
||||
kprintf("Mem Hi: %x\n", mboot_ptr->mem_upper);
|
||||
kprintf("Boot dev: %x\t", mboot_ptr->boot_device);
|
||||
kprintf("cmdline: %x\t", mboot_ptr->cmdline);
|
||||
kprintf("Mods: %x\n", mboot_ptr->mods_count);
|
||||
kprintf("Addr: %x\t", mboot_ptr->mods_addr);
|
||||
kprintf("Syms: %x\t", mboot_ptr->num);
|
||||
kprintf("Syms: %x\n", mboot_ptr->size);
|
||||
kprintf("Syms: %x\t", mboot_ptr->addr);
|
||||
kprintf("Syms: %x\t", mboot_ptr->shndx);
|
||||
kprintf("MMap: %x\n", mboot_ptr->mmap_length);
|
||||
kprintf("Addr: %x\t", mboot_ptr->mmap_addr);
|
||||
kprintf("Drives: %x\t", mboot_ptr->drives_length);
|
||||
kprintf("Addr: %x\n", mboot_ptr->drives_addr);
|
||||
kprintf("Config: %x\t", mboot_ptr->config_table);
|
||||
kprintf("Loader: %x\t", mboot_ptr->boot_loader_name);
|
||||
kprintf("APM: %x\n", mboot_ptr->apm_table);
|
||||
kprintf("VBE Control: %x\t", mboot_ptr->vbe_control_info);
|
||||
kprintf("VBE Mode Info: %x\t", mboot_ptr->vbe_mode_info);
|
||||
kprintf("VBE Mode: %x\n", mboot_ptr->vbe_mode);
|
||||
kprintf("VBE seg: %x\t", mboot_ptr->vbe_interface_seg);
|
||||
kprintf("VBE off: %x\t", mboot_ptr->vbe_interface_off);
|
||||
kprintf("VBE len: %x\n", mboot_ptr->vbe_interface_len);
|
||||
resettextcolor();
|
||||
kprintf("(End multiboot raw data)\n");
|
||||
kprintf("Started with: %s\n", (char *)mboot_ptr->cmdline);
|
||||
kprintf("Booted from: %s\n", (char *)mboot_ptr->boot_loader_name);
|
||||
settextcolor(7,0);
|
||||
kprintf("Testing colors...\n");
|
||||
resettextcolor();
|
||||
int i;
|
||||
for (i = 0; i < 256; ++i) {
|
||||
settextcolor(i,i);
|
||||
putch(' ');
|
||||
}
|
||||
resettextcolor();
|
||||
|
||||
|
||||
//for (;;);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user