#define SERIAL_PORT 0x3F8
#define GDB_SERIAL_PORT 0x2F8
+
// === IMPORTS ===
extern int GetCPUNum(void);
extern void *Proc_GetCurThread(void);
int gbDebug_SerialSetup = 0;
int gbGDB_SerialSetup = 0;
+// === PROTOTYPEs ===
+ int putDebugChar(char ch);
+
// === CODE ===
/**
* \brief Determine if a short spinlock is locked
}
// === DEBUG IO ===
+#if USE_GDB_STUB
int putDebugChar(char ch)
{
if(!gbGDB_SerialSetup) {
while( (inb(GDB_SERIAL_PORT + 5) & 1) == 0) ;
return inb(GDB_SERIAL_PORT);
}
+#endif
void Debug_PutCharDebug(char ch)
{
#endif
}
+void Debug_PutStringDebug(const char *String)
+{
+ while(*String)
+ Debug_PutCharDebug(*String++);
+}
+
// === PORT IO ===
void outb(Uint16 Port, Uint8 Data)
{
}
// === Endianness ===
+/*
Uint32 BigEndian32(Uint32 Value)
{
Uint32 ret;
{
return (Value>>8)|(Value<<8);
}
+*/
// === Memory Manipulation ===
int memcmp(const void *__dest, const void *__src, size_t __count)
void *memcpy(void *__dest, const void *__src, size_t __count)
{
- if( ((tVAddr)__dest & 7) != ((tVAddr)__src & 7) )
- __asm__ __volatile__ ("rep movsb" : : "D"(__dest),"S"(__src),"c"(__count));
- else {
- const Uint8 *src = __src;
- Uint8 *dst = __dest;
- while( (tVAddr)src & 7 && __count ) {
- *dst++ = *src++;
+ tVAddr dst = (tVAddr)__dest, src = (tVAddr)__src;
+ if( (dst & 7) != (src & 7) )
+ {
+ __asm__ __volatile__ ("rep movsb" : : "D"(dst),"S"(src),"c"(__count));
+ }
+ else
+ {
+ while( (src & 7) && __count ) {
+ *(char*)dst++ = *(char*)src++;
__count --;
}
- __asm__ __volatile__ ("rep movsq" : : "D"(dst),"S"(src),"c"(__count/8));
- src += __count & ~7;
- dst += __count & ~7;
+ __asm__ __volatile__ ("rep movsq" : "=D"(dst),"=S"(src) : "0"(dst),"1"(src),"c"(__count/8));
__count = __count & 7;
while( __count-- )
- *dst++ = *src++;
+ *(char*)dst++ = *(char*)src++;
}
return __dest;
}
return __dest;
}
+Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem)
+{
+ Uint64 ret, rem;
+ __asm__ __volatile__(
+ "div %4"
+ : "=a" (ret), "=d" (rem)
+ : "a" ( Num ), "d" (0), "r" (Den)
+ );
+ if(Rem) *Rem = rem;
+ return ret;
+}
+