source: anotherchoice/tags/jsp-1.4.4-full-UTF8/config/s1c33/sys.c@ 363

Last change on this file since 363 was 363, checked in by ykominami, 5 years ago

add tags/jsp-1.4.4-full-UTF8

  • Property svn:executable set to *
File size: 5.5 KB
Line 
1/*
2 * TOPPERS/JSP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
5 *
6 * Additional routine
7 *
8 * Copyright (C) 2003 by SEIKO EPSON Corp, JAPAN
9 *
10 * 上記著作権者
11は,Free Software Foundation によってå…
12¬è¡¨ã•ã‚Œã¦ã„ã‚‹
13 * GNU General Public License の Version 2 に記述されている条件か,以
14 * 下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェア(本ソフトウェ
15 * アを改変したものを含む.以下同じ)を使用・複製・改変・再é…
16å¸ƒï¼ˆä»¥ä¸‹ï¼Œ
17 * 利用と呼ぶ)することを無償で許諾する.
18 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
19 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
20 * スコード中に含まれていること.
21 * (2) 本ソフトウェアを再利用可能なバイナリコード(リロケータブルオブ
22 * ジェクトファイルやライブラリなど)の形で利用する場合には,利用
23 * に伴うドキュメント(利用者
24マニュアルなど)に,上記の著作権表示,
25 * この利用条件および下記の無保証規定を掲載すること.
26 * (3) 本ソフトウェアを再利用不可能なバイナリコードの形または機器に組
27 * み込んだ形で利用する場合には,次のいずれかの条件を満たすこと.
28 * (a) 利用に伴うドキュメント(利用者
29マニュアルなど)に,上記の著作
30 * 権表示,この利用条件および下記の無保証規定を掲載すること.
31 * (b) 利用の形æ…
32‹ã‚’,別に定める方法によって,上記著作権者
33に報告する
34 * こと.
35 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
36 * 害からも,上記著作権者
37をå…
38è²¬ã™ã‚‹ã“と.
39 *
40 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
41は,
42 * 本ソフトウェアに関して,その適用可能性も含めて,いかなる保証も行わ
43 * ない.また,本ソフトウェアの利用により直接的または間接的に生じたい
44 * かなる損害に関しても,その責任を負わない.
45 *
46 */
47
48#include "cpu_rename.h"
49
50unsigned char WRITE_BUF[65];
51
52/* buffer for simulated stdin, WRITE_BUF[0] is size (1-0x40, 0 means no data)
53 WRITE_BUF[1-64] is buffer area for data, max 64 bytes
54 used in write () */
55
56unsigned char READ_BUF[65];
57
58/* buffer for simulated stdin, READ_BUF[0] is size (1-0x40, 0 means EOF)
59 READ_BUF[1-64] is buffer area for data, max 64 bytes
60 used in read() */
61
62static unsigned char READ_EOF; /* if 1: READ_BUFFER become EOF, 0: not EOF */
63
64/*
65 * void _exit
66 * _exit execute inifinity loop.
67 */
68
69void _exit()
70{
71LOOP:
72 goto LOOP;
73}
74
75/*
76 * void _init_sys
77 * _init_sys initialize read() and write() bffer area
78 */
79
80void init_sys()
81{
82 READ_EOF = 0; /* not EOF */
83 READ_BUF[0] = 0; /* BUFFER is empty */
84}
85
86/*
87 * read
88 * Read() get and return required bytes with using simulated input.
89 * If EOF return 0.
90 * READ_FLASH: is break point label for stdin
91 * READ_BUF is buffer area for stdin
92 */
93
94int read (int fhDummy, char *psReadBuf, int iReadBytes)
95{
96 int iBytes; /* data size written to psReadBuf */
97 int iSize; /* data size in READ_BUF */
98 char *psBuf; /* top of read buffer */
99 static int iNdxPos; /* current positon in READ_BUF*/
100
101/* start */
102
103 iBytes = 0; /* no read now */
104 psBuf = psReadBuf;
105
106/* This loop repeat for each byte to copy READ_BUF to psReadBuf */
107
108 for (;;)
109 {
110
111/* if iReadByte become 0, return */
112
113 if (iReadBytes == 0) /* if required size become 0, return */
114 return(iBytes);
115
116/* if EOF, return 0 */
117
118 if (READ_EOF == 1)
119 return(iBytes);
120
121/* if there is data, copy 1 byte */
122
123 iSize = READ_BUF[0];
124 if (iSize > 0 )
125 {
126 *psBuf = READ_BUF[iNdxPos];
127 psBuf++;
128 iReadBytes--;
129 iNdxPos++;
130 iSize--;
131 iBytes++;
132 READ_BUF[0] = (unsigned char)(iSize & 0xff);
133 }
134
135/* if no data, read 0-64 bytes from simulated input */
136
137 else
138 {
139 asm(".global READ_FLASH");
140 asm("READ_FLASH:"); /* label for simulated stdin */
141 if (READ_BUF[0] == 0)
142 READ_EOF = 1; /* if size is 0, EOF */
143 iNdxPos = 1; /* reset index position */
144 }
145 } /* back to for (;;) */
146}
147
148/*
149 * write
150 * write datas with using simulated stdout
151 * WRITE_FLASH: is break point label for stdout
152 * WRITE_BUF is buffer area for stdout
153 */
154
155int write (int fhDummy, char *psWriBuf, int iWriBytes)
156{
157 int iBytes; /* remain data bytes waiting WRITE_BUF */
158 int iSize; /* data size to write to WRITE_BUF */
159 int iCount; /* counter to copy data to WRITE_BUF */
160
161 iBytes = iWriBytes;
162
163 for (;;){ /* repeat each 255 bytes */
164
165/* if remain 0, return original size */
166
167 if (iBytes == 0) /* remain size become 0, so return */
168 return(iWriBytes);
169
170/* if remain > 64, write size is 64 */
171
172 if (iBytes > 64)
173 { /* over 64 */
174 iSize = 64; /* 64 bytes to WRITE_BUF */
175 iBytes = iBytes - 64; /* remain data */
176 }
177 else
178 { /* not over 64 */
179 iSize = iBytes; /* under 64 bytes to WRITE_BUF */
180 iBytes = 0; /* no remain data */
181 }
182
183/* copy psWriBuf to WRITE_BUF */
184
185 WRITE_BUF[0] = (unsigned char)(iSize & 0xff); /* set size */
186 for (iCount = 1 ; iCount <= iSize ; iCount++)
187 {
188 WRITE_BUF[iCount] = *psWriBuf; /* copy data */
189 psWriBuf++;
190 }
191 asm(".global WRITE_FLASH");
192 asm("WRITE_FLASH:"); /* label for simulated stdout */
193
194 } /* back to for (;;) */
195
196 return(iSize);
197}
198
Note: See TracBrowser for help on using the repository browser.