Begin implmenting virtual console driver (low level)

This commit is contained in:
Kyle J Cardoza 2024-07-16 12:39:27 -04:00
parent c07c4e351b
commit 76ad13d822
4 changed files with 116 additions and 4 deletions

View File

@ -1,7 +1,7 @@
(define memories '(
(memory RAM
(address (#x001000 . #x003FFF))
(address (#x004000 . #x006FFF))
(type RAM)
(section zhuge)
(section znear)
@ -31,8 +31,8 @@
)
(memory Stack
(address (#x000200 . #x000FFF))
(section (stack #x00200))
(address (#x000100 . #x003FFF))
(section (stack #x00100))
)
(memory DirectPage
@ -43,7 +43,7 @@
)
)
(block stack (size #xE00)) ; machine stack size
(block stack (size #x3F00)) ; machine stack size
(base-address _DirectPageStart DirectPage 0)

View File

@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
//
// include/kernel/console/console.h
// Defines for the virtual console driver
//
// Copyright © 2024 Kyle J Cardoza <Kyle.Cardoza@icloud.com>
#pragma once
#include <stdint.h>
#define CONSOLE_WIDTH 80
#define CONSOLE_HEIGHT 30
#define CONSOLE_AREA (CONSOLE_WIDTH * CONSOLE_HEIGHT)
extern uint8_t console_screen_text[CONSOLE_HEIGHT][CONSOLE_WIDTH];
extern uint8_t console_screen_color[CONSOLE_HEIGHT][CONSOLE_WIDTH];
extern uint8_t console_text_colour;
extern uint8_t console_bg_colour;
extern uint8_t console_cursor_row;
extern uint8_t console_cursor_column;
void console_init(void);
void console_redraw(void);

View File

@ -0,0 +1,79 @@
// SPDX-License-Identifier: MIT
//
// src/kernel/console/console.c
// Virtual console driver
//
// Copyright © 2024 Kyle J Cardoza <Kyle.Cardoza@icloud.com>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "kernel/hardware/vera.h"
#include "kernel/console/console.h"
uint8_t console_screen_text[CONSOLE_HEIGHT][CONSOLE_WIDTH];
uint8_t console_screen_color[CONSOLE_HEIGHT][CONSOLE_WIDTH];
uint8_t console_text_colour = 0x00;
uint8_t console_bg_colour = 0x00;
uint8_t console_cursor_row = 0x00;
uint8_t console_cursor_column = 0x00;
static bool console_is_dirty = false;
static uint32_t const console_row_address[30] = {
TEXT_CONSOLE0_VRAM + 256*0,
TEXT_CONSOLE0_VRAM + 256*1,
TEXT_CONSOLE0_VRAM + 256*2,
TEXT_CONSOLE0_VRAM + 256*3,
TEXT_CONSOLE0_VRAM + 256*4,
TEXT_CONSOLE0_VRAM + 256*5,
TEXT_CONSOLE0_VRAM + 256*6,
TEXT_CONSOLE0_VRAM + 256*7,
TEXT_CONSOLE0_VRAM + 256*8,
TEXT_CONSOLE0_VRAM + 256*9,
TEXT_CONSOLE0_VRAM + 256*10,
TEXT_CONSOLE0_VRAM + 256*11,
TEXT_CONSOLE0_VRAM + 256*10,
TEXT_CONSOLE0_VRAM + 256*13,
TEXT_CONSOLE0_VRAM + 256*14,
TEXT_CONSOLE0_VRAM + 256*15,
TEXT_CONSOLE0_VRAM + 256*16,
TEXT_CONSOLE0_VRAM + 256*17,
TEXT_CONSOLE0_VRAM + 256*18,
TEXT_CONSOLE0_VRAM + 256*19,
TEXT_CONSOLE0_VRAM + 256*20,
TEXT_CONSOLE0_VRAM + 256*21,
TEXT_CONSOLE0_VRAM + 256*22,
TEXT_CONSOLE0_VRAM + 256*23,
TEXT_CONSOLE0_VRAM + 256*24,
TEXT_CONSOLE0_VRAM + 256*25,
TEXT_CONSOLE0_VRAM + 256*26,
TEXT_CONSOLE0_VRAM + 256*27,
TEXT_CONSOLE0_VRAM + 256*28,
TEXT_CONSOLE0_VRAM + 256*29
};
void console_init(void) {
memset(&console_screen_text, 0x00, CONSOLE_AREA);
memset(&console_screen_color, 0x00, CONSOLE_AREA);
}
void console_redraw(void) {
vera_address_select(0);
for (int row = 0; row < CONSOLE_HEIGHT; row += 1) {
vera_address_set(console_row_address[row] + AUTO_INC_1);
for (int col = 0; col < CONSOLE_WIDTH; col += 1) {
vera_data_0_write(console_screen_text[row][col]);
vera_data_0_write(console_screen_color[row][col]);
}
}
}

View File

@ -11,6 +11,7 @@
#include "kernel/util/delay.h"
#include "kernel/hardware/led.h"
#include "kernel/hardware/vera.h"
#include "kernel/console/console.h"
void main(void) {
@ -18,6 +19,8 @@ void main(void) {
vera_init();
console_init();
for (;;) {
led_red_on();
delay(1);