Changeset 626 for trunk/kernel/syscalls


Ignore:
Timestamp:
Apr 29, 2019, 7:25:09 PM (5 years ago)
Author:
alain
Message:

This version has been tested on the sort multithreaded application
for TSAR_IOB architectures ranging from 1 to 8 clusters.
It fixes three bigs bugs:
1) the dev_ioc device API has been modified: the dev_ioc_sync_read()
and dev_ioc_sync_write() function use now extended pointers on the
kernel buffer to access a mapper stored in any cluster.
2) the hal_uspace API has been modified: the hal_copy_to_uspace()
and hal_copy_from_uspace() functions use now a (cxy,ptr) couple
to identify the target buffer (equivalent to an extended pointer.
3) an implementation bug has been fixed in the assembly code contained
in the hal_copy_to_uspace() and hal_copy_from_uspace() functions.

Location:
trunk/kernel/syscalls
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/shared_include/shared_almos.h

    r623 r626  
    5454    DISPLAY_MAPPER            = 9,
    5555    DISPLAY_BARRIER           = 10,
     56    DISPLAY_FAT               = 11,
    5657}
    5758display_type_t;
  • trunk/kernel/syscalls/shared_include/syscalls_numbers.h

    r610 r626  
    22 * syscalls_numbers.c - Contains enum of the syscalls.
    33 *
    4  * Author    Alain Greiner (2018)
     4 * Author    Alain Greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    8686
    8787    SYS_EXIT           = 50,
     88    SYS_SYNC           = 51,
     89    SYS_FSYNC          = 52,
    8890
    89     SYSCALLS_NR        = 51,
     91    SYSCALLS_NR        = 53,
    9092
    9193} syscalls_t;
  • trunk/kernel/syscalls/sys_barrier.c

    r625 r626  
    104104 
    105105                // copy barrier attributes into kernel space
    106                 hal_copy_from_uspace( &k_attr , (void*)attr , sizeof(pthread_barrierattr_t) );
     106                hal_copy_from_uspace( local_cxy,
     107                                      &k_attr,
     108                                      (void*)attr,
     109                                      sizeof(pthread_barrierattr_t) );
    107110
    108111                if ( count != k_attr.x_size * k_attr.y_size *k_attr.nthreads ) 
  • trunk/kernel/syscalls/sys_display.c

    r625 r626  
    5656    else if( type == DISPLAY_MAPPER            ) return "MAPPER";
    5757    else if( type == DISPLAY_BARRIER           ) return "BARRIER";
     58    else if( type == DISPLAY_FAT               ) return "FAT";
    5859    else                                         return "undefined";
    5960}
     
    436437            break;
    437438        }
     439        /////////////////
     440        case DISPLAY_FAT:
     441        {
     442            uint32_t  entries = (uint32_t)arg1;
     443
     444            if( entries > 4096 )
     445                {
     446
     447#if DEBUG_SYSCALLS_ERROR
     448printk("\n[ERROR] in %s for FAT : nb_entries larger than 4096\n",
     449__FUNCTION__ );
     450#endif
     451                        this->errno = EINVAL;
     452                        return -1;
     453                }
     454
     455            if( entries == 0 )  // display fat context in cluster cxy
     456            {
     457                uint32_t  cxy = (uint32_t)arg0;
     458
     459                if( cluster_is_undefined( cxy ) )
     460                {
     461
     462#if DEBUG_SYSCALLS_ERROR
     463printk("\n[ERROR] in %s for FAT : illegal cxy argument %x\n",
     464__FUNCTION__ , cxy );
     465#endif
     466                     this->errno = EINVAL;
     467                     return -1;
     468                }
     469
     470                fatfs_display_ctx( cxy );
     471            }
     472            else                  // display nb_entries in page
     473            {                       
     474                uint32_t page = (uint32_t)arg0;
     475
     476                fatfs_display_fat( page , entries );
     477            }
     478
     479            break;
     480        }
    438481        ////////
    439482        default:
  • trunk/kernel/syscalls/sys_exec.c

    r625 r626  
    9696
    9797    // copy the array of pointers to kernel buffer
    98     hal_copy_from_uspace( k_pointers,
     98    hal_copy_from_uspace( local_cxy,
     99                          k_pointers,
    99100                          u_pointers,
    100101                          CONFIG_PPM_PAGE_SIZE );
     
    115116
    116117        // copy the user string to kernel buffer
    117         hal_copy_from_uspace( k_buf_ptr,
     118        hal_copy_from_uspace( local_cxy,
     119                              k_buf_ptr,
    118120                              k_pointers[index],
    119121                              length );
  • trunk/kernel/syscalls/sys_fsync.c

    r1 r626  
    11/*
    2  * sys_fsync: sync file
     2 * sys_fsync.c - copy all modified pages of a given file mapper to IOC device.
    33 *
    4  * Copyright (c) 2015 UPMC Sorbonne Universites
     4 * Author    Alain Greiner  (2016,1017)
    55 *
    6  * This file is part of ALMOS-kernel.
     6 * Copyright (c)  UPMC Sorbonne Universites
    77 *
    8  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     8 * This file is part of ALMOS-MKH.
     9 *
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    911 * under the terms of the GNU General Public License as published by
    1012 * the Free Software Foundation; version 2.0 of the License.
    1113 *
    12  * ALMOS-kernel is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1315 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1416 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1618 *
    1719 * You should have received a copy of the GNU General Public License
    18  * along with ALMOS-kernel; if not, write to the Free Software Foundation,
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
    1921 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2022 */
    2123
     24#include <hal_kernel_types.h>
     25#include <vfs.h>
     26#include <process.h>
     27#include <thread.h>
     28#include <printk.h>
    2229
    23 #include <types.h>
     30#include <syscalls.h>
    2431
    25 int sys_fsync (uint_t fd)
     32/////////////////////////////////
     33int sys_fsync( uint32_t file_id )
    2634{
    27         //TODO
    28         return 0;
     35    printk("\n[ERROR] in %d : not implemented yet\n", __FUNCTION__, file_id );
     36    return ENOSYS;
    2937}
  • trunk/kernel/syscalls/sys_get_config.c

    r625 r626  
    111111
    112112    // copy to user space
    113         hal_copy_to_uspace( x_size  , &k_x_size  , sizeof(uint32_t) );
    114         hal_copy_to_uspace( y_size  , &k_y_size  , sizeof(uint32_t) );
    115         hal_copy_to_uspace( ncores  , &k_ncores  , sizeof(uint32_t) );
     113        hal_copy_to_uspace( local_cxy, &k_x_size, x_size, sizeof(uint32_t) );
     114        hal_copy_to_uspace( local_cxy, &k_y_size, y_size, sizeof(uint32_t) );
     115        hal_copy_to_uspace( local_cxy, &k_ncores, ncores, sizeof(uint32_t) );
    116116
    117117    hal_fence();
  • trunk/kernel/syscalls/sys_get_core.c

    r625 r626  
    8282
    8383    // copy to user space
    84         hal_copy_to_uspace( cxy , &k_cxy , sizeof(uint32_t) );
    85         hal_copy_to_uspace( lid , &k_lid , sizeof(uint32_t) );
     84        hal_copy_to_uspace( local_cxy, &k_cxy, cxy, sizeof(uint32_t) );
     85        hal_copy_to_uspace( local_cxy, &k_lid, lid, sizeof(uint32_t) );
    8686
    8787        return 0;
  • trunk/kernel/syscalls/sys_get_cycle.c

    r625 r626  
    6464
    6565    // copy to user space
    66         hal_copy_to_uspace( cycle , &k_cycle , sizeof(uint64_t) );
     66        hal_copy_to_uspace( local_cxy, &k_cycle, cycle, sizeof(uint64_t) );
    6767
    6868        return 0;
  • trunk/kernel/syscalls/sys_is_fg.c

    r625 r626  
    9191
    9292    // copy to user space
    93     hal_copy_to_uspace( is_fg , &is_txt_owner , sizeof(uint32_t) );
     93    hal_copy_to_uspace( local_cxy, &is_txt_owner, is_fg, sizeof(uint32_t) );
    9494
    9595    hal_fence();
  • trunk/kernel/syscalls/sys_mmap.c

    r625 r626  
    7777
    7878    // copy attributes from user space to kernel space
    79     hal_copy_from_uspace( &k_attr , attr , sizeof(mmap_attr_t) );
     79    hal_copy_from_uspace( local_cxy,
     80                          &k_attr,
     81                          attr,
     82                          sizeof(mmap_attr_t) );
    8083
    8184    // get addr, fdid, offset, and length attributes
     
    305308
    306309    // copy vseg base address to user space
    307     hal_copy_to_uspace( &attr->addr , &vseg->min , sizeof(intptr_t) );
    308 
     310    hal_copy_to_uspace( local_cxy,
     311                        &vseg->min,
     312                        &attr->addr,
     313                        sizeof(intptr_t) );
    309314    hal_fence();
    310315
  • trunk/kernel/syscalls/sys_opendir.c

    r625 r626  
    175175
    176176    // set ident value in user buffer
    177     hal_copy_to_uspace( dirp , &ident , sizeof(intptr_t) );
     177    hal_copy_to_uspace( local_cxy,
     178                        &ident,
     179                        dirp,
     180                        sizeof(intptr_t) );
    178181
    179182    hal_fence();
  • trunk/kernel/syscalls/sys_readdir.c

    r625 r626  
    22 * sys_readdir.c - Copy one entry from an open VFS directory to an user buffer.
    33 *
    4  * Author    Alain Greiner (2016,2017,2018)
     4 * Author    Alain Greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    113113
    114114    // copy dirent pointer to user buffer
    115     hal_copy_to_uspace( buffer, &direntp , sizeof(void *) );
     115    hal_copy_to_uspace( local_cxy,
     116                        &direntp,
     117                        buffer,
     118                        sizeof(void *) );
    116119
    117120    // update current index in user_dir structure
  • trunk/kernel/syscalls/sys_sem.c

    r624 r626  
    139139 
    140140            // return value to user
    141             hal_copy_to_uspace( current_value , &current , sizeof(uint32_t) );
     141            hal_copy_to_uspace( local_cxy,
     142                                &current,
     143                                current_value,
     144                                sizeof(uint32_t) );
    142145        }
    143146        break;
  • trunk/kernel/syscalls/sys_stat.c

    r624 r626  
    122122   
    123123    // copy k_stat to u_stat
    124     hal_copy_to_uspace( u_stat , &k_stat , sizeof(struct stat) );
     124    hal_copy_to_uspace( local_cxy,
     125                        &k_stat,
     126                        u_stat,
     127                        sizeof(struct stat) );
    125128
    126129    hal_fence();
  • trunk/kernel/syscalls/sys_thread_create.c

    r624 r626  
    106106            }
    107107       
    108             hal_copy_from_uspace( &kern_attr , user_attr , sizeof(pthread_attr_t) );
     108            hal_copy_from_uspace( local_cxy,
     109                              &kern_attr,
     110                              user_attr,
     111                              sizeof(pthread_attr_t) );
    109112    }
    110113
     
    212215        // returns trdid to user space
    213216        trdid = hal_remote_l32( XPTR( child_cxy , &child_ptr->trdid ) );
    214         hal_copy_to_uspace( trdid_ptr , &trdid , sizeof(pthread_t) );
     217        hal_copy_to_uspace( local_cxy,
     218                        &trdid,
     219                        trdid_ptr,
     220                        sizeof(pthread_t) );
    215221
    216222    // activate new thread
  • trunk/kernel/syscalls/sys_timeofday.c

    r624 r626  
    8383
    8484    // copy values to user space
    85         hal_copy_to_uspace( tv , &k_tv , sizeof(struct timeval) );
     85        hal_copy_to_uspace( local_cxy,
     86                        &k_tv,
     87                        tv,
     88                        sizeof(struct timeval) );
    8689
    8790    hal_fence();
  • trunk/kernel/syscalls/sys_wait.c

    r625 r626  
    154154#endif
    155155                 // return child termination state  to parent process
    156                  hal_copy_to_uspace( status , &child_state , sizeof(int) );
     156                 hal_copy_to_uspace( local_cxy,
     157                                     &child_state,
     158                                     status,
     159                                     sizeof(int) );
    157160                 return child_pid;
    158161            }
  • trunk/kernel/syscalls/syscalls.h

    r623 r626  
    22 * syscalls.h - Kernel side services for syscall handling.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018)
     4 * Author     Alain Greiner (2016,2017,2018,2019)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    584584 * [43] This debug function displays on the kernel terminal TXT0 an user defined string,
    585585 * or the current state of a kernel structure, identified by the <type> argument.
    586  * The <arg0>, <arg1>, and <arg2> arguments depends on the structure type:
    587  * - DISPLAY_STRING          : an user defined string
    588  * - DISPLAY_VMM             : VSL and GPT for a process identified by <pid>.
    589  * - DISPLAY_SCHED           : all threads allocated to a scheduler <cxy> & <lid>.
    590  * - DISPLAY_CLUSTER_PROCESS : all processes registered in a cluster identified by <cxy>. 
    591  * - DISPLAY_TXT_PROCESS     : all processes registered in a cluster identified by <cxy>. 
    592  * - DISPLAY_VFS             : all files registered in the VFS cache.
    593  * - DISPLAY_CHDEV           : all registered channel devices.
    594  * - DISPLAY_DQDT            : all DQDT nodes curren values.
    595  * - DISPLAY_BUSYLOCKS       : all busylocks taken by one thread.
    596  * - DISPLAY_MAPPER          : one page of a given mapper.
     586 * The <arg0>, <arg1>, and <arg2> arguments depends on the structure type.
    597587 ******************************************************************************************
    598588 * type      : [in] type of display
     
    671661
    672662/******************************************************************************************
    673  * [50] This function implements the exit system call terminating a POSIX process.
     663 * [50] This function implements the "exit" system call terminating a POSIX process.
    674664 * It can be called by any thread running in any cluster.
    675665 * It uses both remote accesses to access the owner process descriptor, and the
    676  * RPC_PROCESS_SIGACTION to delete remote process and thread descriptors.
     666 * RPC_PROCESS_SIGACTION to delete remote process copies and thread descriptors.
    677667 * In the present implementation, this function implements actually the _exit():
    678668 * - it does not flush open output streams.
    679669 * - it does not close open streams.
    680670 ******************************************************************************************
    681  * @ status   : terminaison status.
     671 * @ status   : terminaison status returned to parent process.
     672 * @ return 0 if success / return -1 if failure.
    682673 *****************************************************************************************/
    683674int sys_exit( uint32_t status );
    684675
     676/******************************************************************************************
     677 * [51] This function implements the "sync" system call.
     678 * It forces all modified pages in all kernel mappers to be copied to the IOC device.
     679 * It can be called by any thread running in any cluster.
     680 * TODO not implemented yet.
     681 ******************************************************************************************
     682 * @ return 0 if success / return -1 if failure.
     683 *****************************************************************************************/
     684int sys_sync( void );
     685
     686/******************************************************************************************
     687 * [52] This function implements the "fsync" system call.
     688 * It forces all modified pages of the file mapper identified by the <fd> argument
     689 * to be copied to the IOC device.
     690 * It can be called by any thread running in any cluster.
     691 * TODO not implemented yet.
     692 ******************************************************************************************
     693 * @ file_id   : file descriptor index in fd_array.
     694 * @ return 0 if success / return -1 if failure.
     695 *****************************************************************************************/
     696int sys_fsync( uint32_t file_id );
     697
    685698#endif  // _SYSCALLS_H_
Note: See TracChangeset for help on using the changeset viewer.