2 * Copyright (C) 2009 Daniel Verkamp <daniel@drv.nu>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * March-19-2009 @ 02:44: Added sleep command.
20 * Shao Miller <shao.miller@yrdsb.edu.on.ca>.
23 FILE_LICENCE ( GPL2_OR_LATER );
29 #include <ipxe/command.h>
30 #include <ipxe/parseopt.h>
31 #include <ipxe/timer.h>
40 struct time_options {};
42 /** "time" option list */
43 static struct option_descriptor time_opts[] = {};
45 /** "time" command descriptor */
46 static struct command_descriptor time_cmd =
47 COMMAND_DESC ( struct time_options, time_opts, 1, MAX_ARGUMENTS,
53 * @v argc Argument count
54 * @v argv Argument list
55 * @ret rc Return status code
57 static int time_exec ( int argc, char **argv ) {
58 struct time_options opts;
60 unsigned long elapsed;
65 if ( ( rc = parse_options ( argc, argv, &time_cmd, &opts ) ) != 0 )
69 rc = execv ( argv[1], argv + 1 );
70 elapsed = ( currticks() - start );
71 decisecs = ( 10 * elapsed / ticks_per_sec() );
73 printf ( "%s: %d.%ds\n", argv[0],
74 ( decisecs / 10 ), ( decisecs % 10 ) );
80 struct command time_command __command = {