Merge branch 'sd2' into 'main'
use enum See merge request vss/teaching/ss25/v_bsb1/Gruppe_018!1
This commit is contained in:
15
arch/cga.cc
15
arch/cga.cc
@@ -1,10 +1,21 @@
|
||||
#include "cga.h"
|
||||
#include "arch/ioport.h"
|
||||
|
||||
namespace CGA {
|
||||
|
||||
IOPort index_port = IOPort(0x3d4);
|
||||
IOPort data_port = IOPort(0x3d5);
|
||||
|
||||
void writeCGAReg(int reg, int data){
|
||||
index_port.outb(reg);
|
||||
data_port.outb(data);
|
||||
}
|
||||
|
||||
void setCursor(unsigned abs_x, unsigned abs_y) {
|
||||
(void)abs_x;
|
||||
(void)abs_y;
|
||||
uint16_t pos = abs_y * COLUMNS + abs_x;
|
||||
|
||||
writeCGAReg(RegisterIndex::CURSOR_LOW, pos & 0xFF);
|
||||
writeCGAReg(RegisterIndex::CURSOR_HIGH, ((pos >> 8) & 0xFF));
|
||||
}
|
||||
|
||||
void getCursor(unsigned& abs_x, unsigned& abs_y) {
|
||||
|
||||
19
arch/cga.h
19
arch/cga.h
@@ -18,6 +18,15 @@ namespace CGA {
|
||||
constexpr unsigned ROWS = 25; ///< Visible rows in text mode
|
||||
constexpr unsigned COLUMNS = 80; ///< Visible columns in text mode
|
||||
|
||||
enum RegisterIndex {
|
||||
CURSOR_START = 10,
|
||||
CURSOR_END = 11,
|
||||
START_ADDRESS_HIGH = 12,
|
||||
START_ADDRESS_LOW = 13,
|
||||
CURSOR_HIGH = 14,
|
||||
CURSOR_LOW = 15
|
||||
};
|
||||
|
||||
/*! \brief CGA color palette
|
||||
*
|
||||
* Colors for the attribute byte.
|
||||
@@ -62,7 +71,9 @@ enum Color {
|
||||
*/
|
||||
union Attribute {
|
||||
struct {
|
||||
uint8_t todo : 8;
|
||||
uint8_t foreground : 4;
|
||||
uint8_t background : 3;
|
||||
uint8_t blink : 1;
|
||||
} __attribute__((packed));
|
||||
uint8_t value; ///< combined value
|
||||
|
||||
@@ -75,11 +86,7 @@ union Attribute {
|
||||
* \param blink Blink if `true` (default: no blinking)
|
||||
*/
|
||||
explicit Attribute(Color foreground = LIGHT_GREY, Color background = BLACK,
|
||||
bool blink = false) { // NOLINT
|
||||
(void)foreground;
|
||||
(void)background;
|
||||
(void)blink;
|
||||
}
|
||||
bool blink = false) : foreground(foreground), background(background), blink(blink) {}
|
||||
} __attribute__((packed)); // prevent padding by the compiler
|
||||
|
||||
/*! \brief Set the keyboard hardware cursor to absolute screen position
|
||||
|
||||
5
main.cc
5
main.cc
@@ -2,7 +2,7 @@
|
||||
#include "boot/startup_ap.h"
|
||||
#include "debug/output.h"
|
||||
|
||||
#include "cga.h"
|
||||
#include "arch/cga.h"
|
||||
|
||||
// Main function
|
||||
// (the bootstrap processor starts here)}
|
||||
@@ -10,8 +10,7 @@ extern "C" int main() {
|
||||
unsigned int numCPUs = Core::count();
|
||||
DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl;
|
||||
|
||||
clear_display();
|
||||
puts("Moin!");
|
||||
CGA::setCursor(1, 2);
|
||||
|
||||
/* Start application processors
|
||||
* To avoid unexpected behaviour, make sure that interrupts are not
|
||||
|
||||
Reference in New Issue
Block a user