Changeset 685
- Timestamp:
- Jan 13, 2021, 12:45:27 AM (4 years ago)
- Location:
- trunk/libs/libalmosmkh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/libalmosmkh/almosmkh.c
r678 r685 23 23 24 24 #include <almosmkh.h> 25 #include <shared_almos.h> 25 26 #include <hal_user.h> 26 27 #include <hal_macros.h> … … 60 61 int get_config( struct hard_config_s * config ) 61 62 { 62 return hal_user_syscall( SYS_GET_CONFIG, 63 (reg_t)config, 0, 0, 0); 63 return hal_user_syscall( SYS_GET, 64 GET_CONFIG, 65 (reg_t)config, 0, 0); 64 66 } 65 67 … … 68 70 unsigned int * lid ) 69 71 { 70 return hal_user_syscall( SYS_GET_CORE_ID, 72 return hal_user_syscall( SYS_GET, 73 GET_CORE_ID, 71 74 (reg_t)cxy, 72 (reg_t)lid, 0 , 0);75 (reg_t)lid, 0 ); 73 76 } 74 77 … … 77 80 unsigned int * ncores ) 78 81 { 79 return hal_user_syscall( SYS_GET_NB_CORES, 82 return hal_user_syscall( SYS_GET, 83 GET_NB_CORES, 80 84 (reg_t)cxy, 81 (reg_t)ncores, 0 , 0);85 (reg_t)ncores, 0 ); 82 86 } 83 87 … … 88 92 unsigned int * lid ) 89 93 { 90 return hal_user_syscall( SYS_GET _BEST_CORE,91 (reg_t)base_cxy,92 (reg_t) level,94 return hal_user_syscall( SYS_GET, 95 GET_BEST_CORE, 96 (reg_t)((base_cxy << 16) | (level & 0xFFFF)), 93 97 (reg_t)cxy, 94 98 (reg_t)lid ); 95 99 } 96 100 101 ////////////////////////////////////////////// 102 int get_processes( unsigned int cxy, 103 unsigned int owned, 104 char * u_buf, 105 unsigned int size ) 106 { 107 return hal_user_syscall( SYS_GET, 108 GET_PROCESSES, 109 (reg_t)((cxy << 16) | (owned & 0xFFFF)), 110 (reg_t)u_buf, 111 (reg_t)size ); 112 } 113 97 114 /////////////////////////////////////////// 98 115 int get_cycle( unsigned long long * cycle ) 99 116 { 100 return hal_user_syscall( SYS_GET_CYCLE, 101 (reg_t)cycle, 0, 0, 0 ); 117 return hal_user_syscall( SYS_GET, 118 GET_CYCLE, 119 (reg_t)cycle, 0, 0 ); 120 } 121 122 /////////////////////////////////////////// 123 int get_thread_info( thread_info_t * info ) 124 { 125 return hal_user_syscall( SYS_GET, 126 GET_THREAD_INFO, 127 (reg_t)info, 0, 0 ); 102 128 } 103 129 … … 180 206 { 181 207 // test (decimal / hexa) 182 if( (buf[0] == 0x30) && ( buf[1] == 0x58) ) // hexadecimalinput208 if( (buf[0] == 0x30) && ((buf[1] == 0x58) || (buf[1] == 0x78)) ) // hexa input 183 209 { 184 210 for (i = 2; (i < length) && (overflow == 0) ; i++) … … 190 216 } 191 217 } 192 else // decimal input218 else // decimal input 193 219 { 194 220 for (i = 0; (i < length) && (overflow == 0) ; i++) … … 269 295 } 270 296 } 271 272 // set NUL character in string and return success273 274 297 } // end get_string() 275 276 277 /////////////////////////////278 int fget_string( int fdid,279 char * string,280 int maxlen )281 {282 int ret;283 char c;284 int length = 0;285 286 while( 1 )287 {288 // check buffer overflow289 if( length >= maxlen-1 ) length = 0;290 291 // read one character from stream292 ret = read( fdid , &c , 1 );293 294 if( ret == 1 )295 {296 if ( (c >= 0x20) && (c < 0x7F) ) // printable character297 {298 string[length] = (char)c; // register character in string299 length++; // update length300 }301 else if ( c == 0 ) // end of string302 {303 string[length] = (char)c; // register character in string304 length++; // update length305 break; // exit loop306 }307 // discard all characters not printable or NUL308 }309 else310 {311 printf("\n[%s] cannot read stream %d\n", __FUNCTION__, fdid );312 length = 0;313 break;314 }315 }316 } // end fget_string()317 298 318 299 … … 320 301 /////////////// non standard debug functions /////////////////////////////////// 321 302 ////////////////////////////////////////////////////////////////////////////////////// 322 323 ///////////////////////////////////////////324 int get_thread_info( thread_info_t * info )325 {326 return hal_user_syscall( SYS_GET_THREAD_INFO,327 (reg_t)info, 0, 0, 0 );328 }329 303 330 304 //////////////////////////////////// -
trunk/libs/libalmosmkh/almosmkh.h
r678 r685 2 2 * almosmkh.h - User level ALMOS-MKH specific library definition. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019,2020)4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 26 26 27 27 /*************************************************************************************** 28 * This file defines an user level, ALMOS-MKH specific library, containing: 28 * This file defines an user level, ALMOS-MKH specific library, containing various 29 * non standard functions and system calls: 30 * 31 * - non standard get_uint32() and get_string() functions. 29 32 * - non standard system calls. 30 * - debug functions.31 * - remote malloc extensions.32 * - a parallel_pthread_createfunction.33 * - Frame Bufferaccess syscalls.33 * - non standard debug functions. 34 * - non standard remote_malloc() functions. 35 * - non standard parallel_pthread_create() function. 36 * - non standard FBF access syscalls. 34 37 **************************************************************************************/ 35 38 36 39 #include <pthread.h> 37 40 #include <shared_almos.h> 41 42 43 /****************** Non standard (ALMOS_MKH specific) functions **********************/ 44 45 46 /*************************************************************************************** 47 * This syscall returns a 32 bits integer captures from the STDIN terminal. 48 * The value is copied in buffer pointed by the <buf> argument 49 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported. 50 *************************************************************************************** 51 * @ buffer : pointer on buffer. 52 * @ returns 0 if success / returns -1 if failure. 53 **************************************************************************************/ 54 void get_uint32( unsigned int * buffer ); 55 56 57 /*************************************************************************************** 58 * These syscalls return a NUL terminated string captured from the STDIN terminal. 59 * The characters are copied in buffer pointed by the <string> argument. 60 * If the number of captured characters exceeds <maxlen>, all characters are discarded, 61 * and removed from the <string> buffer, and a new string capture start. 62 * - All printable characters 'c' such as (0x20 <= c) and (c < 0x7f) are echoed 63 * and copied in the target buffer. 64 * - The LF (0x0A) or CR (0x13) characters are interpreted as "end of string". 65 * It is echoed, and replaced by the NUL (0x00) character in the target buffer. 66 * - The DEL (0x7F), BS (0x08) control characters are taken into account, and can be 67 * used to correct both the buffer content and the echoed string. 68 * - All other non printable characters are discarded 69 *************************************************************************************** 70 * @ string : pointer on the user space string buffer. 71 * @ maxlen : max number of bytes in string buffer, including the terminating NUL. 72 * @ returns string length (including NUL) if success / returns 0 if failure. 73 **************************************************************************************/ 74 int get_string( char * string, 75 int maxlen ); 76 38 77 39 78 … … 112 151 unsigned int * lid ); 113 152 153 /*************************************************************************************** 154 * This syscall returns in the user buffer defined by the <u_buf> and <size> arguments 155 * a string containing the description of the processes registered in cluster specified 156 * by the <cxy> argument (one line per process in the NUL terminated string). 157 * Only the owned processes are returned when the <owned> argument is non zero. 158 * It can be called by any thread running in any cluster. 159 *************************************************************************************** 160 * @ cxy : [in] target cluster identifier. 161 * @ owned : [in] only owned processes if non zero. 162 * @ return 0 if success / return -1 if illegal argument. 163 **************************************************************************************/ 164 int get_processes( unsigned int cxy, 165 unsigned int owned, 166 char * u_buf, 167 unsigned int size ); 168 114 169 /*************************************************************************************** 115 170 * This function returns the value contained in the calling core cycles counter, … … 120 175 **************************************************************************************/ 121 176 int get_cycle( unsigned long long * cycle ); 122 123 /***************************************************************************************124 * This syscall allows the calling thread to specify the target cluster for125 * a subsequent fork(). It must be called for each fork().126 ***************************************************************************************127 * @ cxy : [in] target cluster identifier.128 * @ return 0 if success / returns -1 if illegal cxy argument.129 **************************************************************************************/130 int place_fork( unsigned int cxy );131 132 /***************************************************************************************133 * This syscall implements the operations related to User Thread Local Storage.134 ***************************************************************************************135 * @ operation : UTLS operation type as defined in "shared_sycalls.h" file.136 * @ value : argument value for the UTLS_SET operation.137 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.138 **************************************************************************************/139 int utls( unsigned int operation,140 unsigned int value );141 142 /***************************************************************************************143 * This syscall returns an 32 bits integer from the TXT terminal.144 * The value is copied in buffer pointed by the <buf> argument145 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported.146 ***************************************************************************************147 * @ buffer : pointer on buffer.148 * @ returns 0 if success / returns -1 if failure.149 **************************************************************************************/150 void get_uint32( unsigned int * buffer );151 152 153 /***************************************************************************************154 * These syscalls return a NUL terminated character string from the TXT terminal.155 * The characters are copied in buffer pointed by the <string> argument.156 * If the number of characters exceeds <maxlen>, all read characters are discarded,157 * and removed from the <string> buffer, and a new string capture start.158 * - Only printable characters c such as (0x20 <= c) and (c < 0x7f) are echoed159 * and copied in the target buffer.160 * - The LF (0x0A) character signaling the end of string is replaced by an extra161 * NUL (0x00) character in the target buffer.162 * - the DEL (0x7F), BS (0x08) control characters are taken into account, and can be163 * used to correct both the buffer content and the echoed string.164 ***************************************************************************************165 * @ string : pointer on the user space string buffer.166 * @ maxlen : max number of bytes in string buffer, including the terminating NUL.167 * @ returns string length (including NUL) if success / returns 0 if failure.168 **************************************************************************************/169 int get_string( char * string,170 int maxlen );171 172 173 /***************** Non standard (ALMOS-MKH specific) debug functions ******************/174 177 175 178 /*************************************************************************************** … … 182 185 int get_thread_info( thread_info_t * info ); 183 186 187 /*************************************************************************************** 188 * This syscall allows the calling thread to specify the target cluster for 189 * a subsequent fork(). It must be called for each fork(). 190 *************************************************************************************** 191 * @ cxy : [in] target cluster identifier. 192 * @ return 0 if success / returns -1 if illegal cxy argument. 193 **************************************************************************************/ 194 int place_fork( unsigned int cxy ); 195 196 /*************************************************************************************** 197 * This syscall implements the operations related to User Thread Local Storage. 198 *************************************************************************************** 199 * @ operation : UTLS operation type as defined in "shared_sycalls.h" file. 200 * @ value : argument value for the UTLS_SET operation. 201 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure. 202 **************************************************************************************/ 203 int utls( unsigned int operation, 204 unsigned int value ); 205 206 207 208 /***************** Non standard (ALMOS-MKH specific) debug functions ******************/ 209 184 210 /*************************************************************************************** 185 211 * This debug syscall displays on the kernel terminal TXT0 186 * the thread / process / core identifiers, the current cycle, plus a user defined 187 * message as specified by the <string> argument. 212 * an user defined message specified by the <string> argument, plus the current cycle. 188 213 *************************************************************************************** 189 214 * @ string : [in] user defined message.
Note: See TracChangeset
for help on using the changeset viewer.