openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

dffs_low.h (9704B)


      1 /* 
      2  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3  * 
      4  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      5 */
      6 
      7 
      8 #ifndef __DFFS_LOW_H_INCLUDED__
      9 /* { */
     10 #define __DFFS_LOW_H_INCLUDED__
     11 
     12 #ifdef  __cplusplus
     13 extern "C" {
     14 #endif
     15 
     16 /*************
     17  * INCLUDES  *
     18  */
     19 /* { */
     20 
     21 #ifdef SAND_LOW_LEVEL_SIMULATION
     22   #include <sim/dpp/ChipSim/chip_sim_flash.h>
     23 #else
     24   #include "bsp_drv_flash28f_dev.h"
     25 #endif /* SAND_LOW_LEVEL_SIMULATION */
     26 
     27 /* } */
     28 
     29 /*************
     30  * DEFINES   *
     31  */
     32 /* { */
     33 #define DFFS_LOW_CRC16_SIZE sizeof(unsigned short)
     34 #define DFFS_LOW_CRC32_SIZE sizeof(unsigned long)
     35 
     36 /* } */
     37 
     38 /*************
     39  *  MACROS   *
     40  */
     41 /* { */
     42 
     43 /* non-zero if the specified bit in the bitmap is on */
     44 #define DFFS_LOW_BIT_IS_ON(_dffsl_bitmap, _dffsl_bit_idx) \
     45   (_dffsl_bitmap & SOC_SAND_BIT(_dffsl_bit_idx))
     46 
     47 /* } */
     48 
     49 /*************
     50  * TYPE DEFS *
     51  */
     52 /* { */
     53 typedef struct
     54 {
     55   unsigned char        dev_code;
     56   unsigned char        descriptor_sector;
     57   unsigned char        first_data_sector;
     58   unsigned char        last_data_sector;
     59   unsigned long        sector_size;
     60   unsigned int         use_bsp_driver;     /* if 1 use BSP driver (see bsp_drv_flash28f_dev.h).
     61                                               Else, use boot driver (see flash_dev.h) */
     62   FLASH_DEF_INF        flash_def_inf;      /* if use_bsp_driver==0, this descriptor is used */
     63   BSP_FLASH28F_DEF_INF bsp_flash_def_inf;  /* if use_bsp_driver==1, this descriptor is used */
     64 }DFFS_LOW_FLASH_INFO_TYPE;
     65 
     66 /* } */
     67 
     68 /*************
     69  * GLOBALS   *
     70  */
     71 /* { */
     72 
     73 /* } */
     74 
     75 /*************
     76  * FUNCTIONS *
     77  */
     78 /* { */
     79 
     80 /*****************************************************
     81 *NAME
     82 * dffs_low_get_flash_info
     83 *TYPE:
     84 *  PROC
     85 *DATE:
     86 *  27/06/2006
     87 *FUNCTION:
     88 *  get information on the flash in use
     89 *INPUT:
     90 *  SOC_SAND_DIRECT:
     91 *    DFFS_LOW_FLASH_INFO_TYPE* flash_info -
     92 *     flash information
     93 *  SOC_SAND_INDIRECT:
     94 *    None.
     95 *OUTPUT:
     96 *  SOC_SAND_DIRECT:
     97 *    error indication
     98 *  SOC_SAND_INDIRECT:
     99 *    flash_info.
    100 *REMARKS:
    101 *    None.
    102 *SEE ALSO:
    103  */
    104 unsigned int
    105   dffs_low_get_flash_info(
    106     DFFS_LOW_FLASH_INFO_TYPE* flash_info
    107   );
    108 
    109 /*****************************************************
    110 *NAME
    111 *  dffs_low_is_flash_invalid
    112 *TYPE:
    113 *  PROC
    114 *DATE:
    115 *  27/06/2006
    116 *FUNCTION:
    117 *  Checks if the flash is invalid for the DFFS
    118 *INPUT:
    119 *  SOC_SAND_DIRECT:
    120 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information
    121 *  SOC_SAND_INDIRECT:
    122 *    None.
    123 *OUTPUT:
    124 *  SOC_SAND_DIRECT:
    125 *    error indication - error means the flash is invalid for DFFS
    126 *  SOC_SAND_INDIRECT:
    127 *    None.
    128 *REMARKS:
    129 *    None.
    130 *SEE ALSO:
    131  */
    132 unsigned int
    133   dffs_low_is_flash_invalid(
    134     const DFFS_LOW_FLASH_INFO_TYPE *flash_info
    135   );
    136 
    137 /*****************************************************
    138 *NAME
    139 *  dffs_low_read_descriptor
    140 *TYPE:
    141 *  PROC
    142 *DATE:
    143 *  27/06/2006
    144 *FUNCTION:
    145 *  Read a dffs descriptor to in-memory buffer.
    146 *INPUT:
    147 *  SOC_SAND_DIRECT:
    148 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    149 *    char* in_mem_buff - in-memory buffer.
    150 *    unsigned char silent - if TRUE, printing is suppressed.
    151 *  SOC_SAND_INDIRECT:
    152 *    None.
    153 *OUTPUT:
    154 *  SOC_SAND_DIRECT:
    155 *    error indication
    156 *  SOC_SAND_INDIRECT:
    157 *    None.
    158 *REMARKS:
    159 *    None.
    160 *SEE ALSO:
    161  */
    162 unsigned int
    163   dffs_low_read_descriptor(
    164     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    165     char* in_mem_buff,
    166     unsigned char silent
    167   );
    168 
    169 /*****************************************************
    170 *NAME
    171 *  dffs_low_write_descriptor
    172 *TYPE:
    173 *  PROC
    174 *DATE:
    175 *  27/06/2006
    176 *FUNCTION:
    177 *  Write a dffs descriptor to flash from in-memory buffer.
    178 *INPUT:
    179 *  SOC_SAND_DIRECT:
    180 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    181 *    char* in_mem_buff - in-memory buffer.
    182 *    unsigned char silent - if TRUE, printing is suppressed.
    183 *  SOC_SAND_INDIRECT:
    184 *    None.
    185 *OUTPUT:
    186 *  SOC_SAND_DIRECT:
    187 *    error indication
    188 *  SOC_SAND_INDIRECT:
    189 *    None.
    190 *REMARKS:
    191 *    None.
    192 *SEE ALSO:
    193  */
    194 unsigned int
    195   dffs_low_write_descriptor(
    196     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    197     char* in_mem_buff,
    198     unsigned char silent
    199   );
    200 
    201 /*****************************************************
    202 *NAME
    203 *  dffs_low_read_file
    204 *TYPE:
    205 *  PROC
    206 *DATE:
    207 *  27/06/2006
    208 *FUNCTION:
    209 *  Read a file from flash to in-memory buffer, based on the supplied bitmap.
    210 *INPUT:
    211 *  SOC_SAND_DIRECT:
    212 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    213 *    char* file_buff - the in-memory buffer.
    214 *    unsigned long sectors_bitmap - if bit i is on, the appropriate sector has
    215 *                                   to be read.
    216 *    unsigned long file_size - the size of the file to read.
    217 *    unsigned int* crc_err_encountered - if TRUE, crc error accured
    218 *                   while reading file from flash
    219 *    unsigned char silent - if TRUE, printing is suppressed.
    220 *  SOC_SAND_INDIRECT:
    221 *    None.
    222 *OUTPUT:
    223 *  SOC_SAND_DIRECT:
    224 *    error indication
    225 *  SOC_SAND_INDIRECT:
    226 *    file_buff.
    227 *REMARKS:
    228 *    If the bitmap doesn't have enough 'on' bits to cover the requested size,
    229 *     an error is initiated.
    230 *SEE ALSO:
    231  */
    232 unsigned int
    233   dffs_low_read_file(
    234     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    235     char* file_buff,
    236     unsigned long sectors_bitmap,
    237     unsigned long file_size,
    238     unsigned int* crc_err_encountered,
    239     unsigned char silent
    240   );
    241 /*****************************************************
    242 *NAME
    243 *  dffs_low_write_file
    244 *TYPE:
    245 *  PROC
    246 *DATE:
    247 *  27/06/2006
    248 *FUNCTION:
    249 *  Write a file from in-memory buffer to flash, based on the supplied bitmap.
    250 *INPUT:
    251 *  SOC_SAND_DIRECT:
    252 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    253 *    char* file_buff - the in-memory buffer.
    254 *    unsigned long sectors_bitmap - if bit i is on, the appropriate sector has
    255 *                                   to be written.
    256 *    unsigned long file_size - the size of the file to write.
    257 *    unsigned char silent - if TRUE, printing is suppressed.
    258 *  SOC_SAND_INDIRECT:
    259 *    None.
    260 *OUTPUT:
    261 *  SOC_SAND_DIRECT:
    262 *    error indication
    263 *  SOC_SAND_INDIRECT:
    264 *    file_buff.
    265 *REMARKS:
    266 *    If the bitmap doesn't have enough 'on' bits to cover the requested size,
    267 *     an error is initiated.
    268 *SEE ALSO:
    269  */
    270 unsigned int
    271   dffs_low_write_file(
    272     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    273     char* file_buff,
    274     unsigned long sectors_bitmap,
    275     unsigned long file_size,
    276     unsigned char silent
    277   );
    278 
    279 /*****************************************************
    280 *NAME
    281 *  dffs_low_erase_file
    282 *TYPE:
    283 *  PROC
    284 *DATE:
    285 *  27/06/2006
    286 *FUNCTION:
    287 *  Erase a file on flash, based on the supplied bitmap.
    288 *INPUT:
    289 *  SOC_SAND_DIRECT:
    290 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    291 *    unsigned long sectors_bitmap - if bit i is on, the appropriate sector has
    292 *                                   to be erased.
    293 *    unsigned long file_size - the size of the file to erase.
    294 *    unsigned char silent - if TRUE, printing is suppressed.
    295 *  SOC_SAND_INDIRECT:
    296 *    None.
    297 *OUTPUT:
    298 *  SOC_SAND_DIRECT:
    299 *    error indication
    300 *  SOC_SAND_INDIRECT:
    301 *    file_buff.
    302 *REMARKS:
    303 *    If the bitmap doesn't have enough 'on' bits to cover the requested size,
    304 *     an error is initiated.
    305 *SEE ALSO:
    306  */
    307 unsigned int
    308   dffs_low_erase_file(
    309     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    310     unsigned long sectors_bitmap,
    311     unsigned long file_size,
    312     unsigned char silent
    313   );
    314 
    315 /*****************************************************
    316 *NAME
    317 *  dffs_low_clear_dffs
    318 *TYPE:
    319 *  PROC
    320 *DATE:
    321 *  27/06/2006
    322 *FUNCTION:
    323 *  Erase the bits on flash dedicated to DFFS descriptor.
    324 *INPUT:
    325 *  SOC_SAND_DIRECT:
    326 *    DFFS_LOW_FLASH_INFO_TYPE* flash_info - flash information
    327 *    unsigned char silent - if TRUE, printing is suppressed.
    328 *  SOC_SAND_INDIRECT:
    329 *    None.
    330 *OUTPUT:
    331 *  SOC_SAND_DIRECT:
    332 *    error indication
    333 *  SOC_SAND_INDIRECT:
    334 *    None.
    335 *REMARKS:
    336 *    None.
    337 *SEE ALSO:
    338  */
    339 unsigned int
    340   dffs_low_clear_dffs(
    341     DFFS_LOW_FLASH_INFO_TYPE* flash_info,
    342     unsigned char silent
    343   );
    344 
    345 /*****************************************************
    346 *NAME
    347 *  dffs_low_write_sector
    348 *TYPE:
    349 *  PROC
    350 *DATE:
    351 *  27/06/2006
    352 *FUNCTION:
    353 *  Writes the specified sector from in-memory buffer flash.
    354 *INPUT:
    355 *  SOC_SAND_DIRECT:
    356 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    357 *    char* buff - input buffer containing the information.
    358 *    unsigned int len - nof bytes to write.
    359 *    unsigned int sector_idx - the index of the sector to write
    360 *                               (0 means flash base address)
    361 *  SOC_SAND_INDIRECT:
    362 *    None.
    363 *OUTPUT:
    364 *  SOC_SAND_DIRECT:
    365 *    error indication
    366 *  SOC_SAND_INDIRECT:
    367 *    None.
    368 *REMARKS:
    369 *    None.
    370 *SEE ALSO:
    371  */
    372 unsigned int
    373   dffs_low_write_sector(
    374     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    375     char* buff,
    376     unsigned int len,
    377     unsigned int sector_idx
    378   );
    379 
    380 /*****************************************************
    381 *NAME
    382 *  dffs_low_read_sector
    383 *TYPE:
    384 *  PROC
    385 *DATE:
    386 *  27/06/2006
    387 *FUNCTION:
    388 *  Reads the specified sector from flash to in-memory buffer.
    389 *INPUT:
    390 *  SOC_SAND_DIRECT:
    391 *    const DFFS_LOW_FLASH_INFO_TYPE *flash_info - flash information.
    392 *    char* buff - where to write the information.
    393 *    unsigned int len - nof bytes to read from the sector to buff.
    394 *    unsigned int sector_idx - the index of the sector to read
    395 *                               (0 means flash base address)
    396 *  SOC_SAND_INDIRECT:
    397 *    None.
    398 *OUTPUT:
    399 *  SOC_SAND_DIRECT:
    400 *    error indication
    401 *  SOC_SAND_INDIRECT:
    402 *    buff.
    403 *REMARKS:
    404 *    None.
    405 *SEE ALSO:
    406  */
    407 unsigned int
    408   dffs_low_read_sector(
    409     const DFFS_LOW_FLASH_INFO_TYPE *flash_info,
    410     char* buff,
    411     unsigned int len,
    412     unsigned int sector_idx
    413   );
    414 /* } */
    415 
    416 #ifdef  __cplusplus
    417 }
    418 #endif
    419 
    420 /* } __DFFS_LOW_H_INCLUDED__*/
    421 #endif