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., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * March-19-2009 @ 02:44: Added sleep command.
19 * Shao Miller <shao.miller@yrdsb.edu.on.ca>.
26 #include <gpxe/command.h>
28 #include <gpxe/timer.h>
30 static int time_exec ( int argc
, char **argv
) {
35 !strcmp ( argv
[1], "--help" ) ||
36 !strcmp ( argv
[1], "-h" ) )
47 rc
= execv ( argv
[1], argv
+ 1 );
48 secs
= (currticks() - start
) / ticks_per_sec();
50 printf ( "%s: %ds\n", argv
[0], secs
);
55 struct command time_command __command
= {
60 static int sleep_exec ( int argc
, char **argv
) {
61 unsigned long start
, delay
;
64 !strcmp ( argv
[1], "--help" ) ||
65 !strcmp ( argv
[1], "-h" ))
70 "Sleep for <seconds> seconds\n",
75 delay
= strtoul ( argv
[1], NULL
, 0 ) * ticks_per_sec();
76 while ( ( currticks() - start
) <= delay
)
81 struct command sleep_command __command
= {