U-Boot runs single-threaded without interrupts.
When cpu_nap is called the process is never woken up again.

With the patch we can use environment variable CPUNONAP
to disable cpu_nap when building iPXE, e.g.

        CPUNONAP=1

Signed-off-by: Heinrich Schuchardt <[email protected]>
---
 src/Makefile.housekeeping |  5 +++++
 src/core/console.c        |  2 ++
 src/core/gdbudp.c         |  2 ++
 src/core/getkey.c         |  2 ++
 src/core/timer.c          |  2 ++
 src/doc/build_sys.dox     | 13 +++++++++++++
 6 files changed, 26 insertions(+)

diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index f09db372..2c47f691 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -769,6 +769,11 @@ ifneq ($(PROFILE),)
 CFLAGS += -DPROFILING=$(PROFILE)
 endif
 
+# Do not let the cpu sleep when waiting for input
+ifneq ($(CPUNONAP),)
+CFLAGS += -DCPUNONAP=1
+endif
+
 include/ipxe/profile.h : $(PROFILE_LIST)
        $(Q)$(TOUCH) $@
 
diff --git a/src/core/console.c b/src/core/console.c
index 7fd00036..1cab3db8 100644
--- a/src/core/console.c
+++ b/src/core/console.c
@@ -98,7 +98,9 @@ int getchar ( void ) {
                 * makes Etherboot waiting for user interaction waste a lot
                 * less CPU time in a VMware session.
                 */
+#ifndef CPUNODEF
                cpu_nap();
+#endif
 
                /* Keep processing background tasks while we wait for
                 * input.
diff --git a/src/core/gdbudp.c b/src/core/gdbudp.c
index e4613d13..af23f859 100644
--- a/src/core/gdbudp.c
+++ b/src/core/gdbudp.c
@@ -156,7 +156,9 @@ static size_t gdbudp_recv ( char *buf, size_t len ) {
 bad_packet:
                        free_iob ( iob );
                }
+#ifndef CPUNODEF
                cpu_nap();
+#endif
        }
 }
 
diff --git a/src/core/getkey.c b/src/core/getkey.c
index 0c280d23..f515c340 100644
--- a/src/core/getkey.c
+++ b/src/core/getkey.c
@@ -51,7 +51,9 @@ static int getchar_timeout ( unsigned long timeout ) {
                step();
                if ( iskey() )
                        return getchar();
+#ifndef CPUNONAP
                cpu_nap();
+#endif
        }
 
        return -1;
diff --git a/src/core/timer.c b/src/core/timer.c
index 24745cef..720966fa 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -106,7 +106,9 @@ static unsigned int sleep_interruptible ( unsigned int secs,
                        step();
                        if ( interrupted && interrupted() )
                                return secs;
+#ifndef CPUNONAP
                        cpu_nap();
+#endif
                }
                start = now;
        }
diff --git a/src/doc/build_sys.dox b/src/doc/build_sys.dox
index 9466f662..28350c46 100644
--- a/src/doc/build_sys.dox
+++ b/src/doc/build_sys.dox
@@ -77,6 +77,19 @@ You can see the full list of object files that will be built 
using
 
 @endcode
 
+@subsection comp_envir Environment variables influencing compilation
+
+In some loops function cpu_nap() is used to wait for an interrupt.
+In single threaded environments without interrupt like U-Boot EFI
+iPXE will never be woken up. cpu_nap() can be disabled by defining
+the following environment variable value before calling make:
+
+@code
+
+       CPUNONAP=1
+
+@endcode
+
 @subsection comp_ar After compilation
 
 Once all objects have been compiled, they will be collected into a
-- 
2.11.0

_______________________________________________
ipxe-devel mailing list
[email protected]
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel

Reply via email to