Index: sys/boot/uboot/common/main.c =================================================================== --- sys/boot/uboot/common/main.c +++ sys/boot/uboot/common/main.c @@ -387,7 +387,7 @@ } int -main(void) +main(int argc, char **argv) { struct api_signature *sig = NULL; int load_type, load_unit, load_slice, load_partition; @@ -395,12 +395,15 @@ const char *ldev; /* + * We first check if a command line argument was passed to us containing + * API's signature address. If it wasn't then we try to search for the + * API signature via the usual hinted address. * If we can't find the magic signature and related info, exit with a * unique error code that U-Boot reports as "## Application terminated, * rc = 0xnnbadab1". Hopefully 'badab1' looks enough like "bad api" to * provide a clue. It's better than 0xffffffff anyway. */ - if (!api_search_sig(&sig)) + if (!api_parse_cmdline_sig(argc, argv, &sig) && !api_search_sig(&sig)) return (0x01badab1); syscall_ptr = sig->syscall; Index: sys/boot/uboot/lib/glue.h =================================================================== --- sys/boot/uboot/lib/glue.h +++ sys/boot/uboot/lib/glue.h @@ -58,6 +58,7 @@ int syscall(int, int *, ...); void *syscall_ptr; +int api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig); int api_search_sig(struct api_signature **sig); #define UB_MAX_MR 16 /* max mem regions number */ Index: sys/boot/uboot/lib/glue.c =================================================================== --- sys/boot/uboot/lib/glue.c +++ sys/boot/uboot/lib/glue.c @@ -68,6 +68,41 @@ } /* + * Checks to see if API signature's address was given to us as a command line + * argument by U-Boot. + * + * returns 1/0 depending on found/not found result + */ +int +api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig) +{ + unsigned long api_address; + int c; + + api_address = 0; + opterr = 0; + optreset = 1; + optind = 1; + + while ((c = getopt (argc, argv, "a:")) != -1) + switch (c) { + case 'a': + api_address = strtoul(optarg, NULL, 16); + break; + default: + break; + } + + if (api_address != 0) { + *sig = (struct api_signature *)api_address; + if (valid_sig(*sig)) + return (1); + } + + return (0); +} + +/* * Searches for the U-Boot API signature * * returns 1/0 depending on found/not found result