mss_comblk_page_handler.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*******************************************************************************
  2. * (c) Copyright 2012-2016 Microsemi SoC Products Group. All rights reserved.
  3. *
  4. * SmartFusion2 MSS COM block driver, page handler callback function prototype.
  5. *
  6. * SVN $Revision: 8345 $
  7. * SVN $Date: 2016-03-23 11:53:04 +0530 (Wed, 23 Mar 2016) $
  8. */
  9. #ifndef __MSS_COMBLK_PAGE_HANDLER_H_
  10. #define __MSS_COMBLK_PAGE_HANDLER_H_ 1
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /*-------------------------------------------------------------------------*//**
  15. The comblk_page_handler_t typedef specifies the function prototype of a COMBLK
  16. page handler callback function. This callback is used by the system services
  17. and COMBLK drivers as part of in-system programming (ISP) to retrieve the next
  18. page of programming information to send to the SmartFusion2 System Controller
  19. via the COMBLK.
  20. The COMBLK page handler must be implemented by the application layer to return
  21. the address of the next page of programming data to be sent to the
  22. SmartFusion2 system controller. It must return the number of bytes contained
  23. in the next page. Returning a value of zero indicates that all programming
  24. data has been passed to the system services/COMBLK drivers.
  25. @code
  26. #define PAGE_LENGTH 512
  27. uint8_t programming_data[PROG_DATA_LENGTH];
  28. uint32_t prog_data_index = 0;
  29. uint32_t page_read_handler
  30. (
  31. uint8_t const ** pp_next_page
  32. )
  33. {
  34. uint32_t returned_page_length;
  35. uint32_t remaining_length;
  36. *pp_next_page = &programming_data[prog_data_index];
  37. remaining_length = PROG_DATA_LENGTH - prog_data_index
  38. if(remaining_length > PAGE_LENGTH)
  39. {
  40. returned_page_length = PAGE_LENGTH;
  41. }
  42. else
  43. {
  44. returned_page_length = remaining_length;
  45. prog_data_index = PROG_DATA_LENGTH;
  46. }
  47. return returned_page_length;
  48. }
  49. @endcode
  50. */
  51. typedef uint32_t (*comblk_page_handler_t)(uint8_t const ** pp_next_page);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* __MSS_COMBLK_PAGE_HANDLER_H_ */