+++ /dev/null
-/* Collection of various routines needed by the GCC when no OS is present \r
-\r
- Works for the PowerPC 403 series currently\r
-\r
- Released under the GNU Public License 4/98 with no guarantee or statement\r
- for fitness of purpose for any application\r
-\r
-Larry Battraw\r
-(battraw@cicddal.com)\r
-*/\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <sys/timeb.h>\r
-#include <sys/times.h>\r
-#include <sys/time.h>\r
-#include <unistd.h>\r
-\r
-\r
-void outbyte(int byte);\r
-int inbyte(void);\r
-\r
-\r
-#define spbase 0x40000000\r
-#define _spls 0\r
-#define _sphs 2\r
-#define _brdh 4\r
-#define _brdl 5\r
-#define _spctl 6\r
-#define _sprc 7\r
-#define _sptc 8\r
-#define _sprb 9\r
-#define _sptb 9\r
-\r
-\r
-#define SPLS (*(volatile unsigned char*) (spbase+_spls))\r
-#define SPHS (*(volatile unsigned char*) (spbase+_sphs))\r
-#define SPBRDH (*(volatile unsigned char*) (spbase+_spbrdh))\r
-#define SPBRDL (*(volatile unsigned char*) (spbase+_spbrdl))\r
-#define SPCTL (*(volatile unsigned char*) (spbase+_spctl))\r
-#define SPRC (*(volatile unsigned char*) (spbase+_sprc))\r
-#define SPTC (*(volatile unsigned char*) (spbase+_sptc))\r
-#define SPRB (*(volatile unsigned char*) (spbase+_sprb))\r
-#define SPTB (*(volatile unsigned char*) (spbase+_sptb))\r
-#define SPRB (*(volatile unsigned char*) (spbase+_sprb))\r
-\r
-\r
-#define sgr 0x03b9\r
-#define iccr 0x3fb\r
-#define br0 0x80\r
-#define br1 0x81\r
-#define br2 0x82\r
-#define iocr 0xa0\r
-#define lr 0x008\r
-\r
- void _start(void)\r
-{\r
- asm("\r
- addis 1,0,0x7fe8\r
- subi 1,1,0x1000 \r
- mr 2,1\r
- addi 3,0,0x1000\r
- mtmsr 3\r
- b main\r
- ");\r
-} \r
-\r
-\r
-int inbyte(void)\r
-{\r
- while((SPLS&128)==0 && (SPLS&0x78)==0) \r
- {\r
- if((SPLS&0x78)!=0) SPLS=0x78;\r
- if((SPHS&0xc0)!=0) SPHS=0xc0;\r
- }\r
- \r
- return(SPRB);\r
-}\r
-\r
-void outbyte(int byte)\r
-{\r
- while((SPLS&4)!=4) ;\r
- SPTB=byte;\r
-}\r
-\r
-void byteout(unsigned char val, unsigned long addr)\r
-{\r
- asm("stb 3,0(4)");\r
-}\r
-int bytein(unsigned long addr)\r
-{\r
- asm("lbz 3,0(3)");\r
-}\r
-\r
-\r
-/* returns -1 if character waiting, 0 if not */\r
-int getchq(void)\r
-{\r
- if((SPLS&128)==0) return(0);\r
- else return(-1);\r
-}\r
-\r
-\r
-int __srget(FILE *stream)\r
-{\r
-return(inbyte());\r
-}\r
-\r
-int rget(FILE *stream)\r
-{\r
-return(inbyte());\r
-}\r
-\r
-\r
-int link(const char *oldpath, const char *newpath) { return(-1); }\r
-\r
-int *__errno(void)\r
-{\r
-static int _errorno_;\r
-return(&_errorno_);\r
-}\r
-\r
-\r
-void prs(char *str)\r
-{\r
-int i;\r
-for(i=0; i<99999; i++)\r
- {\r
- if(str[i]==0) break;\r
- outbyte(str[i]);\r
- if(str[i]=='\n') outbyte('\r');\r
- if(str[i]=='\r') outbyte('\n');\r
- }\r
-}\r
-\r
-\r
-void abort(void)\r
-{\r
-prs("<abort>-- exit to OS\n");\r
-asm(" lis 3,0x7ff0\r
- mtlr 3\r
- blr");\r
- while(1) ;\r
-}\r
-\r
-\r
-\r
-void _exit(int _status ) \r
-{\r
-prs("<normal exit>-- returning to OS\n");\r
-asm(" lis 3,0x7ff0\r
- mtlr 3\r
- blr");\r
- while(1);\r
-}\r
-\r
-int gettimeofday(struct timeval *tv, struct timezone *tz)\r
-{\r
-return(0);\r
-}\r
-clock_t times(struct tms *buf)\r
-{\r
-return(1);\r
-}\r
-int ftime(struct timeb *tp)\r
-{\r
-return(0);\r
-}\r
-\r
-\r
-\r