]> git.sur5r.net Git - u-boot/blobdiff - tools/rkcommon.h
dtoc: Fix some minor errors
[u-boot] / tools / rkcommon.h
index 3d645168c2656ac39cbeb0580bdd479f5222f4f8..47f47a52aaf2208cca1cbf91bc1b547cd6f85af8 100644 (file)
@@ -1,8 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * (C) Copyright 2015 Google,  Inc
  * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef _RKCOMMON_H
@@ -10,6 +9,7 @@
 
 enum {
        RK_BLK_SIZE             = 512,
+       RK_INIT_SIZE_ALIGN      = 2048,
        RK_INIT_OFFSET          = 4,
        RK_MAX_BOOT_SIZE        = 512 << 10,
        RK_SPL_HDR_START        = RK_INIT_OFFSET * RK_BLK_SIZE,
@@ -33,19 +33,6 @@ int rkcommon_check_params(struct image_tool_params *params);
  */
 const char *rkcommon_get_spl_hdr(struct image_tool_params *params);
 
-/**
- * rkcommon_get_spl_hdr_padto8() - check if we need to pad to 8 bytes
- *
- * Rockchip's bootrom starts execution right after the SPL header (i.e.
- * at offset 4), but we can not reasonably align the test section of
- * an AArch64 SPL at 4 bytes (as this would break natural alignment
- * and any embedded constants might cause an alignment exception, which
- * is illegal in privileged modes).
- *
- * Padding is (for now) assumed to occur with a single AArch64 'nop'.
- */
-const bool rkcommon_get_spl_hdr_padto8(struct image_tool_params *params);
-
 /**
  * rkcommon_get_spl_size() - get spl size for a Rockchip boot image
  *
@@ -68,6 +55,25 @@ int rkcommon_get_spl_size(struct image_tool_params *params);
 int rkcommon_set_header(void *buf, uint file_size,
                        struct image_tool_params *params);
 
+/**
+ * rkcommon_verify_header() - verify the header for a Rockchip boot image
+ *
+ * @buf:       Pointer to the image file
+ * @file_size: Size of entire bootable image file (incl. all padding)
+ * @return 0 if OK
+ */
+int rkcommon_verify_header(unsigned char *buf, int size,
+                          struct image_tool_params *params);
+
+/**
+ * rkcommon_print_header() - print the header for a Rockchip boot image
+ *
+ * This prints the header, spl_name and whether this is a SD/MMC or SPI image.
+ *
+ * @buf:       Pointer to the image (can be a read-only file-mapping)
+ */
+void rkcommon_print_header(const void *buf);
+
 /**
  * rkcommon_need_rc4_spl() - check if rc4 encoded spl is required
  *
@@ -96,8 +102,14 @@ void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size);
  * @params:     Pointer to the tool params structure
  * @tparams:    Pointer tot the image type structure (for setting
  *              the header and header_size)
+ * @alignment:  Alignment (a power of two) that the image should be
+ *              padded to (e.g. 512 if we want to align with SD/MMC
+ *              blocksizes or 2048 for the SPI format)
+ *
+ * @return bytes of padding required/added (does not include the header_size)
  */
-void rkcommon_vrec_header(struct image_tool_params *params,
-                         struct image_type_params *tparams);
+int rkcommon_vrec_header(struct image_tool_params *params,
+                        struct image_type_params *tparams,
+                        unsigned int alignment);
 
 #endif