aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/memtext.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/memtext.cc')
-rw-r--r--src/drivers/memtext.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/drivers/memtext.cc b/src/drivers/memtext.cc
new file mode 100644
index 0000000..b5371b1
--- /dev/null
+++ b/src/drivers/memtext.cc
@@ -0,0 +1,41 @@
+#include "memtext.hpp"
+#include "core/paging.hpp"
+#include "core/types.hpp"
+#include "libs/string.hpp"
+
+
+
+char memtext_buffer[MEMTEXT_BUFFER_SIZE];
+u64 memtext_x=0;
+
+void memtext_init(){
+ PAGING_MAP2_RANGE(MEMTEXT_ADDR_LOCATION,0x0,8);
+ u64* p_addr=(u64*)MEMTEXT_ADDR_LOCATION;
+ *p_addr=(u64)memtext_buffer;
+
+ // Cleaning buffer
+ for(memtext_x=0;memtext_x<MEMTEXT_BUFFER_SIZE;memtext_x++)
+ memtext_buffer[memtext_x]=0;
+ memtext_x=0;
+}
+
+void memtext_putchar(char c){
+
+ if(memtext_x>=MEMTEXT_BUFFER_SIZE){
+ memtext_scrollup(1);
+ memtext_buffer[memtext_x-1]=c;
+ return;
+ }
+ memtext_buffer[memtext_x]=c;
+ memtext_x++;
+}
+
+void memtext_scrollup(u32 n){
+ u64 start=(u64)memtext_buffer;
+ for(u64 i=0;i<MEMTEXT_BUFFER_SIZE;i++){
+ if(i+n<MEMTEXT_BUFFER_SIZE)
+ memtext_buffer[i]=memtext_buffer[i+n];
+ else
+ memtext_buffer[i]=0;
+ }
+} \ No newline at end of file