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

Subversion Repositories eco32

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /eco32
    from Rev 212 to Rev 213
    Reverse comparison

Rev 212 → Rev 213

/trunk/disk/tools/fs-EOS32/mkfs/root.fsys
4,12 → 4,16
boot d--755 2 1
hello.bin ---644 2 1 ../../stdalone/hello.bin
hello2.bin ---644 2 1 ../../stdalone/hello2.bin
bottles.bin ---644 2 1 ../../stdalone/bottles.bin
memsize.bin ---644 2 1 ../../stdalone/memsize.bin
memtest.bin ---644 2 1 ../../stdalone/memtest.bin
onetask.bin ---644 2 1 ../../stdalone/onetask.bin
twotasks-1.bin ---644 2 1 ../../stdalone/twotasks-1.bin
twotasks-2.bin ---644 2 1 ../../stdalone/twotasks-2.bin
dskchk.bin ---644 2 1 ../../stdalone/dskchk.bin
dskchk2.bin ---644 2 1 ../../stdalone/dskchk2.bin
wrtmbr.bin ---644 2 1 ../../stdalone/wrtmbr.bin
dskchk.bin ---644 2 1 ../../stdalone/dskchk.bin
dmpmbr.bin ---644 2 1 ../../stdalone/dmpmbr.bin
mkpart.bin ---644 2 1 ../../stdalone/mkpart.bin
shpart.bin ---644 2 1 ../../stdalone/shpart.bin
eos32.bin ---644 2 1 ../../../os-bin/EOS32/eos32.bin
/trunk/stdalone/bottles/iolib.c
0,0 → 1,329
/*
* iolib.c -- I/O library
*/
 
 
#include "types.h"
#include "stdarg.h"
#include "iolib.h"
#include "biolib.h"
 
 
/**************************************************************/
 
/* string functions */
 
 
int strlen(char *str) {
int i;
 
i = 0;
while (*str++ != '\0') {
i++;
}
return i;
}
 
 
void strcpy(char *dst, char *src) {
while ((*dst++ = *src++) != '\0') ;
}
 
 
void memcpy(unsigned char *dst, unsigned char *src, unsigned int cnt) {
while (cnt--) {
*dst++ = *src++;
}
}
 
 
/**************************************************************/
 
/* terminal I/O */
 
 
char getchar(void) {
return getc();
}
 
 
void putchar(char c) {
if (c == '\n') {
putchar('\r');
}
putc(c);
}
 
 
void putString(char *s) {
while (*s != '\0') {
putchar(*s++);
}
}
 
 
/**************************************************************/
 
/* get a line from the terminal */
 
 
void getLine(char *prompt, char *line, int max) {
int index;
char c;
 
putString(prompt);
putString(line);
index = strlen(line);
while (1) {
c = getchar();
switch (c) {
case '\r':
putchar('\n');
line[index] = '\0';
return;
case '\b':
case 0x7F:
if (index == 0) {
break;
}
putchar('\b');
putchar(' ');
putchar('\b');
index--;
break;
default:
if (c == '\t') {
c = ' ';
}
if (c < 0x20 || c > 0x7E) {
break;
}
putchar(c);
line[index++] = c;
break;
}
}
}
 
 
/**************************************************************/
 
