Mercurial > hvf > experimental
changeset 694:4e892db025b5
include: add a sigp_halt() helper to stop the cpu
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Tue, 06 Aug 2019 11:06:05 -0400 |
parents | 9ef53b94bd0a |
children | 2684dfba1884 |
files | include/arch.h |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/include/arch.h Tue Aug 06 12:14:52 2019 -0400 +++ b/include/arch.h Tue Aug 06 11:06:05 2019 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2007-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * 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) \