summaryrefslogtreecommitdiff
path: root/src/kernel/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/dev')
-rw-r--r--src/kernel/dev/display.h1
-rw-r--r--src/kernel/dev/keyboard.cpp2
-rw-r--r--src/kernel/dev/ps2keyboard.cpp1
-rw-r--r--src/kernel/dev/vgatxt.cpp34
-rw-r--r--src/kernel/dev/vgatxt.h7
5 files changed, 42 insertions, 3 deletions
diff --git a/src/kernel/dev/display.h b/src/kernel/dev/display.h
index ec67e7e..963b5e6 100644
--- a/src/kernel/dev/display.h
+++ b/src/kernel/dev/display.h
@@ -22,7 +22,6 @@ class display : public node {
vt *connected_vt;
display(node* parent) : node(parent, FT_DEV) {
- dev_type = DT_DISPLAY;
connected_vt = 0;
}
virtual ~display() {}
diff --git a/src/kernel/dev/keyboard.cpp b/src/kernel/dev/keyboard.cpp
index 3f54b99..af4c380 100644
--- a/src/kernel/dev/keyboard.cpp
+++ b/src/kernel/dev/keyboard.cpp
@@ -77,7 +77,7 @@ static keymap default_km = {
};
keyboard::keyboard(node *parent) : node(parent, FT_DEV) {
- dev_type = DT_KEYBOARD;
+ dev_type = DT_PCKBD;
km = &default_km;
num = true;
diff --git a/src/kernel/dev/ps2keyboard.cpp b/src/kernel/dev/ps2keyboard.cpp
index 31cd75f..c7fc322 100644
--- a/src/kernel/dev/ps2keyboard.cpp
+++ b/src/kernel/dev/ps2keyboard.cpp
@@ -53,3 +53,4 @@ void ps2kbd::kbdIrq() {
escaped = false;
}
}
+
diff --git a/src/kernel/dev/vgatxt.cpp b/src/kernel/dev/vgatxt.cpp
index eb57eb9..7abbaf9 100644
--- a/src/kernel/dev/vgatxt.cpp
+++ b/src/kernel/dev/vgatxt.cpp
@@ -4,11 +4,12 @@
#include <mem/mem.h>
static uint16_t *video_memory = (uint16_t*)((size_t)K_HIGHHALF_ADDR + 0xB8000);
+#define VIDMEM_SIZE (80 * 25 * 2)
vgatxt *text_display;
vgatxt::vgatxt(node *parent) : display(parent) {
- // nothing to do, really
+ dev_type = DT_VGATXT;
}
int vgatxt::text_w() {
@@ -52,3 +53,34 @@ void vgatxt::text_scroll(int n, uint8_t fgcolor, uint8_t bgcolor) {
// TODO
}
}
+
+
+// Operations as a FS node
+
+size_t vgatxt::get_size() { // size as a node of the filesystem
+ return (text_w() << 16) + text_h();
+}
+
+int vgatxt::read(size_t offset, size_t len, char *buffer) {
+ if (offset > VIDMEM_SIZE) return 0;
+ if (offset + len > VIDMEM_SIZE) len = VIDMEM_SIZE - offset;
+
+ char *vm = (char*)video_memory;
+ memcpy(buffer, vm + offset, len);
+ return len;
+}
+
+int vgatxt::write(size_t offset, size_t len, char *buffer) {
+ if (offset > VIDMEM_SIZE) return 0;
+ if (offset + len > VIDMEM_SIZE) len = VIDMEM_SIZE - offset;
+
+ char *vm = (char*)video_memory;
+ memcpy(vm + offset, buffer, len);
+ return len;
+}
+
+int vgatxt::dev_control(char *data) {
+ uint16_t *d = (uint16_t*)data;
+ text_setcsr(d[0], d[1], d[2] != 0);
+ return 0;
+}
diff --git a/src/kernel/dev/vgatxt.h b/src/kernel/dev/vgatxt.h
index 550d4ba..bed743e 100644
--- a/src/kernel/dev/vgatxt.h
+++ b/src/kernel/dev/vgatxt.h
@@ -10,6 +10,13 @@ class vgatxt : public display {
vgatxt(node *parent);
virtual ~vgatxt() {}
+ // as a FS node
+ virtual size_t get_size();
+ virtual int read(size_t offset, size_t len, char *buffer);
+ virtual int write(size_t offset, size_t len, char *buffer);
+ virtual int dev_control(char *data);
+
+ // as a display
virtual int text_w();
virtual int text_h();
virtual void text_setcsr(int l, int c, bool visible);