rkcommon.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * (C) Copyright 2015 Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _RKCOMMON_H
  8. #define _RKCOMMON_H
  9. enum {
  10. RK_BLK_SIZE = 512,
  11. RK_INIT_OFFSET = 4,
  12. RK_MAX_BOOT_SIZE = 512 << 10,
  13. RK_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
  14. RK_SPL_HDR_SIZE = 4,
  15. RK_SPL_START = RK_SPL_HDR_START + RK_SPL_HDR_SIZE,
  16. RK_IMAGE_HEADER_LEN = RK_SPL_START,
  17. };
  18. /**
  19. * rkcommon_check_params() - check params
  20. *
  21. * @return 0 if OK, -1 if ERROR.
  22. */
  23. int rkcommon_check_params(struct image_tool_params *params);
  24. /**
  25. * rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image
  26. *
  27. * Rockchip's bootrom requires the spl loader to start with a 4-bytes
  28. * header. The content of this header depends on the chip type.
  29. */
  30. const char *rkcommon_get_spl_hdr(struct image_tool_params *params);
  31. /**
  32. * rkcommon_get_spl_size() - get spl size for a Rockchip boot image
  33. *
  34. * Different chip may have different sram size. And if we want to jump
  35. * back to the bootrom after spl, we may need to reserve some sram space
  36. * for the bootrom.
  37. * The spl loader size should be sram size minus reserved size(if needed)
  38. */
  39. int rkcommon_get_spl_size(struct image_tool_params *params);
  40. /**
  41. * rkcommon_set_header() - set up the header for a Rockchip boot image
  42. *
  43. * This sets up a 2KB header which can be interpreted by the Rockchip boot ROM.
  44. *
  45. * @buf: Pointer to header place (must be at least 2KB in size)
  46. * @file_size: Size of the file we want the boot ROM to load, in bytes
  47. * @return 0 if OK, -ENOSPC if too large
  48. */
  49. int rkcommon_set_header(void *buf, uint file_size,
  50. struct image_tool_params *params);
  51. #endif