summaryrefslogtreecommitdiff
path: root/minix/kernel/arch/earm/arch_reset.c
blob: 7d5a872de50ca48405f97b4a99c8131df257255a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#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>
#include <io.h>

#include <minix/board.h>
#include <sys/reboot.h>

#include <minix/u64.h>

#include "archconst.h"
#include "arch_proto.h"
#include "bsp_reset.h"
#include "bsp_serial.h"
#include "kernel/proc.h"
#include "kernel/debug.h"
#include "direct_utils.h"
#include <machine/multiboot.h>

void
halt_cpu(void)
{
	asm volatile("dsb");
	asm volatile("cpsie i");
	asm volatile("wfi");
	asm volatile("cpsid i");
}

void
reset(void)
{
	bsp_reset(); /* should not exit */
	direct_print("Reset not supported.");
	while (1);
}

void
poweroff(void)
{
	bsp_poweroff();
	/* fallback option: hang */
	direct_print("Unable to power-off this device.");
	while (1);
}

__dead void
arch_shutdown(int how)
{

	if((how & RB_POWERDOWN) == RB_POWERDOWN) {
		/* Power off if possible, hang otherwise */
		poweroff();
		NOT_REACHABLE;
	}

	if(how & RB_HALT) {
		/* Hang */
		for (; ; ) halt_cpu();
		NOT_REACHABLE;
	}

	/* Reset the system */
	reset();
	NOT_REACHABLE;

	while (1);
}

#ifdef DEBUG_SERIAL
void
ser_putc(char c)
{
	bsp_ser_putc(c);
}

#endif