245d09b056
But something's wrong with the GDT Next up is a Serial Console
36 lines
698 B
C
36 lines
698 B
C
|
|
#include <stddef.h>
|
|
|
|
size_t strlen(const char* string) {
|
|
size_t size = 0;
|
|
while (string[size])
|
|
size++;
|
|
return size;
|
|
}
|
|
|
|
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));
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|