Fixed a bug that caused the kernel image to lose it multiboot signature. Added code to test printing a string to the screen.
This commit is contained in:
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
#ifndef KERNEL_VERSION_NUMBER
|
#ifndef KERNEL_VERSION_NUMBER
|
||||||
#define KERNEL_VERSION_NUMBER "1.4.10-8"
|
#define KERNEL_VERSION_NUMBER "0.0.1-47"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef KERNEL_H
|
||||||
|
#define KERNEL_H
|
||||||
|
|
||||||
|
void write_screen(unsigned int, char, unsigned char, unsigned char);
|
||||||
|
void move(unsigned short);
|
||||||
|
void draw_s(char*, unsigned char, unsigned char);
|
||||||
|
int strlen(char*);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#ifndef SCREEN_H
|
||||||
|
#define SCREEN_H
|
||||||
|
void draw_string(char*, unsigned char, unsigned char);
|
||||||
|
int strlen(char*);
|
||||||
|
#endif
|
||||||
+32
-6
@@ -1,13 +1,20 @@
|
|||||||
#include "../includes/io.h"
|
#include "../includes/io.h"
|
||||||
|
#include "../includes/kernel.h"
|
||||||
|
|
||||||
void write_screen(unsigned int, char, unsigned char, unsigned char);
|
//char* msg = "Hello, World!";
|
||||||
void move(unsigned short);
|
|
||||||
|
|
||||||
extern void kmain()
|
void kmain()
|
||||||
{
|
{
|
||||||
write_screen(0, 'A', 2, 8);
|
draw_s("Hello, World!", 2, 9);/*
|
||||||
move(80);
|
write_screen(0, "k", 2, 9);
|
||||||
//asm("hlt");
|
write_screen(2, 'e', 2, 9);
|
||||||
|
write_screen(4, 'r', 2, 9);
|
||||||
|
write_screen(6, 'n', 2, 9);
|
||||||
|
write_screen(8, 'e', 2, 9);
|
||||||
|
write_screen(10, 'l', 2, 9);
|
||||||
|
write_screen(12, ' ', 2, 9);
|
||||||
|
write_screen(14, '3', 2, 9);
|
||||||
|
//asm("hlt");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_screen(unsigned int i, char c, unsigned char fg, unsigned char bg)
|
void write_screen(unsigned int i, char c, unsigned char fg, unsigned char bg)
|
||||||
@@ -24,3 +31,22 @@ void move(unsigned short pos)
|
|||||||
outb(0x3D4, 15);
|
outb(0x3D4, 15);
|
||||||
outb(0x3D5, pos & 0x00FF);
|
outb(0x3D5, pos & 0x00FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_s(char* string, unsigned char fg, unsigned char bg)
|
||||||
|
{
|
||||||
|
char *video_buffer = 0x000B8000;
|
||||||
|
for(int i = 0; i < strlen(string); i++)
|
||||||
|
{
|
||||||
|
video_buffer[i] = string[i];
|
||||||
|
video_buffer[i+1] = ((fg & 0x0f) << 4) | (bg & 0x0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int strlen(char* string)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
for(int i = 0; string[i] != '\0'; i++) len++;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|||||||
+2
-4
@@ -1,25 +1,23 @@
|
|||||||
global loader
|
global loader
|
||||||
|
|
||||||
|
align 4
|
||||||
MAGIC_NUMBER equ 0x1BADB002
|
MAGIC_NUMBER equ 0x1BADB002
|
||||||
FLAGS equ 0x0
|
FLAGS equ 0x0
|
||||||
CHECKSUM equ -MAGIC_NUMBER
|
CHECKSUM equ -MAGIC_NUMBER
|
||||||
KERNEL_STACK_SIZE equ 4096 ; size of stack in bytes
|
KERNEL_STACK_SIZE equ 4096 ; size of stack in bytes
|
||||||
|
|
||||||
section .text:
|
|
||||||
align 4
|
|
||||||
dd MAGIC_NUMBER
|
dd MAGIC_NUMBER
|
||||||
dd FLAGS
|
dd FLAGS
|
||||||
dd CHECKSUM
|
dd CHECKSUM
|
||||||
|
|
||||||
loader:
|
loader:
|
||||||
|
mov esp, kernel_stack; + KERNEL_STACK_SIZE ; ont ESP to the start of the stack (end of memory area)
|
||||||
extern kmain
|
extern kmain
|
||||||
call kmain
|
call kmain
|
||||||
;mov eax, 0xCAFEBABE
|
;mov eax, 0xCAFEBABE
|
||||||
;mov esp, kernel_stack + KERNEL_STACK_SIZE ; piont ESP to the start of the stack (end of memory area)
|
|
||||||
.loop:
|
.loop:
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
section .bss
|
section .bss
|
||||||
alignb 4
|
|
||||||
resb KERNEL_STACK_SIZE ; reserve stack for kernel
|
resb KERNEL_STACK_SIZE ; reserve stack for kernel
|
||||||
kernel_stack:
|
kernel_stack:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
megs: 32
|
megs: 32
|
||||||
display_library: x
|
display_library: x, options = "gui_debug"
|
||||||
romimage: file=/usr/share/bochs/BIOS-bochs-latest
|
romimage: file=/usr/share/bochs/BIOS-bochs-latest
|
||||||
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
|
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
|
||||||
ata0-master: type=cdrom, path=kernel.iso, status=inserted
|
ata0-master: type=cdrom, path=kernel.iso, status=inserted
|
||||||
|
|||||||
Reference in New Issue
Block a user