Skip to content
Snippets Groups Projects
Commit 1201ac28 authored by Claudio Fontana's avatar Claudio Fontana
Browse files

arch.hh: introduce arch::halt_no_interrupts


rename processor::halt_no_interrupts to cli_hlt, which
logically matches existing processor::sti_hlt.

Make use of arch::halt_no_interrupts in core/power.cc,
enclose x64-specific code in ifdefs, as well as putting
code on AArch64.

Signed-off-by: default avatarClaudio Fontana <claudio.fontana@huawei.com>
parent 2df1be5d
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,11 @@ inline void wait_for_interrupt()
processor::sti_hlt();
}
inline void halt_no_interrupts()
{
processor::cli_hlt();
}
class irq_flag {
public:
// need to clear the red zone when playing with the stack. also, can't
......
......@@ -263,7 +263,7 @@ void divide_error(exception_frame *ef)
extern "C" void nmi(exception_frame* ef)
{
while (true) {
processor::halt_no_interrupts();
processor::cli_hlt();
}
}
......
......@@ -237,7 +237,7 @@ inline void wrfsbase(u64 data)
asm volatile("wrfsbase %0" : : "r"(data));
}
inline void halt_no_interrupts() {
inline void cli_hlt() {
asm volatile ("cli; hlt" : : : "memory");
}
......
......@@ -9,10 +9,13 @@
#include <osv/debug.hh>
#include <smp.hh>
#include <processor.hh>
#include <arch.hh>
#ifndef AARCH64_PORT_STUB
extern "C" {
#include "acpi.h"
}
#endif /* !AARCH64_PORT_STUB */
namespace osv {
......@@ -23,13 +26,18 @@ namespace osv {
void halt(void)
{
#ifndef AARCH64_PORT_STUB
crash_other_processors();
while (true)
processor::halt_no_interrupts();
#endif /* !AARCH64_PORT_STUB */
while (true) {
arch::halt_no_interrupts();
}
}
void poweroff(void)
{
#ifndef AARCH64_PORT_STUB
ACPI_STATUS status = AcpiEnterSleepStatePrep(ACPI_STATE_S5);
if (ACPI_FAILURE(status)) {
debug("AcpiEnterSleepStatePrep failed: %s\n", AcpiFormatException(status));
......@@ -40,7 +48,9 @@ void poweroff(void)
debug("AcpiEnterSleepState failed: %s\n", AcpiFormatException(status));
halt();
}
// We shouldn't get here.
#endif /* !AARCH64_PORT_STUB */
// We shouldn't get here on x86.
halt();
}
......@@ -48,10 +58,13 @@ void poweroff(void)
// some reson fails.
void reboot(void)
{
#ifdef __x86_64__
// It would be nice if AcpiReset() worked, but it doesn't seem to work
// (on qemu & kvm), so let's resort to brute force...
processor::outb(1, 0x92);
debug("osv::reboot() did not work :(\n");
#endif /* __x86_64__ */
halt();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment