finally to a point where i can start building ddrivers for this framebuffer's output smh

This commit is contained in:
shockrahwow 2019-10-01 10:35:35 -07:00
parent d5af87e3b0
commit 7bc439f3ad
10 changed files with 31 additions and 18 deletions

View File

@ -1,6 +1,6 @@
#ifndef INCLUDE_IO_H #ifndef INCLUDE_IO_H
#define INCLUDE_IO_H #define INCLUDE_IO_H
void out_buffer(unsigned short, unsigned char); void fb_cursor_control(unsigned short, unsigned char);
#endif /* INCLUDE_IO_H */ #endif /* INCLUDE_IO_H */

10
fb.s Normal file
View File

@ -0,0 +1,10 @@
; Helpers for frame buffer which pretty much have to to be
; written in asm
global fb_cursor_control
fb_cursor_control:
mov al, [esp+8]
mov dx, [esp+4]
out dx, al
ret

View File

@ -24,13 +24,14 @@ void clear_fb(void) {
for(unsigned cell=0;cell<AREA; cell+=2) { for(unsigned cell=0;cell<AREA; cell+=2) {
write_cell_fb(' ', 0x00, 0x00); write_cell_fb(' ', 0x00, 0x00);
} }
Frame_Buffer_Cursor = 0x0000;
} }
// Takes the linear indexed position to move the cursos, if there is nothing at that position we should still have something there // Takes the linear indexed position to move the cursos, if there is nothing at that position we should still have something there
void fb_move_cursor(u16 position) { void fb_move_cursor(u16 position) {
out_buffer(FB_CMD, FB_HIGH_CMD); fb_cursor_control(FB_CMD, FB_HIGH_CMD);
out_buffer(FB_DATA, ((position >> 8) & 0x00ff) ); fb_cursor_control(FB_DATA, ((position >> 8) & 0x00ff) );
out_buffer(FB_CMD, FB_LOW_CMD); fb_cursor_control(FB_CMD, FB_LOW_CMD);
out_buffer(FB_DATA, position & 0x00ff); fb_cursor_control(FB_DATA, position & 0x00ff);
} }

View File

@ -1,5 +1,5 @@
#include "types.h" #include "types.h"
#include "io.h" #include "fb.h"
#define COLUMNS 80 #define COLUMNS 80
#define ROWS 25 #define ROWS 25

7
io.s
View File

@ -1,7 +0,0 @@
global out_buffer
out_buffer:
mov al, [esp+8]
mov dx, [esp+4]
out dx, al
ret

View File

@ -3,7 +3,7 @@ ASM=nasm
LINK=ld LINK=ld
ISO=genisoimage ISO=genisoimage
OBJECTS=loader.o framebuffer.o io.o stlio.o tests.o OBJECTS=loader.o framebuffer.o fb.o stlio.o tests.o
AFLAGS=-f elf32 AFLAGS=-f elf32
CFLAGS=-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \ CFLAGS=-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \
-nodefaultlibs -Wall -Wextra -Werror -c -nodefaultlibs -Wall -Wextra -Werror -c

View File

@ -1,6 +1,12 @@
#include "stlio.h" #include "stlio.h"
u64 write(const s8* buffer, const u64 size) { // We are assuming null-terminated strings here
u64 strlen(char* buffer) {
char* c;
for(c = buffer; *c != '\0'; c++); // LULW
return (u64)(c - buffer);
}
u64 write(const char* buffer, const u64 size) {
u64 i; u64 i;
for(i = 0; i < size; i++) { for(i = 0; i < size; i++) {
write_cell_fb(buffer[i], Green, White); write_cell_fb(buffer[i], Green, White);

View File

@ -2,4 +2,5 @@
#include "framebuffer.h" #include "framebuffer.h"
// Frame buffer driver // Frame buffer driver
u64 write(const s8*, const u64); u64 strlen(char*);
u64 write(const char*, const u64);

View File

@ -1,8 +1,9 @@
// Module for testing drivers and other things // Module for testing drivers and other things
#include "stlio.h"
#include "tests.h" #include "tests.h"
void test_write() { void test_write() {
clear_fb(); clear_fb();
s8* msg1 = (s8*)"big yeet"; char* msg1 = "bigyeet";
write(msg1, sizeof(msg1)); write(msg1, strlen(msg1));
} }

View File

@ -1,3 +1,4 @@
#include "types.h" #include "types.h"
#include "stlio.h" #include "stlio.h"
void test_write(); void test_write();