tools: moved code common to all image tools to a separated module.

In order to avoid duplicating code and keep only one point of modification,
the functions, structs and defines useful for "dumpimage" were moved from
"mkimage" to a common module called "imagetool".

This modification also weakens the coupling between image types (FIT, IMX, MXS,
and so on) and image tools (mkimage and dumpimage). Any tool may initialize the
"imagetool" through register_image_tool() function, while the image types
register themselves within an image tool using the register_image_type()
function:

                                                      +---------------+
                                               +------|   fit_image   |
 +--------------+          +-----------+       |      +---------------+
 |    mkimage   |--------> |           | <-----+
 +--------------+          |           |              +---------------+
                           | imagetool | <------------|    imximage   |
 +--------------+          |           |              +---------------+
 |  dumpimage   |--------> |           | <-----+
 +--------------+          +-----------+       |      +---------------+
                                               +------| default_image |
                                                      +---------------+

          register_image_tool()           register_image_type()

Also, the struct "mkimage_params" was renamed to "image_tool_params" to make
clear its general purpose.

Signed-off-by: Guilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Guilherme Maciel Ferreira 2013-12-01 12:43:10 -07:00 committed by Tom Rini
parent f1cc458cf3
commit f86ed6a8d5
14 changed files with 276 additions and 191 deletions

View file

@ -19,7 +19,7 @@ static void usage(void);
struct image_type_params *mkimage_tparams = NULL;
/* parameters initialized by core will be used by the image type code */
struct mkimage_params params = {
struct image_tool_params params = {
.os = IH_OS_LINUX,
.arch = IH_ARCH_PPC,
.type = IH_TYPE_KERNEL,
@ -139,24 +139,8 @@ main (int argc, char **argv)
struct image_type_params *tparams = NULL;
int pad_len = 0;
/* Init Freescale PBL Boot image generation/list support */
init_pbl_image_type();
/* Init Kirkwood Boot image generation/list support */
init_kwb_image_type ();
/* Init Freescale imx Boot image generation/list support */
init_imx_image_type ();
/* Init Freescale mxs Boot image generation/list support */
init_mxs_image_type();
/* Init FIT image generation/list support */
init_fit_image_type ();
/* Init TI OMAP Boot image generation/list support */
init_omap_image_type();
/* Init Default image generation/list support */
init_default_image_type ();
/* Init Davinci UBL support */
init_ubl_image_type();
/* Init Davinci AIS support */
init_ais_image_type();
/* Init all image generation/list support */
register_image_tool(mkimage_register);
params.cmdname = *argv;
params.addr = params.ep = 0;