PAL A Platform Abstraction Layer connects the mbed-client with the underlying platform.

- Main Page
- Data Structures
- Files

- File List
- Globals

Functions
pal_update.c File Reference
`#include "pal_plat_update.h"`
`#include "pal_update.h"`
`#include "pal_macros.h"`

## Functions
palStatus_t | pal_imageInitAPI (palImageSignalEvent_t CBfunction)
palStatus_t | pal_imageDeInit (void)
palStatus_t | pal_imagePrepare (palImageId_t imageId, palImageHeaderDeails_t *headerDetails)
palStatus_t | pal_imageWrite (palImageId_t imageId, size_t offset, palConstBuffer_t *chunk)
palStatus_t | pal_imageFinalize (palImageId_t imageId)
palStatus_t | pal_imageGetDirectMemoryAccess (palImageId_t imageId, void **imagePtr, size_t *imageSizeInBytes)
palStatus_t | pal_imageReadToBuffer (palImageId_t imageId, size_t offset, palBuffer_t *chunk)
palStatus_t | pal_imageActivate (palImageId_t imageId)
palStatus_t | pal_imageGetActiveHash (palBuffer_t *hash)
palStatus_t | pal_imageGetActiveVersion (palBuffer_t *version)
palStatus_t | pal_imageWriteDataToMemory (palImagePlatformData_t dataId, const palConstBuffer_t *const dataBuffer)

## Function Documentation

palStatus_t pal_imageActivate | ( | palImageId_t | imageId | ) |

Sets image imageId to be the active image (after device reset). the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | imageId | the image id

palStatus_t pal_imageDeInit | ( | void |  | ) |

clearing all the resources used by the pal_update APIs

Returns
  the function returns the status in the form of palStatus_t which will be PAL_SUCCESS(0) in case of success and another negative value indicating a specific error code in case of failure

palStatus_t pal_imageFinalize | ( | palImageId_t | imageId | ) |

Flushes the image data and sets the version of imageId to imageVersion. the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | imageId | the image id
  [in] | imageVersion | a struct containing the version as a buffer and the size

Returns
  the function returns the status in the form of palStatus_t which will be PAL_SUCCESS(0) in case of success and another negative value indicating a specific error code in case of failure

palStatus_t pal_imageGetActiveHash | ( | palBuffer_t * | hash | ) |

Retrieve the hash value of the active image to hash buffer with max size hash maxBufferLength and sets to hash bufferLength to the hash size. the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [out] | hash | struct containing the hash and actual size of hash read

palStatus_t pal_imageGetActiveVersion | ( | palBuffer_t * | version | ) |

Retrieve the version of the active image to version buffer with size set to version bufferLength. the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [out] | version | struct containing the version and actual size of version read

palStatus_t pal_imageGetDirectMemoryAccess | ( | palImageId_t | imageId,
|  | void ** | imagePtr,
|  | size_t * | imageSizeInBytes
| ) |  |

Verifies whether image imageId is readable and sets imagePtr to point to the beginning of start of the image in the memory and imageSizeInBytes to the image size. In case of failure sets imagePtr to NULL and returns relevant palStatus_t error

Parameters

  [in] | imageId | the image id
  [out] | imagePtr | pointer to the start of the image
  [out] | imageSizeInBytes | the size of the image

Returns
  the function returns the status in the form of palStatus_t which will be PAL_SUCCESS(0) in case of success and another negative value indicating a specific error code in case of failure

palStatus_t pal_imageInitAPI | ( | palImageSignalEvent_t | CBfunction | ) |

setting the callback function that will be called before the end of each API (except imageGetDirectMemAccess)

WARNING: please do not change this function! this function loads a call back function received from the upper layer (service). the call back should be called at the end of each function (except pal_plat_imageGetDirectMemAccess) the call back receives the event type that just happened defined by the ENUM palImageEvents_t.

if you will not call the call back at the end the service behaver will be undefined the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | CBfunction | pointer to the call back function

Returns
  the function returns the status in the form of palStatus_t which will be PAL_SUCCESS(0) in case of success and another negative value indicating a specific error code in case of failure

palStatus_t pal_imagePrepare | ( | palImageId_t | imageId,
|  | palImageHeaderDeails_t * | headerDetails
| ) |  |

Prepare to write image with id imageId and size imageSize in suitable memory region (Space availability will be verified and reserved). the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | imageId | the image id
  [in] | imageSize | the size of the image

Returns
  the function returns the status in the form of palStatus_t which will be PAL_SUCCESS(0) in case of success and another negative value indicating a specific error code in case of failure

palStatus_t pal_imageReadToBuffer | ( | palImageId_t | imageId,
|  | size_t | offset,
|  | palBuffer_t * | chunk
| ) |  |

Reads max of chunk maxBufferLength bytes from image imageId with relative offset offset and stores it in chunk buffer. And sets chunk bufferLength value to the actual number of bytes read. Note: Please use this API in case image is not directly accessible via imageGetDirectMemAccess function.

the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | imageId | the image id
  [in] | offset | offset to start read from
  [out] | chunk | struct containing the data and actual bytes read

palStatus_t pal_imageWrite | ( | palImageId_t | imageId,
|  | size_t | offset,
|  | palConstBuffer_t * | chunk
| ) |  |

Writes the data in chunk buffer with size chunk bufferLength in the location of imageId adding the relative offset. the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | imageId | the image id
  [in] | offset | the offset to write the data into
  [in] | pointer | to struct containing the data and the data length to write

Returns
  the function returns the status in the form of palStatus_t which will be PAL_SUCCESS(0) in case of success and another negative value indicating a specific error code in case of failure

palStatus_t pal_imageWriteDataToMemory | ( | palImagePlatformData_t | dataId,
|  | const palConstBuffer_t *const | dataBuffer
| ) |  |

Writing the data of dataId stored in dataBuffer to memory accessible to bootloader. Currently only has is available. the function must call g_palUpdateServiceCBfunc before after finished

Parameters

  [in] | dataId | one of the members of palImagePlatformData_t enum
  [in] | dataBuffer | struct containing the data and actual bytes to be written