URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [branches/] [oc/] [orpmon/] [common/] [support.c] - Rev 1767
Go to most recent revision | Compare with Previous | Blame | View Log
/* Support */ #include <sys/time.h> #include "spr_defs.h" #include "support.h" #include "int.h" unsigned long timestamp = 0; void int_main(void); /* return value by making a syscall */ void exit (int i) { asm("l.add r3,r0,%0": : "r" (i)); asm("l.nop %0": :"K" (NOP_EXIT)); while (1); } /* activate printf support in simulator */ void __printf(const char *fmt, ...) { va_list args; va_start(args, fmt); __asm__ __volatile__ (" l.addi\tr3,%1,0\n \ l.addi\tr4,%2,0\n \ l.nop %0": :"K" (NOP_PRINTF), "r" (fmt), "r" (args) : "r3", "r4"); } /* print long */ void report(unsigned long value) { asm("l.addi\tr3,%0,0": :"r" (value)); asm("l.nop %0": :"K" (NOP_REPORT)); } /* just to satisfy linker */ void __main(void) { } /* For writing into SPR. */ void mtspr(unsigned long spr, unsigned long value) { asm("l.mtspr\t\t%0,%1,0": : "r" (spr), "r" (value)); } /* For reading SPR. */ unsigned long mfspr(unsigned long spr) { unsigned long value; asm("l.mfspr\t\t%0,%1,0" : "=r" (value) : "r" (spr)); return value; } void *memcpy (void *__restrict dstvoid, __const void *__restrict srcvoid, size_t length) { char *dst = dstvoid; const char *src = (const char *) srcvoid; while (length--) *dst++ = *src++; return dst; } int memcmp (void *__restrict dstvoid, __const void *__restrict srcvoid, size_t length) { char *dst = dstvoid; const char *src = (const char *) srcvoid; while (length--) if(*dst++ != *src++) if(*(--dst) > *(--src)) return 1; else return -1; return 1; } void *memchr (void *__restrict dstvoid, __const char data, size_t length) { char *dst = dstvoid; while (length--) *dst++ = data; return dst; } int strlen (__const char *srcvoid) { int len = 0; while (*srcvoid++) len++; return len; } int strcmp (const char *s1, const char *s2) { while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } return (*(unsigned char *) s1) - (*(unsigned char *) s2); } char *strcpy (char *dst0, char *src0) { char *s = dst0; while ((*dst0++ = *src0++)); return s; } void reset_timer (void) { timestamp = 0; } unsigned long get_timer (unsigned long base) { return (timestamp - base); } void set_timer (unsigned long t) { timestamp = t; }
Go to most recent revision | Compare with Previous | Blame | View Log