2012-10-08 03:38:03 +02:00
|
|
|
#include "kernel/kernel.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <machine/vm.h>
|
2013-08-02 16:10:55 +02:00
|
|
|
#include <io.h>
|
2012-10-08 03:38:03 +02:00
|
|
|
|
2013-12-13 14:12:50 +01:00
|
|
|
#include <minix/board.h>
|
2013-09-09 15:20:18 +02:00
|
|
|
#include <sys/reboot.h>
|
|
|
|
|
2012-10-08 03:38:03 +02:00
|
|
|
#include <minix/u64.h>
|
|
|
|
|
|
|
|
#include "archconst.h"
|
|
|
|
#include "arch_proto.h"
|
2014-02-07 08:46:29 +01:00
|
|
|
#include "bsp_reset.h"
|
|
|
|
#include "bsp_serial.h"
|
2012-10-08 03:38:03 +02:00
|
|
|
#include "kernel/proc.h"
|
|
|
|
#include "kernel/debug.h"
|
|
|
|
#include "direct_utils.h"
|
|
|
|
#include <machine/multiboot.h>
|
|
|
|
|
2012-10-18 12:03:34 +02:00
|
|
|
void
|
|
|
|
halt_cpu(void)
|
2012-10-08 03:38:03 +02:00
|
|
|
{
|
2012-10-18 12:03:34 +02:00
|
|
|
asm volatile("dsb");
|
|
|
|
asm volatile("cpsie i");
|
|
|
|
asm volatile("wfi");
|
2013-02-15 01:07:04 +01:00
|
|
|
asm volatile("cpsid i");
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
reset(void)
|
|
|
|
{
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_reset(); /* should not exit */
|
2013-08-03 14:40:59 +02:00
|
|
|
direct_print("Reset not supported.");
|
|
|
|
while (1);
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
2013-08-02 16:10:55 +02:00
|
|
|
void
|
|
|
|
poweroff(void)
|
|
|
|
{
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_poweroff();
|
2013-08-02 16:10:55 +02:00
|
|
|
/* fallback option: hang */
|
|
|
|
direct_print("Unable to power-off this device.");
|
|
|
|
while (1);
|
|
|
|
}
|
|
|
|
|
2012-10-18 12:03:34 +02:00
|
|
|
__dead void
|
|
|
|
arch_shutdown(int how)
|
2012-10-08 03:38:03 +02:00
|
|
|
{
|
2013-08-02 16:10:55 +02:00
|
|
|
|
2013-09-09 15:20:18 +02:00
|
|
|
if((how & RB_POWERDOWN) == RB_POWERDOWN) {
|
2013-08-02 16:10:55 +02:00
|
|
|
/* Power off if possible, hang otherwise */
|
|
|
|
poweroff();
|
|
|
|
NOT_REACHABLE;
|
2013-09-09 15:20:18 +02:00
|
|
|
}
|
2013-08-02 16:10:55 +02:00
|
|
|
|
2013-09-09 15:20:18 +02:00
|
|
|
if(how & RB_HALT) {
|
|
|
|
/* Hang */
|
|
|
|
for (; ; ) halt_cpu();
|
2013-08-03 14:40:59 +02:00
|
|
|
NOT_REACHABLE;
|
2013-08-02 16:10:55 +02:00
|
|
|
}
|
2013-09-09 15:20:18 +02:00
|
|
|
|
|
|
|
/* Reset the system */
|
|
|
|
reset();
|
|
|
|
NOT_REACHABLE;
|
|
|
|
|
2012-10-18 12:03:34 +02:00
|
|
|
while (1);
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_SERIAL
|
2012-10-18 12:03:34 +02:00
|
|
|
void
|
|
|
|
ser_putc(char c)
|
2012-10-08 03:38:03 +02:00
|
|
|
{
|
2014-02-07 08:46:29 +01:00
|
|
|
bsp_ser_putc(c);
|
2012-10-08 03:38:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|