finally to a point where i can start building ddrivers for this framebuffer's output smh
This commit is contained in:
parent
d5af87e3b0
commit
7bc439f3ad
@ -1,6 +1,6 @@
|
||||
#ifndef 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 */
|
10
fb.s
Normal file
10
fb.s
Normal 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
|
@ -24,13 +24,14 @@ void clear_fb(void) {
|
||||
for(unsigned cell=0;cell<AREA; cell+=2) {
|
||||
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
|
||||
void fb_move_cursor(u16 position) {
|
||||
out_buffer(FB_CMD, FB_HIGH_CMD);
|
||||
out_buffer(FB_DATA, ((position >> 8) & 0x00ff) );
|
||||
out_buffer(FB_CMD, FB_LOW_CMD);
|
||||
out_buffer(FB_DATA, position & 0x00ff);
|
||||
fb_cursor_control(FB_CMD, FB_HIGH_CMD);
|
||||
fb_cursor_control(FB_DATA, ((position >> 8) & 0x00ff) );
|
||||
fb_cursor_control(FB_CMD, FB_LOW_CMD);
|
||||
fb_cursor_control(FB_DATA, position & 0x00ff);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "types.h"
|
||||
#include "io.h"
|
||||
#include "fb.h"
|
||||
|
||||
#define COLUMNS 80
|
||||
#define ROWS 25
|
||||
|
7
io.s
7
io.s
@ -1,7 +0,0 @@
|
||||
global out_buffer
|
||||
|
||||
out_buffer:
|
||||
mov al, [esp+8]
|
||||
mov dx, [esp+4]
|
||||
out dx, al
|
||||
ret
|
2
makefile
2
makefile
@ -3,7 +3,7 @@ ASM=nasm
|
||||
LINK=ld
|
||||
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
|
||||
CFLAGS=-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \
|
||||
-nodefaultlibs -Wall -Wextra -Werror -c
|
||||
|
8
stlio.c
8
stlio.c
@ -1,6 +1,12 @@
|
||||
#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;
|
||||
for(i = 0; i < size; i++) {
|
||||
write_cell_fb(buffer[i], Green, White);
|
||||
|
3
stlio.h
3
stlio.h
@ -2,4 +2,5 @@
|
||||
#include "framebuffer.h"
|
||||
// Frame buffer driver
|
||||
|
||||
u64 write(const s8*, const u64);
|
||||
u64 strlen(char*);
|
||||
u64 write(const char*, const u64);
|
||||
|
5
tests.c
5
tests.c
@ -1,8 +1,9 @@
|
||||
// Module for testing drivers and other things
|
||||
#include "stlio.h"
|
||||
#include "tests.h"
|
||||
|
||||
void test_write() {
|
||||
clear_fb();
|
||||
s8* msg1 = (s8*)"big yeet";
|
||||
write(msg1, sizeof(msg1));
|
||||
char* msg1 = "bigyeet";
|
||||
write(msg1, strlen(msg1));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user