= GIET-VM / Miscelaneous common kernel functions = [[PageOutline]] The [source:soft/giet_vm/giet_common/utils.c utils.c] and [source:soft/giet_vm/giet_common/utils.h utils.h] files define various kernel functions that can be used by both the kernel code and the boot code. === void '''_exit'''(void) === This function is called in case of kernel error. The processor try to displays an error message on TTY0, and suicide (enter infinite loop)... === void '''_random_wait'''( unsigned int value ) === This function implements a pseudo-random delay. The 5 LSB bits of the '''value''' argument (number between 0 and 31) define the average delay value: 2 * (2**(value[4:0] === void '''_break'''( char* str ) === This function can be used for interactive kernel debug. It displays the '''str''' string on TTY0, and waits until a character typed on TTY0. === unsigned int '''_strncmp'''( const char* s1, const char* s2, unsigned int n ); This function compares the '''n''' first characters of the two '''s1''' and '''s2''' strings. Returns 0 if all characters are identical. returns 1 otherwise. === char* '''_strcpy'''( char* dest, char* source ) === This function copies the '''source''' string to the '''dest''' string, and returns a pointer on the '''dest''' string. === void '''_dcache_buf_invalidate'''( unsigned int buf_vbase, unsigned int buf_size ) === This function invalidates all cache lines contained in the L1 data cache that overlap the buffer defined by the '''buf_vbase''' and '''buf_size''' arguments. === void '''_get_sqt_footprint'''( unsigned int* width, unsigned int* heigth, unsigned int* levels ) === Scalable, distributed synchronisation mechanisms , such as a barrier or a lock can be implemented with a Synchronisation Quad Tree (SQT). This function computes the smallest SQT covering all clusters containing processors in a platform. The SQT footprint is defined by the '''width''' (number of clusters in a row) and '''heigth''' (number of clusters in a column) parameters. The '''levels''' parameter define the number of levels between the root and the leaves, with the following constraints: * cluster[0][0] is always covered by the SQT * width and heigth are not always power of 2 * they cannot be larger than the mesh (X_SIZE/Y_SIZE) parameters, * they can be smaller when the upper row, or the right column does not contain processors.