| 1 | /*************************************************************** |
|---|
| 2 | ** |
|---|
| 3 | ** Broadcom Corp. Confidential |
|---|
| 4 | ** Copyright 2007 Broadcom Corp. All Rights Reserved. |
|---|
| 5 | ** |
|---|
| 6 | ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED |
|---|
| 7 | ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. |
|---|
| 8 | ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT |
|---|
| 9 | ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 10 | ** |
|---|
| 11 | ** File: fstore.h |
|---|
| 12 | ** Description: Flash storage |
|---|
| 13 | ** Created: Wed Mar 21 13:31:21 PDT 2007 - Jeffrey P. Fisher |
|---|
| 14 | ** |
|---|
| 15 | ****************************************************************/ |
|---|
| 16 | #ifndef __FSTORE_H__ |
|---|
| 17 | #define __FSTORE_H__ |
|---|
| 18 | |
|---|
| 19 | #include "bapp_types.h" |
|---|
| 20 | |
|---|
| 21 | /* |
|---|
| 22 | * Data types Flash memory map determined internaly based on |
|---|
| 23 | * strapping options and data type enum. |
|---|
| 24 | */ |
|---|
| 25 | typedef enum fstore_data_type_t |
|---|
| 26 | { |
|---|
| 27 | eFS_BOOT_PATCH, /* Boot code patch */ |
|---|
| 28 | eFS_INIT_PATCH, /* Initialization code patch */ |
|---|
| 29 | eFS_APP_DATA, /* Application data */ |
|---|
| 30 | eFS_MAX_DATA_TYPE, /* Max number of data types */ |
|---|
| 31 | }fstore_data_type_t; |
|---|
| 32 | |
|---|
| 33 | /* |
|---|
| 34 | * control structure, enables fstore API to multiple flash devices |
|---|
| 35 | */ |
|---|
| 36 | typedef struct fstore_t |
|---|
| 37 | { |
|---|
| 38 | unsigned int read_base; /* Read base address of device (read/write base to support BSPI on 3543 */ |
|---|
| 39 | unsigned int write_base; /* Write base address of device */ |
|---|
| 40 | unsigned int offset[eFS_MAX_DATA_TYPE]; /* offset from base */ |
|---|
| 41 | unsigned int sector_size; /* Sector size in bytes */ |
|---|
| 42 | unsigned int block_size; /* Block size in bytes */ |
|---|
| 43 | unsigned int max_size; /* Block size in bytes */ |
|---|
| 44 | bresult (*read)(void *p_fs, unsigned int offset, unsigned char *data, unsigned int size); |
|---|
| 45 | bresult (*erase)(void *p_fs, unsigned int offset, unsigned int size); |
|---|
| 46 | bresult (*program)(void *p_fs, unsigned int offset,void *buffer, unsigned int size); |
|---|
| 47 | }fstore_t; |
|---|
| 48 | |
|---|
| 49 | #ifdef __cplusplus |
|---|
| 50 | extern "C" { |
|---|
| 51 | #endif |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | /* |
|---|
| 55 | Summary: |
|---|
| 56 | Detect the flash type and initialze the fstore structure. |
|---|
| 57 | */ |
|---|
| 58 | bresult fstore_init(fstore_t *p_fs); |
|---|
| 59 | |
|---|
| 60 | /* |
|---|
| 61 | Summary: |
|---|
| 62 | Update flash at the specified offset. Length is in bytes |
|---|
| 63 | */ |
|---|
| 64 | bresult fstore_update(fstore_t *p_fs, |
|---|
| 65 | fstore_data_type_t type, |
|---|
| 66 | void *data, |
|---|
| 67 | unsigned int length); |
|---|
| 68 | /* |
|---|
| 69 | Summary: |
|---|
| 70 | Get the stored data for type. Returns b_ok on success. |
|---|
| 71 | */ |
|---|
| 72 | bresult fstore_get(fstore_t *p_fs, |
|---|
| 73 | fstore_data_type_t type, |
|---|
| 74 | void **data, |
|---|
| 75 | unsigned int *length); |
|---|
| 76 | |
|---|
| 77 | /* |
|---|
| 78 | Summary: |
|---|
| 79 | Perform a test to validate the fstore module. |
|---|
| 80 | */ |
|---|
| 81 | #ifdef BCM_FSTORE_TEST |
|---|
| 82 | bresult fstore_test(fstore_t *p_fs,int reserved); |
|---|
| 83 | #endif |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | #ifdef __cplusplus |
|---|
| 87 | } |
|---|
| 88 | #endif |
|---|
| 89 | |
|---|
| 90 | #endif /* __FSTORE_H__ */ |
|---|
| 91 | |
|---|