add getCursor
This commit is contained in:
14
arch/cga.cc
14
arch/cga.cc
@@ -8,7 +8,12 @@ namespace CGA {
|
||||
|
||||
void writeCGAReg(int reg, int data){
|
||||
index_port.outb(reg);
|
||||
data_port.outb(data);
|
||||
data_port.outw(data);
|
||||
}
|
||||
|
||||
uint16_t readCGAReg(int reg){
|
||||
index_port.outb(reg);
|
||||
return data_port.inb();
|
||||
}
|
||||
|
||||
void setCursor(unsigned abs_x, unsigned abs_y) {
|
||||
@@ -19,8 +24,11 @@ void setCursor(unsigned abs_x, unsigned abs_y) {
|
||||
}
|
||||
|
||||
void getCursor(unsigned& abs_x, unsigned& abs_y) {
|
||||
(void)abs_x;
|
||||
(void)abs_y;
|
||||
uint16_t pos = readCGAReg(RegisterIndex::CURSOR_LOW);
|
||||
pos |= (readCGAReg(RegisterIndex::CURSOR_HIGH) << 8);
|
||||
|
||||
abs_x = pos / 80;
|
||||
abs_y = pos % 80;
|
||||
}
|
||||
|
||||
void show(unsigned abs_x, unsigned abs_y, char character, Attribute attrib) {
|
||||
|
||||
@@ -67,7 +67,6 @@ enum Color {
|
||||
* (`-fno-strict-aliasing`). In \StuBS we use this feature extensively due to
|
||||
* the improved code readability.
|
||||
*
|
||||
* \todo(11) Fill in the bitfield
|
||||
*/
|
||||
union Attribute {
|
||||
struct {
|
||||
@@ -79,8 +78,6 @@ union Attribute {
|
||||
|
||||
/*! \brief Attribute constructor (with default values)
|
||||
*
|
||||
* \todo(11) Complete constructor
|
||||
*
|
||||
* \param foreground Foreground color (Default: \ref LIGHT_GREY)
|
||||
* \param background Background color (Default: \ref BLACK)
|
||||
* \param blink Blink if `true` (default: no blinking)
|
||||
@@ -91,8 +88,6 @@ union Attribute {
|
||||
|
||||
/*! \brief Set the keyboard hardware cursor to absolute screen position
|
||||
*
|
||||
* \todo(11) Implement the method using \ref IOPort
|
||||
*
|
||||
* \param abs_x absolute column of the keyboard hardware cursor
|
||||
* \param abs_y absolute row of the keyboard hardware cursor
|
||||
*/
|
||||
|
||||
9
main.cc
9
main.cc
@@ -10,8 +10,13 @@ extern "C" int main() {
|
||||
unsigned int numCPUs = Core::count();
|
||||
DBG_VERBOSE << "Number of CPUs: " << numCPUs << endl;
|
||||
|
||||
CGA::setCursor(1, 2);
|
||||
|
||||
CGA::setCursor(0, 0);
|
||||
|
||||
unsigned x,y;
|
||||
CGA::getCursor(x, y);
|
||||
|
||||
CGA::setCursor(x+1, y+1);
|
||||
|
||||
/* Start application processors
|
||||
* To avoid unexpected behaviour, make sure that interrupts are not
|
||||
* enabled before the APs are booted. Otherwise it might interfere with the
|
||||
|
||||
Reference in New Issue
Block a user