2019-04-03 08:51:46 +00:00
|
|
|
|
2019-04-01 11:21:00 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
size_t strlen(const char* string) {
|
|
|
|
size_t size = 0;
|
|
|
|
while (string[size])
|
|
|
|
size++;
|
|
|
|
return size;
|
2019-04-03 08:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char inb(unsigned short port) {
|
|
|
|
unsigned char ptr;
|
|
|
|
asm volatile("inb %1, %0" : "=a" (ptr) : "dN" (port));
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void outb(unsigned short port, unsigned char data) {
|
|
|
|
asm volatile("outb %1, %0" : : "dN" (port), "a" (data));
|
2019-04-07 12:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void memcpy(void* dest, void* src, size_t n) {
|
|
|
|
char* src_c = (char*)src;
|
|
|
|
char* dest_c = (char*)dest;
|
|
|
|
|
|
|
|
for(size_t i = 0; i < n; i++) {
|
|
|
|
dest_c[i] = src_c[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void memset(void* src, int chr, size_t n) {
|
|
|
|
unsigned char* ptr = src;
|
|
|
|
while(n--) {
|
|
|
|
*ptr++ = (unsigned char) chr;
|
|
|
|
}
|
|
|
|
}
|