|
|
@@ -31,6 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|
31
|
31
|
#include <ipxe/command.h>
|
|
32
|
32
|
#include <ipxe/parseopt.h>
|
|
33
|
33
|
#include <ipxe/settings.h>
|
|
|
34
|
+#include <ipxe/nap.h>
|
|
34
|
35
|
#include <ipxe/shell.h>
|
|
35
|
36
|
|
|
36
|
37
|
/** @file
|
|
|
@@ -527,3 +528,42 @@ struct command iseq_command __command = {
|
|
527
|
528
|
.name = "iseq",
|
|
528
|
529
|
.exec = iseq_exec,
|
|
529
|
530
|
};
|
|
|
531
|
+
|
|
|
532
|
+/** "sleep" options */
|
|
|
533
|
+struct sleep_options {};
|
|
|
534
|
+
|
|
|
535
|
+/** "sleep" option list */
|
|
|
536
|
+static struct option_descriptor sleep_opts[] = {};
|
|
|
537
|
+
|
|
|
538
|
+/** "sleep" command descriptor */
|
|
|
539
|
+static struct command_descriptor sleep_cmd =
|
|
|
540
|
+ COMMAND_DESC ( struct sleep_options, sleep_opts, 1, 1, "<seconds>" );
|
|
|
541
|
+
|
|
|
542
|
+/**
|
|
|
543
|
+ * "sleep" command
|
|
|
544
|
+ *
|
|
|
545
|
+ * @v argc Argument count
|
|
|
546
|
+ * @v argv Argument list
|
|
|
547
|
+ * @ret rc Return status code
|
|
|
548
|
+ */
|
|
|
549
|
+static int sleep_exec ( int argc, char **argv ) {
|
|
|
550
|
+ struct sleep_options opts;
|
|
|
551
|
+ unsigned long start, delay;
|
|
|
552
|
+ int rc;
|
|
|
553
|
+
|
|
|
554
|
+ /* Parse options */
|
|
|
555
|
+ if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
|
|
|
556
|
+ return rc;
|
|
|
557
|
+
|
|
|
558
|
+ start = currticks();
|
|
|
559
|
+ delay = strtoul ( argv[1], NULL, 0 ) * ticks_per_sec();
|
|
|
560
|
+ while ( ( currticks() - start ) <= delay )
|
|
|
561
|
+ cpu_nap();
|
|
|
562
|
+ return 0;
|
|
|
563
|
+}
|
|
|
564
|
+
|
|
|
565
|
+/** "sleep" command */
|
|
|
566
|
+struct command sleep_command __command = {
|
|
|
567
|
+ .name = "sleep",
|
|
|
568
|
+ .exec = sleep_exec,
|
|
|
569
|
+};
|