blob: b5371b1742e90c4bb40c528e6cfa5bb22168abe9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
}
}
|