source: anotherchoice/tags/jsp-1.4.4-full-UTF8/config/ia32/pcat/sys_config.c@ 26

Last change on this file since 26 was 26, checked in by ykominami, 12 years ago

initial

File size: 6.8 KB
Line 
1/*
2 * TOPPERS/JSP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Just Standard Profile Kernel
5 *
6 * Copyright (C) 2000,2001 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * Copyright (C) 2002 by Monami software, Limited Partners.
9 * Copyright (C) 2002 by MURANAKA Masaki
10 * Copyright (C) 2008- by Monami Software Limited Partnership, JAPAN
11 *
12 * 上記著作権者
13は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
14 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
15 * 変・再é…
16å¸ƒï¼ˆä»¥ä¸‹ï¼Œåˆ©ç”¨ã¨å‘¼ã¶ï¼‰ã™ã‚‹ã“とを無償で許諾する.
17 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
18 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
19 * スコード中に含まれていること.
20 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
21 * 用できる形で再é…
22å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œå†é…
23å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨
24 * 者
25マニュアルなど)に,上記の著作権表示,この利用条件および下記
26 * の無保証規定を掲載すること.
27 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
28 * 用できない形で再é…
29å¸ƒã™ã‚‹å ´åˆã«ã¯ï¼Œæ¬¡ã®ã„ずれかの条件を満たすこ
30 * と.
31 * (a) 再é…
32å¸ƒã«ä¼´ã†ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆï¼ˆåˆ©ç”¨è€…
33マニュアルなど)に,上記の著
34 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
35 * (b) 再é…
36å¸ƒã®å½¢æ…
37‹ã‚’,別に定める方法によって,TOPPERSプロジェクトに
38 * 報告すること.
39 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
40 * 害からも,上記著作権者
41およびTOPPERSプロジェクトをå…
42è²¬ã™ã‚‹ã“と.
43 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
44 * 由に基づく請求からも,上記著作権者
45およびTOPPERSプロジェクトを
46 * å…
47è²¬ã™ã‚‹ã“と.
48 *
49 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者
50お
51 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
52 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
53 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
54 * の責任を負わない.
55 *
56 * @(#) $Id: sys_config.c,v 1.1 2004/07/21 02:49:36 monaka Exp $
57 */
58
59/*
60 * ターゲットシステム依存モジュール(PC/AT用)
61 */
62
63#include "jsp_kernel.h"
64#include <sil.h>
65#include <i386.h>
66#include <irc.h>
67#include <irc_inline.h>
68
69#ifndef SYS_PUTC_PORTID
70#define SYS_PUTC_PORTID 1
71#endif
72
73#if SYS_PUTC_PORTID >= 1
74#include <pcat_com.h>
75#else
76#define VIDEO_ADDRESS 0xb8000
77#define VIDEO_ATTRIBUTE 7
78#define VIDEO_X_SIZE 80
79#define VIDEO_Y_SIZE 25
80UB video_x;
81UB video_y;
82Inline void video_write(UB x, UB y, char c) {
83 sil_wrb_mem((VP)(VIDEO_ADDRESS + (VIDEO_X_SIZE * y + x) * 2), c);
84 sil_wrb_mem((VP)(VIDEO_ADDRESS + (VIDEO_X_SIZE * y + x) * 2 + 1), VIDEO_ATTRIBUTE);
85}
86void video_init(void) {
87 UB y;
88 for (y = 0; y < VIDEO_Y_SIZE; ++y) {
89 UB x;
90 for (x = 0; x < VIDEO_X_SIZE; ++x) {
91 video_write(x, y, ' ');
92 }
93 }
94}
95void video_putc(char c) {
96 switch (c) {
97 case '\n':
98 video_x = VIDEO_X_SIZE;
99 break;
100 case '\r':
101 video_x = 0;
102 break;
103 default:
104 video_write(video_x, video_y, c);
105 ++video_x;
106 break;
107 }
108 if (video_x >= VIDEO_X_SIZE) {
109 UB x;
110 video_x = 0;
111 ++video_y;
112 if (video_y >= VIDEO_Y_SIZE) {
113 video_y = 0;
114 }
115 for (x = 0; x < VIDEO_X_SIZE; ++x) {
116 video_write(x, video_y, ' ');
117 }
118 }
119}
120#endif
121
122FP int_table[0x10]; /* 割込みハンドラのテーブル */
123
124/*
125 * ターゲットシステム依存の初期化
126 */
127void
128sys_initialize()
129{
130 set_gate_descriptor(0x20, 0x8, interrupt0, I386_TYPE_GATE_INTR, 0);
131 set_gate_descriptor(0x21, 0x8, interrupt1, I386_TYPE_GATE_INTR, 0);
132 set_gate_descriptor(0x22, 0x8, interrupt2, I386_TYPE_GATE_INTR, 0);
133 set_gate_descriptor(0x23, 0x8, interrupt3, I386_TYPE_GATE_INTR, 0);
134 set_gate_descriptor(0x24, 0x8, interrupt4, I386_TYPE_GATE_INTR, 0);
135 set_gate_descriptor(0x25, 0x8, interrupt5, I386_TYPE_GATE_INTR, 0);
136 set_gate_descriptor(0x26, 0x8, interrupt6, I386_TYPE_GATE_INTR, 0);
137 set_gate_descriptor(0x27, 0x8, interrupt7, I386_TYPE_GATE_INTR, 0);
138 set_gate_descriptor(0x28, 0x8, interrupt8, I386_TYPE_GATE_INTR, 0);
139 set_gate_descriptor(0x29, 0x8, interrupt9, I386_TYPE_GATE_INTR, 0);
140 set_gate_descriptor(0x2a, 0x8, interrupt10, I386_TYPE_GATE_INTR, 0);
141 set_gate_descriptor(0x2b, 0x8, interrupt11, I386_TYPE_GATE_INTR, 0);
142 set_gate_descriptor(0x2c, 0x8, interrupt12, I386_TYPE_GATE_INTR, 0);
143 set_gate_descriptor(0x2d, 0x8, interrupt13, I386_TYPE_GATE_INTR, 0);
144 set_gate_descriptor(0x2e, 0x8, interrupt14, I386_TYPE_GATE_INTR, 0);
145 set_gate_descriptor(0x2f, 0x8, interrupt15, I386_TYPE_GATE_INTR, 0);
146
147 irc_initialize();
148#if SYS_PUTC_PORTID >= 1
149 pcat_com_init(SYS_PUTC_PORTID);
150#else
151 video_init();
152#endif
153}
154
155/*
156 * ターゲットシステムの終了
157 */
158void
159sys_exit(void)
160{
161 while(1);
162}
163
164ER irc_dis_irq(UB irq)
165{
166 BOOL cpu_locked;
167
168 if (irq > 15) {
169 return E_PAR;
170 }
171
172 cpu_locked = sense_lock();
173
174 if(!cpu_locked)
175 {
176 x_lock_cpu();
177 }
178
179 if(irq < 8)
180 {
181 sil_wrb_iop((VP)0x21, sil_reb_iop((VP)0x21) | (1 << irq));
182 }
183 else
184 {
185 sil_wrb_iop((VP)0xA1, sil_reb_iop((VP)0xA1) | (1 << (irq - 8)));
186 }
187
188 if(!cpu_locked)
189 {
190 x_unlock_cpu();
191 }
192
193 return E_OK;
194}
195
196ER irc_ena_irq(UB irq)
197{
198 BOOL cpu_locked;
199
200 if (irq > 15) {
201 return E_PAR;
202 }
203
204 cpu_locked = sense_lock();
205
206 if(!cpu_locked)
207 {
208 x_lock_cpu();
209 }
210
211 if(irq < 8)
212 {
213 sil_wrb_iop((VP)0x21, sil_reb_iop((VP)0x21) & ~(1 << irq));
214 }
215 else
216 {
217 sil_wrb_iop((VP)0xA1, sil_reb_iop((VP)0xA1) & ~(1 << (irq - 8)));
218 }
219
220 if(!cpu_locked)
221 {
222 x_unlock_cpu();
223 }
224
225 return E_OK;
226}
227
228#if SYS_PUTC_PORTID >= 1
229#define SYS_PUT_CHAR(c) pcat_com_putc(SYS_PUTC_PORTID, (c))
230#else
231#define SYS_PUT_CHAR(c) video_putc(c)
232#endif
233
234void
235sys_putc(char c)
236{
237 if (c == '\n') {
238 SYS_PUT_CHAR('\r');
239 }
240 SYS_PUT_CHAR(c);
241}
242
243
244void
245define_inh(INHNO inhno, FP inthdr)
246{
247#if 0
248 if (inhno >= 256 || inthdr == NULL)
249 {
250 return; /*??? Should I generate assertion? */
251 }
252#endif
253 int_table[TO_INTNO(inhno)] = inthdr;
254}
255
256ER vdef_inh(INHNO inhno, const T_DINH *pk_dinh) {
257 BOOL locked;
258 if (!(0x20 <= inhno && inhno <= 0x2f)) {
259 return E_PAR;
260 }
261 if (pk_dinh->inhatr != TA_HLNG) {
262 return E_RSATR;
263 }
264 locked = sense_lock();
265 if (!locked) {
266 x_lock_cpu();
267 }
268 define_inh(inhno, pk_dinh->inthdr);
269 if (!locked) {
270 x_unlock_cpu();
271 }
272 return E_OK;
273}
Note: See TracBrowser for help on using the repository browser.