85 lines
1.7 KiB
C
85 lines
1.7 KiB
C
#ifndef __SYSTEM_H
|
|
#define __SYSTEM_H
|
|
#include <sys/declarat.h>
|
|
|
|
#define true 1
|
|
#define false 0
|
|
|
|
byte *TextVideoRam;
|
|
volatile static int cursor_x, cursor_y;
|
|
int current_mode_width;
|
|
int current_mode_height;
|
|
|
|
void *memcpy(void *dest, const void *src, int count)
|
|
{
|
|
const char *sp = (const char *)src;
|
|
char *dp = (char *)dest;
|
|
for(; count != 0; count--) *dp++ = *sp++;
|
|
return dest;
|
|
}
|
|
|
|
void *memset(void *dest, char val, int count)
|
|
{
|
|
char *temp = (char *)dest;
|
|
for( ; count != 0; count--) *temp++ = val;
|
|
return dest;
|
|
}
|
|
|
|
unsigned short *memsetw(unsigned short *dest, unsigned short val, int count)
|
|
{
|
|
unsigned short *temp = (unsigned short *)dest;
|
|
for( ; count != 0; count--) *temp++ = val;
|
|
return dest;
|
|
}
|
|
|
|
|
|
// strlen -- Get lenght of str
|
|
int strlen (const char *str)
|
|
{
|
|
int i;
|
|
for (i = 0; *str!=0; str++) i++;
|
|
return i;
|
|
}
|
|
|
|
int strcmp(const char *pStr1, const char *pStr2)
|
|
{
|
|
char c1, c2;
|
|
int v;
|
|
|
|
do {
|
|
c1 = *pStr1++;
|
|
c2 = *pStr2++;
|
|
/* the casts are necessary when pStr1 is shorter & char is signed */
|
|
v = (unsigned int)c1 - (unsigned int)c2;
|
|
} while ((v == 0) && (c1 != '\0'));
|
|
|
|
return v;
|
|
}
|
|
|
|
|
|
|
|
byte inportb (word _port) {
|
|
byte rv;
|
|
__asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
|
|
return rv;
|
|
}
|
|
byte inb (word _port) {
|
|
byte rv;
|
|
__asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
|
|
return rv;
|
|
}
|
|
|
|
static inline void iowait() {
|
|
asm volatile ("outb %al, $0x80");
|
|
}
|
|
|
|
|
|
void outportb (word _port, byte _data) {
|
|
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
|
}
|
|
void outb (word _port, byte _data) {
|
|
__asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
|
|
}
|
|
|
|
|
|
#endif |