do first tests with FPGA config. SDRAM doesn't seem to work, reading and writing of Firebee CLUT does work, hovever.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* tc.printf.c: A public-domain, minimal printf/sprintf routine that prints
|
* tc.printf.c: A public-domain, minimal printf/sprintf routine that prints
|
||||||
* through the putchar() routine. Feel free to use for
|
* through the putchar() routine. Feel free to use for
|
||||||
* anything... -- 7/17/87 Paul Placeway
|
* anything... -- 7/17/87 Paul Placeway
|
||||||
*/
|
*/
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1991 The Regents of the University of California.
|
* Copyright (c) 1980, 1991 The Regents of the University of California.
|
||||||
@@ -44,165 +44,165 @@
|
|||||||
* The eighth/sixteenth bit of characters is used to prevent recognition,
|
* The eighth/sixteenth bit of characters is used to prevent recognition,
|
||||||
* and eventually stripped.
|
* and eventually stripped.
|
||||||
*/
|
*/
|
||||||
#define META 0200
|
#define META 0200
|
||||||
#define ASCII 0177
|
#define ASCII 0177
|
||||||
#define QUOTE ((char) 0200) /* Eighth char bit used for 'ing */
|
#define QUOTE ((char) 0200) /* Eighth char bit used for 'ing */
|
||||||
#define TRIM 0177 /* Mask to strip quote bit */
|
#define TRIM 0177 /* Mask to strip quote bit */
|
||||||
#define UNDER 0000000 /* No extra bits to do both */
|
#define UNDER 0000000 /* No extra bits to do both */
|
||||||
#define BOLD 0000000 /* Bold flag */
|
#define BOLD 0000000 /* Bold flag */
|
||||||
#define STANDOUT META /* Standout flag */
|
#define STANDOUT META /* Standout flag */
|
||||||
#define LITERAL 0000000 /* Literal character flag */
|
#define LITERAL 0000000 /* Literal character flag */
|
||||||
#define ATTRIBUTES 0200 /* The bits used for attributes */
|
#define ATTRIBUTES 0200 /* The bits used for attributes */
|
||||||
#define CHAR 0000177 /* Mask to mask out the character */
|
#define CHAR 0000177 /* Mask to mask out the character */
|
||||||
|
|
||||||
#define INF 32766 /* should be bigger than any field to print */
|
#define INF 32766 /* should be bigger than any field to print */
|
||||||
|
|
||||||
static char snil[] = "(nil)";
|
static char snil[] = "(nil)";
|
||||||
|
|
||||||
void xputchar(int c)
|
void xputchar(int c)
|
||||||
{
|
{
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
(
|
(
|
||||||
".extern printf_helper\n\t"
|
".extern printf_helper\n\t"
|
||||||
"move.b %0,d0\n\t"
|
"move.b %0,d0\n\t"
|
||||||
"bsr printf_helper\n\t"
|
"bsr printf_helper\n\t"
|
||||||
/* output */:
|
/* output */:
|
||||||
/* input */: "r" (c)
|
/* input */: "r" (c)
|
||||||
/* clobber */: "d0","d2","a0","memory"
|
/* clobber */: "d0","d2","a0","memory"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doprnt(void (*addchar)(int), const char *sfmt, va_list ap)
|
static void doprnt(void (*addchar)(int), const char *sfmt, va_list ap)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
char *bp;
|
char *bp;
|
||||||
const char *f;
|
const char *f;
|
||||||
float flt;
|
float flt;
|
||||||
long l;
|
long l;
|
||||||
unsigned long u;
|
unsigned long u;
|
||||||
int i;
|
int i;
|
||||||
int fmt;
|
int fmt;
|
||||||
unsigned char pad = ' ';
|
unsigned char pad = ' ';
|
||||||
int flush_left = 0;
|
int flush_left = 0;
|
||||||
int f_width = 0;
|
int f_width = 0;
|
||||||
int prec = INF;
|
int prec = INF;
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
int do_long = 0;
|
int do_long = 0;
|
||||||
int sign = 0;
|
int sign = 0;
|
||||||
int attributes = 0;
|
int attributes = 0;
|
||||||
|
|
||||||
f = sfmt;
|
f = sfmt;
|
||||||
for (; *f; f++)
|
for (; *f; f++)
|
||||||
{
|
{
|
||||||
if (*f != '%')
|
if (*f != '%')
|
||||||
{
|
{
|
||||||
/* then just out the char */
|
/* then just out the char */
|
||||||
(*addchar)((int) (((unsigned char) *f) | attributes));
|
(*addchar)((int) (((unsigned char) *f) | attributes));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f++; /* skip the % */
|
f++; /* skip the % */
|
||||||
|
|
||||||
if (*f == '-')
|
if (*f == '-')
|
||||||
{ /* minus: flush left */
|
{ /* minus: flush left */
|
||||||
flush_left = 1;
|
flush_left = 1;
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*f == '0' || *f == '.')
|
if (*f == '0' || *f == '.')
|
||||||
{
|
{
|
||||||
/* padding with 0 rather than blank */
|
/* padding with 0 rather than blank */
|
||||||
pad = '0';
|
pad = '0';
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
if (*f == '*')
|
if (*f == '*')
|
||||||
{
|
{
|
||||||
/* field width */
|
/* field width */
|
||||||
f_width = va_arg(ap, int);
|
f_width = va_arg(ap, int);
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
else if (isdigit((unsigned char)*f))
|
else if (isdigit((unsigned char)*f))
|
||||||
{
|
{
|
||||||
f_width = atoi(f);
|
f_width = atoi(f);
|
||||||
while (isdigit((unsigned char)*f))
|
while (isdigit((unsigned char)*f))
|
||||||
f++; /* skip the digits */
|
f++; /* skip the digits */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*f == '.')
|
if (*f == '.')
|
||||||
{ /* precision */
|
{ /* precision */
|
||||||
f++;
|
f++;
|
||||||
if (*f == '*')
|
if (*f == '*')
|
||||||
{
|
{
|
||||||
prec = va_arg(ap, int);
|
prec = va_arg(ap, int);
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
else if (isdigit((unsigned char)*f))
|
else if (isdigit((unsigned char)*f))
|
||||||
{
|
{
|
||||||
prec = atoi(f);
|
prec = atoi(f);
|
||||||
while (isdigit((unsigned char)*f))
|
while (isdigit((unsigned char)*f))
|
||||||
f++; /* skip the digits */
|
f++; /* skip the digits */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*f == '#')
|
if (*f == '#')
|
||||||
{ /* alternate form */
|
{ /* alternate form */
|
||||||
hash = 1;
|
hash = 1;
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*f == 'l')
|
if (*f == 'l')
|
||||||
{ /* long format */
|
{ /* long format */
|
||||||
do_long++;
|
do_long++;
|
||||||
f++;
|
f++;
|
||||||
if (*f == 'l')
|
if (*f == 'l')
|
||||||
{
|
{
|
||||||
do_long++;
|
do_long++;
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt = (unsigned char) *f;
|
fmt = (unsigned char) *f;
|
||||||
if (fmt != 'S' && fmt != 'Q' && isupper(fmt))
|
if (fmt != 'S' && fmt != 'Q' && isupper(fmt))
|
||||||
{
|
{
|
||||||
do_long = 1;
|
do_long = 1;
|
||||||
fmt = tolower(fmt);
|
fmt = tolower(fmt);
|
||||||
}
|
}
|
||||||
bp = buf;
|
bp = buf;
|
||||||
switch (fmt)
|
switch (fmt)
|
||||||
{ /* do the format */
|
{ /* do the format */
|
||||||
case 'd':
|
case 'd':
|
||||||
switch (do_long)
|
switch (do_long)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
l = (long) (va_arg(ap, int));
|
l = (long) (va_arg(ap, int));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
default:
|
default:
|
||||||
l = va_arg(ap, long);
|
l = va_arg(ap, long);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l < 0)
|
if (l < 0)
|
||||||
{
|
{
|
||||||
sign = 1;
|
sign = 1;
|
||||||
l = -l;
|
l = -l;
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*bp++ = (char) (l % 10) + '0';
|
*bp++ = (char) (l % 10) + '0';
|
||||||
} while ((l /= 10) > 0);
|
} while ((l /= 10) > 0);
|
||||||
if (sign)
|
if (sign)
|
||||||
*bp++ = '-';
|
*bp++ = '-';
|
||||||
f_width = f_width - (int) (bp - buf);
|
f_width = f_width - (int) (bp - buf);
|
||||||
if (!flush_left)
|
if (!flush_left)
|
||||||
while (f_width-- > 0)
|
while (f_width-- > 0)
|
||||||
(*addchar)((int) (pad | attributes));
|
(*addchar)((int) (pad | attributes));
|
||||||
for (bp--; bp >= buf; bp--)
|
for (bp--; bp >= buf; bp--)
|
||||||
(*addchar)((int) (((unsigned char) *bp) | attributes));
|
(*addchar)((int) (((unsigned char) *bp) | attributes));
|
||||||
if (flush_left)
|
if (flush_left)
|
||||||
while (f_width-- > 0)
|
while (f_width-- > 0)
|
||||||
(*addchar)((int) (' ' | attributes));
|
(*addchar)((int) (' ' | attributes));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
/* this is actually more than stupid, but does work for now */
|
/* this is actually more than stupid, but does work for now */
|
||||||
@@ -242,179 +242,179 @@ static void doprnt(void (*addchar)(int), const char *sfmt, va_list ap)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
do_long = 1;
|
do_long = 1;
|
||||||
hash = 1;
|
hash = 1;
|
||||||
fmt = 'x';
|
fmt = 'x';
|
||||||
/* no break */
|
/* no break */
|
||||||
case 'o':
|
case 'o':
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'u':
|
case 'u':
|
||||||
switch (do_long)
|
switch (do_long)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
u = (unsigned long) (va_arg(ap, unsigned int));
|
u = (unsigned long) (va_arg(ap, unsigned int));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
default:
|
default:
|
||||||
u = va_arg(ap, unsigned long);
|
u = va_arg(ap, unsigned long);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fmt == 'u')
|
if (fmt == 'u')
|
||||||
{ /* unsigned decimal */
|
{ /* unsigned decimal */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*bp++ = (char) (u % 10) + '0';
|
*bp++ = (char) (u % 10) + '0';
|
||||||
} while ((u /= 10) > 0);
|
} while ((u /= 10) > 0);
|
||||||
}
|
}
|
||||||
else if (fmt == 'o')
|
else if (fmt == 'o')
|
||||||
{ /* octal */
|
{ /* octal */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*bp++ = (char) (u % 8) + '0';
|
*bp++ = (char) (u % 8) + '0';
|
||||||
} while ((u /= 8) > 0);
|
} while ((u /= 8) > 0);
|
||||||
if (hash)
|
if (hash)
|
||||||
*bp++ = '0';
|
*bp++ = '0';
|
||||||
}
|
}
|
||||||
else if (fmt == 'x')
|
else if (fmt == 'x')
|
||||||
{ /* hex */
|
{ /* hex */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
i = (int) (u % 16);
|
i = (int) (u % 16);
|
||||||
if (i < 10)
|
if (i < 10)
|
||||||
*bp++ = i + '0';
|
*bp++ = i + '0';
|
||||||
else
|
else
|
||||||
*bp++ = i - 10 + 'a';
|
*bp++ = i - 10 + 'a';
|
||||||
} while ((u /= 16) > 0);
|
} while ((u /= 16) > 0);
|
||||||
if (hash)
|
if (hash)
|
||||||
{
|
{
|
||||||
*bp++ = 'x';
|
*bp++ = 'x';
|
||||||
*bp++ = '0';
|
*bp++ = '0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = f_width - (int) (bp - buf);
|
i = f_width - (int) (bp - buf);
|
||||||
if (!flush_left)
|
if (!flush_left)
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
(*addchar)((int) (pad | attributes));
|
(*addchar)((int) (pad | attributes));
|
||||||
for (bp--; bp >= buf; bp--)
|
for (bp--; bp >= buf; bp--)
|
||||||
(*addchar)((int) (((unsigned char) *bp) | attributes));
|
(*addchar)((int) (((unsigned char) *bp) | attributes));
|
||||||
if (flush_left)
|
if (flush_left)
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
(*addchar)((int) (' ' | attributes));
|
(*addchar)((int) (' ' | attributes));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
i = va_arg(ap, int);
|
i = va_arg(ap, int);
|
||||||
(*addchar)((int) (i | attributes));
|
(*addchar)((int) (i | attributes));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
case 'Q':
|
case 'Q':
|
||||||
case 's':
|
case 's':
|
||||||
case 'q':
|
case 'q':
|
||||||
bp = va_arg(ap, char *);
|
bp = va_arg(ap, char *);
|
||||||
if (!bp)
|
if (!bp)
|
||||||
bp = snil;
|
bp = snil;
|
||||||
f_width = f_width - strlen((char *) bp);
|
f_width = f_width - strlen((char *) bp);
|
||||||
if (!flush_left)
|
if (!flush_left)
|
||||||
while (f_width-- > 0)
|
while (f_width-- > 0)
|
||||||
(*addchar)((int) (pad | attributes));
|
(*addchar)((int) (pad | attributes));
|
||||||
for (i = 0; *bp && i < prec; i++)
|
for (i = 0; *bp && i < prec; i++)
|
||||||
{
|
{
|
||||||
if (fmt == 'q' && (*bp & QUOTE))
|
if (fmt == 'q' && (*bp & QUOTE))
|
||||||
(*addchar)((int) ('\\' | attributes));
|
(*addchar)((int) ('\\' | attributes));
|
||||||
(*addchar)(
|
(*addchar)(
|
||||||
(int) (((unsigned char) *bp & TRIM) | attributes));
|
(int) (((unsigned char) *bp & TRIM) | attributes));
|
||||||
bp++;
|
bp++;
|
||||||
}
|
}
|
||||||
if (flush_left)
|
if (flush_left)
|
||||||
while (f_width-- > 0)
|
while (f_width-- > 0)
|
||||||
(*addchar)((int) (' ' | attributes));
|
(*addchar)((int) (' ' | attributes));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
attributes = va_arg(ap, int);
|
attributes = va_arg(ap, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '%':
|
case '%':
|
||||||
(*addchar)((int) ('%' | attributes));
|
(*addchar)((int) ('%' | attributes));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
|
flush_left = 0, f_width = 0, prec = INF, hash = 0, do_long = 0;
|
||||||
sign = 0;
|
sign = 0;
|
||||||
pad = ' ';
|
pad = ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *xstring, *xestring;
|
static char *xstring, *xestring;
|
||||||
|
|
||||||
void xaddchar(int c)
|
void xaddchar(int c)
|
||||||
{
|
{
|
||||||
if (xestring == xstring)
|
if (xestring == xstring)
|
||||||
*xstring = '\0';
|
*xstring = '\0';
|
||||||
else
|
else
|
||||||
*xstring++ = (char) c;
|
*xstring++ = (char) c;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sprintf(char *str, const char *format, ...)
|
int sprintf(char *str, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
|
|
||||||
xstring = str;
|
xstring = str;
|
||||||
|
|
||||||
doprnt(xaddchar, format, va);
|
doprnt(xaddchar, format, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
*xstring++ = '\0';
|
*xstring++ = '\0';
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xsnprintf(char *str, size_t size, const char *fmt, ...)
|
void xsnprintf(char *str, size_t size, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
|
|
||||||
xstring = str;
|
xstring = str;
|
||||||
xestring = str + size - 1;
|
xestring = str + size - 1;
|
||||||
doprnt(xaddchar, fmt, va);
|
doprnt(xaddchar, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
*xstring++ = '\0';
|
*xstring++ = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void xprintf(const char *fmt, ...)
|
void xprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
doprnt(xputchar, fmt, va);
|
doprnt(xputchar, fmt, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xvprintf(const char *fmt, va_list va)
|
void xvprintf(const char *fmt, va_list va)
|
||||||
{
|
{
|
||||||
doprnt(xputchar, fmt, va);
|
doprnt(xputchar, fmt, va);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xvsnprintf(char *str, size_t size, const char *fmt, va_list va)
|
void xvsnprintf(char *str, size_t size, const char *fmt, va_list va)
|
||||||
{
|
{
|
||||||
xstring = str;
|
xstring = str;
|
||||||
xestring = str + size - 1;
|
xestring = str + size - 1;
|
||||||
doprnt(xaddchar, fmt, va);
|
doprnt(xaddchar, fmt, va);
|
||||||
*xstring++ = '\0';
|
*xstring++ = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void display_progress()
|
void display_progress()
|
||||||
{
|
{
|
||||||
static int _progress_index;
|
static int _progress_index;
|
||||||
char progress_char[] = "|/-\\";
|
char progress_char[] = "|/-\\";
|
||||||
|
|
||||||
xputchar(progress_char[_progress_index++ % strlen(progress_char)]);
|
xputchar(progress_char[_progress_index++ % strlen(progress_char)]);
|
||||||
xputchar('\r');
|
xputchar('\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
void hexdump(uint8_t buffer[], int size)
|
void hexdump(uint8_t buffer[], int size)
|
||||||
|
|||||||
@@ -26,131 +26,131 @@
|
|||||||
|
|
||||||
void *memcpy(void *dst, const void *src, size_t n)
|
void *memcpy(void *dst, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
uint8_t *to = dst;
|
uint8_t *to = dst;
|
||||||
|
|
||||||
while (to < (uint8_t *) dst + n)
|
while (to < (uint8_t *) dst + n)
|
||||||
*to++ = * (uint8_t *) src++;
|
*to++ = * (uint8_t *) src++;
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void bzero(void *s, size_t n)
|
void bzero(void *s, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
((unsigned char *) s)[i] = '\0';
|
((unsigned char *) s)[i] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memset(void *s, int c, size_t n)
|
void *memset(void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
uint8_t *dst = s;
|
uint8_t *dst = s;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*dst++ = c;
|
*dst++ = c;
|
||||||
} while ((dst - (uint8_t *) s) < n);
|
} while ((dst - (uint8_t *) s) < n);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int memcmp(const void *s1, const void *s2, size_t max)
|
int memcmp(const void *s1, const void *s2, size_t max)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
for (i = 0; i < max; i++)
|
for (i = 0; i < max; i++)
|
||||||
{
|
{
|
||||||
cmp = (* (const char *) s1 - * (const char *) s2);
|
cmp = (* (const char *) s1 - * (const char *) s2);
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strcmp(const char *s1, const char *s2)
|
int strcmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
for (i = 0; *s1++ && *s2++; i++)
|
for (i = 0; *s1++ && *s2++; i++)
|
||||||
{
|
{
|
||||||
cmp = (*s1 - *s2);
|
cmp = (*s1 - *s2);
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strncmp(const char *s1, const char *s2, size_t max)
|
int strncmp(const char *s1, const char *s2, size_t max)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
for (i = 0; i < max && *s1++ && *s2++; i++);
|
for (i = 0; i < max && *s1++ && *s2++; i++);
|
||||||
{
|
{
|
||||||
cmp = (*s1 - *s2);
|
cmp = (*s1 - *s2);
|
||||||
if (cmp != 0) return cmp;
|
if (cmp != 0) return cmp;
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strcpy(char *dst, const char *src)
|
char *strcpy(char *dst, const char *src)
|
||||||
{
|
{
|
||||||
char *ptr = dst;
|
char *ptr = dst;
|
||||||
|
|
||||||
while ((*dst++ = *src++) != '\0');
|
while ((*dst++ = *src++) != '\0');
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strncpy(char *dst, const char *src, size_t max)
|
char *strncpy(char *dst, const char *src, size_t max)
|
||||||
{
|
{
|
||||||
char *ptr = dst;
|
char *ptr = dst;
|
||||||
|
|
||||||
while ((*dst++ = *src++) != '\0' && max-- >= 0);
|
while ((*dst++ = *src++) != '\0' && max-- >= 0);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int atoi(const char *c)
|
int atoi(const char *c)
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
while (isdigit(*c))
|
while (isdigit(*c))
|
||||||
{
|
{
|
||||||
value *= 10;
|
value *= 10;
|
||||||
value += (int) (*c - '0');
|
value += (int) (*c - '0');
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t strlen(const char *s)
|
size_t strlen(const char *s)
|
||||||
{
|
{
|
||||||
const char *start = s;
|
const char *start = s;
|
||||||
|
|
||||||
while (*s++);
|
while (*s++);
|
||||||
|
|
||||||
return s - start - 1;
|
return s - start - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *strcat(char *dst, const char *src)
|
char *strcat(char *dst, const char *src)
|
||||||
{
|
{
|
||||||
char *ret = dst;
|
char *ret = dst;
|
||||||
dst = &dst[strlen(dst)];
|
dst = &dst[strlen(dst)];
|
||||||
while ((*dst++ = *src++) != '\0');
|
while ((*dst++ = *src++) != '\0');
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strncat(char *dst, const char *src, size_t max)
|
char *strncat(char *dst, const char *src, size_t max)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
char *ret = dst;
|
char *ret = dst;
|
||||||
|
|
||||||
dst = &dst[strlen(dst)];
|
dst = &dst[strlen(dst)];
|
||||||
for (i = 0; i < max && *src; i++)
|
for (i = 0; i < max && *src; i++)
|
||||||
{
|
{
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
}
|
}
|
||||||
*dst++ = '\0';
|
*dst++ = '\0';
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,6 @@
|
|||||||
#include "MCF5475.h"
|
#include "MCF5475.h"
|
||||||
#include "driver_vec.h"
|
#include "driver_vec.h"
|
||||||
|
|
||||||
extern long _FPGA_JTAG_LOADED;
|
|
||||||
extern long _FPGA_JTAG_VALID;
|
|
||||||
|
|
||||||
#define VALID_JTAG 0xaffeaffe
|
|
||||||
|
|
||||||
#define FPGA_CONFIG (1 << 2)
|
#define FPGA_CONFIG (1 << 2)
|
||||||
#define FPGA_CONF_DONE (1 << 5)
|
#define FPGA_CONF_DONE (1 << 5)
|
||||||
|
|
||||||
@@ -22,8 +17,47 @@ extern long _FPGA_JTAG_VALID;
|
|||||||
#define NOP() __asm__ __volatile__("nop\n\t" : : : "memory")
|
#define NOP() __asm__ __volatile__("nop\n\t" : : : "memory")
|
||||||
|
|
||||||
long bas_start = 0xe0000000;
|
long bas_start = 0xe0000000;
|
||||||
volatile uint32_t *_VRAM = (uint32_t *) 0x60000000;
|
volatile uint32_t *_VRAM = (uint32_t *) 0x40000000;
|
||||||
|
|
||||||
|
void do_tests(void)
|
||||||
|
{
|
||||||
|
/* read out shifter registers */
|
||||||
|
unsigned char * _vmem_hi = (unsigned char *) 0xffff8201;
|
||||||
|
unsigned char * _vmem_mid = (unsigned char *) 0xffff8203;
|
||||||
|
unsigned char * _vmem_lo = (unsigned char *) 0xffff820d;
|
||||||
|
|
||||||
|
xprintf("vmem_hi = %x\r\n", *_vmem_hi);
|
||||||
|
xprintf("vmem_mid = %x\r\n", *_vmem_mid);
|
||||||
|
xprintf("vmem_lo = %x\r\n", *_vmem_lo);
|
||||||
|
|
||||||
|
/* try to write to them */
|
||||||
|
|
||||||
|
xprintf("trying to write to _vbas\r\n");
|
||||||
|
|
||||||
|
*_vmem_hi = 0xd0;
|
||||||
|
*_vmem_mid = 0x00;
|
||||||
|
*_vmem_lo = 0x00;
|
||||||
|
|
||||||
|
xprintf("read back values\r\n");
|
||||||
|
|
||||||
|
xprintf("vmem_hi = %x\r\n", *_vmem_hi);
|
||||||
|
xprintf("vmem_mid = %x\r\n", *_vmem_mid);
|
||||||
|
xprintf("vmem_lo = %x\r\n", *_vmem_lo);
|
||||||
|
|
||||||
|
xprintf("read Firebee clut\r\n");
|
||||||
|
|
||||||
|
hexdump((uint8_t *) 0xf0000000, 0x400);
|
||||||
|
|
||||||
|
xprintf("set Firebee clut\r\n");
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 0x400; i++)
|
||||||
|
{
|
||||||
|
* (unsigned char *) (0xf0000000 + i) = (uint8_t) i;
|
||||||
|
}
|
||||||
|
|
||||||
|
hexdump((uint8_t *) 0xf0000000, 0x400);
|
||||||
|
}
|
||||||
|
|
||||||
void wait_for_jtag(void)
|
void wait_for_jtag(void)
|
||||||
{
|
{
|
||||||
@@ -69,29 +103,20 @@ void wait_for_jtag(void)
|
|||||||
while (!(MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load finished */
|
while (!(MCF_GPIO_PPDSDR_FEC1L & FPGA_CONF_DONE)); /* wait for JTAG config load finished */
|
||||||
|
|
||||||
xprintf("JTAG configuration finished.\r\n");
|
xprintf("JTAG configuration finished.\r\n");
|
||||||
_FPGA_JTAG_LOADED = 1; /* indicate jtag loaded FPGA config to BaS */
|
|
||||||
_FPGA_JTAG_VALID = VALID_JTAG; /* set magic word to indicate _FPGA_JTAG_LOADED is valid */
|
|
||||||
|
|
||||||
/* wait */
|
/* wait */
|
||||||
xprintf("wait a little to let things settle...\r\n");
|
xprintf("wait a little to let things settle...\r\n");
|
||||||
for (i = 0; i < 10000000; i++);
|
for (i = 0; i < 10000000; i++);
|
||||||
|
|
||||||
xprintf("write byte data to FPGA memory\r\n");
|
/* begin of tests */
|
||||||
for (i = 0; i < 512; i++)
|
do_tests();
|
||||||
{
|
|
||||||
_VRAM[i] = i;
|
|
||||||
}
|
|
||||||
hexdump((uint8_t *) _VRAM, 512);
|
|
||||||
|
|
||||||
xprintf("wait a little to let things settle...\r\n");
|
xprintf("wait a little to let things settle...\r\n");
|
||||||
for (i = 0; i < 10000000; i++);
|
for (i = 0; i < 10000000; i++);
|
||||||
|
|
||||||
__asm__ __volatile__(
|
xprintf("INFO: endless loop now. Press reset to reboot\r\n");
|
||||||
" jmp (%[bas_start])\n\t"
|
while (1)
|
||||||
: /* no output */
|
;
|
||||||
: [bas_start] "a" (bas_start)
|
|
||||||
: /* clobber not needed */
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|||||||
Reference in New Issue
Block a user