fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / libgloss / zpu / crt_io.c
blobefd9be64d12921ce256af8b9c2549aa11a92405f
1 #include <syscall.h>
2 #include <stdio.h>
3 #include <errno.h>
4 #include <sys/stat.h>
6 extern int _hardware;
7 /* _cpu_config==0 => Abel
8 * _cpu_config==1 => Zeta
9 * _cpu_config==2 => Phi
11 extern int _cpu_config;
12 static volatile int *UART;
13 static volatile int *TIMER;
14 volatile int *MHZ;
19 * Wait indefinitely for input byte
23 int __attribute__ ((weak)) inbyte()
25 int val;
26 for (;;)
28 val=UART[1];
29 if ((val&0x100)!=0)
31 return val&0xff;
38 /*
39 * Output one character to the serial port
43 void __attribute__ ((weak)) outbyte(int c)
45 /* Wait for space in FIFO */
46 while ((UART[0]&0x100)==0);
47 UART[0]=c;
50 static const int mhz=64;
52 void __attribute__ ((weak)) _initIO(void)
54 if (_hardware)
56 if (_cpu_config==2)
58 /* Phi board addresses */
59 UART=(volatile int *)0x080a000c;
60 TIMER=(volatile int *)0x080a0014;
61 MHZ=(volatile int *)&mhz;
62 } else
64 /* Abel board */
65 UART=(volatile int *)0xc000;
66 TIMER=(volatile int *)0x9000;
67 MHZ=(volatile int *)0x8800;
69 } else
71 UART=(volatile int *)0x80000024;
72 TIMER=(volatile int *)0x80000100;
73 MHZ=(volatile int *)0x80000200;
79 long long __attribute__ ((weak)) _readCycles()
81 long long clock;
82 unsigned int i;
84 TIMER[0]=0x2; /* sample timer */
85 clock=0;
86 for (i=0; i<2; i++)
88 clock|=((long long )(TIMER[i]))<<(i*32);
90 return clock;