1 #include "kernel/kernel.h" 2 3 #include <unistd.h> 4 #include <ctype.h> 5 #include <string.h> 6 #include <machine/cpu.h> 7 #include <assert.h> 8 #include <signal.h> 9 #include <machine/vm.h> 10 #include <io.h> 11 12 #include <minix/board.h> 13 #include <sys/reboot.h> 14 15 #include <minix/u64.h> 16 17 #include "archconst.h" 18 #include "arch_proto.h" 19 #include "bsp_reset.h" 20 #include "bsp_serial.h" 21 #include "kernel/proc.h" 22 #include "kernel/debug.h" 23 #include "direct_utils.h" 24 #include <machine/multiboot.h> 25 26 void halt_cpu(void)27halt_cpu(void) 28 { 29 asm volatile("dsb"); 30 asm volatile("cpsie i"); 31 asm volatile("wfi"); 32 asm volatile("cpsid i"); 33 } 34 35 void reset(void)36reset(void) 37 { 38 bsp_reset(); /* should not exit */ 39 direct_print("Reset not supported."); 40 while (1); 41 } 42 43 void poweroff(void)44poweroff(void) 45 { 46 bsp_poweroff(); 47 /* fallback option: hang */ 48 direct_print("Unable to power-off this device."); 49 while (1); 50 } 51 52 __dead void arch_shutdown(int how)53arch_shutdown(int how) 54 { 55 56 if((how & RB_POWERDOWN) == RB_POWERDOWN) { 57 /* Power off if possible, hang otherwise */ 58 poweroff(); 59 NOT_REACHABLE; 60 } 61 62 if(how & RB_HALT) { 63 /* Hang */ 64 for (; ; ) halt_cpu(); 65 NOT_REACHABLE; 66 } 67 68 /* Reset the system */ 69 reset(); 70 NOT_REACHABLE; 71 72 while (1); 73 } 74 75 #ifdef DEBUG_SERIAL 76 void ser_putc(char c)77ser_putc(char c) 78 { 79 bsp_ser_putc(c); 80 } 81 82 #endif 83