mirror of
https://gitlab.com/bztsrc/posix-uefi
synced 2026-08-26 10:23:04 -04:00
Use timer instead of stall in sleep, fix issue #56
This commit is contained in:
parent
5fbf2d61e9
commit
8d50e069f3
1 changed files with 11 additions and 1 deletions
|
|
@ -40,7 +40,17 @@ int usleep (unsigned long int __useconds)
|
|||
|
||||
unsigned int sleep (unsigned int __seconds)
|
||||
{
|
||||
BS->Stall((unsigned long int)__seconds * 1000000UL);
|
||||
/* Issue 56: some real firmware is buggy and Stall doesn't work for large delays, so use a timer instead */
|
||||
uint64_t usec = (uint64_t)__seconds * 1000000UL;
|
||||
uintn_t index = 0;
|
||||
efi_event_t timer_event;
|
||||
efi_status_t status = status = BS->CreateEvent(EVT_TIMER, 0, NULL, NULL, &timer_event);
|
||||
if(!EFI_ERROR(status)) {
|
||||
BS->SetTimer(timer_event, TimerRelative, usec * 10UL);
|
||||
BS->WaitForEvent(1, &timer_event, &index);
|
||||
BS->CloseEvent(timer_event);
|
||||
} else
|
||||
BS->Stall(usec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue