wiki:kernel_miscelaneous

Version 3 (modified by alain, 10 years ago) (diff)

--

GIET-VM / Miscelaneous common kernel functions

The utils.c and 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_sbt_footprint( unsigned int* width, unsigned int* heigth, unsigned int* levels )

A Sliced Binary Tree (SBT) can be used to implement a scalable, distributed synchronisation, such as a sbt_barrier or a sbt_lock. This function computes the footprint of the smallest SBT covering all clusters containing processors in a platform. The SBT footprint is defined by the width and heigth 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 SBT
  • the number of clusters in a row (width) is always power of 2
  • the number of xlusters in a column (heigth) is always power of 2
  • (width = heigth) OR (width = 2 * heigth)

The width/heigth parameters can be larger than the X_SIZE/Y_SIZE parameters, when X_SIZE or Y_SIZE are not power of 2. The width/heigth parameters can be smaller than the X_SIZE/Y_SIZE parameters, when the upper row, or the right column of clusters does not contain processors.