summaryrefslogtreecommitdiff
path: root/firmware/test/memory/test.y
diff options
context:
space:
mode:
authorAlan Korr <alkorr@rockbox.org>2002-04-21 12:21:14 +0000
committerAlan Korr <alkorr@rockbox.org>2002-04-21 12:21:14 +0000
commitb7cf0602fd08f6a367d42f0b6adadb8322b3d35d (patch)
treeabbfb87b615f4c01a5f56eedacd75acbd2e52b87 /firmware/test/memory/test.y
parent257d17da6d64d2e265df3c80192a01f47e1dd2b7 (diff)
downloadrockbox-b7cf0602fd08f6a367d42f0b6adadb8322b3d35d.tar.gz
rockbox-b7cf0602fd08f6a367d42f0b6adadb8322b3d35d.zip
removing all that stuff permanently.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@159 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/test/memory/test.y')
-rw-r--r--firmware/test/memory/test.y180
1 files changed, 0 insertions, 180 deletions
diff --git a/firmware/test/memory/test.y b/firmware/test/memory/test.y
deleted file mode 100644
index b3b39acc26..0000000000
--- a/firmware/test/memory/test.y
+++ /dev/null
@@ -1,180 +0,0 @@
1%{
2#include "memory.h"
3#include "memory-page.h"
4#include <stdlib.h>
5#include <stdio.h>
6#include <string.h>
7void allocate (int);
8void release (int);
9void spy (int);
10void dump (void);
11void prompt (void);
12%}
13
14%token NUMBER
15%token ALLOCATE
16%token RELEASE
17%token DUMP
18%token SPY
19%token CHECK
20%token INIT
21%token QUIT
22
23%left '+' '-'
24%left '*' '/'
25%nonassoc UMINUS
26
27%%
28commands
29 : command ';'
30 { }
31 | commands command ';'
32 { }
33 | error ';'
34 { yyerrok; }
35 ;
36
37command
38 : allocate
39 | release
40 | spy
41 | check
42 | INIT
43 { memory_setup (); }
44 | DUMP
45 { dump (); }
46 | QUIT
47 { return 0; }
48 ;
49
50allocate
51 : ALLOCATE expression
52 { allocate (yylval); }
53 ;
54
55release
56 : RELEASE expression
57 { release (yylval); }
58 ;
59
60spy
61 : SPY expression
62 { spy (yylval); }
63 ;
64
65check
66 : CHECK expression
67 { __memory_check (yylval); }
68 ;
69
70expression
71 : expression '+' expression
72 { $$ = $1 + $3; }
73 | expression '-' expression
74 { $$ = $1 - $3; }
75 | expression '*' expression
76 { $$ = $1 * $3; }
77 | expression '/' expression
78 {
79 if($3 == 0)
80 yyerror("divide by zero");
81 else
82 $$ = $1 / $3;
83 }
84 | '-' expression %prec UMINUS
85 {
86 $$ = -$2;
87 }
88 | '(' expression ')'
89 {
90 $$ = $2;
91 }
92 | NUMBER
93 {
94 $$ = $1;
95 }
96 ;
97
98%%
99
100#include <readline/readline.h>
101#include <readline/history.h>
102
103int yyerror(char *s)
104 {
105 fprintf(stderr,"\nBad command");
106 return 1;
107 }
108
109void prompt (void)
110 {
111 printf("\n>"); fflush (stdout);
112 }
113
114void allocate (int order)
115 {
116 void *address;
117 printf("\nallocating a page of %d bytes...",512<<order);
118 if ((unsigned)order > 21)
119 printf (" bad order !");
120 else if ((address = memory_allocate_page (order)))
121 printf (" page #%d allocated !",((char *)address - (char *)__memory_free_page) >> 9);
122 else
123 printf (" cannot allocate a page !");
124 }
125
126void release (int page)
127 {
128 void *address = (void *)((char *)__memory_free_page + (page << 9));
129 printf("\nreleasing page #%d...",page);
130 if ((unsigned)page >= (2*1024*1024/512))
131 printf (" bad page number !");
132 else if (memory_release_page (address))
133 printf (" page #%d released !",page);
134 else
135 printf (" cannot release this page !");
136 }
137
138void spy (int page)
139 {
140 void *address = (void *)((char *)__memory_free_page + (page << 9));
141 printf("\nspying page #%d...",page);
142 if ((unsigned)page >= (2*1024*1024/512))
143 printf (" bad page number !");
144 else
145 __memory_spy_page (address);
146 }
147
148void dump (void)
149 {
150 int order;
151 printf("\ndumping free pages list...");
152 for (order = 0; order < 13; ++order)
153 __memory_dump (order);
154 }
155
156int main ()
157 {
158 yyparse();
159 return 0;
160 }
161
162int read_input (char *buffer,int max)
163 {
164 char *line = 0;
165 while (1)
166 {
167 line = readline ("\n>");
168 if (!line)
169 break;
170 if (*line)
171 add_history(line);
172 strncpy (buffer,line,max);
173 strcat (buffer,";");
174 free (line);
175 return strlen (buffer);
176 }
177 buffer[0] = ';';
178 return 1;
179 }
180