/* scaled-down version of printf */
 
 
/*
* Count the number of characters needed to represent
* a given number in base 10.
*/
int countPrintn(long n) {
long a;
int res;
 
res = 0;
if (n < 0) {
res++;
n = -n;
}
a = n / 10;
if (a != 0) {
res += countPrintn(a);
}
return res + 1;
}
 
 
/*
* Output a number in base 10.
*/
void printn(long n) {
long a;
 
if (n < 0) {
putchar('-');
n = -n;
}
a = n / 10;
if (a != 0) {
printn(a);
}
putchar(n % 10 + '0');
}
 
 
/*
* Count the number of characters needed to represent
* a given number in a given base.
*/
int countPrintu(unsigned long n, unsigned long b) {
unsigned long a;
int res;
 
res = 0;
a = n / b;
if (a != 0) {
res += countPrintu(a, b);
}
return res + 1;
}
 
 
/*
* Output a number in a given base.
*/
void printu(unsigned long n, unsigned long b, Bool upperCase) {
unsigned long a;
 
a = n / b;
if (a != 0) {
printu(a, b, upperCase);
}
if (upperCase) {
putchar("0123456789ABCDEF"[n % b]);
} else {
putchar("0123456789abcdef"[n % b]);
}
}
 
 
/*
* Output a number of filler characters.
*/
void fill(int numFillers, char filler) {
while (numFillers-- > 0) {
putchar(filler);
}
}
 
 
/*
* Formatted output with a variable argument list.
*/
void vprintf(char *fmt, va_list ap) {
char c;
int n;
long ln;
unsigned int u;
unsigned long lu;
char *s;
Bool negFlag;
char filler;
int width, count;
 
while (1) {
while ((c = *fmt++) != '%') {
if (c == '\0') {
return;
}
putchar(c);
}
c = *fmt++;
if (c == '-') {
negFlag = TRUE;
c = *fmt++;
} else {
negFlag = FALSE;
}
if (c == '0') {
filler = '0';
c = *fmt++;
} else {
filler = ' ';
}
width = 0;
while (c >= '0' && c <= '9') {
width *= 10;
width += c - '0';
c = *fmt++;
}
if (c == 'd') {
n = va_arg(ap, int);
count = countPrintn(n);
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printn(n);
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'u' || c == 'o' || c == 'x' || c == 'X') {
u = va_arg(ap, int);
count = countPrintu(u,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10));
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printu(u,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10),
c == 'X');
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'l') {
c = *fmt++;
if (c == 'd') {
ln = va_arg(ap, long);
count = countPrintn(ln);
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printn(ln);
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'u' || c == 'o' || c == 'x' || c == 'X') {
lu = va_arg(ap, long);
count = countPrintu(lu,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10));
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printu(lu,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10),
c == 'X');
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else {
putchar('l');
putchar(c);
}
} else
if (c == 's') {
s = va_arg(ap, char *);
count = strlen(s);
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
while ((c = *s++) != '\0') {
putchar(c);
}
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'c') {
c = va_arg(ap, char);
putchar(c);
} else {
putchar(c);
}
}
}
 
 
/*
* Formatted output.
* This is a scaled-down version of the C library's
* printf. Used to print diagnostic information on
* the console (and optionally to a logfile).
*/
void printf(char *fmt, ...) {
va_list ap;
 
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
/trunk/stdalone/bottles/lyrics.ref
0,0 → 1,299
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
 
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
 
97 bottles of beer on the wall, 97 bottles of beer.
Take one down and pass it around, 96 bottles of beer on the wall.
 
96 bottles of beer on the wall, 96 bottles of beer.
Take one down and pass it around, 95 bottles of beer on the wall.
 
95 bottles of beer on the wall, 95 bottles of beer.
Take one down and pass it around, 94 bottles of beer on the wall.
 
94 bottles of beer on the wall, 94 bottles of beer.
Take one down and pass it around, 93 bottles of beer on the wall.
 
93 bottles of beer on the wall, 93 bottles of beer.
Take one down and pass it around, 92 bottles of beer on the wall.
 
92 bottles of beer on the wall, 92 bottles of beer.
Take one down and pass it around, 91 bottles of beer on the wall.
 
91 bottles of beer on the wall, 91 bottles of beer.
Take one down and pass it around, 90 bottles of beer on the wall.
 
90 bottles of beer on the wall, 90 bottles of beer.
Take one down and pass it around, 89 bottles of beer on the wall.
 
89 bottles of beer on the wall, 89 bottles of beer.
Take one down and pass it around, 88 bottles of beer on the wall.
 
88 bottles of beer on the wall, 88 bottles of beer.
Take one down and pass it around, 87 bottles of beer on the wall.
 
87 bottles of beer on the wall, 87 bottles of beer.
Take one down and pass it around, 86 bottles of beer on the wall.
 
86 bottles of beer on the wall, 86 bottles of beer.
Take one down and pass it around, 85 bottles of beer on the wall.
 
85 bottles of beer on the wall, 85 bottles of beer.
Take one down and pass it around, 84 bottles of beer on the wall.
 
84 bottles of beer on the wall, 84 bottles of beer.
Take one down and pass it around, 83 bottles of beer on the wall.
 
83 bottles of beer on the wall, 83 bottles of beer.
Take one down and pass it around, 82 bottles of beer on the wall.
 
82 bottles of beer on the wall, 82 bottles of beer.
Take one down and pass it around, 81 bottles of beer on the wall.
 
81 bottles of beer on the wall, 81 bottles of beer.
Take one down and pass it around, 80 bottles of beer on the wall.
 
80 bottles of beer on the wall, 80 bottles of beer.
Take one down and pass it around, 79 bottles of beer on the wall.
 
79 bottles of beer on the wall, 79 bottles of beer.
Take one down and pass it around, 78 bottles of beer on the wall.
 
78 bottles of beer on the wall, 78 bottles of beer.
Take one down and pass it around, 77 bottles of beer on the wall.
 
77 bottles of beer on the wall, 77 bottles of beer.
Take one down and pass it around, 76 bottles of beer on the wall.
 
76 bottles of beer on the wall, 76 bottles of beer.
Take one down and pass it around, 75 bottles of beer on the wall.
 
75 bottles of beer on the wall, 75 bottles of beer.
Take one down and pass it around, 74 bottles of beer on the wall.
 
74 bottles of beer on the wall, 74 bottles of beer.
Take one down and pass it around, 73 bottles of beer on the wall.
 
73 bottles of beer on the wall, 73 bottles of beer.
Take one down and pass it around, 72 bottles of beer on the wall.
 
72 bottles of beer on the wall, 72 bottles of beer.
Take one down and pass it around, 71 bottles of beer on the wall.
 
71 bottles of beer on the wall, 71 bottles of beer.
Take one down and pass it around, 70 bottles of beer on the wall.
 
70 bottles of beer on the wall, 70 bottles of beer.
Take one down and pass it around, 69 bottles of beer on the wall.
 
69 bottles of beer on the wall, 69 bottles of beer.
Take one down and pass it around, 68 bottles of beer on the wall.
 
68 bottles of beer on the wall, 68 bottles of beer.
Take one down and pass it around, 67 bottles of beer on the wall.
 
67 bottles of beer on the wall, 67 bottles of beer.
Take one down and pass it around, 66 bottles of beer on the wall.
 
66 bottles of beer on the wall, 66 bottles of beer.
Take one down and pass it around, 65 bottles of beer on the wall.
 
65 bottles of beer on the wall, 65 bottles of beer.
Take one down and pass it around, 64 bottles of beer on the wall.
 
64 bottles of beer on the wall, 64 bottles of beer.
Take one down and pass it around, 63 bottles of beer on the wall.
 
63 bottles of beer on the wall, 63 bottles of beer.
Take one down and pass it around, 62 bottles of beer on the wall.
 
62 bottles of beer on the wall, 62 bottles of beer.
Take one down and pass it around, 61 bottles of beer on the wall.
 
61 bottles of beer on the wall, 61 bottles of beer.
Take one down and pass it around, 60 bottles of beer on the wall.
 
60 bottles of beer on the wall, 60 bottles of beer.
Take one down and pass it around, 59 bottles of beer on the wall.
 
59 bottles of beer on the wall, 59 bottles of beer.
Take one down and pass it around, 58 bottles of beer on the wall.
 
58 bottles of beer on the wall, 58 bottles of beer.
Take one down and pass it around, 57 bottles of beer on the wall.
 
57 bottles of beer on the wall, 57 bottles of beer.
Take one down and pass it around, 56 bottles of beer on the wall.
 
56 bottles of beer on the wall, 56 bottles of beer.
Take one down and pass it around, 55 bottles of beer on the wall.
 
55 bottles of beer on the wall, 55 bottles of beer.
Take one down and pass it around, 54 bottles of beer on the wall.
 
54 bottles of beer on the wall, 54 bottles of beer.
Take one down and pass it around, 53 bottles of beer on the wall.
 
53 bottles of beer on the wall, 53 bottles of beer.
Take one down and pass it around, 52 bottles of beer on the wall.
 
52 bottles of beer on the wall, 52 bottles of beer.
Take one down and pass it around, 51 bottles of beer on the wall.
 
51 bottles of beer on the wall, 51 bottles of beer.
Take one down and pass it around, 50 bottles of beer on the wall.
 
50 bottles of beer on the wall, 50 bottles of beer.
Take one down and pass it around, 49 bottles of beer on the wall.
 
49 bottles of beer on the wall, 49 bottles of beer.
Take one down and pass it around, 48 bottles of beer on the wall.
 
48 bottles of beer on the wall, 48 bottles of beer.
Take one down and pass it around, 47 bottles of beer on the wall.
 
47 bottles of beer on the wall, 47 bottles of beer.
Take one down and pass it around, 46 bottles of beer on the wall.
 
46 bottles of beer on the wall, 46 bottles of beer.
Take one down and pass it around, 45 bottles of beer on the wall.
 
45 bottles of beer on the wall, 45 bottles of beer.
Take one down and pass it around, 44 bottles of beer on the wall.
 
44 bottles of beer on the wall, 44 bottles of beer.
Take one down and pass it around, 43 bottles of beer on the wall.
 
43 bottles of beer on the wall, 43 bottles of beer.
Take one down and pass it around, 42 bottles of beer on the wall.
 
42 bottles of beer on the wall, 42 bottles of beer.
Take one down and pass it around, 41 bottles of beer on the wall.
 
41 bottles of beer on the wall, 41 bottles of beer.
Take one down and pass it around, 40 bottles of beer on the wall.
 
40 bottles of beer on the wall, 40 bottles of beer.
Take one down and pass it around, 39 bottles of beer on the wall.
 
39 bottles of beer on the wall, 39 bottles of beer.
Take one down and pass it around, 38 bottles of beer on the wall.
 
38 bottles of beer on the wall, 38 bottles of beer.
Take one down and pass it around, 37 bottles of beer on the wall.
 
37 bottles of beer on the wall, 37 bottles of beer.
Take one down and pass it around, 36 bottles of beer on the wall.
 
36 bottles of beer on the wall, 36 bottles of beer.
Take one down and pass it around, 35 bottles of beer on the wall.
 
35 bottles of beer on the wall, 35 bottles of beer.
Take one down and pass it around, 34 bottles of beer on the wall.
 
34 bottles of beer on the wall, 34 bottles of beer.
Take one down and pass it around, 33 bottles of beer on the wall.
 
33 bottles of beer on the wall, 33 bottles of beer.
Take one down and pass it around, 32 bottles of beer on the wall.
 
32 bottles of beer on the wall, 32 bottles of beer.
Take one down and pass it around, 31 bottles of beer on the wall.
 
31 bottles of beer on the wall, 31 bottles of beer.
Take one down and pass it around, 30 bottles of beer on the wall.
 
30 bottles of beer on the wall, 30 bottles of beer.
Take one down and pass it around, 29 bottles of beer on the wall.
 
29 bottles of beer on the wall, 29 bottles of beer.
Take one down and pass it around, 28 bottles of beer on the wall.
 
28 bottles of beer on the wall, 28 bottles of beer.
Take one down and pass it around, 27 bottles of beer on the wall.
 
27 bottles of beer on the wall, 27 bottles of beer.
Take one down and pass it around, 26 bottles of beer on the wall.
 
26 bottles of beer on the wall, 26 bottles of beer.
Take one down and pass it around, 25 bottles of beer on the wall.
 
25 bottles of beer on the wall, 25 bottles of beer.
Take one down and pass it around, 24 bottles of beer on the wall.
 
24 bottles of beer on the wall, 24 bottles of beer.
Take one down and pass it around, 23 bottles of beer on the wall.
 
23 bottles of beer on the wall, 23 bottles of beer.
Take one down and pass it around, 22 bottles of beer on the wall.
 
22 bottles of beer on the wall, 22 bottles of beer.
Take one down and pass it around, 21 bottles of beer on the wall.
 
21 bottles of beer on the wall, 21 bottles of beer.
Take one down and pass it around, 20 bottles of beer on the wall.
 
20 bottles of beer on the wall, 20 bottles of beer.
Take one down and pass it around, 19 bottles of beer on the wall.
 
19 bottles of beer on the wall, 19 bottles of beer.
Take one down and pass it around, 18 bottles of beer on the wall.
 
18 bottles of beer on the wall, 18 bottles of beer.
Take one down and pass it around, 17 bottles of beer on the wall.
 
17 bottles of beer on the wall, 17 bottles of beer.
Take one down and pass it around, 16 bottles of beer on the wall.
 
16 bottles of beer on the wall, 16 bottles of beer.
Take one down and pass it around, 15 bottles of beer on the wall.
 
15 bottles of beer on the wall, 15 bottles of beer.
Take one down and pass it around, 14 bottles of beer on the wall.
 
14 bottles of beer on the wall, 14 bottles of beer.
Take one down and pass it around, 13 bottles of beer on the wall.
 
13 bottles of beer on the wall, 13 bottles of beer.
Take one down and pass it around, 12 bottles of beer on the wall.
 
12 bottles of beer on the wall, 12 bottles of beer.
Take one down and pass it around, 11 bottles of beer on the wall.
 
11 bottles of beer on the wall, 11 bottles of beer.
Take one down and pass it around, 10 bottles of beer on the wall.
 
10 bottles of beer on the wall, 10 bottles of beer.
Take one down and pass it around, 9 bottles of beer on the wall.
 
9 bottles of beer on the wall, 9 bottles of beer.
Take one down and pass it around, 8 bottles of beer on the wall.
 
8 bottles of beer on the wall, 8 bottles of beer.
Take one down and pass it around, 7 bottles of beer on the wall.
 
7 bottles of beer on the wall, 7 bottles of beer.
Take one down and pass it around, 6 bottles of beer on the wall.
 
6 bottles of beer on the wall, 6 bottles of beer.
Take one down and pass it around, 5 bottles of beer on the wall.
 
5 bottles of beer on the wall, 5 bottles of beer.
Take one down and pass it around, 4 bottles of beer on the wall.
 
4 bottles of beer on the wall, 4 bottles of beer.
Take one down and pass it around, 3 bottles of beer on the wall.
 
3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 bottles of beer on the wall.
 
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
 
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
 
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
/trunk/stdalone/bottles/biolib.c
0,0 → 1,26
/*
* biolib.c -- basic I/O library
*/
 
 
#include "biolib.h"
 
 
char getc(void) {
unsigned int *base;
char c;
 
base = (unsigned int *) 0xF0300000;
while ((*(base + 0) & 1) == 0) ;
c = *(base + 1);
return c;
}
 
 
void putc(char c) {
unsigned int *base;
 
base = (unsigned int *) 0xF0300000;
while ((*(base + 2) & 1) == 0) ;
*(base + 3) = c;
}
/trunk/stdalone/bottles/iolib.h
0,0 → 1,21
/*
* iolib.h -- I/O library
*/
 
 
#ifndef _IOLIB_H_
#define _IOLIB_H_
 
 
int strlen(char *str);
void strcpy(char *dst, char *src);
void memcpy(unsigned char *dst, unsigned char *src, unsigned int cnt);
char getchar(void);
void putchar(char c);
void putString(char *s);
void getLine(char *prompt, char *line, int max);
void vprintf(char *fmt, va_list ap);
void printf(char *fmt, ...);
 
 
#endif /* _IOLIB_H_ */
/trunk/stdalone/bottles/main.c
0,0 → 1,48
/*
* main.c -- main program
*/
 
 
#include "types.h"
#include "stdarg.h"
#include "iolib.h"
 
 
#define MAX_BEER 99
 
 
char *t = "bottle";
char *b = "of beer";
char *w = "on the wall";
char *m = "more";
 
 
void beer(int n) {
char *s;
 
s = (n == 1 ? "" : "s");
printf("%d %s%s %s %s, ", n, t, s, b, w);
printf("%d %s%s %s.\n", n, t, s, b);
n--;
s = (n == 1 ? "" : "s");
printf("Take one down and pass it around, ");
if (n == 0) {
printf("no %s", m);
} else {
printf("%d", n);
}
printf(" %s%s %s %s.\n\n", t, s, b, w);
}
 
 
void main(void) {
int i;
 
for (i = MAX_BEER; i > 0; i--) {
beer(i);
}
printf("No %s %ss %s %s, ", m, t, b, w);
printf("no %s %ss %s.\n", m, t, b);
printf("Go to the store and buy some %s, ", m);
printf("%d %ss %s %s.\n", MAX_BEER, t, b, w);
}
/trunk/stdalone/bottles/biolib.h
0,0 → 1,14
/*
* biolib.h -- basic I/O library
*/
 
 
#ifndef _BIOLIB_H_
#define _BIOLIB_H_
 
 
char getc(void);
void putc(char c);
 
 
#endif /* _BIOLIB_H_ */
/trunk/stdalone/bottles/end.s
0,0 → 1,19
;
; end.s -- end-of-segment labels
;
 
.export _ecode
.export _edata
.export _ebss
 
.code
.align 4
_ecode:
 
.data
.align 4
_edata:
 
.bss
.align 4
_ebss:
/trunk/stdalone/bottles/types.h
0,0 → 1,16
/*
* types.h -- additional types
*/
 
 
#ifndef _TYPES_H_
#define _TYPES_H_
 
 
typedef int Bool;
 
#define FALSE 0
#define TRUE 1
 
 
#endif /* _TYPES_H_ */
/trunk/stdalone/bottles/stdarg.h
0,0 → 1,41
/*
* stdarg.h -- variable argument lists
*/
 
 
#ifndef _STDARG_H_
#define _STDARG_H_
 
 
typedef char *va_list;
 
 
static float __va_arg_tmp;
 
 
#define va_start(list, start) \
((void)((list) = (sizeof(start)<4 ? \
(char *)((int *)&(start)+1) : (char *)(&(start)+1))))
 
#define __va_arg(list, mode, n) \
(__typecode(mode)==1 && sizeof(mode)==4 ? \
(__va_arg_tmp = *(double *)(&(list += \
((sizeof(double)+n)&~n))[-(int)((sizeof(double)+n)&~n)]), \
*(mode *)&__va_arg_tmp) : \
*(mode *)(&(list += \
((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))
 
#define _bigendian_va_arg(list, mode, n) \
(sizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \
sizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : \
__va_arg(list, mode, n))
 
#define va_end(list) ((void)0)
 
#define va_arg(list, mode) \
(sizeof(mode)==8 ? \
*(mode *)(&(list = (char*)(((int)list + 15)&~7U))[-8]) : \
_bigendian_va_arg(list, mode, 3U))
 
 
#endif /* _STDARG_H_ */
/trunk/stdalone/bottles/Makefile
0,0 → 1,33
#
# Makefile for "bottles", a program for testing variable argument lists
#
 
BUILD = ../../build
 
SRC = start.s main.c iolib.c biolib.c end.s
BIN = bottles.bin
MAP = bottles.map
EXO = bottles.exo
 
.PHONY: all install run clean
 
all: $(BIN) $(EXO)
 
install: $(BIN) $(EXO)
mkdir -p $(BUILD)/stdalone
cp $(BIN) $(BUILD)/stdalone
cp $(MAP) $(BUILD)/stdalone
cp $(EXO) $(BUILD)/stdalone
 
run: $(BIN)
$(BUILD)/bin/sim -i -t 1 -l $(BIN) -a 0x10000
 
$(EXO): $(BIN)
$(BUILD)/bin/bin2exo -S2 0x10000 $(BIN) $(EXO)
 
$(BIN): $(SRC)
$(BUILD)/bin/lcc -A -Wo-kernel \
-Wl-m -Wl$(MAP) -o $(BIN) $(SRC)
 
clean:
rm -f *~ $(BIN) $(MAP) $(EXO)
/trunk/stdalone/bottles/start.s
0,0 → 1,58
;
; start.s -- startup code
;
 
.import main
.import _ecode
.import _edata
.import _ebss
 
.export _bcode
.export _bdata
.export _bbss
 
.code
_bcode:
 
.data
_bdata:
 
.bss
_bbss:
 
.code
 
start:
mvfs $8,0
or $8,$8,1 << 27 ; let vector point to RAM
mvts $8,0
add $29,$0,stack ; set sp
add $10,$0,_bdata ; copy data segment
add $8,$0,_edata
sub $9,$8,$10
add $9,$9,_ecode
j cpytest
cpyloop:
ldw $11,$9,0
stw $11,$8,0
cpytest:
sub $8,$8,4
sub $9,$9,4
bgeu $8,$10,cpyloop
add $8,$0,_bbss ; clear bss
add $9,$0,_ebss
j clrtest
clrloop:
stw $0,$8,0
add $8,$8,4
clrtest:
bltu $8,$9,clrloop
jal main ; call 'main'
start1:
j start1 ; loop
 
.bss
 
.align 4
.space 0x800
stack:
/trunk/stdalone/Makefile
5,8 → 5,8
 
BUILD = ../build
 
DIRS = hello hello2 memsize onetask twotasks-1 twotasks-2 \
dskchk dskchk2 wrtmbr dmpmbr mkpart shpart
DIRS = hello hello2 bottles memsize memtest onetask twotasks-1 \
twotasks-2 dskchk dskchk2 wrtmbr dmpmbr mkpart shpart
 
.PHONY: all install clean
 
/trunk/stdalone/memtest/iolib.c
0,0 → 1,329
/*
* iolib.c -- I/O library
*/
 
 
#include "types.h"
#include "stdarg.h"
#include "iolib.h"
#include "biolib.h"
 
 
/**************************************************************/
 
/* string functions */
 
 
int strlen(char *str) {
int i;
 
i = 0;
while (*str++ != '\0') {
i++;
}
return i;
}
 
 
void strcpy(char *dst, char *src) {
while ((*dst++ = *src++) != '\0') ;
}
 
 
void memcpy(unsigned char *dst, unsigned char *src, unsigned int cnt) {
while (cnt--) {
*dst++ = *src++;
}
}
 
 
/**************************************************************/
 
/* terminal I/O */
 
 
char getchar(void) {
return getc();
}
 
 
void putchar(char c) {
if (c == '\n') {
putchar('\r');
}
putc(c);
}
 
 
void putString(char *s) {
while (*s != '\0') {
putchar(*s++);
}
}
 
 
/**************************************************************/
 
/* get a line from the terminal */
 
 
void getLine(char *prompt, char *line, int max) {
int index;
char c;
 
putString(prompt);
putString(line);
index = strlen(line);
while (1) {
c = getchar();
switch (c) {
case '\r':
putchar('\n');
line[index] = '\0';
return;
case '\b':
case 0x7F:
if (index == 0) {
break;
}
putchar('\b');
putchar(' ');
putchar('\b');
index--;
break;
default:
if (c == '\t') {
c = ' ';
}
if (c < 0x20 || c > 0x7E) {
break;
}
putchar(c);
line[index++] = c;
break;
}
}
}
 
 
/**************************************************************/
 
/* scaled-down version of printf */
 
 
/*
* Count the number of characters needed to represent
* a given number in base 10.
*/
int countPrintn(long n) {
long a;
int res;
 
res = 0;
if (n < 0) {
res++;
n = -n;
}
a = n / 10;
if (a != 0) {
res += countPrintn(a);
}
return res + 1;
}
 
 
/*
* Output a number in base 10.
*/
void printn(long n) {
long a;
 
if (n < 0) {
putchar('-');
n = -n;
}
a = n / 10;
if (a != 0) {
printn(a);
}
putchar(n % 10 + '0');
}
 
 
/*
* Count the number of characters needed to represent
* a given number in a given base.
*/
int countPrintu(unsigned long n, unsigned long b) {
unsigned long a;
int res;
 
res = 0;
a = n / b;
if (a != 0) {
res += countPrintu(a, b);
}
return res + 1;
}
 
 
/*
* Output a number in a given base.
*/
void printu(unsigned long n, unsigned long b, Bool upperCase) {
unsigned long a;
 
a = n / b;
if (a != 0) {
printu(a, b, upperCase);
}
if (upperCase) {
putchar("0123456789ABCDEF"[n % b]);
} else {
putchar("0123456789abcdef"[n % b]);
}
}
 
 
/*
* Output a number of filler characters.
*/
void fill(int numFillers, char filler) {
while (numFillers-- > 0) {
putchar(filler);
}
}
 
 
/*
* Formatted output with a variable argument list.
*/
void vprintf(char *fmt, va_list ap) {
char c;
int n;
long ln;
unsigned int u;
unsigned long lu;
char *s;
Bool negFlag;
char filler;
int width, count;
 
while (1) {
while ((c = *fmt++) != '%') {
if (c == '\0') {
return;
}
putchar(c);
}
c = *fmt++;
if (c == '-') {
negFlag = TRUE;
c = *fmt++;
} else {
negFlag = FALSE;
}
if (c == '0') {
filler = '0';
c = *fmt++;
} else {
filler = ' ';
}
width = 0;
while (c >= '0' && c <= '9') {
width *= 10;
width += c - '0';
c = *fmt++;
}
if (c == 'd') {
n = va_arg(ap, int);
count = countPrintn(n);
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printn(n);
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'u' || c == 'o' || c == 'x' || c == 'X') {
u = va_arg(ap, int);
count = countPrintu(u,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10));
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printu(u,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10),
c == 'X');
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'l') {
c = *fmt++;
if (c == 'd') {
ln = va_arg(ap, long);
count = countPrintn(ln);
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printn(ln);
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'u' || c == 'o' || c == 'x' || c == 'X') {
lu = va_arg(ap, long);
count = countPrintu(lu,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10));
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
printu(lu,
c == 'o' ? 8 : ((c == 'x' || c == 'X') ? 16 : 10),
c == 'X');
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else {
putchar('l');
putchar(c);
}
} else
if (c == 's') {
s = va_arg(ap, char *);
count = strlen(s);
if (width > 0 && !negFlag) {
fill(width - count, filler);
}
while ((c = *s++) != '\0') {
putchar(c);
}
if (width > 0 && negFlag) {
fill(width - count, filler);
}
} else
if (c == 'c') {
c = va_arg(ap, char);
putchar(c);
} else {
putchar(c);
}
}
}
 
 
/*
* Formatted output.
* This is a scaled-down version of the C library's
* printf. Used to print diagnostic information on
* the console (and optionally to a logfile).
*/
void printf(char *fmt, ...) {
va_list ap;
 
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
/trunk/stdalone/memtest/biolib.c
0,0 → 1,26
/*
* biolib.c -- basic I/O library
*/
 
 
#include "biolib.h"
 
 
char getc(void) {
unsigned int *base;
char c;
 
base = (unsigned int *) 0xF0300000;
while ((*(base + 0) & 1) == 0) ;
c = *(base + 1);
return c;
}
 
 
void putc(char c) {
unsigned int *base;
 
base = (unsigned int *) 0xF0300000;
while ((*(base + 2) & 1) == 0) ;
*(base + 3) = c;
}
/trunk/stdalone/memtest/iolib.h
0,0 → 1,21
/*
* iolib.h -- I/O library
*/
 
 
#ifndef _IOLIB_H_
#define _IOLIB_H_
 
 
int strlen(char *str);
void strcpy(char *dst, char *src);
void memcpy(unsigned char *dst, unsigned char *src, unsigned int cnt);
char getchar(void);
void putchar(char c);
void putString(char *s);
void getLine(char *prompt, char *line, int max);
void vprintf(char *fmt, va_list ap);
void printf(char *fmt, ...);
 
 
#endif /* _IOLIB_H_ */
/trunk/stdalone/memtest/main.c
0,0 → 1,230
/*
* main.c -- ECO32 memory test
*/
 
 
#include "types.h"
#include "stdarg.h"
#include "iolib.h"
 
 
#define K 1024
#define M (K * K)
#define MEM_ADDR ((void *) (0xC0000000 + 0x10000 + 0x3000))
#define MEM_SIZE (32 * M - (0x10000 + 0x3000))
#define PASSES 3
 
 
/**************************************************************/
 
 
unsigned int randomNumber;
 
 
void setRandomNumber(unsigned int seed) {
randomNumber = seed;
}
 
 
unsigned int getRandomNumber(void) {
randomNumber = randomNumber * (unsigned) 1103515245 + (unsigned) 12345;
return randomNumber;
}
 
 
/**************************************************************/
 
 
void writeWords(void *start,
unsigned int numWords,
unsigned int seed) {
unsigned int *addr;
unsigned int rn;
 
setRandomNumber(seed);
addr = (unsigned int *) start;
while (numWords -= 1) {
rn = getRandomNumber();
*addr++ = rn;
}
}
 
 
void writeHalfs(void *start,
unsigned int numHalfs,
unsigned int seed) {
unsigned short *addr;
unsigned int rn;
 
setRandomNumber(seed);
addr = (unsigned short *) start;
while (numHalfs -= 2) {
rn = getRandomNumber();
*addr++ = (rn >> 16) & 0x0000FFFF;
*addr++ = (rn >> 0) & 0x0000FFFF;
}
}
 
 
void writeBytes(void *start,
unsigned int numBytes,
unsigned int seed) {
unsigned char *addr;
unsigned int rn;
 
setRandomNumber(seed);
addr = (unsigned char *) start;
while (numBytes -= 4) {
rn = getRandomNumber();
*addr++ = (rn >> 24) & 0x000000FF;
*addr++ = (rn >> 16) & 0x000000FF;
*addr++ = (rn >> 8) & 0x000000FF;
*addr++ = (rn >> 0) & 0x000000FF;
}
}
 
 
unsigned int readWords(void *start,
unsigned int numWords,
unsigned int seed) {
unsigned int errors;
unsigned int *addr;
unsigned int rn;
 
errors = 0;
setRandomNumber(seed);
addr = (unsigned int *) start;
while (numWords -= 1) {
rn = getRandomNumber();
if (*addr++ != rn) {
errors++;
}
}
return errors;
}
 
 
unsigned int readHalfs(void *start,
unsigned int numHalfs,
unsigned int seed) {
unsigned int errors;
unsigned short *addr;
unsigned int rn;
 
errors = 0;
setRandomNumber(seed);
addr = (unsigned short *) start;
while (numHalfs -= 2) {
rn = getRandomNumber();
if (*addr++ != ((rn >> 16) & 0x0000FFFF)) {
errors++;
}
if (*addr++ != ((rn >> 0) & 0x0000FFFF)) {
errors++;
}
}
return errors;
}
 
 
unsigned int readBytes(void *start,
unsigned int numBytes,
unsigned int seed) {
unsigned int errors;
unsigned char *addr;
unsigned int rn;
 
errors = 0;
setRandomNumber(seed);
addr = (unsigned char *) start;
while (numBytes -= 4) {
rn = getRandomNumber();
if (*addr++ != ((rn >> 24) & 0x000000FF)) {
errors++;
}
if (*addr++ != ((rn >> 16) & 0x000000FF)) {
errors++;
}
if (*addr++ != ((rn >> 8) & 0x000000FF)) {
errors++;
}
if (*addr++ != ((rn >> 0) & 0x000000FF)) {
errors++;
}
}
return errors;
}
 
 
/**************************************************************/
 
 
void memtest(void *start, unsigned int size, int passes) {
int i;
int j;
unsigned int seed;
 
setRandomNumber(10007);
for (i = 1; i <= passes; i++) {
printf("Pass %d\n", i);
/* -------------------- */
printf(" writing words...\n");
for (j = 0; j < i; j++) {
getRandomNumber();
}
seed = getRandomNumber();
writeWords(start, size / 4, seed);
printf(" reading words: ");
printf("%d", readWords(start, size / 4, seed));
printf(" errors\n");
printf(" reading halfs: ");
printf("%d", readHalfs(start, size / 2, seed));
printf(" errors\n");
printf(" reading bytes: ");
printf("%d", readBytes(start, size / 1, seed));
printf(" errors\n");
/* -------------------- */
printf(" writing halfs...\n");
for (j = 0; j < i; j++) {
getRandomNumber();
}
seed = getRandomNumber();
writeHalfs(start, size / 2, seed);
printf(" reading words: ");
printf("%d", readWords(start, size / 4, seed));
printf(" errors\n");
printf(" reading halfs: ");
printf("%d", readHalfs(start, size / 2, seed));
printf(" errors\n");
printf(" reading bytes: ");
printf("%d", readBytes(start, size / 1, seed));
printf(" errors\n");
/* -------------------- */
printf(" writing bytes...\n");
for (j = 0; j < i; j++) {
getRandomNumber();
}
seed = getRandomNumber();
writeBytes(start, size / 1, seed);
printf(" reading words: ");
printf("%d", readWords(start, size / 4, seed));
printf(" errors\n");
printf(" reading halfs: ");
printf("%d", readHalfs(start, size / 2, seed));
printf(" errors\n");
printf(" reading bytes: ");
printf("%d", readBytes(start, size / 1, seed));
printf(" errors\n");
}
}
 
 
/**************************************************************/
 
 
int main(void) {
printf("\nECO32 memory test started\n\n");
memtest(MEM_ADDR, MEM_SIZE, PASSES);
printf("\nECO32 memory test finished\n");
return 0;
}
/trunk/stdalone/memtest/biolib.h
0,0 → 1,14
/*
* biolib.h -- basic I/O library
*/
 
 
#ifndef _BIOLIB_H_
#define _BIOLIB_H_
 
 
char getc(void);
void putc(char c);
 
 
#endif /* _BIOLIB_H_ */
/trunk/stdalone/memtest/end.s
0,0 → 1,19
;
; end.s -- end-of-segment labels
;
 
.export _ecode
.export _edata
.export _ebss
 
.code
.align 4
_ecode:
 
.data
.align 4
_edata:
 
.bss
.align 4
_ebss:
/trunk/stdalone/memtest/types.h
0,0 → 1,16
/*
* types.h -- additional types
*/
 
 
#ifndef _TYPES_H_
#define _TYPES_H_
 
 
typedef int Bool;
 
#define FALSE 0
#define TRUE 1
 
 
#endif /* _TYPES_H_ */
/trunk/stdalone/memtest/stdarg.h
0,0 → 1,41
/*
* stdarg.h -- variable argument lists
*/
 
 
#ifndef _STDARG_H_
#define _STDARG_H_
 
 
typedef char *va_list;
 
 
static float __va_arg_tmp;
 
 
#define va_start(list, start) \
((void)((list) = (sizeof(start)<4 ? \
(char *)((int *)&(start)+1) : (char *)(&(start)+1))))
 
#define __va_arg(list, mode, n) \
(__typecode(mode)==1 && sizeof(mode)==4 ? \
(__va_arg_tmp = *(double *)(&(list += \
((sizeof(double)+n)&~n))[-(int)((sizeof(double)+n)&~n)]), \
*(mode *)&__va_arg_tmp) : \
*(mode *)(&(list += \
((sizeof(mode)+n)&~n))[-(int)((sizeof(mode)+n)&~n)]))
 
#define _bigendian_va_arg(list, mode, n) \
(sizeof(mode)==1 ? *(mode *)(&(list += 4)[-1]) : \
sizeof(mode)==2 ? *(mode *)(&(list += 4)[-2]) : \
__va_arg(list, mode, n))
 
#define va_end(list) ((void)0)
 
#define va_arg(list, mode) \
(sizeof(mode)==8 ? \
*(mode *)(&(list = (char*)(((int)list + 15)&~7U))[-8]) : \
_bigendian_va_arg(list, mode, 3U))
 
 
#endif /* _STDARG_H_ */
/trunk/stdalone/memtest/Makefile
0,0 → 1,33
#
# Makefile for "memtest", a program for testing the memory
#
 
BUILD = ../../build
 
SRC = start.s main.c iolib.c biolib.c end.s
BIN = memtest.bin
MAP = memtest.map
EXO = memtest.exo
 
.PHONY: all install run clean
 
all: $(BIN) $(EXO)
 
install: $(BIN) $(EXO)
mkdir -p $(BUILD)/stdalone
cp $(BIN) $(BUILD)/stdalone
cp $(MAP) $(BUILD)/stdalone
cp $(EXO) $(BUILD)/stdalone
 
run: $(BIN)
$(BUILD)/bin/sim -i -m 32 -t 1 -l $(BIN) -a 0x10000
 
$(EXO): $(BIN)
$(BUILD)/bin/bin2exo -S2 0x10000 $(BIN) $(EXO)
 
$(BIN): $(SRC)
$(BUILD)/bin/lcc -A -Wo-kernel \
-Wl-m -Wl$(MAP) -o $(BIN) $(SRC)
 
clean:
rm -f *~ $(BIN) $(MAP) $(EXO)
/trunk/stdalone/memtest/start.s
0,0 → 1,58
;
; start.s -- startup code
;
 
.import main
.import _ecode
.import _edata
.import _ebss
 
.export _bcode
.export _bdata
.export _bbss
 
.code
_bcode:
 
.data
_bdata:
 
.bss
_bbss:
 
.code
 
start:
mvfs $8,0
or $8,$8,1 << 27 ; let vector point to RAM
mvts $8,0
add $29,$0,stack ; set sp
add $10,$0,_bdata ; copy data segment
add $8,$0,_edata
sub $9,$8,$10
add $9,$9,_ecode
j cpytest
cpyloop:
ldw $11,$9,0
stw $11,$8,0
cpytest:
sub $8,$8,4
sub $9,$9,4
bgeu $8,$10,cpyloop
add $8,$0,_bbss ; clear bss
add $9,$0,_ebss
j clrtest
clrloop:
stw $0,$8,0
add $8,$8,4
clrtest:
bltu $8,$9,clrloop
jal main ; call 'main'
start1:
j start1 ; loop
 
.bss
 
.align 4
.space 0x800
stack:

powered by: WebSVN 2.1.0

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