OpenCores
URL https://opencores.org/ocsvn/test_project/test_project/trunk

Subversion Repositories test_project

[/] [test_project/] [trunk/] [sw/] [support/] [support.c] - Diff between revs 33 and 52

Show entire file | Details | Blame | View Log

Rev 33 Rev 52
Line 6... Line 6...
 
 
#include "spr_defs.h"
#include "spr_defs.h"
#include "support.h"
#include "support.h"
#include "int.h"
#include "int.h"
 
 
 
#ifdef UART_PRINTF
 
//#include "snprintf.h"
 
#include "vfnprintf.h"
 
#include "uart.h"
 
#endif
 
 
#if OR32
#if OR32
void excpt_dummy();
void excpt_dummy();
void int_main();
void int_main();
 
 
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
unsigned long excpt_buserr = (unsigned long) excpt_dummy;
Line 29... Line 35...
 
 
/* Start function, called by reset exception handler.  */
/* Start function, called by reset exception handler.  */
void reset ()
void reset ()
{
{
  int i = main();
  int i = main();
  exit (i);
  or32_exit (i);
}
}
 
 
/* return value by making a syscall */
/* return value by making a syscall */
void exit (int i)
void or32_exit (int i)
{
{
  asm("l.add r3,r0,%0": : "r" (i));
  asm("l.add r3,r0,%0": : "r" (i));
  asm("l.nop %0": :"K" (NOP_EXIT));
  asm("l.nop %0": :"K" (NOP_EXIT));
  while (1);
  while (1);
}
}
 
 
 
#ifdef UART_PRINTF
 
 
 
static int uart_init_done = 0;
 
 
 
#define PRINTFBUFFER_SIZE 512
 
char PRINTFBUFFER[PRINTFBUFFER_SIZE]; // Declare a global printf buffer
 
 
 
void printf(const char *fmt, ...)
 
{
 
  // init uart if not done already
 
  if (!uart_init_done)
 
    {
 
      uart_init();
 
      uart_init_done = 1;
 
    }
 
 
 
  va_list args;
 
  va_start(args, fmt);
 
 
 
  //int str_l = vsnprintf(PRINTFBUFFER, PRINTFBUFFER_SIZE, fmt, args);
 
  int str_l = vfnprintf(PRINTFBUFFER, PRINTFBUFFER_SIZE, fmt, args);
 
 
 
  if (!str_l) return; // no length string - just return
 
 
 
  int c=0;
 
  // now print each char via the UART
 
  while (c < str_l)
 
    uart_putc(PRINTFBUFFER[c++]);
 
 
 
  va_end(args);
 
 
 
}
 
 
 
#else
/* activate printf support in simulator */
/* activate printf support in simulator */
void printf(const char *fmt, ...)
void printf(const char *fmt, ...)
{
{
  va_list args;
  va_list args;
  va_start(args, fmt);
  va_start(args, fmt);
  __asm__ __volatile__ ("  l.addi\tr3,%1,0\n \
  __asm__ __volatile__ ("  l.addi\tr3,%1,0\n \
                           l.addi\tr4,%2,0\n \
                           l.addi\tr4,%2,0\n \
                           l.nop %0": :"K" (NOP_PRINTF), "r" (fmt), "r"  (args));
                           l.nop %0": :"K" (NOP_PRINTF), "r" (fmt), "r"  (args));
}
}
 
 
 
/*
 
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;
 
}
 
*/
 
#endif
 
 
 
 
 
 
 
 
 
 
/* print long */
/* print long */
void report(unsigned long value)
void report(unsigned long value)
{
{
  asm("l.addi\tr3,%0,0": :"r" (value));
  asm("l.addi\tr3,%0,0": :"r" (value));
  asm("l.nop %0": :"K" (NOP_REPORT));
  asm("l.nop %0": :"K" (NOP_REPORT));
Line 118... Line 176...
  return(tv.tv_sec*1000000+tv.tv_usec);
  return(tv.tv_sec*1000000+tv.tv_usec);
}
}
 
 
#endif
#endif
 
 
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;
 
}
 
 
 
void excpt_dummy() {}
void excpt_dummy() {}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.