Changeset 657 for trunk/libs
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (5 years ago)
- Location:
- trunk/libs/libalmosmkh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/libalmosmkh/almosmkh.c
r650 r657 2 2 * almosmkh.c - User level ALMOS-MKH specific library implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 122 122 } 123 123 124 /////////////////////////////// 125 unsigned int get_uint32( void)124 /////////////////////////////////////// 125 int get_uint32( unsigned int * buffer ) 126 126 { 127 127 unsigned int i; … … 168 168 else if ( c == 0 ) // EOF character 169 169 { 170 return -1; 170 overflow = 1; 171 done = 1; 171 172 } 172 173 … … 208 209 { 209 210 // return value 210 return value; 211 *buffer = value; 212 return 0; 211 213 } 212 214 else … … 222 224 223 225 // return 0 value 224 return 0; 226 *buffer = 0; 227 return -1; 225 228 } 226 229 } // end get_uint32() … … 388 391 389 392 /////////////////////////////////////// 390 int display_fat( unsigned int page_id,391 unsigned int nb_ entries )393 int display_fat( unsigned int min_slot, 394 unsigned int nb_slots ) 392 395 { 393 396 return hal_user_syscall( SYS_DISPLAY, 394 397 DISPLAY_FAT, 395 (reg_t) page_id,396 (reg_t)nb_ entries, 0 );398 (reg_t)min_slot, 399 (reg_t)nb_slots, 0 ); 397 400 } 398 401 … … 412 415 { 413 416 char cmd; 417 int error; 414 418 415 419 while( 1 ) … … 424 428 if( cmd == 'b' ) 425 429 { 430 unsigned int pid; 431 unsigned int trdid; 432 426 433 printf("b / pid = "); 427 unsigned int pid = get_uint32(); 434 error = get_uint32( &pid ); 435 428 436 printf(" / trdid = "); 429 unsigned int trdid = get_uint32(); 430 display_busylocks( pid , trdid ); 437 error |= get_uint32( &trdid ); 438 439 if( error == 0 ) display_busylocks( pid , trdid ); 431 440 } 432 441 // return to calling process … … 436 445 break; 437 446 } 438 // display FAT mapper( page,entries)447 // display FAT mapper(min,slots) 439 448 else if( cmd == 'f' ) 440 449 { 441 printf("f / page = "); 442 unsigned int page = get_uint32(); 443 printf(" / entries = "); 444 unsigned int entries = get_uint32(); 445 display_fat( page , entries ); 450 unsigned int min; 451 unsigned int slots; 452 453 printf(" / min = "); 454 error = get_uint32( &min ); 455 456 printf(" / slots = "); 457 error |= get_uint32( &slots ); 458 459 if( error == 0 ) display_fat( min , slots ); 446 460 } 447 461 // list all supported commands … … 451 465 "- b : display on TXT0 busylocks taken by thread[pid,trdid]\n" 452 466 "- c : resume calling process execution\n" 453 "- f : display on TXT0 FAT mapper[ page,entries]\n"467 "- f : display on TXT0 FAT mapper[min_slot,nb_slotss]\n" 454 468 "- h : list of supported commands\n" 455 469 "- m : display on TXT0 mapper[path,page,nbytes]\n" … … 467 481 { 468 482 char path[128]; 483 unsigned int page; 484 unsigned int nbytes; 485 469 486 printf("m / path = "); 470 int error = get_string( path , 128 ); 487 error = get_string( path , 128 ); 488 471 489 printf(" / page = "); 472 unsigned int page = get_uint32(); 490 error |= get_uint32( &page ); 491 473 492 printf(" / nbytes = "); 474 unsigned int nbytes = get_uint32(); 493 error |= get_uint32( &nbytes ); 494 475 495 if( error == 0 ) display_mapper( path , page , nbytes ); 476 496 } … … 478 498 else if( cmd == 'p' ) 479 499 { 500 unsigned int cxy; 501 480 502 printf("p / cxy = "); 481 unsigned int cxy = get_uint32(); 482 display_cluster_processes( cxy , 0 ); 503 error = get_uint32( &cxy ); 504 505 if( error == 0 ) display_cluster_processes( cxy , 0 ); 483 506 } 484 507 // display DQDT … … 491 514 else if( cmd == 's' ) 492 515 { 516 unsigned int cxy; 517 unsigned int lid; 518 493 519 printf("s / cxy = "); 494 unsigned int cxy = get_uint32(); 520 error = get_uint32( &cxy ); 521 495 522 printf(" / lid = "); 496 unsigned int lid = get_uint32(); 497 display_sched( cxy , lid ); 523 error |= get_uint32( &lid ); 524 525 if( error == 0 ) display_sched( cxy , lid ); 498 526 } 499 527 // display all processes attached to TXT(txt_id) 500 528 else if( cmd == 't' ) 501 529 { 530 unsigned int txt_id; 531 502 532 printf("t / txt_id = "); 503 unsigned int txt_id = get_uint32(); 504 display_txt_processes( txt_id ); 533 error = get_uint32( &txt_id ); 534 535 if( error == 0 ) display_txt_processes( txt_id ); 505 536 } 506 537 // display vmm state for process(cxy, pid) 507 538 else if( cmd == 'v' ) 508 539 { 540 unsigned int cxy; 541 unsigned int pid; 542 unsigned int map; 543 509 544 printf("v / cxy = "); 510 unsigned int cxy = get_uint32(); 545 error = get_uint32( &cxy ); 546 511 547 printf(" / pid = "); 512 unsigned int pid = get_uint32(); 548 error |= get_uint32( &pid ); 549 513 550 printf(" / mapping = "); 514 unsigned int map = get_uint32(); 515 display_vmm( cxy , pid , map ); 551 error |= get_uint32( &map ); 552 553 if( error == 0 ) display_vmm( cxy , pid , map ); 516 554 } 517 555 // force the calling process to exit … … 524 562 else if( cmd == 'y' ) 525 563 { 564 unsigned int active; 565 unsigned int cxy; 566 unsigned int lid; 567 526 568 printf("y / active = "); 527 unsigned int active = get_uint32(); 569 error = get_uint32( &active ); 570 528 571 printf(" / cxy = "); 529 unsigned int cxy = get_uint32(); 572 error |= get_uint32( &cxy ); 573 530 574 printf(" / lid = "); 531 unsigned int lid = get_uint32(); 532 trace( active , cxy , lid ); 575 error |= get_uint32( &lid ); 576 577 if( error == 0 ) trace( active , cxy , lid ); 533 578 } 534 579 } // en while … … 1500 1545 { 1501 1546 return hal_user_syscall( SYS_FBF, 1502 FBF_GET_CONFIG,1547 (reg_t)FBF_GET_CONFIG, 1503 1548 (reg_t)width, 1504 1549 (reg_t)height, … … 1512 1557 { 1513 1558 return hal_user_syscall( SYS_FBF, 1514 FBF_READ,1559 (reg_t)FBF_DIRECT_READ, 1515 1560 (reg_t)buffer, 1516 1561 (reg_t)length, … … 1524 1569 { 1525 1570 return hal_user_syscall( SYS_FBF, 1526 FBF_WRITE,1571 (reg_t)FBF_DIRECT_WRITE, 1527 1572 (reg_t)buffer, 1528 1573 (reg_t)length, 1529 1574 (reg_t)offset ); 1575 } 1576 1577 ////////////////////////////////////////////// 1578 int fbf_create_window( unsigned int l_zero, 1579 unsigned int p_zero, 1580 unsigned int nlines, 1581 unsigned int npixels, 1582 void ** buffer ) 1583 { 1584 return hal_user_syscall( SYS_FBF, 1585 (reg_t)FBF_CREATE_WINDOW, 1586 (reg_t)((l_zero << 16) | p_zero), 1587 (reg_t)((nlines << 16) | npixels), 1588 (reg_t)buffer ); 1589 } 1590 1591 ////////////////////////////////////////// 1592 int fbf_delete_window( unsigned int wid ) 1593 { 1594 return hal_user_syscall( SYS_FBF, 1595 (reg_t)FBF_DELETE_WINDOW, 1596 (reg_t)wid, 0, 0 ); 1597 } 1598 1599 /////////////////////////////////////// 1600 int fbf_move_window( unsigned int wid, 1601 unsigned int l_zero, 1602 unsigned int p_zero ) 1603 { 1604 return hal_user_syscall( SYS_FBF, 1605 (reg_t)FBF_MOVE_WINDOW, 1606 (reg_t)wid, 1607 (reg_t)l_zero, 1608 (reg_t)p_zero ); 1609 } 1610 1611 ///////////////////////////////////////// 1612 int fbf_resize_window( unsigned int wid, 1613 unsigned int width, 1614 unsigned int height ) 1615 { 1616 return hal_user_syscall( SYS_FBF, 1617 (reg_t)FBF_RESIZE_WINDOW, 1618 (reg_t)wid, 1619 (reg_t)width, 1620 (reg_t)height ); 1621 } 1622 1623 ////////////////////////////////////////// 1624 int fbf_refresh_window( unsigned int wid, 1625 unsigned int line_first, 1626 unsigned int line_last ) 1627 { 1628 return hal_user_syscall( SYS_FBF, 1629 (reg_t)FBF_REFRESH_WINDOW, 1630 (reg_t)wid, 1631 (reg_t)line_first, 1632 (reg_t)line_last ); 1530 1633 } 1531 1634 -
trunk/libs/libalmosmkh/almosmkh.h
r650 r657 2 2 * almosmkh.h - User level ALMOS-MKH specific library definition. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 29 29 * - non standard system calls. 30 30 * - debug functions. 31 * - remote malloc extensions. 31 * - remote malloc extensions. 32 * - a parallel_pthread_create function. 33 * - Frame Buffer access syscalls. 32 34 **************************************************************************************/ 33 35 34 36 #include <pthread.h> 35 37 #include <shared_almos.h> 38 36 39 37 40 /****************** Non standard (ALMOS_MKH specific) system calls ********************/ … … 138 141 139 142 /*************************************************************************************** 140 * This syscall returns an unsigned 32 bits integer from the standard "stdin" stream. 143 * This syscall returns an 32 bits integer from the standard "stdin" stream. 144 * The value is copied in buffer pointed by the <buf> argument 141 145 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported. 142 146 *************************************************************************************** 143 * returns the integer value if success / returns -1 if failure. 144 **************************************************************************************/ 145 unsigned int get_uint32( void ); 147 * @ buffer : pointer on buffer. 148 * @ returns 0 if success / returns -1 if failure. 149 **************************************************************************************/ 150 int get_uint32( unsigned int * buffer ); 151 152 /*************************************************************************************** 153 * This syscall returns a character string from the standard "stdin" stream. 154 * The string is copied in buffer pointed by the <string> argument. 155 * The string length (including the NUL terminating character) cannot be larger 156 * than the size defined by the <size> argument. 157 *************************************************************************************** 158 * @ string : pointer on the string buffer. 159 * @ maxlen : max number of bytes in string buffer. 160 * @ returns 0 if success / returns -1 if failure. 161 **************************************************************************************/ 162 int get_string( char * string, 163 int maxlen ); 146 164 147 165 … … 278 296 279 297 /*************************************************************************************** 280 * This debug syscall displays on the kernel terminal TXT0 the content of one given 281 * page of the FAT mapper. 282 * It can be called by any thread running in any cluster. 283 *************************************************************************************** 284 * @ page_id : page index in file. 285 * @ nb_entries : number of bytes to display. 298 * This debug syscall displays on the kernel terminal TXT0 the content of <nb_slots> 299 * of the FAT mapper, starting from <min_slot>. 300 * If <nb_slots> is zero, it displays the state of the FATFS context in cluster 301 * defined by the <min_slot> argument interpreted as a cluster identifier. 302 * It can be called by any thread running in any cluster. 303 *************************************************************************************** 304 * @ min_slot : first slot in page 305 * @ nb_slots : number of slots to display. 286 306 * @ return 0 if success / return -1 if page not found. 287 307 **************************************************************************************/ 288 int display_fat( unsigned int page_id,289 unsigned int nb_ entries );308 int display_fat( unsigned int min_slot, 309 unsigned int nb_slots ); 290 310 291 311 /***************************************************************************************** … … 551 571 552 572 553 554 555 573 /********* Non standard (ALMOS-MKH specific) Frame Buffer access syscalls *************/ 556 574 … … 562 580 563 581 /***************************************************************************************** 564 * This function returns in the <width> and <height> arguments the buffer size. 582 * This function returns in the <width>, <height> and <type> arguments 583 * the implementation specific frame buffer features. 565 584 ***************************************************************************************** 566 585 * @ width : [out] number of pixels per line. 567 586 * @ height : [out] number of lines. 568 587 * @ type : [out] pixel encoding type. 569 * @ returns 0 if success / returns -1 if error.588 * @ returns 0 if success / returns -1 if not found. 570 589 ****************************************************************************************/ 571 590 int fbf_get_config( unsigned int * width, … … 574 593 575 594 /***************************************************************************************** 576 * This blocking function moves <length> bytes from the frame buffer, starting 577 * from <offset>, to the user buffer defined by <buffer> argument. 595 * This function creates a new window defined by the <l_zero>, <p_zero>, <nlines>, 596 * and <npixels> arguments for the calling process, and register the process PID, the 597 * allocated <wid>, and the window size and coordinates in the FBF device descriptor. 598 * It returns in the output argument <buffer> the pointer on the buffer associated to 599 * the window, mapped in user space. 600 * Warning : Both pixel [p_zero,l_zero] and pixel [p_zero+npixels-1,l_zero+nlines-1] 601 * must be contained in the frame buffer. 602 ***************************************************************************************** 603 * @ l_zero : [in] first line index in FBF coordinates system. 604 * @ p_zero : [in] first pixel index in FBF coordinates system. 605 * @ nlines : [in] number of lines in the window. 606 * @ npixels : [in] number of pixels per line in the window. 607 * @ buffer : [out] pointer on 608 * @ returns <wid> if success / returns -1 if illegal size or coordinates. 609 ****************************************************************************************/ 610 int fbf_create_window( unsigned int l_zero, 611 unsigned int p_zero, 612 unsigned int nlines, 613 unsigned int npixels, 614 void ** buffer ); 615 616 /***************************************************************************************** 617 * This function deletes an existing window, identified by the <wid> argument. 618 * The calling process must be the window owner. 619 ***************************************************************************************** 620 * @ wid : window identifier. 621 * @ returns 0 if success / returns -1 if not found or process not owner. 622 ****************************************************************************************/ 623 int fbf_delete_window( unsigned int wid ); 624 625 /***************************************************************************************** 626 * This function refreshes in FBF all lines of a window identified by the <wid> argument, 627 * when the line index is in the interval [line_first,line_last[. 628 * It scans all registered windows to take into account the windows overlap. 629 ***************************************************************************************** 630 * @ wid : window identifier. 631 * @ line_first : first line index. 632 * @ line_last : last line index (excluded). 633 * @ returns 0 if success / returns -1 if illegal argument. 634 ****************************************************************************************/ 635 int fbf_refresh_window( unsigned int wid, 636 unsigned int line_first, 637 unsigned int line_last ); 638 639 /***************************************************************************************** 640 * This function changes the size of a window identified by the <wid> argument as defined 641 * by the <width> and height> arguments. The calling process must be the window owner. 642 * WARNING : Both pixel [p_zero,l_zero] and pixel [p_zero+width-1,l_zero+height-1] 643 * must be contained in the frame buffer. 644 ***************************************************************************************** 645 * @ wid : window identifier. 646 * @ width : number of pixels in line (one byte per pixel). 647 * @ height : number of lines in window. 648 * @ returns 0 if success / returns -1 if illegal arguments. 649 ****************************************************************************************/ 650 int fbf_resize_window( unsigned int wid, 651 unsigned int width, 652 unsigned int height ); 653 654 /***************************************************************************************** 655 * This function changes the <l_zero> & <p_zero> coordinates of a window identified 656 * by the <wid> argument. The calling process must be the window owner. 657 * WARNING : Both pixel [p_zero,l_zero] and pixel [p_zero+width-1,l_zero+height-1] 658 * must be contained in the frame buffer. 659 ***************************************************************************************** 660 * @ wid : window identifier. 661 * @ l_zero : new first line index in FBF. 662 * @ p_zero : new first pixel index in FBF. 663 * @ returns 0 if success / returns -1 if illegal arguments. 664 ****************************************************************************************/ 665 int fbf_move_window( unsigned int wid, 666 unsigned int l_zero, 667 unsigned int p_zero ); 668 669 /***************************************************************************************** 670 * This syscall is deprecated (january 2020 AG) 671 * This blocking function moves <length> pixels from the user buffer defined by <buffer> 672 * argument to the frame buffer, starting at <offset> in FBF. 578 673 ***************************************************************************************** 579 674 * @ buffer : pointer on buffer in user space. 580 675 * @ length : number of pixels (one byte per pixel). 581 * @ offset : first pixel index in frame buffer. 582 * @ returns 0 if success / returns -1 if error. 676 * @ offset : first pixel index in window. 677 * @ returns 0 if success / returns -1 if illegal arguments. 678 ****************************************************************************************/ 679 int fbf_write( void * buffer, 680 unsigned int length, 681 unsigned int offset ); 682 683 /***************************************************************************************** 684 * This syscall is deprecated (january 2020 AG) 685 * This blocking function moves <length> pixels from the frame buffer, starting at 686 * <offset> in FBF, to the user buffer defined by <buffer> argument. 687 ***************************************************************************************** 688 * @ buffer : pointer on buffer in user space. 689 * @ length : number of pixels (one byte per pixel). 690 * @ offset : first pixel index in window. 691 * @ returns 0 if success / returns -1 if illegal arguments. 583 692 ****************************************************************************************/ 584 693 int fbf_read( void * buffer, … … 586 695 unsigned int offset ); 587 696 588 /*****************************************************************************************589 * This blocking function moves <length> bytes from the user buffer defined by <buffer>590 * argument to the frame buffer, starting at <offset> in frame buffer.591 *****************************************************************************************592 * @ buffer : pointer on buffer in user space.593 * @ length : number of pixels (one byte per pixel).594 * @ offset : first pixel index in frame buffer.595 * @ returns 0 if success / returns -1 if error.596 ****************************************************************************************/597 int fbf_write( void * buffer,598 unsigned int length,599 unsigned int offset );600 697 601 698 #endif /* _LIBALMOSMKH_H_ */
Note: See TracChangeset
for help on using the changeset viewer.