Ignore:
Timestamp:
May 29, 2018, 9:27:23 AM (6 years ago)
Author:
alain
Message:

Restructure the mini_libc.

Location:
trunk/libs/libalmosmkh
Files:
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/libs/libalmosmkh/almosmkh.h

    r444 r445  
     1/*
     2 * almosmkh.h - User level ALMOS-MKH specific library definition.
     3 *
     4 * Author     Alain Greiner (2016,2017,2018)
     5 *
     6 * Copyright (c) UPMC Sorbonne Universites
     7 *
     8 * This file is part of ALMOS-MKH.
     9 *
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
     11 * under the terms of the GNU General Public License as published by
     12 * the Free Software Foundation; version 2.0 of the License.
     13 *
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
     15 * WITHOUT ANY WARRANTY; without even the implied warranty of
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     17 * General Public License for more details.
     18 *
     19 * You should have received a copy of the GNU General Public License
     20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
     21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
     22 */
     23
    124#ifndef _LIBALMOSMKH_H_
    225#define _LIBALMOSMKH_H_
    326
    4 #include <almos-mkh/almos-mkh.h>
     27/***************************************************************************************
     28 * various the user level, ALMOS-MKH specific library. It contains:
     29 * - non standard system calls.
     30 * - debug functions.
     31 * - remote malloc extensions.
     32 **************************************************************************************/
     33
    534#include <pthread.h>
    6 
    7 /****************** Non standard (ALMOS_MKH specific) system calls **********************/
    8 
    9 
    10 /*****************************************************************************************
     35#include <shared_almos.h>
     36
     37/****************** Non standard (ALMOS_MKH specific) system calls ********************/
     38
     39
     40/***************************************************************************************
    1141 * This function is used to give the process identified by the <pid> argument the
    1242 * exclusive ownership of the attached TXT_RX terminal.
    13  *****************************************************************************************
     43 ***************************************************************************************
    1444 * @ pid        : process identifier.
    1545 * @ returns O if success / returns -1 if process not found.
    16  ****************************************************************************************/
     46 **************************************************************************************/
    1747int fg( unsigned int pid );
    1848
     
    4979
    5080/***************************************************************************************
     81 * This function implement the operations related to User Thread Local Storage.
     82 ***************************************************************************************
     83 * @ operation  : UTLS operation type as defined in "shared_sycalls.h" file.
     84 * @ value      : argument value for the UTLS_SET operation.
     85 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
     86 **************************************************************************************/
     87int utls( unsigned int operation,
     88          unsigned int value );
     89
     90/***************************************************************************************
     91 * This function returns a positive integer fom the standard "stdin" stream.
     92 ***************************************************************************************
     93 * returns the integer value if success / returns -1 if failure.
     94 **************************************************************************************/
     95int getint();
     96
     97
     98/***************** Non standard (ALMOS-MKH specific) debug functions ******************/
     99
     100
     101/***************************************************************************************
    51102 * This debug function displays on the kernel terminal TXT0
    52103 * the thread / process / core identifiers, the current cycle, plus a user defined
     
    91142/***************************************************************************************
    92143 * This debug function displays on the kernel terminal TXT0
     144 * the list of processes attached to a given TXT channel.
     145 * It can be called by any thread running in any cluster.
     146 ***************************************************************************************
     147 * @ txt_id   : [in] TXT terminal indes.
     148 * @ return 0 if success / return -1 if illegal argument.
     149 **************************************************************************************/
     150int display_txt_processes( unsigned int txt_id );
     151
     152/***************************************************************************************
     153 * This debug function displays on the kernel terminal TXT0
    93154 * the list of channel devices available in the architecture.
    94155 * It can be called by any thread running in any cluster.
     
    108169
    109170/***************************************************************************************
    110  * This debug function displays on the kernel terminal TXT0
    111  * the list of processes attached to a given TXT channel.
    112  * It can be called by any thread running in any cluster.
    113  ***************************************************************************************
    114  * @ return always 0.
    115  **************************************************************************************/
    116 int display_txt_processes( unsigned int txt_id );
     171 * This debug function displays on the kernel terminal TXT0 the current DQDT state.
     172 * It can be called by any thread running in any cluster.
     173 ***************************************************************************************
     174 * @ return always 0.
     175 **************************************************************************************/
     176int display_dqdt();
    117177
    118178/*****************************************************************************************
     
    126186* @ returns O if success / returns -1 if illegal arguments.
    127187****************************************************************************************/
    128 
    129188int trace( unsigned int active,
    130189           unsigned int pid,
    131190           unsigned int trdid );
    132191
    133 /*****************************************************************************************
    134  * This function implement the operations related to User Thread Local Storage.
    135  *****************************************************************************************
    136  * @ operation  : UTLS operation type as defined in "shared_sycalls.h" file.
    137  * @ value      : argument value for the UTLS_SET operation.
    138  * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
    139  ****************************************************************************************/
    140 int utls( unsigned int operation,
    141           unsigned int value );
    142 
    143 /*********************************************************************************************
    144  * This function returns a positive integer fom the standard "stdin" stream.
    145  *********************************************************************************************
    146  * returns the integer value if success / returns -1 if failure.
    147  ********************************************************************************************/
    148 int getint();
    149 
    150 
    151 /////// Non-standard memory operations ////////////
    152 ////////////////////////////////////////////////////////////////////////////////
     192/****************************************************************************************
     193 * This blocking function implements an user-level interactive debugger that can be
     194 * introduced in any user application to display various kernel distributed structures.
     195 * The supported commands are:
     196 * - p (cxy)     : display all processes descriptors in a given cluster.
     197 * - s (cxy,lid) : display all threads attached to a given core in a given cluster.
     198 * - v (cxy)     : display the calling process VMM in a given cluster.
     199 * - t (tid)     : display all owner process descriptors attached to a TXT terminal.
     200 * - x           : force the calling process to exit.
     201 * - c           : continue calling process execution.
     202 * - h           : list the supported commands
     203 ***************************************************************************************/
     204void idbg();
     205
     206
     207/****************** Non standard (ALMOS-MKH specific) malloc operations  ***************/
     208
     209/////////////////////////////////////////////////////////////////////////////////////////
    153210// General principles:
    154211// - In user space the HEAP zone spread between the ELF zone and the STACK zone,
     
    168225//        We should introduce the possibility to dynamically allocate
    169226//        several vsegs in each cluster, using several mmap when required.
    170 ////////////////////////////////////////////////////////////////////////////////
     227/////////////////////////////////////////////////////////////////////////////////////////
    171228// Free blocks organisation in each cluster :
    172229// - All free blocks have a size that is a power of 2, larger or equal
     
    179236// - The pointers on the first free block for each size are stored in an
    180237//   array of pointers free[32] in the storage(x,y) descriptor.
    181 ////////////////////////////////////////////////////////////////////////////////
     238/////////////////////////////////////////////////////////////////////////////////////////
    182239// Allocation policy:
    183240// - The block size required by the user can be any value, but the allocated
     
    200257//   If the vseg is aligned (the vseg base is a multiple of the
    201258//   vseg size), all allocated blocks are aligned on the actual_size.
    202 ////////////////////////////////////////////////////////////////////////////////
     259/////////////////////////////////////////////////////////////////////////////////////////
    203260// Free policy:
    204261// - Each allocated block is registered in an alloc[] array of unsigned char.
     
    213270// - The alloc[] array is stored at the end of heap segment. This consume
    214271//   (1 / MALLOC_MIN_BLOCK_SIZE) of the total storage capacity.
    215 ////////////////////////////////////////////////////////////////////////////////
     272/////////////////////////////////////////////////////////////////////////////////////////
    216273
    217274
     
    221278#define MALLOC_MAX_CLUSTERS        0x100        // 256 clusters
    222279
    223 ////////////////////////////////////////////////////////////////////////////////
    224 // store(x,y) descriptor (one per cluster)
    225 ////////////////////////////////////////////////////////////////////////////////
     280/////////////////////////////////////////////////////////////////////////////////////////
     281//               store(x,y) descriptor (one per cluster)
     282/////////////////////////////////////////////////////////////////////////////////////////
    226283
    227284typedef struct malloc_store_s
    228285{
    229     pthread_mutex_t mutex;           // lock protecting exclusive access
     286    pthread_mutex_t mutex;           // lock protecting exclusive access to local heap
    230287    unsigned int    initialized;     // initialised when value == MALLOC_INITIALIZED
    231288    unsigned int    cxy;             // cluster identifier 
     
    276333                       unsigned int  size,
    277334                       unsigned int  cxy );
     335
    278336/*****************************************************************************************
    279337 * This function allocates enough space for <count> objects that are <size> bytes
     
    290348                      unsigned int cxy );
    291349
    292 /*********************************************************************************************
    293  * This blocking function implements an user-level interactive debugger that can be
    294  * introduced in any user application to display various kernel distributed structures
    295  * related to the calling process. The supported commands are:
    296  * - p (cxy)     : display all processes descriptors in a given cluster.
    297  * - s (cxy,lid) : display all threads attached to a given core in a given cluster.
    298  * - v (cxy)     : display the calling process VMM in a given cluster.
    299  * - t (tid)     : display all owner process descriptors attached to a given TXT terminal.
    300  * - x           : force the calling process to exit.
    301  * - c           : continue calling process execution.
    302  *********************************************************************************************
    303  * @ return an integer value between 0 and RAND_MAX.
    304  ********************************************************************************************/
    305 void idbg();
    306 
    307350#endif /* _LIBALMOSMKH_H_ */
    308351
Note: See TracChangeset for help on using the changeset viewer.