Update the changelog
[opencv] / apps / Hawk / CVEiCL / EiC / src / ppc403 / io.bku
1 /* Collection of various routines needed by the GCC when no OS is present \r
2 \r
3   Works for the PowerPC 403 series currently\r
4 \r
5   Released under the GNU Public License 4/98 with no guarantee or statement\r
6   for fitness of purpose for any application\r
7 \r
8 Larry Battraw\r
9 (battraw@cicddal.com)\r
10 */\r
11 \r
12 #include <stdio.h>\r
13 #include <stdlib.h>\r
14 #include <sys/timeb.h>\r
15 #include <sys/times.h>\r
16 #include <sys/time.h>\r
17 #include <unistd.h>\r
18 \r
19 \r
20 void outbyte(int byte);\r
21 int inbyte(void);\r
22 \r
23 \r
24 #define spbase 0x40000000\r
25 #define _spls   0\r
26 #define _sphs   2\r
27 #define _brdh   4\r
28 #define _brdl   5\r
29 #define _spctl  6\r
30 #define _sprc   7\r
31 #define _sptc   8\r
32 #define _sprb   9\r
33 #define _sptb   9\r
34 \r
35 \r
36 #define SPLS (*(volatile unsigned char*) (spbase+_spls))\r
37 #define SPHS (*(volatile unsigned char*) (spbase+_sphs))\r
38 #define SPBRDH (*(volatile unsigned char*) (spbase+_spbrdh))\r
39 #define SPBRDL (*(volatile unsigned char*) (spbase+_spbrdl))\r
40 #define SPCTL (*(volatile unsigned char*) (spbase+_spctl))\r
41 #define SPRC (*(volatile unsigned char*) (spbase+_sprc))\r
42 #define SPTC (*(volatile unsigned char*) (spbase+_sptc))\r
43 #define SPRB (*(volatile unsigned char*) (spbase+_sprb))\r
44 #define SPTB (*(volatile unsigned char*) (spbase+_sptb))\r
45 #define SPRB (*(volatile unsigned char*) (spbase+_sprb))\r
46 \r
47 \r
48 #define sgr     0x03b9\r
49 #define iccr    0x3fb\r
50 #define br0     0x80\r
51 #define br1     0x81\r
52 #define br2     0x82\r
53 #define iocr    0xa0\r
54 #define lr      0x008\r
55 \r
56  void _start(void)\r
57 {\r
58         asm("\r
59         addis 1,0,0x7fe8\r
60         subi  1,1,0x1000        \r
61         mr    2,1\r
62         addi  3,0,0x1000\r
63         mtmsr 3\r
64         b main\r
65         ");\r
66\r
67 \r
68 \r
69 int inbyte(void)\r
70 {\r
71         while((SPLS&128)==0) ;\r
72         return(SPRB);\r
73 }\r
74 \r
75 void outbyte(int byte)\r
76 {\r
77         while((SPLS&4)!=4) ;\r
78         SPTB=byte;\r
79 }\r
80 \r
81 void byteout(unsigned char val, unsigned long addr)\r
82 {\r
83         asm("stb  3,0(4)");\r
84 }\r
85 int bytein(unsigned long addr)\r
86 {\r
87         asm("lbz 3,0(3)");\r
88 }\r
89 \r
90 \r
91 /* returns -1 if character waiting, 0 if not */\r
92 int getchq(void)\r
93 {\r
94         if((SPLS&128)==0) return(0);\r
95         else return(-1);\r
96 }\r
97 \r
98 \r
99 int __srget(FILE *stream)\r
100 {\r
101 return(inbyte());\r
102 }\r
103 \r
104 int rget(FILE *stream)\r
105 {\r
106 return(inbyte());\r
107 }\r
108 \r
109 \r
110 int link(const char *oldpath, const char *newpath) { return(-1); }\r
111 \r
112 int *__errno(void)\r
113 {\r
114 static int _errorno_;\r
115 return(&_errorno_);\r
116 }\r
117 \r
118 \r
119 void prs(char *str)\r
120 {\r
121 int i;\r
122 for(i=0; i<99999; i++)\r
123  {\r
124         if(str[i]==0) break;\r
125         outbyte(str[i]);\r
126         if(str[i]=='\n') outbyte('\r');\r
127         if(str[i]=='\r') outbyte('\n');\r
128  }\r
129 }\r
130 \r
131 \r
132 void abort(void)\r
133 {\r
134 prs("<abort>-- exit to OS\n");\r
135 asm("   lis     3,0x7ff0\r
136         mtlr    3\r
137         blr");\r
138         while(1) ;\r
139 }\r
140 \r
141 \r
142 \r
143 void _exit(int _status ) \r
144 {\r
145 prs("<normal exit>-- returning to OS\n");\r
146 asm("   lis     3,0x7ff0\r
147         mtlr    3\r
148         blr");\r
149         while(1);\r
150 }\r
151 \r
152 int gettimeofday(struct timeval *tv, struct timezone *tz)\r
153 {\r
154 return(0);\r
155 }\r
156 clock_t times(struct tms *buf)\r
157 {\r
158 return(1);\r
159 }\r
160 int ftime(struct timeb *tp)\r
161 {\r
162 return(0);\r
163 }\r
164 \r
165 \r
166 \r