boucane/src/drivers/memtext.cc
2021-04-29 08:49:41 +02:00

41 lines
No EOL
930 B
C++

#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;
}
}