On Monday 06 February 2006 21:39, Marco Gerards wrote: > Although it is not very important to handle those events, it can be > nice and is efficient and easy to do. Here is some proposed function > and interface: > > void grub_idle (int msec); > > When this function is called, GRUB will be idle for about MSEC > milliseconds. When nothing can be sanely done with this time, some > machine specific function is called instead of an idle loop. > Otherwise some functions will be called that can be registered to run > during idle time. But the next function will not be called it MSECS > have passed.
In my opinion, the essential function would be something similar to pause in POSIX, since the timer itself is an event. If you want to stop CPU while waiting, the events must be hardware interrupts, or triggered by hardware interrupts (such as a timer). Probably the most difficult architecture is PC in this case, because the interrupt handling is different between protected mode and real mode, and we may not interfere with BIOS. Looking at Etherboot's experience, this should be feasible but not trivial. However, it is easy to make a fake component for this, so I don't object to this. For example: void grub_pause (void) { grub_event_start (); while (1) if (grub_event_poll ()) break; grub_event_stop (); } grub_uint32_t start_time; unsigned long sleep_usecs; void grub_timer_event_start (void) { start_time = grub_get_rtc (); } int grub_timer_event_poll (void) { grub_uint32_t duration; duration = grub_get_rtc () - start_time; if (duration * GRUB_TICKS_PER_SECOND * 1000000 >= sleep_usecs) return 1; return 0; } void grub_timer_event_stop (void) { } void grub_usleep (unsigned long usecs) { sleep_usecs = usecs; grub_pause (); } Okuji _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel