Setup a graphics 'driver' of sorts that can display a banner at the top of the screen.
This commit is contained in:
@@ -3,3 +3,4 @@
|
|||||||
*.log
|
*.log
|
||||||
*.iso
|
*.iso
|
||||||
*.bin
|
*.bin
|
||||||
|
*.ini
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ kernel.iso: kernel.o
|
|||||||
cp obj/bin/kernel.o iso/boot/kernel.bin
|
cp obj/bin/kernel.o iso/boot/kernel.bin
|
||||||
grub-mkrescue --output=kernel.iso iso
|
grub-mkrescue --output=kernel.iso iso
|
||||||
|
|
||||||
|
qemu: kernel.iso
|
||||||
|
qemu-system-x86_64 -m 256M -cdrom kernel.iso &
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf obj/* kernel.iso
|
rm -rf obj/* kernel.iso
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
#ifndef KERNEL_VERSION_NUMBER
|
#ifndef KERNEL_VERSION_NUMBER
|
||||||
#define KERNEL_VERSION_NUMBER "0.0.1-47"
|
#define KERNEL_VERSION_NUMBER "0.0.1-239"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ void write_screen(unsigned int, char, unsigned char, unsigned char);
|
|||||||
void move(unsigned short);
|
void move(unsigned short);
|
||||||
void draw_s(char*, unsigned char, unsigned char);
|
void draw_s(char*, unsigned char, unsigned char);
|
||||||
int strlen(char*);
|
int strlen(char*);
|
||||||
|
void clear_screen(void);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,4 +2,6 @@
|
|||||||
#define SCREEN_H
|
#define SCREEN_H
|
||||||
void draw_string(char*, unsigned char, unsigned char);
|
void draw_string(char*, unsigned char, unsigned char);
|
||||||
int strlen(char*);
|
int strlen(char*);
|
||||||
|
void clear_screen(void);
|
||||||
|
void print_banner(void);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+8
-32
@@ -1,20 +1,15 @@
|
|||||||
#include "../includes/io.h"
|
#include "../includes/io.h"
|
||||||
#include "../includes/kernel.h"
|
#include "../includes/screen.h"
|
||||||
|
|
||||||
//char* msg = "Hello, World!";
|
|
||||||
|
|
||||||
void kmain()
|
void kmain()
|
||||||
{
|
{
|
||||||
draw_s("Hello, World!", 2, 9);/*
|
clear_screen();
|
||||||
write_screen(0, "k", 2, 9);
|
print_banner();
|
||||||
write_screen(2, 'e', 2, 9);
|
//draw_s("Hello, World!", 2, 9);
|
||||||
write_screen(4, 'r', 2, 9);
|
//row = 2;
|
||||||
write_screen(6, 'n', 2, 9);
|
///column = 80;
|
||||||
write_screen(8, 'e', 2, 9);
|
//draw_s("And 2nd Row. Now the 3rd row.", 2, 9);
|
||||||
write_screen(10, 'l', 2, 9);
|
asm("hlt");
|
||||||
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)
|
||||||
@@ -31,22 +26,3 @@ 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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
#include "../includes/screen.h"
|
||||||
|
#include "../build_numbers.c"
|
||||||
|
|
||||||
|
unsigned char row = 1;
|
||||||
|
unsigned char column = 0;
|
||||||
|
unsigned char screen_width = 80;
|
||||||
|
|
||||||
|
|
||||||
|
void print_banner(){
|
||||||
|
unsigned short *buffer = 0x000B8000;
|
||||||
|
unsigned short attr = 0x1800;
|
||||||
|
|
||||||
|
unsigned char* banner = "Project Code Name: kernel3";
|
||||||
|
char* version = KERNEL_VERSION_NUMBER;
|
||||||
|
unsigned char banner_length = (80 - strlen(banner)) / 2;
|
||||||
|
// Add 14 for the string "Kernel Version: ".
|
||||||
|
unsigned char version_length = (80 - (strlen(version) + 16)) / 2;
|
||||||
|
|
||||||
|
for(unsigned char i = 0; i < screen_width; i++){
|
||||||
|
*buffer++ = ' ';
|
||||||
|
*buffer++ = attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned char i = 0; i < screen_width; i++){
|
||||||
|
if(i == banner_length){
|
||||||
|
for(unsigned short j = 0; j < strlen(banner); j++){
|
||||||
|
unsigned short *where = (unsigned short*) 0x000B8000 + j + i;
|
||||||
|
*where = banner[j] | attr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == version_length){
|
||||||
|
unsigned short offset = 0;
|
||||||
|
char* tmp = "Kernel Version: ";
|
||||||
|
for(unsigned char j = 0; j < strlen(tmp); j++){
|
||||||
|
unsigned short *where = (unsigned short*) 0x000B8000 + j + 80 + i;
|
||||||
|
*where = tmp[j] | attr;
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned char j = 0; j < strlen(version); j++){
|
||||||
|
unsigned short *where = (unsigned short*) 0x000B8000 + j + 80 + offset + i;
|
||||||
|
*where = version[j] | attr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_s(char* string, unsigned char fg, unsigned char bg)
|
||||||
|
{
|
||||||
|
char *video_buffer = 0x000B8000;
|
||||||
|
|
||||||
|
for(int i = 0; i < strlen(string); i++)
|
||||||
|
{
|
||||||
|
char current_char = string[i];
|
||||||
|
|
||||||
|
if(current_char == '\n'){
|
||||||
|
//row++;
|
||||||
|
column = row * column;
|
||||||
|
row++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
video_buffer[i*2 + (row * column)] = string[i];
|
||||||
|
video_buffer[i * 2 + 1 + (row * column)] = ((fg & 0x0f) << 4) | (bg & 0x0F);
|
||||||
|
//column++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear_screen(){
|
||||||
|
char *video_buffer = 0x000B8000;
|
||||||
|
|
||||||
|
for(unsigned char i = 0; i < 25; i++){
|
||||||
|
for(unsigned char j = 0; j < 80; j++){
|
||||||
|
*video_buffer++ = ' ';//0x20 | (0x0F << 8);
|
||||||
|
*video_buffer++ = 0x82;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int strlen(char* string)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
for(int i = 0; string[i] != '\0'; i++) len++;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user