Changeset 267 for soft


Ignore:
Timestamp:
Jan 13, 2014, 3:20:29 PM (11 years ago)
Author:
cfuguet
Message:
  • Adding new task context information: THREAD INDEX.

This value can be accessed by USER applications to get the
thread index of the current task. This thread index
corresponds to the index in a vspace.

The value of this index can be forced in the vspace part
of the XML description file using the trdid field in the
task description. When this value is missing, for each
task, a value from 0 to N-1 will be assigned, where N is
the number of task in the vspace.

The user application access this value through the
giet_thread_id() function defined in the stdio library
which uses the SYSCALL_THREAD_ID to access the task
context information.

  • Supporting mono TTY platforms

When the GIET_MONO_TTY constant defined in the giet_config
file, contains a value different than 0, all tasks will
share the TTY[0]. If this is the case, in the stdio
library, the giet_tty_printf() function will take the TTY
hardware lock before writing

Location:
soft/giet_vm
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_boot/boot.c

    r263 r267  
    11571157    //   are reserved for the kernel (context switch)
    11581158
    1159     unsigned int alloc_tty_channel = 1;            // TTY channel allocator
     1159    unsigned int alloc_tty_channel = 0;            // TTY channel allocator
    11601160    unsigned int alloc_nic_channel = 0;            // NIC channel allocator
    11611161    unsigned int alloc_cma_channel = 0;            // CMA channel allocator
    11621162    unsigned int alloc_hba_channel = 0;            // IOC channel allocator
    11631163    unsigned int alloc_tim_channel[X_SIZE*Y_SIZE]; // user TIMER allocators
     1164
     1165    if (!GIET_MONO_TTY) alloc_tty_channel++;
    11641166
    11651167    /////////////////////////////////////////////////////////////////////////
     
    13641366                }
    13651367                ctx_tty = alloc_tty_channel;
    1366                 alloc_tty_channel++;
     1368                if (!GIET_MONO_TTY) alloc_tty_channel++;
    13671369            }
    13681370            // ctx_nic : NIC channel global index provided by the global allocator
     
    14681470            // get local task index in scheduler
    14691471            unsigned int ltid = psched->tasks;
     1472
     1473            // get vspace thread index
     1474            unsigned int thread_id = task[task_id].trdid;
    14701475
    14711476            if (ltid >= IDLE_TASK_INDEX)
     
    15001505            psched->context[ltid][CTX_LTID_ID]  = ltid;
    15011506            psched->context[ltid][CTX_GTID_ID]  = task_id;
     1507            psched->context[ltid][CTX_TRDID_ID] = thread_id;
    15021508            psched->context[ltid][CTX_VSID_ID]  = vspace_id;
    15031509            psched->context[ltid][CTX_RUN_ID]   = 1;
     
    15051511#if BOOT_DEBUG_SCHED
    15061512_puts("\nTask ");
    1507 _puts( task[task_id].name );
    1508 _puts(" (");
    15091513_putd( task_id );
    1510 _puts(") allocated to processor ");
     1514_puts(" allocated to processor ");
    15111515_putd( gpid );
    15121516_puts("\n  - ctx[LTID]   = ");
     
    15361540_puts("\n  - ctx[VSID]   = ");
    15371541_putd( psched->context[ltid][CTX_VSID_ID] );
     1542_puts("\n  - ctx[TRDID]  = ");
     1543_putd( psched->context[ltid][CTX_TRDID_ID] );
    15381544_puts("\n");
    15391545#endif
  • soft/giet_vm/giet_config.h

    r264 r267  
    3535
    3636#define GIET_IDLE_TASK_PERIOD    10000000   /* Idle Task message period */
     37#define GIET_IDLE_TASK_VERBOSITY 1
     38
     39#define GIET_MONO_TTY            0          /* Only one terminal is used */
     40
    3741#define GIET_MAX_ELF_FILES       20         /* max .elf files loaded by boot-loader */
    3842#define GIET_OPEN_FILES_MAX      16         /* max simultaneously open files */
  • soft/giet_vm/giet_drivers/dma_driver.c

    r263 r267  
    134134    return dma_address[channel_id * DMA_SPAN + DMA_LEN];
    135135#else
    136     return DMA_ERROR;
     136    return DMA_IDLE;
    137137#endif
    138138}
  • soft/giet_vm/giet_kernel/ctx_handler.c

    r258 r267  
    4141// - LTID   : Task local index (in scheduler)
    4242// - VSID   : Virtual space index
    43 // - RUN    : Task state (0 => sleeping / 1 => runable )
     43// - RUN    : Task state (0 => sleeping / 1 => runnable )
     44// - TRDID  : Thread ID index (in vspace)
    4445//
    4546// ctx[0]<- ***|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC  |ctx[40]<- TTY
     
    5152// ctx[6]<- $6 |ctx[14]<- $14|ctx[22]<- $22|ctx[30]<- $30|ctx[38]<- VSID |ctx[46]<- GTID
    5253// ctx[7]<- $7 |ctx[15]<- $15|ctx[23]<- $23|ctx[31]<- RA |ctx[39]<- PTPR |ctx[47]<- RUN
     54//
     55// ctx[48]<- TRDID
    5356//////////////////////////////////////////////////////////////////////////////////////////
    5457
     
    164167                : "$3" );
    165168
     169#if GIET_IDLE_TASK_VERBOSITY == 1
    166170        _tty_get_lock( 0 );
    167171        _puts("\n[GIET WARNING] Processor ");
     
    171175        _puts("\n");
    172176        _tty_release_lock( 0 );
     177#endif
    173178
    174179         count = GIET_IDLE_TASK_PERIOD;
  • soft/giet_vm/giet_kernel/ctx_handler.h

    r258 r267  
    4848#define CTX_GTID_ID      46  // Global Task Index
    4949#define CTX_RUN_ID       47  // Boolean: task runable
     50#define CTX_TRDID_ID     48  // Thread Index in vspace
    5051
    5152//////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_kernel/giet.s

    r258 r267  
    99* - the _cause_vector[16] array defines the 16 causes to enter the GIET
    1010*   it is initialized in th exc_handler.c file
    11 * - the _syscall_vector[32] array defines the 32 system calls entry points
     11* - the _syscall_vector[64] array defines the 64 system calls entry points
    1212*   it is initialised in the sys_handler.c file
    1313***********************************************************************************/
  • soft/giet_vm/giet_kernel/sys_handler.c

    r263 r267  
    4848    &_fb_sync_write,       /* 0x10 */
    4949    &_fb_sync_read,        /* 0x11 */
    50     &_sys_ukn,             /* 0x12 */
    51     &_sys_ukn,             /* 0x13 */
     50    &_thread_id,           /* 0x12 */
     51    &_tty_get_release_lock,/* 0x13 */
    5252    &_sys_ukn,             /* 0x14 */
    5353    &_sys_ukn,             /* 0x15 */
     
    180180{
    181181    return _get_context_slot(CTX_GTID_ID);
     182}
     183
     184/////////////////////////////////////////////////////////////////////////////
     185// _thread_id()
     186// Returns current thread index.
     187/////////////////////////////////////////////////////////////////////////////
     188unsigned int _thread_id()
     189{
     190    return _get_context_slot(CTX_TRDID_ID);
     191}
     192
     193/////////////////////////////////////////////////////////////////////////////
     194// _tty_get_release_lock(int val)
     195// Get or release the hardware TTY lock depending on val (0: get,1: release)
     196/////////////////////////////////////////////////////////////////////////////
     197int _tty_get_release_lock(unsigned int val)
     198{
     199    unsigned int channel = _get_context_slot(CTX_TTY_ID);
     200
     201    if      ( val == 0 ) _tty_get_lock(channel);
     202    else if ( val == 1 ) _tty_release_lock(channel);
     203    else return -1; // Wrong action
     204
     205    return 0;
    182206}
    183207
  • soft/giet_vm/giet_kernel/sys_handler.h

    r258 r267  
    2424unsigned int _local_task_id();
    2525unsigned int _global_task_id();
     26unsigned int _thread_id();
     27
     28int          _tty_get_release_lock(unsigned int val);
    2629
    2730unsigned int _procs_number( unsigned int  cluster_id,
  • soft/giet_vm/giet_libs/stdio.c

    r260 r267  
    1212#include <stdarg.h>
    1313#include <stdio.h>
     14#include <giet_config.h>
    1415
    1516
     
    298299    unsigned int ret;
    299300
     301    if (GIET_MONO_TTY)
     302    {
     303        ret = sys_call(SYSCALL_TTY_LOCK, 0, 0, 0, 0); // Get TTY lock
     304    }
     305
    300306printf_text:
    301307
     
    311317                           0xFFFFFFFF,
    312318                           0);
    313             if (ret != i)  return 1;     /* return error */
     319
     320            if (ret != i) goto return_error;
     321
    314322            format += i;
    315323        }
     
    319327            goto printf_arguments;
    320328        }
     329    }
     330
     331    if (GIET_MONO_TTY)
     332    {
     333        ret = sys_call(SYSCALL_TTY_LOCK, 1, 0, 0, 0); // Release TTY lock
    321334    }
    322335
     
    349362                                   0xFFFFFFFF,
    350363                                   0);
    351                     if (ret != 1)  return 1;     /* return error */
     364                    if (ret != 1) goto return_error;
    352365                }
    353366            case ('u'):             /* decimal unsigned integer */
     
    366379                               0xFFFFFFFF,
    367380                               0);
    368                 if (ret != 2) return 1;       /* return error */
     381                if (ret != 2) goto return_error;       /* return error */
    369382                for(i = 0; i < 8; i++)
    370383                {
     
    394407                       0xFFFFFFFF,
    395408                       0);
    396         if (ret != len)  return 1;
     409        if (ret != len)  goto return_error;
     410       
    397411        goto printf_text;
    398412    }
     413
     414return_error:
     415    if (GIET_MONO_TTY)
     416    {
     417        ret = sys_call(SYSCALL_TTY_LOCK, 1, 0, 0, 0); // Release TTY lock
     418    }
     419
     420    return 1;
    399421}
    400422
     
    663685}
    664686
     687//////////////////////////////////////////////////////////////////////////////////
     688// giet_thread_id()
     689//////////////////////////////////////////////////////////////////////////////////
     690// This functions returns the thread index of the current task.
     691//////////////////////////////////////////////////////////////////////////////////
     692int giet_thread_id()
     693{
     694    return sys_call( SYSCALL_THREAD_ID,
     695                     0, 0, 0, 0 );
     696}
     697
    665698///////////////////////////////////////////////////////////////////////////////////
    666699///////////////////// FAT related system calls ////////////////////////////////////
  • soft/giet_vm/giet_libs/stdio.h

    r260 r267  
    3131#define SYSCALL_FB_SYNC_WRITE     0x10
    3232#define SYSCALL_FB_SYNC_READ      0x11
    33 #define SYSCALL_FREE_12           0x12
    34 #define SYSCALL_FREE_13           0x13
     33#define SYSCALL_THREAD_ID         0x12
     34#define SYSCALL_TTY_LOCK          0x13
    3535#define SYSCALL_FREE_14           0x14
    3636#define SYSCALL_FREE_15           0x15
     
    209209extern int giet_global_task_id();
    210210
     211extern int giet_thread_id();
     212
    211213extern void giet_assert( unsigned int,
    212214                         char* string );
  • soft/giet_vm/giet_xml/mapping_info.h

    r263 r267  
    252252    unsigned int    clusterid;       // linear index in array of clusters
    253253    unsigned int    proclocid;       // processor local index (inside cluster)
     254    unsigned int    trdid;           // thread index in vspace
    254255    unsigned int    stack_vobjid;    // stack vobj index in vspace
    255256    unsigned int    heap_vobjid;     // heap vobj index in vspace
  • soft/giet_vm/giet_xml/xml_parser.c

    r263 r267  
    463463
    464464    ///////// get x coordinate
    465      x = getIntValue(reader, "x", &ok);
     465    task[task_index]->trdid = getIntValue(reader, "trdid", &ok);
     466#if XML_PARSER_DEBUG
     467printf("      x         = %d\n", x);
     468#endif
     469    if ( !ok )
     470    {
     471        task[task_index]->trdid = task_loc_index;
     472        printf("[XML WARNING] missing trdid (thread index) attribute "
     473               "for task in vspace %d. Using value %d\n"
     474               , vspace_index, task_loc_index);
     475    } 
     476
     477    ///////// get x coordinate
     478    x = getIntValue(reader, "x", &ok);
    466479#if XML_PARSER_DEBUG
    467480printf("      x         = %d\n", x);
     
    475488
    476489    ///////// get y coordinate
    477      y = getIntValue(reader, "y", &ok);
     490    y = getIntValue(reader, "y", &ok);
    478491#if XML_PARSER_DEBUG
    479492printf("      y         = %d\n", y);
Note: See TracChangeset for help on using the changeset viewer.