]> Joshua Wise's Git repositories - firearm.git/blame - tests/testbench.c
Add chip enable correctness for CellularRAM.
[firearm.git] / tests / testbench.c
CommitLineData
392d1bec
JW
1extern void putc(unsigned char c);
2
121556d6
JW
3int serial_getc (void)
4{
5 int c;
6 do
7 asm volatile("mrc 5, 0, %0, c1, c1, 1" : "=r"(c));
8 while (!(c & 0x100));
9 return c & 0xFF;
10}
11
392d1bec
JW
12void puts(unsigned char *s)
13{
14 while (*s)
15 putc(*(s++));
16}
17
18void puthex(unsigned int x)
19{
20 unsigned char *hex = "0123456789ABCDEF";
21 int i;
22
23 for (i = 7; i >= 0; i--)
24 putc(hex[(x >> (i * 4)) & 0xF]);
25}
26
27#define putchar putc
28#include "ack.c"
29#include "j4cbo.c"
30#include "corecurse.c"
35c31084 31#include "miniblarg.c"
392d1bec
JW
32
33int fact(int n)
34{
35 if (n == 0)
36 return 1;
37 else
38 return n * fact(n-1);
39}
40
41void facttest()
42{
43 if (fact(10) != 3628800)
44 puts("FAIL\n");
45 else
46 puts("PASS\n");
47}
48
49struct tests {
50 char *name;
51 void (*test)();
52};
53
54extern int ldm_bonehead();
35c31084 55
4ad5ab91 56#ifndef X86
35c31084
JW
57int shnasto()
58{
59__asm__ volatile(
392d1bec
JW
60".globl ldm_bonehead\n"
61"ldm_bonehead:;"
62"mov r3, lr;"
63"bl 1f;"
64"nop;"
65"nop;"
66"nop;"
67"nop;"
68"nop;"
69"nop;"
70"nop;"
71"nop;"
72"nop;"
73"mov pc, r3\n;"
74"1:\n"
35c31084
JW
75"mov r2, #0x00002F00;"
76"orr r2, r2, #0x000000E0;"
77"mov r1, #0x0000004C;"
392d1bec
JW
78"mov ip, sp;"
79"stmdb sp!, {fp, ip, lr, pc};"
80"mov r0, #0x00880000;"
81"ldmia sp, {fp, sp, pc};"
82"mul r0, r1, r2;"
83"nop;"
84"nop;\n"
85);
35c31084 86}
4ad5ab91 87#endif
35c31084 88
392d1bec
JW
89void ldm_tester()
90{
4ad5ab91
JW
91#ifdef X86
92 int x = 0x00880000;
93#else
392d1bec 94 int x = ldm_bonehead();
4ad5ab91 95#endif
392d1bec
JW
96 if (x != 0x00880000)
97 {
98 puts("FAIL: result was ");
99 puthex(x);
100 puts("\n");
101 } else
102 puts("PASS\n");
103}
104
1e7ff543
JW
105void cellularram()
106{
107 volatile int *p = 0x80010000;
108
109 puts("[writing] ");
110 p[0] = 0x12345678;
111 p[1] = 0x87654321;
112 p[2] = 0xAAAA5555;
113 p[3] = 0x5555AAAA;
114 puts("[cache flush] ");
115 p[0x1000] = 0x00000000;
116 puts("[reading: ");
117 puthex(p[0]);
118 puthex(p[1]);
119 puthex(p[2]);
120 puthex(p[3]);
121 puts("]\n");
122}
123
392d1bec
JW
124struct tests tlist[] = {
125 {"ldm pc/mul", ldm_tester},
126 {"fact", facttest},
127 {"j4cbo", j4cbo},
1e7ff543 128 {"cellularram", cellularram},
392d1bec 129 {"ack", acktest},
35c31084 130 {"miniblarg", testmain},
392d1bec
JW
131 {"corecurse", corecurse},
132 {0, 0}};
133
134int main()
135{
136 struct tests *t;
137
138 puts("Testbench running\n");
139
140 for (t = tlist; t->name; t++)
141 {
142 puts("Running ");
143 puts(t->name);
144 puts(": ");
145 t->test();
146 }
121556d6 147 puts("Done! Echoing characters.\n");
392d1bec 148
121556d6
JW
149 while (1)
150 putc(serial_getc());
392d1bec
JW
151 return 0;
152}
This page took 0.05287 seconds and 5 git commands to generate.