Changeset 580 for trunk/libs/libalmosmkh
- Timestamp:
- Oct 8, 2018, 11:31:42 AM (6 years ago)
- Location:
- trunk/libs/libalmosmkh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/libalmosmkh/almosmkh.c
r573 r580 88 88 } 89 89 90 //////////// 91 int getint( void )90 /////////////////////////////// 91 unsigned int get_uint32( void ) 92 92 { 93 93 unsigned int i; 94 int val; // ASCII character value94 int c; // ASCII character value 95 95 96 96 unsigned char buf[32]; 97 97 98 unsigned int save = 0; 98 unsigned int dec= 0;99 unsigned int value = 0; 99 100 unsigned int done = 0; 100 101 unsigned int overflow = 0; 101 102 unsigned int length = 0; 102 103 103 104 // get characters 104 105 while (done == 0) 105 106 { 106 107 // read one character 107 val = getchar(); 108 109 // analyse character 110 if ((val > 0x2F) && (val < 0x3A)) // decimal character 111 { 112 buf[length] = (unsigned char)val; 108 c = getchar(); 109 110 // analyse this character 111 if ( ((c > 0x2F) && (c < 0x3A)) || // 0 to 9 112 ((c > 0x40) && (c < 0x47)) || // A to F 113 ((c > 0x60) && (c < 0x67)) || // a to f 114 (((c == 0x58) || (c == 0x78)) && (length == 1)) ) // X or x 115 { 116 putchar( c ); // echo 117 if ( c > 0x60 ) c = c - 0x20; // to upper case 118 buf[length] = (unsigned char)c; 113 119 length++; 114 putchar( val ); // echo 115 } 116 else if (val == 0x0A) // LF character 120 } 121 else if (c == 0x0A) // LF character 117 122 { 118 123 done = 1; 119 124 } 120 else if ( ( val == 0x7F) ||// DEL character121 ( val == 0x08) )// BS character125 else if ( (c == 0x7F) || // DEL character 126 (c == 0x08) ) // BS character 122 127 { 123 128 if ( length > 0 ) 124 129 { 125 130 length--; 126 printf("\b \b"); 131 printf("\b \b"); // BS / / BS 127 132 } 128 133 } 129 else if ( val == 0 ) // EOF134 else if ( c == 0 ) // EOF character 130 135 { 131 136 return -1; … … 140 145 } // end while characters 141 146 142 // string to int conversion with overflow detection 147 // string to int conversion with overflow detection 143 148 if ( overflow == 0 ) 144 149 { 145 for (i = 0; (i < length) && (overflow == 0) ; i++) 146 { 147 dec = dec * 10 + (buf[i] - 0x30); 148 if (dec < save) overflow = 1; 149 save = dec; 150 // test (decimal / hexa) 151 if( (buf[0] == 0x30) && (buf[1] == 0x58) ) // hexadecimal input 152 { 153 for (i = 2; (i < length) && (overflow == 0) ; i++) 154 { 155 if( buf[i] < 0x40 ) value = (value << 4) + (buf[i] - 0x30); 156 else value = (value << 4) + (buf[i] - 0x37); 157 if (value < save) overflow = 1; 158 save = value; 159 } 160 } 161 else // decimal input 162 { 163 for (i = 0; (i < length) && (overflow == 0) ; i++) 164 { 165 value = (value * 10) + (buf[i] - 0x30); 166 if (value < save) overflow = 1; 167 save = value; 168 } 150 169 } 151 170 } … … 155 174 { 156 175 // return value 157 return dec;176 return value; 158 177 } 159 178 else … … 171 190 return 0; 172 191 } 173 } // end get int()192 } // end get_uint32() 174 193 175 194 … … 184 203 } 185 204 186 /////////////////////////////////// 205 ///////////////////////////////////////////////////// 187 206 int display_vmm( unsigned int cxy, unsigned int pid ) 188 207 { 189 208 return hal_user_syscall( SYS_DISPLAY, 190 209 DISPLAY_VMM, 191 (reg_t) pid,192 (reg_t) cxy, 0 );210 (reg_t)cxy, 211 (reg_t)pid, 0 ); 193 212 } 194 213 … … 211 230 } 212 231 213 /////////////////// 232 //////////////////////////////////////// 233 int display_busylocks( unsigned int pid, 234 unsigned int trdid ) 235 { 236 return hal_user_syscall( SYS_DISPLAY, 237 DISPLAY_BUSYLOCKS, 238 (reg_t)pid, 239 (reg_t)trdid, 0 ); 240 } 241 242 ///////////////////////// 214 243 int display_chdev( void ) 215 244 { … … 258 287 unsigned int lid; 259 288 unsigned int txt; 289 unsigned int pid; 290 unsigned int trdid; 260 291 unsigned int active; 261 292 … … 270 301 "p : display on TXT0 process descriptors in cluster[cxy]\n" 271 302 "s : display on TXT0 scheduler state for core[cxy,lid]\n" 272 "v : display on TXT0 VMM for calling process in cluster [cxy]\n"303 "v : display on TXT0 VMM state for process[cxy,pid]\n" 273 304 "t : display on TXT0 process decriptors attached to TXT[tid]\n" 305 "b : display on TXT0 busylocks taken by thread[pid,trdid]\n" 274 306 "y : activate/desactivate trace for core[cxy,lid]\n" 275 307 "x : force calling process to exit\n" … … 280 312 { 281 313 printf("p / cxy = "); 282 cxy = get int();314 cxy = get_uint32(); 283 315 display_cluster_processes( cxy ); 284 316 } … … 286 318 { 287 319 printf("s / cxy = "); 288 cxy = get int();320 cxy = get_uint32(); 289 321 printf(" / lid = "); 290 lid = get int();322 lid = get_uint32(); 291 323 display_sched( cxy , lid ); 292 324 } … … 294 326 { 295 327 printf("v / cxy = "); 296 cxy = getint(); 297 display_vmm( cxy , (unsigned int)getpid() ); 328 cxy = get_uint32(); 329 printf(" / pid = "); 330 pid = get_uint32(); 331 display_vmm( cxy , pid ); 298 332 } 299 333 else if( cmd == 't' ) 300 334 { 301 335 printf("t / txt_id = "); 302 txt = get int();336 txt = get_uint32(); 303 337 display_txt_processes( txt ); 304 338 } … … 306 340 { 307 341 printf("y / active = "); 308 active = get int();342 active = get_uint32(); 309 343 printf(" / cxy = "); 310 cxy = get int();344 cxy = get_uint32(); 311 345 printf(" / lid = "); 312 lid = get int();346 lid = get_uint32(); 313 347 trace( active , cxy , lid ); 348 } 349 else if( cmd == 'b' ) 350 { 351 printf("b / pid = "); 352 pid = get_uint32(); 353 printf(" / trdid = "); 354 trdid = get_uint32(); 355 display_busylocks( pid , trdid ); 314 356 } 315 357 else if( cmd == 'x' ) -
trunk/libs/libalmosmkh/almosmkh.h
r478 r580 101 101 102 102 /*************************************************************************************** 103 * This function returns a positive integer fom the standard "stdin" stream. 103 * This function returns an unsigned 32 bits integer from the standard "stdin" stream. 104 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported. 104 105 *************************************************************************************** 105 106 * returns the integer value if success / returns -1 if failure. 106 107 **************************************************************************************/ 107 int getint( void );108 unsigned int getint32( void ); 108 109 109 110
Note: See TracChangeset
for help on using the changeset viewer.