[26] | 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
|
---|
| 80 | UB video_x;
|
---|
| 81 | UB video_y;
|
---|
| 82 | Inline 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 | }
|
---|
| 86 | void 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 | }
|
---|
| 95 | void 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 |
|
---|
| 122 | FP int_table[0x10]; /* å²è¾¼ã¿ãã³ãã©ã®ãã¼ãã« */
|
---|
| 123 |
|
---|
| 124 | /*
|
---|
| 125 | * ã¿ã¼ã²ããã·ã¹ãã ä¾åã®åæå
|
---|
| 126 | */
|
---|
| 127 | void
|
---|
| 128 | sys_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 | */
|
---|
| 158 | void
|
---|
| 159 | sys_exit(void)
|
---|
| 160 | {
|
---|
| 161 | while(1);
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | ER 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 |
|
---|
| 196 | ER 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 |
|
---|
| 234 | void
|
---|
| 235 | sys_putc(char c)
|
---|
| 236 | {
|
---|
| 237 | if (c == '\n') {
|
---|
| 238 | SYS_PUT_CHAR('\r');
|
---|
| 239 | }
|
---|
| 240 | SYS_PUT_CHAR(c);
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 |
|
---|
| 244 | void
|
---|
| 245 | define_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 |
|
---|
| 256 | ER 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 | }
|
---|