1    /*
     2     *  Copyright 2013 by Texas Instruments Incorporated.
     3     *
     4     */
     5    
     6    /*
     7     * Copyright (c) 2013, Texas Instruments Incorporated
     8     * All rights reserved.
     9     *
    10     * Redistribution and use in source and binary forms, with or without
    11     * modification, are permitted provided that the following conditions
    12     * are met:
    13     *
    14     * *  Redistributions of source code must retain the above copyright
    15     *    notice, this list of conditions and the following disclaimer.
    16     *
    17     * *  Redistributions in binary form must reproduce the above copyright
    18     *    notice, this list of conditions and the following disclaimer in the
    19     *    documentation and/or other materials provided with the distribution.
    20     *
    21     * *  Neither the name of Texas Instruments Incorporated nor the names of
    22     *    its contributors may be used to endorse or promote products derived
    23     *    from this software without specific prior written permission.
    24     *
    25     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    26     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    27     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    28     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    29     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    30     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    31     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    32     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    33     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    34     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    35     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    36     *
    37     */
    38    /*
    39     *  ======== ThreadSupport.xdc ========
    40     */
    41    
    42    import xdc.runtime.Assert;
    43    import xdc.runtime.Diags;
    44    import xdc.runtime.Error;
    45    import xdc.runtime.Log;
    46    import xdc.runtime.knl.IThreadSupport;
    47    
    48    @ModuleStartup          /* need to initialize the pthread_key_t */
    49    @InstanceInitError      /* because initialization can fail */
    50    @InstanceFinalize       /* have to Thread_Proxy_delete(sem) on delete */
    51    module ThreadSupport inherits IThreadSupport
    52    {
    53        config Error.Id E_priority = {
    54            msg: "E_priority: Thread priority is invalid %d"
    55        };
    56    
    57        config Assert.Id A_POSIX_Error = {
    58            msg: "A_POSIX_Error: a POSIX function returned failure"
    59        };
    60    
    61        config Error.Id E_POSIX_Error = {
    62            msg: "E_POSIX_Error: a POSIX function returned failure, errno is %d"
    63        };
    64    
    65        config Log.Event L_start = {
    66            mask: Diags.LIFECYCLE,
    67            msg: "<-- start: (%p)"
    68        };
    69    
    70        config Log.Event L_finish = {
    71            mask: Diags.LIFECYCLE,
    72            msg: "--> finish: (%p)"
    73        };
    74    
    75        config Log.Event L_join = {
    76            mask: Diags.LIFECYCLE,
    77            msg: "--> join: (%p)"
    78        };
    79    
    80    internal:
    81    
    82    
    83        const Int PRI_FAILURE = 4;
    84        const Int SETUP_FAILURE = 3; /*! return code for Instance_init */
    85        const Int ALLOC_FAILURE = 2; /*! return code for Instance_init */
    86        const Int POSIX_FAILURE = 1; /*! return code for Instance_init */
    87    
    88        struct Instance_State {
    89            Ptr tls; /*! store env parameter */
    90            RunFxn startFxn; /*! store fxn parameter */
    91            IArg startFxnArg; /*! store arg parameter */
    92            SizeT stackSize; /*! store stackSize parameter */
    93            //pthread_t* tid;
    94            void* tid; /*! pointer to a pthread_t - can't use pthread_t* because we
    95                           can't see pthread.h */
    96            Ptr stackBase; /*! pointer to near the top of the stack */
    97            Int staticOsPri;
    98        }
    99    
   100        struct Module_State {
   101             Int lowestPriority;
   102             Int belowNormalPriority;
   103             Int normalPriority;
   104             Int aboveNormalPriority;
   105             Int highestPriority;
   106        };
   107    }
   108    /*
   109     *  @(#) ti.sdo.xdcruntime.linux; 1, 0, 0,1; 5-20-2013 14:37:24; /db/atree/library/trees/osal/osal-g09/src/packages/ xlibrary
   110    
   111     */
   112