Ignore:
Timestamp:
Apr 26, 2017, 2:14:33 PM (7 years ago)
Author:
alain
Message:

Modify the boot_info_t struct to describe external peripherals in all clusters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bootloader_tsar/boot_utils.h

    r1 r6  
     1/*
     2 * boot_utils.h - TSAR bootloader utilities definition.
     3 *
     4 * Authors :   Alain Greiner / Vu Son  (2016)
     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/****************************************************************************
    225 * This file defines various utility functions for the boot code.           *
     
    2649
    2750/****************************************************************************
    28  * This function reads an aligned 32-bit word from another memory address   *
    29  * space.                                                                   *
    30  * @ xp     : extended pointer to the distant memory location to be read    *
    31  *            from.                                                         *
    32  *                                                                          *
    33  * @ returns the value read.                                                *
     51 * This function reads an aligned 32-bit word from a remote cluster.
     52 * @ xp     : extended pointer to the distant memory location.
     53 * @ returns the value read.     
    3454 ****************************************************************************/
    3555uint32_t boot_remote_lw(xptr_t xp);
    3656
    3757/****************************************************************************
    38  * This function writes an aligned 32-bit word in another memory address    *
    39  * space.                                                                   *
    40  * @ xp     : extended pointer to the distant memory location to be written *
    41  *            to.                                                           *
    42  * @ data   : data value to be written to the distant memory location.      *
     58 * This function writes an aligned 32-bit word to a remote cluster.
     59 * @ xp     : extended pointer to the distant memory location.
     60 * @ data   : data value to be written.
    4361 ****************************************************************************/
    4462void boot_remote_sw(xptr_t xp, uint32_t data);
    4563
    4664/****************************************************************************
    47  * This function atomically adds an value 'val' to the current value stored *
    48  * at a distant memory location pointed to by the extended pointer 'xp'.    *
    49  * @ xp     : extended pointer to the distant memory location whose value   *
    50  *            is to be modified.                                            *
    51  * @ val    : signed value to be added.                                     *
    52  *                                                                          *
    53  * @ returns the value stored at the distant memory location BEFORE the     *
    54  *   atomic operation.                                                      *
     65 * This function atomically adds a value 'val' to the current value stored
     66 * in a remote cluster.
     67 * @ xp     : extended pointer to the distant memory location.
     68 * @ val    : signed value to be added.
     69 * @ returns the value stored BEFORE the atomic operation.
    5570 ****************************************************************************/
    5671int32_t boot_remote_atomic_add(xptr_t xp, int32_t val);
    5772
    5873/****************************************************************************
    59  * This function copies 'size' bytes from the buffer pointed to by 'src'    *
    60  * to the buffer pointed to by 'dest'. These 2 addresses may be in any      *
    61  * different memory address spaces.                                         *
    62  * @ dest   : extended pointer to the destination buffer.                   *
    63  * @ src    : extended pointer to the source buffer.                        *
    64  * @ size   : size of memory block to be copied (in bytes).                 *   
    65  ****************************************************************************/
    66 void boot_remote_memcpy(xptr_t dest, xptr_t src, unsigned int size);
     74 * This function copies 'size' bytes from the buffer pointed to by 'src'
     75 * to the buffer pointed to by 'dest'. These 2 addresses may be in any
     76 * different memory address spaces. 
     77 * @ dest   : extended pointer to the destination buffer.
     78 * @ src    : extended pointer to the source buffer.
     79 * @ size   : size of memory block to be copied (in bytes).   
     80 ****************************************************************************/
     81void boot_remote_memcpy(xptr_t dest, xptr_t src, uint32_t size);
    6782
    6883/****************************************************************************
     
    7186
    7287/****************************************************************************
    73  * This function atomically adds an value 'val' to the current variable     *
    74  * pointed to by 'ptr'. It only returns when the atomic operation is        *
    75  * successful.                                                              *
    76  * @ ptr    : pointer to the variable to be modified.                       *
    77  * @ val    : signed value to be added.                                     *
    78  *                                                                          *
    79  * @ returns the value of the variable BEFORE the atomic operation.         *
     88 * This function atomically adds an value 'val' to the current variable 
     89 * pointed to by 'ptr'. It only returns when the atomic operation is
     90 * successful. 
     91 * @ ptr    : pointer to the variable to be modified. 
     92 * @ val    : signed value to be added.
     93 * @ returns the value of the variable BEFORE the atomic operation. 
    8094 ****************************************************************************/
    8195int32_t boot_atomic_add(int32_t* ptr, int32_t val);
     
    86100
    87101/****************************************************************************
    88  * This function performs a local memory copy (destination and source       *
    89  * addresses are in the same memory space) of 'size' bytes from 'src'       *
    90  * address to 'dest' address.                                               *
    91  * @ dest   : destination physical address,                                 *
    92  * @ src    : source physical address,                                      *
    93  * @ size   : size of memory block to be copied in bytes.                   *
    94  ****************************************************************************/
    95 void boot_memcpy(void* dest, void* src, unsigned int size);
    96 
    97 /****************************************************************************
    98  * This function fills the first 'size' bytes of the local memory area,     *
    99  * pointed to by 'base' with a constant value 'val'.                        *
    100  * @ base   : base address of the memory area to be initialized,            *
    101  * @ val    : value of the constant byte to initialize the area,            *
    102  * @ size   : size of memory block to be filled in bytes.                   *
    103  ****************************************************************************/
    104 void boot_memset(void* base, int val,   unsigned int size);
     102 * This function performs a local memory copy (destination and source 
     103 * addresses are in the same memory space) of 'size' bytes from 'src'
     104 * address to 'dest' address.                   
     105 * @ dest   : destination physical address, 
     106 * @ src    : source physical address,   
     107 * @ size   : size of memory block to be copied in bytes.
     108 ****************************************************************************/
     109void boot_memcpy(void* dest, void* src, uint32_t size);
     110
     111/****************************************************************************
     112 * This function fills the first 'size' bytes of the local memory area,
     113 * pointed to by 'base' with a constant value 'val'.                 
     114 * @ base   : base address of the memory area to be initialized,   
     115 * @ val    : value of the constant byte to initialize the area,
     116 * @ size   : size of memory block to be filled in bytes.   
     117 ****************************************************************************/
     118void boot_memset(void* base, int val,   uint32_t size);
    105119
    106120/****************************************************************************
     
    109123
    110124/****************************************************************************
    111  * This function converts the letter 'c' to lower case, if possible.        *
    112  * @ c  : letter to be converted.                                           *
    113  *                                                                          *
    114  * @ returns the converted letter, or 'c' if the conversion was not         *
    115  *   possible.                                                              *
     125 * This function converts the letter 'c' to lower case, if possible.
     126 * @ c  : letter to be converted.                   
     127 * @ returns the converted letter, or 'c' if conversion not possible.
    116128 ****************************************************************************/
    117129static inline unsigned char boot_to_lower(unsigned char c)
     
    122134
    123135/****************************************************************************
    124  * This function converts the letter 'c' to upper case, if possible.        *
    125  * @ c  : letter to be converted.                                           *
    126  *                                                                          *
    127  * @ returns the converted letter, or 'c' if the conversion was not         *
    128  *   possible.                                                              *
     136 * This function converts the letter 'c' to upper case, if possible.
     137 * @ c  : letter to be converted.
     138 * @ returns the converted letter, or 'c' if conversion not possible.
    129139 ****************************************************************************/
    130140static inline unsigned char boot_to_upper(unsigned char c)
     
    135145
    136146/****************************************************************************
    137  * This function copies the string pointed to by 'src' (the terminating     *
    138  * null byte '\0' NOT included) to the buffer pointed to by 'dest'.         *
    139  * @ src    : pointer to the string to be copied.                           *
    140  * @ dest   : pointer to the destination string.                            *
     147 * This function copies the string pointed to by 'src' (the terminating
     148 * null byte '\0' NOT included) to the buffer pointed to by 'dest'.
     149 * @ src    : pointer to the string to be copied. 
     150 * @ dest   : pointer to the destination string.
    141151 ****************************************************************************/
    142152void boot_strcpy(char* dest, char* src);
    143153
    144154/****************************************************************************
    145  * This function calculates the length of the string pointed to by 's',     *
    146  * excluding the terminating null byte '\0'.                                *
    147  * @ s  : pointer to the string whose length is to be computed.             *
    148  *                                                                          *
    149  * @ returns the number of bytes in the string.                             *
    150  ****************************************************************************/
    151 unsigned int boot_strlen(char* s);
    152 
    153 /****************************************************************************
    154  * This function compares the 2 strings pointed to by 's1' and 's2'.        *
    155  * @ s1 : pointer to the first string to be compared.                       *
    156  * @ s2 : pointer to the second string to be compared.                      *
    157  *                                                                          *
    158  * @ returns 0 if these 2 strings match, 1 otherwise.                       *
     155 * This function calculates the length of the string pointed to by 's',
     156 * excluding the terminating null byte '\0'. 
     157 * @ s  : pointer to the string whose length is to be computed.
     158 * @ returns the number of bytes in the string.
     159 ****************************************************************************/
     160uint32_t boot_strlen(char* s);
     161
     162/****************************************************************************
     163 * This function compares the 2 strings pointed to by 's1' and 's2'.
     164 * @ s1 : pointer to the first string to be compared.
     165 * @ s2 : pointer to the second string to be compared.
     166 * @ returns 0 if these 2 strings match, 1 otherwise.
    159167 ****************************************************************************/
    160168int boot_strcmp(char* s1, char* s2);
     
    165173
    166174/****************************************************************************
    167  * This function writes the NUL terminated string pointed to by 'str' to    *
    168  * the boot TTY terminal.                                                   *
    169  * @ str    : pointer to the string to be printed on the boot TTY terminal. *
     175 * This function writes the NUL terminated string pointed to by 'str'
     176 * to the boot TTY terminal.                           
     177 * @ str    : pointer to the string to be printed on the boot TTY terminal.
    170178 ****************************************************************************/
    171179void boot_puts(char* str);
    172180
    173181/****************************************************************************
    174  * This function produces output, according to the 'format' format, to the  *
    175  * boot TTY terminal.                                                       *
    176  * @ format : the string defining the format of the output. It is composed  *
    177  *            of 0 or more directives:                                      *
    178  *            - ordinary characters (not %), which are copied unchanged to  *
    179  *              the boot TTY terminal.                                      *
    180  *            - conversion specifications (introduced by the character %,   *
    181  *              ended by a conversion specifier), each of which results in  *
    182  *              fetching 0 or more subsequent arguments. The arguments must *
    183  *              correspond properly (after type promotion) with the         *
    184  *              conversion specifier.                                       *
    185  *                                                                          *
    186  * Conversion specifiers:                                                   *
    187  *  - %d : 32-bit signed decimal notation of an integer,                    *
    188  *  - %u : 32-bit unsigned decimal notation of an integer,                  *
    189  *  - %x : 32-bit unsigned hexadecimal notation of an integer,              *
    190  *  - %l : 64-bit unsigned hexadecimal notation of an integer,              *
    191  *  - %c : character,                                                       *
    192  *  - %s : NUL terminated string.                                           *
     182 * This function produces output, according to the 'format' format, to the
     183 * boot TTY terminal.
     184 * @ format : the string defining the format of the output. It is composed
     185 *            of 0 or more directives:                                 
     186 *            - ordinary characters (not %), which are copied unchanged to
     187 *              the boot TTY terminal.                                 
     188 *            - conversion specifications (introduced by the character %,
     189 *              ended by a conversion specifier), each of which results in
     190 *              fetching 0 or more subsequent arguments. The arguments must
     191 *              correspond properly (after type promotion) with the 
     192 *              conversion specifier.                           
     193 *                                                           
     194 * Conversion specifiers:                                 
     195 *  - %d : 32-bit signed decimal notation of an integer, 
     196 *  - %u : 32-bit unsigned decimal notation of an integer,
     197 *  - %x : 32-bit unsigned hexadecimal notation of an integer,
     198 *  - %l : 64-bit unsigned hexadecimal notation of an integer,
     199 *  - %c : character,                                     
     200 *  - %s : NUL terminated string. 
    193201 ****************************************************************************/
    194202void boot_printf(char* format, ...);
     
    199207
    200208/****************************************************************************
    201  * This function causes a termination during the boot procedure once the    *
    202  * boot code detects an error.                                              *
     209 * This function causes a termination during the boot procedure once the
     210 * boot code detects an error.
    203211 ****************************************************************************/
    204212void boot_exit() __attribute__((noreturn));
    205213
    206214/****************************************************************************
    207  * This function returns the cycle count stored in the CP0_COUNT register   *
    208  * of the currently running processor.                                      *
    209  *                                                                          *
    210  * @ returns the processor cycle count.                                     *
    211  ****************************************************************************/
    212 unsigned int boot_get_proctime();
    213 
    214 /****************************************************************************
    215  * This function returns the global hardware identifier gid stored in the   *
    216  * CP0_PROCID register of the currently running processor.                  *
    217  *                                                                          *
    218  * @ returns the processor gid.                                             *
    219  ****************************************************************************/
    220 unsigned int boot_get_procid();
    221 
    222 /****************************************************************************
    223  * This structure defines a toggling barrier, that can be used to           *
    224  * synchronize a group of cores, whether or not they are in a same cluster, *
    225  * without any specific initialization.                                     *
    226  ****************************************************************************/
    227 typedef struct boot_barrier_s
     215 * This function returns the cycle count stored in the CP0_COUNT register
     216 * of the currently running processor. 
     217 * @ returns the processor cycle count.
     218 ****************************************************************************/
     219uint32_t boot_get_proctime();
     220
     221/****************************************************************************
     222 * This function returns the global hardware identifier gid stored in the
     223 * CP0_PROCID register of the currently running processor.
     224 * @ returns the processor gid
     225 ****************************************************************************/
     226uint32_t boot_get_procid();
     227
     228/****************************************************************************
     229 * This structure defines a toggling barrier, that can be used to 
     230 * synchronize a group of cores, whether or not they are in a same cluster,
     231 * without any specific initialization.   
     232 ****************************************************************************/
     233typedef struct boot_remote_barrier_s
    228234{
    229235    uint32_t current;                      // Number of arrived cores
     
    231237    uint32_t pad[(CACHE_LINE_SIZE>>2)-2];  // Padding
    232238}
    233 boot_barrier_t;
    234 
    235 /****************************************************************************
    236  * This function blocks all processors arriving at the barrier pointed to   *
    237  * by the extend pointer 'xp_barrier' and only returns when all 'count'     *
    238  * expected processors reach the barrier.                                   *
    239  * @ xp_barrier : extended pointer to a toggling barrier.                   *
    240  * @ count      : number of expected processors.                            *
    241  ****************************************************************************/
    242 void boot_barrier( xptr_t   xp_barrier,
    243                    uint32_t count );
     239boot_remote_barrier_t;
     240
     241/****************************************************************************
     242 * This function blocks all processors arriving at the barrier pointed to
     243 * by the extend pointer 'xp_barrier' and only returns when all 'count'
     244 * expected processors reach the barrier. 
     245 * @ xp_barrier : extended pointer to a toggling barrier.
     246 * @ count      : number of expected processors. 
     247 ****************************************************************************/
     248void boot_remote_barrier( xptr_t   xp_barrier,
     249                          uint32_t count );
     250
     251/****************************************************************************
     252 * This structure defines a remote queuing spinlock, that can be used to
     253 * synchronize a group of cores, whether or not they are in a same cluster,
     254 * without any specific initialization. 
     255 ****************************************************************************/
     256typedef struct boot_remote_spinlock_s
     257{
     258    uint32_t     ticket;                       // next free ticket index       
     259    uint32_t     current;                      // current owner index
     260    uint32_t     pad[(CACHE_LINE_SIZE>>2)-2];  // Padding
     261}
     262boot_remote_spinlock_t;
     263
     264/****************************************************************************
     265 * This blocking function returns only when the lock is successfully taken.
     266 * @ lock_xp    : extended pointer on lock.
     267 ****************************************************************************/
     268void boot_remote_lock( xptr_t  lock_xp );
     269
     270/****************************************************************************
     271 * This function release the lock.
     272 * @ lock_xp    : extended pointer on lock.
     273 ****************************************************************************/
     274void boot_remote_unlock( xptr_t  lock_xp );
    244275
    245276
Note: See TracChangeset for help on using the changeset viewer.