|
@@ -14,12 +14,17 @@
|
14
|
14
|
* You should have received a copy of the GNU General Public License
|
15
|
15
|
* along with this program; if not, write to the Free Software
|
16
|
16
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
+ *
|
|
18
|
+ * March-19-2009 @ 02:44: Added sleep command.
|
|
19
|
+ * Shao Miller <shao.miller@yrdsb.edu.on.ca>.
|
17
|
20
|
*/
|
18
|
21
|
|
19
|
22
|
#include <stdio.h>
|
|
23
|
+#include <stdlib.h>
|
20
|
24
|
#include <string.h>
|
21
|
25
|
#include <unistd.h>
|
22
|
26
|
#include <gpxe/command.h>
|
|
27
|
+#include <gpxe/nap.h>
|
23
|
28
|
#include <gpxe/timer.h>
|
24
|
29
|
|
25
|
30
|
static int time_exec ( int argc, char **argv ) {
|
|
@@ -52,3 +57,28 @@ struct command time_command __command = {
|
52
|
57
|
.exec = time_exec,
|
53
|
58
|
};
|
54
|
59
|
|
|
60
|
+static int sleep_exec ( int argc, char **argv ) {
|
|
61
|
+ unsigned long start, delay;
|
|
62
|
+
|
|
63
|
+ if ( argc == 1 ||
|
|
64
|
+ !strcmp ( argv[1], "--help" ) ||
|
|
65
|
+ !strcmp ( argv[1], "-h" ))
|
|
66
|
+ {
|
|
67
|
+ printf ( "Usage:\n"
|
|
68
|
+ " %s <seconds>\n"
|
|
69
|
+ "\n"
|
|
70
|
+ "Sleep for <seconds> seconds\n",
|
|
71
|
+ argv[0] );
|
|
72
|
+ return 1;
|
|
73
|
+ }
|
|
74
|
+ start = currticks();
|
|
75
|
+ delay = strtoul ( argv[1], NULL, 0 ) * ticks_per_sec();
|
|
76
|
+ while ( ( currticks() - start ) <= delay )
|
|
77
|
+ cpu_nap();
|
|
78
|
+ return 0;
|
|
79
|
+}
|
|
80
|
+
|
|
81
|
+struct command sleep_command __command = {
|
|
82
|
+ .name = "sleep",
|
|
83
|
+ .exec = sleep_exec,
|
|
84
|
+};
|