Commit 0985ab53 authored by Luc Lenôtre's avatar Luc Lenôtre

Troubleshooting

parent cde66909
......@@ -6,7 +6,6 @@ SECTIONS
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
......
......@@ -18,7 +18,6 @@
.set STACK_SIZE, 16384
.text
.global start, _start
start:
......@@ -38,9 +37,9 @@ address_tag:
.short 1
.long (address_tag_end - address_tag)
.long header
.long start
.long edata
.long end
.long _start
.long 0
.long bss_end
address_tag_end:
.align 8
......@@ -80,12 +79,12 @@ multiboot_entry:
push %ebx
call kernel_init
call _init
#call _init
pop %ebx
push %ebx
call kernel_main
call _fini
#call _fini
cli
halt_loop:
......@@ -101,6 +100,4 @@ halt_loop:
stack_bottom:
.skip STACK_SIZE
stack_top:
end:
edata:
bss_end:
#include "../kernel.h"
#include "framebuffer.h"
void text_clear()
{
for(size_t y = 0; y < TEXT_HEIGHT; ++y) {
for(size_t x = 0; x < TEXT_WIDTH; ++x) {
text_putchar(' ', x, y);
}
}
}
void text_putchar_color(const char c, const uint8_t color,
const size_t x, const size_t y)
{
const uint16_t i = y * TEXT_WIDTH + x;
*((uint16_t*) TEXT_BUFFER + i) = (uint16_t) c | ((uint16_t) color << 8);
}
#include "kernel.h"
#include "tty/tty.h"
#include "framebuffer/framebuffer.h"
#include "vga/vga.h"
void kernel_main(const void* bi)
{
boot_info = load_boot_info(bi);
(void) bi;
tty_init();
const char* str = "Hello world!";
for(size_t i = 0; i < 10; ++i) tty_write(str, strlen(str));
// boot_info = load_boot_info(bi);
//const char* str = "Hello world!";
//for(size_t i = 0; i < 10; ++i) tty_write(str, strlen(str));
vga_putchar('H', 0, 0);
}
#include "../kernel.h"
#include "tty.h"
#include "../framebuffer/framebuffer.h"
#include "../vga/vga.h"
void tty_init()
{
// TODO Switch from graphical to text mode if needed
text_clear();
vga_clear();
}
void tty_write(const char* buffer, const size_t size)
......@@ -28,7 +28,7 @@ void tty_write(const char* buffer, const size_t size)
}
default: {
text_putchar(buffer[i], cursor_x, cursor_y);
vga_putchar(buffer[i], cursor_x, cursor_y);
if(cursor_x + 1 < boot_info.framebuffer_width) {
++cursor_x;
......
#include "../kernel.h"
#include "vga.h"
void vga_clear()
{
*((uint16_t*) VGA_BUFFER) = 0;
bzero((void*) VGA_BUFFER, VGA_WIDTH * VGA_HEIGHT * sizeof(uint16_t));
}
void vga_putchar_color(const char c, const uint8_t color,
const size_t x, const size_t y)
{
((uint16_t*) VGA_BUFFER)[y * VGA_WIDTH + x]
= (uint16_t) c | ((uint16_t) color << 8);
}
......@@ -3,13 +3,13 @@
# include "../libc/string.h"
# define TEXT_BUFFER 0xb8000
# define TEXT_WIDTH 0xb8000
# define TEXT_HEIGHT 0xb8000
# define VGA_BUFFER 0xb8000
# define VGA_WIDTH 80
# define VGA_HEIGHT 24
# define TEXT_DEFAULT_COLOR VGA_COLOR_WHITE | (VGA_COLOR_BLACK << 4)
# define VGA_DEFAULT_COLOR VGA_COLOR_WHITE | (VGA_COLOR_BLACK << 4)
typedef enum text_color
typedef enum
{
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
......@@ -29,18 +29,18 @@ typedef enum text_color
VGA_COLOR_WHITE = 15
} vga_color_t;
inline uint8_t text_entry_color(const vga_color_t fg, const vga_color_t bg)
inline uint8_t vga_entry_color(const vga_color_t fg, const vga_color_t bg)
{
return fg | (bg << 4);
}
void text_clear();
void text_putchar_color(const char c, const uint8_t color,
void vga_clear();
void vga_putchar_color(const char c, const uint8_t color,
const size_t x, const size_t y);
inline void text_putchar(const char c, const size_t x, const size_t y)
inline void vga_putchar(const char c, const size_t x, const size_t y)
{
text_putchar_color(c, TEXT_DEFAULT_COLOR, x, y);
vga_putchar_color(c, VGA_DEFAULT_COLOR, x, y);
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment