Commit 5f910377 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

restore: Implement local_sleep helper

Use it instead of pause insns to not burn cpu cycles.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 85237215
...@@ -81,6 +81,18 @@ static void always_inline write_hex_n(unsigned long num) ...@@ -81,6 +81,18 @@ static void always_inline write_hex_n(unsigned long num)
sys_write(1, &c, 1); sys_write(1, &c, 1);
} }
static void always_inline local_sleep(long seconds)
{
struct timespec req, rem;
req = (struct timespec){
.tv_sec = seconds,
.tv_nsec = 0,
};
sys_nanosleep(&req, &rem);
}
long restorer(long cmd) long restorer(long cmd)
{ {
long ret = -1; long ret = -1;
...@@ -228,9 +240,11 @@ self_len_end: ...@@ -228,9 +240,11 @@ self_len_end:
goto core_restore_end; goto core_restore_end;
write_hex_n(__LINE__); write_hex_n(__LINE__);
write_hex_n(va);
if (!va) if (!va)
break; break;
write_hex_n(__LINE__);
ret = sys_read(fd_core, (void *)va, PAGE_SIZE); ret = sys_read(fd_core, (void *)va, PAGE_SIZE);
if (ret != PAGE_SIZE) if (ret != PAGE_SIZE)
goto core_restore_end; goto core_restore_end;
...@@ -248,7 +262,7 @@ self_len_end: ...@@ -248,7 +262,7 @@ self_len_end:
core_restore_end: core_restore_end:
for (;;) for (;;)
asm volatile("pause"); local_sleep(5);
sys_exit(0); sys_exit(0);
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment