Merge tag 'pull-sp-20240412' of https://gitlab.com/rth7680/qemu into staging
[qemu/armbru.git] / pc-bios / s390-ccw / helper.h
blob8e3dfcb6d6cc3069eb33456dd0a0fc41be04db49
1 /*
2 * Helper Functions
4 * Copyright (c) 2019 IBM Corp.
6 * Author(s): Jason J. Herne <jjherne@us.ibm.com>
8 * This work is licensed under the terms of the GNU GPL, version 2 or (at
9 * your option) any later version. See the COPYING file in the top-level
10 * directory.
13 #ifndef S390_CCW_HELPER_H
14 #define S390_CCW_HELPER_H
16 #include "s390-ccw.h"
17 #include "s390-time.h"
19 /* Avoids compiler warnings when casting a pointer to a u32 */
20 static inline uint32_t ptr2u32(void *ptr)
22 IPL_assert((uint64_t)ptr <= 0xffffffffull, "ptr2u32: ptr too large");
23 return (uint32_t)(uint64_t)ptr;
26 /* Avoids compiler warnings when casting a u32 to a pointer */
27 static inline void *u32toptr(uint32_t n)
29 return (void *)(uint64_t)n;
32 static inline void yield(void)
34 asm volatile ("diag %%r0,%%r0,0x44"
35 : :
36 : "memory", "cc");
39 static inline void sleep(unsigned int seconds)
41 unsigned long target = get_time_seconds() + seconds;
43 while (get_time_seconds() < target) {
44 yield();
48 #endif