-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.c
More file actions
68 lines (57 loc) · 1.03 KB
/
kernel.c
File metadata and controls
68 lines (57 loc) · 1.03 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#define kb 0x60
#define kbst 0x64
#define vdo 0xB8000
#define whOnBlck 0x0F
unsigned short crsr;
void MiCore(void);
void _start(void){
MiCore();
}
void ptChr(char c, unsigned short pos){
unsigned char *video = (unsigned char*)vdo;
video[pos*2] = c;
video[pos*2 + 1] = whOnBlck;
}
void nl() {
crsr = (crsr / 80 + 1) * 80;
}
void prt(const char* str){
while(*str){
if(*str == '\n'){
nl();
} else{
ptChr(*str, crsr++);
}
str++;
}
}
void clrScr(){
unsigned char *video = (unsigned char*)vdo;
for(int i = 0; i < 80 * 25; i++){
video[i*2] = ' ';
video[i*2 + 1] = whOnBlck;
crsr = 0;
}
}
static inline unsigned char inb(unsigned short port){
unsigned char ret;
asm volatile ("inb %1, %0"
: "=a"(ret)
: "Nd"(port));
return ret;
}
void wtKyB(){
while(!inb(kbst) & 1);
}
unsigned char rdKyB(){
wtKyB();
return inb(kb);
}
void MiCore(){
asm volatile("cli");
clrScr();
prt("MiCore LOAD");
while(1){
asm volatile("nop");
}
}