restructuring build setup

This commit is contained in:
shockrahwow
2019-09-12 11:46:41 -07:00
parent b3ef53ccab
commit ee4026a89e
4 changed files with 4 additions and 3 deletions

46
core/framebuffer.c Normal file
View File

@@ -0,0 +1,46 @@
// Driver implementation for Jank's text frame buffer
// Buffer can display 80 columns by 25 Rows
// Start of buffer is at (real)address 0x000B8000
// Memory at this section is divided into 16-bit cells
// | 15-8 | 7-4 | 0-3
// | Asci | FG | BG
#include "framebuffer.h"
#include "io.h"
static char* Frame_Buffer = (char*)FRAME_BUFFER_ADDR;
//static char* Frame_Buffer_End = (char*)(FRAME_BUFFER_ADDR + AREA);
// Writes character to a given cell in the framebuffer
// @cell parameter is the logical (linear)index into the buffer
// _not_ the actual offset from the buffer addr
// also proper location is caller's responsibility
void write_cell_fb(unsigned cell, char c, char fg, char bg) {
Frame_Buffer[cell] = c;
Frame_Buffer[cell+1] = (fg & 0x0f << 4) | (bg & 0x0f);
}
void clear_fb() {
for(unsigned cell=0;cell<AREA; cell+=2) {
write_cell_fb(cell, ' ', 0x00, 0x00);
}
}
void fb_move_cursor(unsigned short 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);
}
/* generic test func for this module */
void test_fb() {
clear_fb();
write_cell_fb(FRAME_CELL(0), 'a', Green, White);
write_cell_fb(FRAME_CELL(1), 'b', Green, White);
write_cell_fb(FRAME_CELL(2), 'c', Green, White);
write_cell_fb(FRAME_CELL(3), 'c', Green, White);
write_cell_fb(FRAME_CELL(4), 'c', Green, White);
write_cell_fb(FRAME_CELL(5), 'c', Green, White);
fb_move_cursor(5);
}

48
core/framebuffer.h Normal file
View File

@@ -0,0 +1,48 @@
#include "stl/string.h"
#include "io.h"
#define COLUMNS 80
#define ROWS 25
#define AREA ( COLUMNS * ROWS )
// frame buffer port commansd
#define FB_CMD 0x3d4
#define FB_DATA 0x3d5
#define FB_HIGH_CMD 14
#define FB_LOW_CMD 15
void fb_move_cursor(unsigned short position);
// address of our frame buffer
#define FRAME_BUFFER_ADDR 0x000B8000
// Logical index of a cell in the frame buffer
#define FRAME_CELL(cell_) (cell_ * 2)
// Colors available in text framebuffer
#define Black 0x01
#define Blue 0x02
#define Green 0x03
#define Cyan 0x04
#define Red 0x05
#define Magenta 0x05
#define Brown 0x06
#define LightGrey 0x07
#define DarkGrey 0x08
#define LightBlue 0x09
#define LightGreen 0x0a
#define LightCyan 0x0b
#define LightRed 0x0c
#define LightMagenta 0x0d
#define LightBrown 0x0e
#define White 0x0f
void write_cell_fb(unsigned cell, char c , char fg, char bg);
void print_fb(char* str, unsigned position);
void clear_fb();
/* Testing function because yote squad in here yeye */
void test_fb();

1
core/kernel.c Normal file
View File

@@ -0,0 +1 @@
// Main kernel code (duh)