Simple interface for Mbed Cloud Client

Dependents:  

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_uc_pal_blockdevice_platform.h Source File

arm_uc_pal_blockdevice_platform.h

00001 //----------------------------------------------------------------------------
00002 //   The confidential and proprietary information contained in this file may
00003 //   only be used by a person authorised under and to the extent permitted
00004 //   by a subsisting licensing agreement from ARM Limited or its affiliates.
00005 //
00006 //          (C) COPYRIGHT 2017 ARM Limited or its affiliates.
00007 //              ALL RIGHTS RESERVED
00008 //
00009 //   This entire notice must be reproduced on all copies of this file
00010 //   and copies of this file may only be made by a person if such person is
00011 //   permitted to do so under the terms of a subsisting license agreement
00012 //   from ARM Limited or its affiliates.
00013 //----------------------------------------------------------------------------
00014 
00015 #ifndef ARM_UC_PAL_BLOCKDEVICE_PLATFORM_H
00016 #define ARM_UC_PAL_BLOCKDEVICE_PLATFORM_H
00017 
00018 #include <stdint.h>
00019 
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif
00023 
00024 enum {
00025     ARM_UC_BLOCKDEVICE_SUCCESS = 0,
00026     ARM_UC_BLOCKDEVICE_FAIL    = -1
00027 };
00028 
00029 /** Initialize a block device
00030  *
00031  *  @return         0 on success or a negative error code on failure
00032  */
00033 int32_t arm_uc_blockdevice_init(void);
00034 
00035 /** Erase blocks on a block device
00036  *
00037  *  The state of an erased block is undefined until it has been programmed
00038  *
00039  *  @param address  Address of block to begin erasing
00040  *  @param size     Size to erase in bytes, must be a multiple of erase block size
00041  *  @return         0 on success, negative error code on failure
00042  */
00043 int32_t arm_uc_blockdevice_erase(uint64_t address, uint64_t size);
00044 
00045 /** Program blocks to a block device
00046  *
00047  *  The blocks must have been erased prior to being programmed
00048  *
00049  *  If a failure occurs, it is not possible to determine how many bytes succeeded
00050  *
00051  *  @param buffer   Buffer of data to write to blocks
00052  *  @param address  Address of block to begin writing to
00053  *  @param size     Size to write in bytes, must be a multiple of program block size
00054  *  @return         0 on success, negative error code on failure
00055  */
00056 int32_t arm_uc_blockdevice_program(const uint8_t* buffer,
00057                                    uint64_t address,
00058                                    uint32_t size);
00059 
00060 /** Read blocks from a block device
00061  *
00062  *  If a failure occurs, it is not possible to determine how many bytes succeeded
00063  *
00064  *  @param buffer   Buffer to write blocks to
00065  *  @param address  Address of block to begin reading from
00066  *  @param size     Size to read in bytes, must be a multiple of read block size
00067  *  @return         0 on success, negative error code on failure
00068  */
00069 int32_t arm_uc_blockdevice_read(uint8_t* buffer,
00070                                 uint64_t address,
00071                                 uint32_t size);
00072 
00073 /** Get the size of a programable block
00074  *
00075  *  @return         Size of a programable block in bytes
00076  *  @note Must be a multiple of the read size
00077  */
00078 uint32_t arm_uc_blockdevice_get_program_size(void);
00079 
00080 /** Get the size of a eraseable block
00081  *
00082  *  @return         Size of a eraseable block in bytes
00083  *  @note Must be a multiple of the program size
00084  */
00085 uint32_t arm_uc_blockdevice_get_erase_size(void);
00086 
00087 #ifdef __cplusplus
00088 }
00089 #endif
00090 
00091 #endif /* ARM_UC_PAL_BLOCKDEVICE_PLATFORM_H */