# HG changeset patch # User Josef 'Jeff' Sipek # Date 1565103965 14400 # Tue Aug 06 11:06:05 2019 -0400 # Node ID 4e892db025b5502135336f69dae2f4e9de31f269 # Parent 9ef53b94bd0a9b01b52673d513fd007eebe2c28c include: add a sigp_halt() helper to stop the cpu Signed-off-by: Josef 'Jeff' Sipek diff --git a/include/arch.h b/include/arch.h --- a/include/arch.h +++ b/include/arch.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2011 Josef 'Jeff' Sipek + * Copyright (c) 2007-2019 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -64,6 +64,29 @@ } /* + * Stop the cpu + * + * NOTE: We don't care about not clobbering registers as when this + * code executes, the CPU will be stopped. + * + * TODO: mark this with a no-return attribute + */ +static inline void sigp_stop(void) +{ + asm volatile( + "SR %r1, %r1 # not used, but should be zero\n" + "SR %r3, %r3 # CPU Address\n" + "SIGP %r1, %r3, 0x05 # order 0x05 = stop\n" + ); + + /* + * Just in case SIGP fails + */ + for (;;) + ; +} + +/* * Control Register handling */ #define set_cr(cr, val) \