Changeset 678 for trunk/libs/libalmosmkh/almosmkh.c
- Timestamp:
- Nov 20, 2020, 12:23:31 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/libalmosmkh/almosmkh.c
r661 r678 118 118 } 119 119 120 /////////////////////////////////////// 121 intget_uint32( unsigned int * buffer )120 //////////////////////////////////////// 121 void get_uint32( unsigned int * buffer ) 122 122 { 123 123 unsigned int i; … … 201 201 } 202 202 203 // final evaluation203 // write value to buffer 204 204 if ( overflow == 0 ) 205 205 { 206 206 // return value 207 207 *buffer = value; 208 return 0;209 208 } 210 209 else … … 221 220 // return 0 value 222 221 *buffer = 0; 223 return -1;224 222 } 225 223 } // end get_uint32() 226 224 227 ////////////////////////////// 225 /////////////////////////////// 228 226 int get_string( char * string, 229 227 int maxlen ) 230 228 { 231 229 int c; 232 int done = 0;233 230 int length = 0; 234 231 235 while( done == 0)232 while( 1 ) 236 233 { 237 234 // check buffer overflow … … 256 253 length++; // update length 257 254 } 258 else if (c == 0x0A) // LF character marks end of string 259 { 260 putchar( c ); 261 done = 1; 255 else if( c == 0x0A ) // LF character marks end of string 256 { 257 putchar( c ); // echo 258 string[length] = 0; // register NUL character in string 259 return length + 1; 262 260 } 263 261 else if ( (c == 0x7F) || // DEL character … … 270 268 } 271 269 } 272 else if ( c == 0 ) // EOF character 273 { 274 // cancel all echo characters 275 while( length ) 270 } 271 272 // set NUL character in string and return success 273 274 } // end get_string() 275 276 277 ///////////////////////////// 278 int fget_string( int fdid, 279 char * string, 280 int maxlen ) 281 { 282 int ret; 283 char c; 284 int length = 0; 285 286 while( 1 ) 287 { 288 // check buffer overflow 289 if( length >= maxlen-1 ) length = 0; 290 291 // read one character from stream 292 ret = read( fdid , &c , 1 ); 293 294 if( ret == 1 ) 295 { 296 if ( (c >= 0x20) && (c < 0x7F) ) // printable character 276 297 { 277 printf("\b \b"); // cancel one echo character278 length--;298 string[length] = (char)c; // register character in string 299 length++; // update length 279 300 } 280 return -1; // return failure 281 } 282 } 283 284 // set NUL character in string and return success 285 string[length] = 0; 286 return length + 1; 287 288 } // end get_string() 301 else if ( c == 0 ) // end of string 302 { 303 string[length] = (char)c; // register character in string 304 length++; // update length 305 break; // exit loop 306 } 307 // discard all characters not printable or NUL 308 } 309 else 310 { 311 printf("\n[%s] cannot read stream %d\n", __FUNCTION__, fdid ); 312 length = 0; 313 break; 314 } 315 } 316 } // end fget_string() 317 289 318 290 319 ////////////////////////////////////////////////////////////////////////////////////// … … 418 447 } 419 448 449 //////////////////////////////////////// 450 int display_fd_array( unsigned int pid ) 451 { 452 return hal_user_syscall( SYS_DISPLAY, 453 DISPLAY_FD, 454 (reg_t)pid, 0, 0 ); 455 } 456 457 /////////////////////////////////////////// 458 int display_fbf_windows( unsigned int pid ) 459 { 460 return hal_user_syscall( SYS_DISPLAY, 461 DISPLAY_WINDOWS, 462 (reg_t)pid, 0, 0 ); 463 } 464 420 465 /////////////////////////////// 421 466 int trace( unsigned int active, … … 433 478 { 434 479 char cmd; 435 int error;436 480 437 481 while( 1 ) … … 450 494 451 495 printf("b / pid = "); 452 error =get_uint32( &pid );496 get_uint32( &pid ); 453 497 454 498 printf(" / trdid = "); 455 error |=get_uint32( &trdid );456 457 if( error == 0 )display_busylocks( pid , trdid );499 get_uint32( &trdid ); 500 501 display_busylocks( pid , trdid ); 458 502 } 459 503 // return to calling process … … 470 514 471 515 printf(" / min = "); 472 error =get_uint32( &min );516 get_uint32( &min ); 473 517 474 518 printf(" / slots = "); 475 error |=get_uint32( &slots );476 477 if( error == 0 )display_fat( min , slots );519 get_uint32( &slots ); 520 521 display_fat( min , slots ); 478 522 } 479 523 // list all supported commands … … 503 547 504 548 printf("m / path = "); 505 error =get_string( path , 128 );549 get_string( path , 128 ); 506 550 507 551 printf(" / page = "); 508 error |=get_uint32( &page );552 get_uint32( &page ); 509 553 510 554 printf(" / nbytes = "); 511 error |=get_uint32( &nbytes );512 513 if( error == 0 )display_mapper( path , page , nbytes );555 get_uint32( &nbytes ); 556 557 display_mapper( path , page , nbytes ); 514 558 } 515 559 // display all processes in cluster(cxy) … … 519 563 520 564 printf("p / cxy = "); 521 error =get_uint32( &cxy );522 523 if( error == 0 )display_cluster_processes( cxy , 0 );565 get_uint32( &cxy ); 566 567 display_cluster_processes( cxy , 0 ); 524 568 } 525 569 // display DQDT … … 536 580 537 581 printf("s / cxy = "); 538 error =get_uint32( &cxy );582 get_uint32( &cxy ); 539 583 540 584 printf(" / lid = "); 541 error |=get_uint32( &lid );542 543 if( error == 0 )display_sched( cxy , lid );585 get_uint32( &lid ); 586 587 display_sched( cxy , lid ); 544 588 } 545 589 // display all processes attached to TXT(txt_id) … … 549 593 550 594 printf("t / txt_id = "); 551 error =get_uint32( &txt_id );552 553 if( error == 0 )display_txt_processes( txt_id );595 get_uint32( &txt_id ); 596 597 display_txt_processes( txt_id ); 554 598 } 555 599 // display vmm state for process(cxy, pid) … … 561 605 562 606 printf("v / cxy = "); 563 error =get_uint32( &cxy );607 get_uint32( &cxy ); 564 608 565 609 printf(" / pid = "); 566 error |=get_uint32( &pid );610 get_uint32( &pid ); 567 611 568 612 printf(" / mapping = "); 569 error |=get_uint32( &map );570 571 if( error == 0 )display_vmm( cxy , pid , map );613 get_uint32( &map ); 614 615 display_vmm( cxy , pid , map ); 572 616 } 573 617 // force the calling process to exit … … 585 629 586 630 printf("y / active = "); 587 error =get_uint32( &active );631 get_uint32( &active ); 588 632 589 633 printf(" / cxy = "); 590 error |=get_uint32( &cxy );634 get_uint32( &cxy ); 591 635 592 636 printf(" / lid = "); 593 error |=get_uint32( &lid );594 595 if( error == 0 )trace( active , cxy , lid );637 get_uint32( &lid ); 638 639 trace( active , cxy , lid ); 596 640 } 597 641 } // en while … … 1366 1410 if( child_sts[i][j] < 0 ) // failure => report error 1367 1411 { 1368 printf("\n[ERROR] in %s select core forchild[%d,%d] of <build> thread[%d,%d]\n",1412 printf("\n[ERROR] in %s : child[%d,%d] of <build> thread[%d,%d]\n", 1369 1413 __FUNCTION__ , i , j , cid , level ); 1370 1414 … … 1558 1602 ///////////////////////////////////////////////////////////////////////////////////////// 1559 1603 1560 //////////////////////////////// /////////1561 int fbf_get_config( unsignedint * width,1562 unsignedint * height,1563 unsignedint * type )1604 //////////////////////////////// 1605 int fbf_get_config( int * width, 1606 int * height, 1607 int * type ) 1564 1608 { 1565 1609 return hal_user_syscall( SYS_FBF, … … 1570 1614 } 1571 1615 1572 //////////////////////////////////// 1573 int fbf_read( void * buffer, 1574 unsigned int length, 1575 unsigned int offset ) 1576 { 1616 //////////////////////////// 1617 int fbf_read( void * buffer, 1618 int length, 1619 int offset ) 1620 { 1621 printf("[WARNING] the <%s> syscall is deprecated\n", __FUNCTION__ ); 1622 1577 1623 return hal_user_syscall( SYS_FBF, 1578 1624 (reg_t)FBF_DIRECT_READ, … … 1582 1628 } 1583 1629 1584 ///////////////////////////////////// 1585 int fbf_write( void * buffer, 1586 unsigned int length, 1587 unsigned int offset ) 1588 { 1630 ///////////////////////////// 1631 int fbf_write( void * buffer, 1632 int length, 1633 int offset ) 1634 { 1635 printf("[WARNING] the <%s> syscall is deprecated\n", __FUNCTION__ ); 1636 1589 1637 return hal_user_syscall( SYS_FBF, 1590 1638 (reg_t)FBF_DIRECT_WRITE, … … 1594 1642 } 1595 1643 1596 ////////////////////////////////////// ////////1597 int fbf_create_window( unsigned intl_zero,1598 unsigned intp_zero,1599 unsigned intnlines,1600 unsigned intnpixels,1601 void 1644 ////////////////////////////////////// 1645 int fbf_create_window( int l_zero, 1646 int p_zero, 1647 int nlines, 1648 int npixels, 1649 void ** buffer ) 1602 1650 { 1603 1651 return hal_user_syscall( SYS_FBF, … … 1608 1656 } 1609 1657 1610 ////////////////////////////////////////// 1611 int fbf_delete_window( unsigned int wid ) 1658 /////////////////////////////// 1659 int fbf_active_window( int wid, 1660 int active ) 1661 { 1662 return hal_user_syscall( SYS_FBF, 1663 (reg_t)FBF_ACTIVE_WINDOW, 1664 (reg_t)wid, 1665 (reg_t)active, 0 ); 1666 } 1667 1668 ///////////////////////////////// 1669 int fbf_delete_window( int wid ) 1612 1670 { 1613 1671 return hal_user_syscall( SYS_FBF, … … 1616 1674 } 1617 1675 1618 ////////////////////////////// /////////1619 int fbf_move_window( unsignedint wid,1620 unsignedint l_zero,1621 unsignedint p_zero )1676 ////////////////////////////// 1677 int fbf_move_window( int wid, 1678 int l_zero, 1679 int p_zero ) 1622 1680 { 1623 1681 return hal_user_syscall( SYS_FBF, … … 1628 1686 } 1629 1687 1630 //////////////////////////////// /////////1631 int fbf_resize_window( unsignedint wid,1632 unsignedint width,1633 unsignedint height )1688 //////////////////////////////// 1689 int fbf_resize_window( int wid, 1690 int width, 1691 int height ) 1634 1692 { 1635 1693 return hal_user_syscall( SYS_FBF, … … 1640 1698 } 1641 1699 1642 ///////////////////////////////// /////////1643 int fbf_refresh_window( unsignedint wid,1644 unsignedint line_first,1645 unsignedint line_last )1700 ///////////////////////////////// 1701 int fbf_refresh_window( int wid, 1702 int line_first, 1703 int line_last ) 1646 1704 { 1647 1705 return hal_user_syscall( SYS_FBF, … … 1652 1710 } 1653 1711 1712 ///////////////////////////////// 1713 int fbf_front_window( int wid ) 1714 { 1715 return hal_user_syscall( SYS_FBF, 1716 (reg_t)FBF_FRONT_WINDOW, 1717 (reg_t)wid, 0, 0 ); 1718 } 1654 1719 1655 1720 // Local Variables:
Note: See TracChangeset
for help on using the changeset viewer.