Ignore:
Timestamp:
Feb 14, 2018, 3:40:19 PM (6 years ago)
Author:
alain
Message:

blip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_display.c

    r421 r433  
    2525#include <hal_uspace.h>
    2626#include <errno.h>
     27#include <vmm.h>
    2728#include <cluster.h>
    2829#include <thread.h>
    2930#include <process.h>
     31#include <string.h>
    3032
    3133
     
    3537                 reg_t  arg1 )
    3638{
     39    // get thread, process and core
     40    thread_t  * this    = CURRENT_THREAD;
     41    process_t * process = this->process;
     42    core_t    * core    = this->core;
     43
     44#if CONFIG_DEBUG_SYS_DISPLAY
     45uint64_t    tm_start;
     46uint64_t    tm_end;
     47tm_start = hal_get_cycles();
     48if( CONFIG_DEBUG_SYS_DISPLAY < tm_start )
     49printk("\n[DBG] %s : thread %d enter / process %x / cycle = %d\n",
     50__FUNCTION__, this, process->pid, (uint32_t)tm_start );
     51#endif
     52
    3753    if( type == DISPLAY_STRING )
    3854    {
    3955        paddr_t   paddr;
    4056        char      kbuf[256];
     57        uint32_t  length;
    4158
    4259        char    * string = (char *)arg0;
    4360 
    4461        // check string in user space
    45         if( vmm_v2p_translate( false , string , &paddr ) ) return -1;
     62        if( vmm_v2p_translate( false , string , &paddr ) )
     63        {
     64            printk("\n[ERROR] in %s : string buffer %x unmapped\n",
     65            __FUNCTION__ , string );
     66            return -1;
     67        }
    4668
    4769        // ckeck string length
    48         if( hal_strlen_from_uspace( string ) >= 256 ) return -1;
     70        length = hal_strlen_from_uspace( string );
     71        if( length >= 256 )
     72        {
     73            printk("\n[ERROR] in %s : string length %d too large\n",
     74            __FUNCTION__ , length );
     75            return -1;
     76        }
    4977
    5078        // copy string in kernel space
    5179        hal_strcpy_from_uspace( kbuf , string , 256 );
    52 
    53         // get thread, process and core
    54         thread_t  * this    = CURRENT_THREAD;
    55         process_t * process = this->process;
    56         core_t    * core    = this->core;
    5780
    5881        // print message on TXT0 kernel terminal
     
    6083        this->trdid , process->pid , local_cxy, core->lid ,
    6184        (uint32_t)hal_get_cycles() , kbuf );
    62 
    63             return 0;
    6485    }
    6586    else if( type == DISPLAY_VMM )
     
    7091        xptr_t process_xp = cluster_get_reference_process_from_pid( pid );
    7192
    72             if( process_xp == XPTR_NULL ) return -1;
     93            if( process_xp == XPTR_NULL )
     94        {
     95            printk("\n[ERROR] in %s : undefined PID %x\n",
     96            __FUNCTION__ , pid );
     97            return -1;
     98        }
    7399
    74100        // get cluster and local pointer on process
     
    85111            rpc_vmm_display_client( process_cxy , process_ptr , true );
    86112        }
    87 
    88             return 0;
    89113    }
    90114    else if( type == DISPLAY_SCHED )
     
    94118
    95119        // check cluster argument
    96             if( cluster_is_undefined( cxy ) ) return -1;
     120            if( cluster_is_undefined( cxy ) )
     121        {
     122            printk("\n[ERROR] in %s : undefined cluster identifier %x\n",
     123            __FUNCTION__ , cxy );
     124            return -1;
     125        }
    97126
    98127        // check core argument
    99         if( lid >= LOCAL_CLUSTER->cores_nr ) return -1;
     128        if( lid >= LOCAL_CLUSTER->cores_nr )
     129        {
     130            printk("\n[ERROR] in %s : undefined local index %d\n",
     131            __FUNCTION__ , lid );
     132            return -1;
     133        }
    100134
    101         // call kernel function
    102135        if( cxy == local_cxy )
    103136        {
     
    108141            rpc_sched_display_client( cxy , lid );
    109142        }
    110 
    111             return 0;
    112143    }
    113144    else if( type == DISPLAY_PROCESS )
     
    116147
    117148        // check cluster argument
    118             if( cluster_is_undefined( cxy ) ) return -1;
     149            if( cluster_is_undefined( cxy ) )
     150        {
     151            printk("\n[ERROR] in %s : undefined cluster identifier %x\n",
     152            __FUNCTION__ , cxy );
     153            return -1;
     154        }
    119155
    120         // call kernel function
    121156        cluster_processes_display( cxy );
    122 
    123         return 0;
    124157    }
    125158    else if( type == DISPLAY_VFS )
     
    128161        process_t * process = CURRENT_THREAD->process;
    129162        vfs_display( process->vfs_root_xp );
    130 
    131         return 0;
    132163    }
    133164    else if( type == DISPLAY_CHDEV )
    134165    {
    135         // call kernel function
    136166        chdev_dir_display();
     167    }
     168    else
     169    {
     170        printk("\n[ERROR] in %s : undefined display type %x\n",
     171        __FUNCTION__ , type );
     172        return -1;
     173    }
    137174
    138         return 0;
    139     }
    140     else return -1;
     175#if CONFIG_DEBUG_SYS_DISPLAY
     176tm_end = hal_get_cycles();
     177if( CONFIG_DEBUG_SYS_DISPLAY < tm_end )
     178printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n",
     179__FUNCTION__, this, process->pid, (uint32_t)(tm_end - tm_start) , (uint32_t)tm_end );
     180#endif
    141181
    142 }  // end sys_get_sched()
     182    return 0;
     183
     184}  // end sys_display()
Note: See TracChangeset for help on using the changeset viewer.