[26] | 1 | /*
|
---|
| 2 | * TOPPERS/JSP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Just Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2004 by SEIKO EPSON Corp, JAPAN
|
---|
| 7 | *
|
---|
| 8 | * ä¸è¨èä½æ¨©è
|
---|
| 9 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 10 | * ã«ãã£ã¦å
|
---|
| 11 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 12 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 13 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 14 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 15 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 16 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 17 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 18 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 19 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 20 | * ç¨ã§ããå½¢ã§åé
|
---|
| 21 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 22 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 23 | * è
|
---|
| 24 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 25 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 26 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 27 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 28 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 29 | * ã¨ï¼
|
---|
| 30 | * (a) åé
|
---|
| 31 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 32 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 33 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 34 | * (b) åé
|
---|
| 35 | å¸ã®å½¢æ
|
---|
| 36 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 37 | * å ±åãããã¨ï¼
|
---|
| 38 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 39 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 40 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 41 | 責ãããã¨ï¼
|
---|
| 42 | *
|
---|
| 43 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 44 | ã
|
---|
| 45 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 46 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 47 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 48 | *
|
---|
| 49 | */
|
---|
| 50 | #include "smcvals.h"
|
---|
| 51 | #include "stdio.h"
|
---|
| 52 | #include "cpu_rename.h"
|
---|
| 53 |
|
---|
| 54 | FILE _iob[FOPEN_MAX + 1]; /* standard i/o stream */
|
---|
| 55 |
|
---|
| 56 | FILE *stdin; /* standard input */
|
---|
| 57 | FILE *stdout; /* standard output */
|
---|
| 58 | FILE *stderr; /* standard error */
|
---|
| 59 |
|
---|
| 60 | int errno; /* error number */
|
---|
| 61 |
|
---|
| 62 | unsigned int seed; /* seed of random value */
|
---|
| 63 |
|
---|
| 64 | unsigned char *ucNxtAlcP; /* next memory allocate address */
|
---|
| 65 | unsigned char *ucBefAlcP; /* one previous allocated address */
|
---|
| 66 | unsigned char *end_alloc; /* end memory allocate address */
|
---|
| 67 |
|
---|
| 68 | #ifndef DBL_LNG_TYPE
|
---|
| 69 |
|
---|
| 70 | #define DBL_LNG_TYPE
|
---|
| 71 |
|
---|
| 72 | /* the architecture of double floating point
|
---|
| 73 | *
|
---|
| 74 | * 0 1 11 31 32 63 bit
|
---|
| 75 | * -----------------------------------------------------------------------
|
---|
| 76 | * | | exponent | fraction |
|
---|
| 77 | * -----------------------------------------------------------------------
|
---|
| 78 | *
|
---|
| 79 | * | | | |
|
---|
| 80 | * | 12bits 20 bits | 32 bits |
|
---|
| 81 | * | lower word | higher word |
|
---|
| 82 | *
|
---|
| 83 | * bit 0 sign bit ( 1 bit )
|
---|
| 84 | * 1 - 11 exponent part ( 11 bits )
|
---|
| 85 | * 12 - 63 fraction part ( 52 bits )
|
---|
| 86 | *
|
---|
| 87 | */
|
---|
| 88 |
|
---|
| 89 | typedef union {
|
---|
| 90 | struct {
|
---|
| 91 | #ifdef BIG_ENDIAN
|
---|
| 92 | unsigned long _LL;
|
---|
| 93 | unsigned long _LH;
|
---|
| 94 | #else
|
---|
| 95 | unsigned long _LH;
|
---|
| 96 | unsigned long _LL;
|
---|
| 97 | #endif
|
---|
| 98 | } st;
|
---|
| 99 | } DBL_LNG;
|
---|
| 100 |
|
---|
| 101 | #endif
|
---|
| 102 |
|
---|
| 103 | DBL_LNG _HUGE; /* HUGE VALUE */
|
---|
| 104 |
|
---|
| 105 | unsigned char *_STACK_TOP; /* address of stack top */
|
---|
| 106 | unsigned char *_STACK_BOTTOM; /* address of stack bottom */
|
---|
| 107 |
|
---|
| 108 | long gm_sec;
|
---|
| 109 |
|
---|
| 110 | /*
|
---|
| 111 | * initialize routine
|
---|
| 112 | */
|
---|
| 113 |
|
---|
| 114 | void init_lib()
|
---|
| 115 | {
|
---|
| 116 |
|
---|
| 117 | /* initialize allocate address */
|
---|
| 118 | end_alloc = (unsigned char *)_STACK_TOP;
|
---|
| 119 | ucNxtAlcP = (unsigned char *)(_BOUND((unsigned long)_STACK_BOTTOM));
|
---|
| 120 | ucBefAlcP = (unsigned char *)NULL;
|
---|
| 121 |
|
---|
| 122 | errno = 0; /* clear error number */
|
---|
| 123 |
|
---|
| 124 | seed = 1; /* initialize random seed */
|
---|
| 125 |
|
---|
| 126 | gm_sec = -1; /* initialize time */
|
---|
| 127 |
|
---|
| 128 | _HUGE.st._LL = 0x7ff00000; /* HUGE VALUE */
|
---|
| 129 | _HUGE.st._LH = 0;
|
---|
| 130 |
|
---|
| 131 | /*
|
---|
| 132 | * INITIALIZE STANDARD STREAMS
|
---|
| 133 | */
|
---|
| 134 |
|
---|
| 135 | _iob[0]._flg = _UGETN; /* initialize stdin stream */
|
---|
| 136 | _iob[0]._buf = 0;
|
---|
| 137 | _iob[0]._fd = 0;
|
---|
| 138 |
|
---|
| 139 | _iob[1]._flg = _UGETN; /* initialize stdout stream */
|
---|
| 140 | _iob[1]._buf = 0;
|
---|
| 141 | _iob[1]._fd = 1;
|
---|
| 142 |
|
---|
| 143 | _iob[2]._flg = _UGETN; /* initialize stderr stream */
|
---|
| 144 | _iob[2]._buf = 0;
|
---|
| 145 | _iob[2]._fd = 2;
|
---|
| 146 |
|
---|
| 147 | stdin = &_iob[0];
|
---|
| 148 | stdout = &_iob[1];
|
---|
| 149 | stderr = &_iob[2];
|
---|
| 150 |
|
---|
| 151 | }
|
---|
| 152 |
|
---|