forked from ReturnInfinity/BareMetal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibBareMetal.c
More file actions
56 lines (42 loc) · 1.71 KB
/
libBareMetal.c
File metadata and controls
56 lines (42 loc) · 1.71 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
// =============================================================================
// BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
// Copyright (C) 2008-2024 Return Infinity -- see LICENSE.TXT
//
// Version 1.0
// =============================================================================
unsigned char b_input(void) {
unsigned char chr;
asm volatile ("call *0x00100010" : "=a" (chr));
return chr;
}
void b_output(const char *str, unsigned long nbr) {
asm volatile ("call *0x00100018" : : "S"(str), "c"(nbr));
}
void b_net_tx(void *mem, unsigned long len, unsigned long iid) {
asm volatile ("call *0x00100020" : : "S"(mem), "c"(len), "d"(iid));
}
unsigned long b_net_rx(void *mem, unsigned long iid) {
unsigned long tlong;
asm volatile ("call *0x00100028" : "=c"(tlong) : "D"(mem), "d"(iid));
return tlong;
}
unsigned long b_storage_read(void *mem, unsigned long start, unsigned long num, unsigned long drivenum) {
unsigned long tlong;
asm volatile ("call *0x00100030" : "=c"(tlong) : "a"(start), "c"(num), "d"(drivenum), "D"(mem));
return tlong;
}
unsigned long b_storage_write(void *mem, unsigned long start, unsigned long num, unsigned long drivenum) {
unsigned long tlong = 0;
asm volatile ("call *0x00100038" : "=c"(tlong) : "a"(start), "c"(num), "d"(drivenum), "S"(mem));
return tlong;
}
unsigned long b_config(unsigned long function, unsigned long var) {
unsigned long tlong;
asm volatile ("call *0x00100040" : "=a"(tlong) : "c"(function), "a"(var));
return tlong;
}
void b_system(unsigned long function, void* var1, void* var2) {
asm volatile ("call *0x00100048" : : "c"(function), "a"(var1), "d"(var2));
}
// =============================================================================
// EOF