1 // SPDX-License-Identifier: GPL-2.0+
3 * Image code used by boards (and not host tools)
5 * (C) Copyright 2008 Semihalf
7 * (C) Copyright 2000-2006
12 #include <bootstage.h>
20 #include <asm/cache.h>
21 #include <asm/global_data.h>
23 #ifndef CONFIG_SYS_BARGSIZE
24 #define CONFIG_SYS_BARGSIZE 512
27 DECLARE_GLOBAL_DATA_PTR;
29 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
31 * image_get_ramdisk - get and verify ramdisk image
32 * @rd_addr: ramdisk image start address
33 * @arch: expected ramdisk architecture
34 * @verify: checksum verification flag
36 * image_get_ramdisk() returns a pointer to the verified ramdisk image
37 * header. Routine receives image start address and expected architecture
38 * flag. Verification done covers data and header integrity and os/type/arch
42 * pointer to a ramdisk image header, if image was found and valid
43 * otherwise, return NULL
45 static const image_header_t *image_get_ramdisk(ulong rd_addr, u8 arch,
48 const image_header_t *rd_hdr = (const image_header_t *)rd_addr;
50 if (!image_check_magic(rd_hdr)) {
51 puts("Bad Magic Number\n");
52 bootstage_error(BOOTSTAGE_ID_RD_MAGIC);
56 if (!image_check_hcrc(rd_hdr)) {
57 puts("Bad Header Checksum\n");
58 bootstage_error(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
62 bootstage_mark(BOOTSTAGE_ID_RD_MAGIC);
63 image_print_contents(rd_hdr);
66 puts(" Verifying Checksum ... ");
67 if (!image_check_dcrc(rd_hdr)) {
68 puts("Bad Data CRC\n");
69 bootstage_error(BOOTSTAGE_ID_RD_CHECKSUM);
75 bootstage_mark(BOOTSTAGE_ID_RD_HDR_CHECKSUM);
77 if (!image_check_os(rd_hdr, IH_OS_LINUX) ||
78 !image_check_arch(rd_hdr, arch) ||
79 !image_check_type(rd_hdr, IH_TYPE_RAMDISK)) {
80 printf("No Linux %s Ramdisk Image\n",
81 genimg_get_arch_name(arch));
82 bootstage_error(BOOTSTAGE_ID_RAMDISK);
90 /*****************************************************************************/
91 /* Shared dual-format routines */
92 /*****************************************************************************/
93 ulong image_load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */
94 ulong image_save_addr; /* Default Save Address */
95 ulong image_save_size; /* Default Save Size (in bytes) */
97 static int on_loadaddr(const char *name, const char *value, enum env_op op,
102 case env_op_overwrite:
103 image_load_addr = hextoul(value, NULL);
111 U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
113 ulong env_get_bootm_low(void)
115 char *s = env_get("bootm_low");
118 ulong tmp = hextoul(s, NULL);
122 #if defined(CONFIG_SYS_SDRAM_BASE)
123 return CONFIG_SYS_SDRAM_BASE;
124 #elif defined(CONFIG_ARM) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_RISCV)
125 return gd->bd->bi_dram[0].start;
131 phys_size_t env_get_bootm_size(void)
133 phys_size_t tmp, size;
135 char *s = env_get("bootm_size");
138 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
142 start = gd->ram_base;
145 if (start + size > gd->ram_top)
146 size = gd->ram_top - start;
148 s = env_get("bootm_low");
150 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
154 return size - (tmp - start);
157 phys_size_t env_get_bootm_mapsize(void)
160 char *s = env_get("bootm_mapsize");
163 tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
167 #if defined(CONFIG_SYS_BOOTMAPSZ)
168 return CONFIG_SYS_BOOTMAPSZ;
170 return env_get_bootm_size();
174 void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
179 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
185 size_t tail = (len > chunksz) ? chunksz : len;
192 memmove(to, from, tail);
199 #else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
200 memmove(to, from, len);
201 #endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
205 * genimg_get_kernel_addr_fit - get the real kernel address and return 2
207 * @img_addr: a string might contain real image address
208 * @fit_uname_config: double pointer to a char, will hold pointer to a
209 * configuration unit name
210 * @fit_uname_kernel: double pointer to a char, will hold pointer to a subimage
213 * genimg_get_kernel_addr_fit get the real kernel start address from a string
214 * which is normally the first argv of bootm/bootz
217 * kernel start address
219 ulong genimg_get_kernel_addr_fit(char * const img_addr,
220 const char **fit_uname_config,
221 const char **fit_uname_kernel)
225 /* find out kernel image address */
227 kernel_addr = image_load_addr;
228 debug("* kernel: default image load address = 0x%08lx\n",
230 #if CONFIG_IS_ENABLED(FIT)
231 } else if (fit_parse_conf(img_addr, image_load_addr, &kernel_addr,
233 debug("* kernel: config '%s' from image at 0x%08lx\n",
234 *fit_uname_config, kernel_addr);
235 } else if (fit_parse_subimage(img_addr, image_load_addr, &kernel_addr,
237 debug("* kernel: subimage '%s' from image at 0x%08lx\n",
238 *fit_uname_kernel, kernel_addr);
241 kernel_addr = hextoul(img_addr, NULL);
242 debug("* kernel: cmdline image address = 0x%08lx\n",
250 * genimg_get_kernel_addr() is the simple version of
251 * genimg_get_kernel_addr_fit(). It ignores those return FIT strings
253 ulong genimg_get_kernel_addr(char * const img_addr)
255 const char *fit_uname_config = NULL;
256 const char *fit_uname_kernel = NULL;
258 return genimg_get_kernel_addr_fit(img_addr, &fit_uname_config,
263 * genimg_get_format - get image format type
264 * @img_addr: image start address
266 * genimg_get_format() checks whether provided address points to a valid
267 * legacy or FIT image.
269 * New uImage format and FDT blob are based on a libfdt. FDT blob
270 * may be passed directly or embedded in a FIT image. In both situations
271 * genimg_get_format() must be able to dectect libfdt header.
274 * image format type or IMAGE_FORMAT_INVALID if no image is present
276 int genimg_get_format(const void *img_addr)
278 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
279 const image_header_t *hdr;
281 hdr = (const image_header_t *)img_addr;
282 if (image_check_magic(hdr))
283 return IMAGE_FORMAT_LEGACY;
285 #if CONFIG_IS_ENABLED(FIT) || CONFIG_IS_ENABLED(OF_LIBFDT)
286 if (fdt_check_header(img_addr) == 0)
287 return IMAGE_FORMAT_FIT;
289 #ifdef CONFIG_ANDROID_BOOT_IMAGE
290 if (android_image_check_header(img_addr) == 0)
291 return IMAGE_FORMAT_ANDROID;
294 return IMAGE_FORMAT_INVALID;
298 * fit_has_config - check if there is a valid FIT configuration
299 * @images: pointer to the bootm command headers structure
301 * fit_has_config() checks if there is a FIT configuration in use
302 * (if FTI support is present).
305 * 0, no FIT support or no configuration found
306 * 1, configuration found
308 int genimg_has_config(bootm_headers_t *images)
310 #if CONFIG_IS_ENABLED(FIT)
311 if (images->fit_uname_cfg)
318 * boot_get_ramdisk - main ramdisk handling routine
319 * @argc: command argument count
320 * @argv: command argument list
321 * @images: pointer to the bootm images structure
322 * @arch: expected ramdisk architecture
323 * @rd_start: pointer to a ulong variable, will hold ramdisk start address
324 * @rd_end: pointer to a ulong variable, will hold ramdisk end
326 * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
327 * Currently supported are the following ramdisk sources:
328 * - multicomponent kernel/ramdisk image,
329 * - commandline provided address of decicated ramdisk image.
332 * 0, if ramdisk image was found and valid, or skiped
333 * rd_start and rd_end are set to ramdisk start/end addresses if
334 * ramdisk image is found and valid
336 * 1, if ramdisk image is found but corrupted, or invalid
337 * rd_start and rd_end are set to 0 if no ramdisk exists
339 int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images,
340 u8 arch, ulong *rd_start, ulong *rd_end)
342 ulong rd_addr, rd_load;
343 ulong rd_data, rd_len;
344 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
345 const image_header_t *rd_hdr;
348 #ifdef CONFIG_SUPPORT_RAW_INITRD
351 #if CONFIG_IS_ENABLED(FIT)
352 const char *fit_uname_config = images->fit_uname_cfg;
353 const char *fit_uname_ramdisk = NULL;
357 const char *select = NULL;
362 #ifdef CONFIG_ANDROID_BOOT_IMAGE
364 * Look for an Android boot image.
366 buf = map_sysmem(images->os.start, 0);
367 if (buf && genimg_get_format(buf) == IMAGE_FORMAT_ANDROID)
368 select = (argc == 0) ? env_get("loadaddr") : argv[0];
375 * Look for a '-' which indicates to ignore the
378 if (select && strcmp(select, "-") == 0) {
379 debug("## Skipping init Ramdisk\n");
382 } else if (select || genimg_has_config(images)) {
383 #if CONFIG_IS_ENABLED(FIT)
386 * If the init ramdisk comes from the FIT image and
387 * the FIT image address is omitted in the command
388 * line argument, try to use os FIT image address or
389 * default load address.
391 if (images->fit_uname_os)
392 default_addr = (ulong)images->fit_hdr_os;
394 default_addr = image_load_addr;
396 if (fit_parse_conf(select, default_addr,
397 &rd_addr, &fit_uname_config)) {
398 debug("* ramdisk: config '%s' from image at 0x%08lx\n",
399 fit_uname_config, rd_addr);
400 } else if (fit_parse_subimage(select, default_addr,
402 &fit_uname_ramdisk)) {
403 debug("* ramdisk: subimage '%s' from image at 0x%08lx\n",
404 fit_uname_ramdisk, rd_addr);
408 rd_addr = hextoul(select, NULL);
409 debug("* ramdisk: cmdline image address = 0x%08lx\n",
412 #if CONFIG_IS_ENABLED(FIT)
414 /* use FIT configuration provided in first bootm
415 * command argument. If the property is not defined,
418 rd_addr = map_to_sysmem(images->fit_hdr_os);
419 rd_noffset = fit_get_node_from_config(images,
422 if (rd_noffset == -ENOENT)
424 else if (rd_noffset < 0)
430 * Check if there is an initrd image at the
431 * address provided in the second bootm argument
432 * check image type, for FIT images get FIT node.
434 buf = map_sysmem(rd_addr, 0);
435 switch (genimg_get_format(buf)) {
436 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
437 case IMAGE_FORMAT_LEGACY:
438 printf("## Loading init Ramdisk from Legacy Image at %08lx ...\n",
441 bootstage_mark(BOOTSTAGE_ID_CHECK_RAMDISK);
442 rd_hdr = image_get_ramdisk(rd_addr, arch,
448 rd_data = image_get_data(rd_hdr);
449 rd_len = image_get_data_size(rd_hdr);
450 rd_load = image_get_load(rd_hdr);
453 #if CONFIG_IS_ENABLED(FIT)
454 case IMAGE_FORMAT_FIT:
455 rd_noffset = fit_image_load(images,
456 rd_addr, &fit_uname_ramdisk,
457 &fit_uname_config, arch,
459 BOOTSTAGE_ID_FIT_RD_START,
460 FIT_LOAD_OPTIONAL_NON_ZERO,
465 images->fit_hdr_rd = map_sysmem(rd_addr, 0);
466 images->fit_uname_rd = fit_uname_ramdisk;
467 images->fit_noffset_rd = rd_noffset;
470 #ifdef CONFIG_ANDROID_BOOT_IMAGE
471 case IMAGE_FORMAT_ANDROID:
472 android_image_get_ramdisk((void *)images->os.start,
477 #ifdef CONFIG_SUPPORT_RAW_INITRD
480 end = strchr(select, ':');
482 rd_len = hextoul(++end, NULL);
487 puts("Wrong Ramdisk Image Format\n");
494 } else if (images->legacy_hdr_valid &&
495 image_check_type(&images->legacy_hdr_os_copy,
498 * Now check if we have a legacy mult-component image,
499 * get second entry data start address and len.
501 bootstage_mark(BOOTSTAGE_ID_RAMDISK);
502 printf("## Loading init Ramdisk from multi component Legacy Image at %08lx ...\n",
503 (ulong)images->legacy_hdr_os);
505 image_multi_getimg(images->legacy_hdr_os, 1, &rd_data, &rd_len);
510 bootstage_mark(BOOTSTAGE_ID_NO_RAMDISK);
516 debug("## No init Ramdisk\n");
519 *rd_end = rd_data + rd_len;
521 debug(" ramdisk start = 0x%08lx, ramdisk end = 0x%08lx\n",
527 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
529 * boot_ramdisk_high - relocate init ramdisk
530 * @lmb: pointer to lmb handle, will be used for memory mgmt
531 * @rd_data: ramdisk data start address
532 * @rd_len: ramdisk data length
533 * @initrd_start: pointer to a ulong variable, will hold final init ramdisk
534 * start address (after possible relocation)
535 * @initrd_end: pointer to a ulong variable, will hold final init ramdisk
536 * end address (after possible relocation)
538 * boot_ramdisk_high() takes a relocation hint from "initrd_high" environment
539 * variable and if requested ramdisk data is moved to a specified location.
541 * Initrd_start and initrd_end are set to final (after relocation) ramdisk
542 * start/end addresses if ramdisk image start and len were provided,
543 * otherwise set initrd_start and initrd_end set to zeros.
549 int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
550 ulong *initrd_start, ulong *initrd_end)
554 int initrd_copy_to_ram = 1;
556 s = env_get("initrd_high");
558 /* a value of "no" or a similar string will act like 0,
559 * turning the "load high" feature off. This is intentional.
561 initrd_high = hextoul(s, NULL);
562 if (initrd_high == ~0)
563 initrd_copy_to_ram = 0;
565 initrd_high = env_get_bootm_mapsize() + env_get_bootm_low();
568 debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
569 initrd_high, initrd_copy_to_ram);
572 if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
573 debug(" in-place initrd\n");
574 *initrd_start = rd_data;
575 *initrd_end = rd_data + rd_len;
576 lmb_reserve(lmb, rd_data, rd_len);
579 *initrd_start = (ulong)lmb_alloc_base(lmb,
580 rd_len, 0x1000, initrd_high);
582 *initrd_start = (ulong)lmb_alloc(lmb, rd_len,
585 if (*initrd_start == 0) {
586 puts("ramdisk - allocation error\n");
589 bootstage_mark(BOOTSTAGE_ID_COPY_RAMDISK);
591 *initrd_end = *initrd_start + rd_len;
592 printf(" Loading Ramdisk to %08lx, end %08lx ... ",
593 *initrd_start, *initrd_end);
595 memmove_wd((void *)*initrd_start,
596 (void *)rd_data, rd_len, CHUNKSZ);
600 * Ensure the image is flushed to memory to handle
601 * AMP boot scenarios in which we might not be
604 flush_cache((unsigned long)*initrd_start,
605 ALIGN(rd_len, ARCH_DMA_MINALIGN));
613 debug(" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
614 *initrd_start, *initrd_end);
621 #endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */
623 int boot_get_setup(bootm_headers_t *images, u8 arch,
624 ulong *setup_start, ulong *setup_len)
626 #if CONFIG_IS_ENABLED(FIT)
627 return boot_get_setup_fit(images, arch, setup_start, setup_len);
633 #if CONFIG_IS_ENABLED(FIT)
634 #if defined(CONFIG_FPGA)
635 int boot_get_fpga(int argc, char *const argv[], bootm_headers_t *images,
636 u8 arch, const ulong *ld_start, ulong * const ld_len)
638 ulong tmp_img_addr, img_data, img_len;
642 const char *uname, *name;
644 int devnum = 0; /* TODO support multi fpga platforms */
646 /* Check to see if the images struct has a FIT configuration */
647 if (!genimg_has_config(images)) {
648 debug("## FIT configuration was not specified\n");
653 * Obtain the os FIT header from the images struct
655 tmp_img_addr = map_to_sysmem(images->fit_hdr_os);
656 buf = map_sysmem(tmp_img_addr, 0);
658 * Check image type. For FIT images get FIT node
659 * and attempt to locate a generic binary.
661 switch (genimg_get_format(buf)) {
662 case IMAGE_FORMAT_FIT:
663 conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
665 uname = fdt_stringlist_get(buf, conf_noffset, FIT_FPGA_PROP, 0,
668 debug("## FPGA image is not specified\n");
671 fit_img_result = fit_image_load(images,
673 (const char **)&uname,
674 &images->fit_uname_cfg,
677 BOOTSTAGE_ID_FPGA_INIT,
678 FIT_LOAD_OPTIONAL_NON_ZERO,
679 &img_data, &img_len);
681 debug("FPGA image (%s) loaded to 0x%lx/size 0x%lx\n",
682 uname, img_data, img_len);
684 if (fit_img_result < 0) {
685 /* Something went wrong! */
686 return fit_img_result;
689 if (!fpga_is_partial_data(devnum, img_len)) {
691 err = fpga_loadbitstream(devnum, (char *)img_data,
694 err = fpga_load(devnum, (const void *)img_data,
698 err = fpga_loadbitstream(devnum, (char *)img_data,
699 img_len, BIT_PARTIAL);
701 err = fpga_load(devnum, (const void *)img_data,
702 img_len, BIT_PARTIAL);
708 printf(" Programming %s bitstream... OK\n", name);
711 printf("The given image format is not supported (corrupt?)\n");
719 static void fit_loadable_process(u8 img_type,
724 const unsigned int count =
725 ll_entry_count(struct fit_loadable_tbl, fit_loadable);
726 struct fit_loadable_tbl *fit_loadable_handler =
727 ll_entry_start(struct fit_loadable_tbl, fit_loadable);
728 /* For each loadable handler */
729 for (i = 0; i < count; i++, fit_loadable_handler++)
730 /* matching this type */
731 if (fit_loadable_handler->type == img_type)
732 /* call that handler with this image data */
733 fit_loadable_handler->handler(img_data, img_len);
736 int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images,
737 u8 arch, const ulong *ld_start, ulong * const ld_len)
740 * These variables are used to hold the current image location
745 * These two variables are requirements for fit_image_load, but
746 * their values are not used
748 ulong img_data, img_len;
756 /* Check to see if the images struct has a FIT configuration */
757 if (!genimg_has_config(images)) {
758 debug("## FIT configuration was not specified\n");
763 * Obtain the os FIT header from the images struct
765 tmp_img_addr = map_to_sysmem(images->fit_hdr_os);
766 buf = map_sysmem(tmp_img_addr, 0);
768 * Check image type. For FIT images get FIT node
769 * and attempt to locate a generic binary.
771 switch (genimg_get_format(buf)) {
772 case IMAGE_FORMAT_FIT:
773 conf_noffset = fit_conf_get_node(buf, images->fit_uname_cfg);
775 for (loadables_index = 0;
776 uname = fdt_stringlist_get(buf, conf_noffset,
778 loadables_index, NULL), uname;
780 fit_img_result = fit_image_load(images, tmp_img_addr,
782 &images->fit_uname_cfg,
783 arch, IH_TYPE_LOADABLE,
784 BOOTSTAGE_ID_FIT_LOADABLE_START,
785 FIT_LOAD_OPTIONAL_NON_ZERO,
786 &img_data, &img_len);
787 if (fit_img_result < 0) {
788 /* Something went wrong! */
789 return fit_img_result;
792 fit_img_result = fit_image_get_node(buf, uname);
793 if (fit_img_result < 0) {
794 /* Something went wrong! */
795 return fit_img_result;
797 fit_img_result = fit_image_get_type(buf,
800 if (fit_img_result < 0) {
801 /* Something went wrong! */
802 return fit_img_result;
805 fit_loadable_process(img_type, img_data, img_len);
809 printf("The given image format is not supported (corrupt?)\n");
818 * boot_get_cmdline - allocate and initialize kernel cmdline
819 * @lmb: pointer to lmb handle, will be used for memory mgmt
820 * @cmd_start: pointer to a ulong variable, will hold cmdline start
821 * @cmd_end: pointer to a ulong variable, will hold cmdline end
823 * boot_get_cmdline() allocates space for kernel command line below
824 * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environment
825 * variable is present its contents is copied to allocated kernel
832 int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
837 cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
838 env_get_bootm_mapsize() + env_get_bootm_low());
842 s = env_get("bootargs");
848 *cmd_start = (ulong)cmdline;
849 *cmd_end = *cmd_start + strlen(cmdline);
851 debug("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
857 * boot_get_kbd - allocate and initialize kernel copy of board info
858 * @lmb: pointer to lmb handle, will be used for memory mgmt
859 * @kbd: double pointer to board info data
861 * boot_get_kbd() allocates space for kernel copy of board info data below
862 * BOOTMAPSZ + env_get_bootm_low() address and kernel board info is initialized
863 * with the current u-boot board info data.
869 int boot_get_kbd(struct lmb *lmb, struct bd_info **kbd)
871 *kbd = (struct bd_info *)(ulong)lmb_alloc_base(lmb,
872 sizeof(struct bd_info),
874 env_get_bootm_mapsize() +
875 env_get_bootm_low());
881 debug("## kernel board info at 0x%08lx\n", (ulong)*kbd);
884 if (IS_ENABLED(CONFIG_CMD_BDI)
885 do_bdinfo(NULL, 0, 0, NULL);
891 int image_setup_linux(bootm_headers_t *images)
893 ulong of_size = images->ft_len;
894 char **of_flat_tree = &images->ft_addr;
895 struct lmb *lmb = &images->lmb;
898 if (CONFIG_IS_ENABLED(OF_LIBFDT))
899 boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree);
901 if (IS_ENABLED(CONFIG_SYS_BOOT_GET_CMDLINE)) {
902 ret = boot_get_cmdline(lmb, &images->cmdline_start,
903 &images->cmdline_end);
905 puts("ERROR with allocation of cmdline\n");
910 if (CONFIG_IS_ENABLED(OF_LIBFDT)) {
911 ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size);
916 if (CONFIG_IS_ENABLED(OF_LIBFDT) && of_size) {
917 ret = image_setup_libfdt(images, *of_flat_tree, of_size, lmb);
925 void genimg_print_size(uint32_t size)
927 printf("%d Bytes = ", size);
928 print_size(size, "\n");
931 void genimg_print_time(time_t timestamp)
935 rtc_to_tm(timestamp, &tm);
936 printf("%4d-%02d-%02d %2d:%02d:%02d UTC\n",
937 tm.tm_year, tm.tm_mon, tm.tm_mday,
938 tm.tm_hour, tm.tm_min, tm.tm_sec);