xref: /openbmc/linux/arch/s390/include/asm/os_info.h (revision 82806c25)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * OS info memory interface
4  *
5  * Copyright IBM Corp. 2012
6  * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
7  */
8 #ifndef _ASM_S390_OS_INFO_H
9 #define _ASM_S390_OS_INFO_H
10 
11 #include <linux/uio.h>
12 
13 #define OS_INFO_VERSION_MAJOR	1
14 #define OS_INFO_VERSION_MINOR	1
15 #define OS_INFO_MAGIC		0x4f53494e464f535aULL /* OSINFOSZ */
16 
17 #define OS_INFO_VMCOREINFO	0
18 #define OS_INFO_REIPL_BLOCK	1
19 
20 struct os_info_entry {
21 	u64	addr;
22 	u64	size;
23 	u32	csum;
24 } __packed;
25 
26 struct os_info {
27 	u64	magic;
28 	u32	csum;
29 	u16	version_major;
30 	u16	version_minor;
31 	u64	crashkernel_addr;
32 	u64	crashkernel_size;
33 	struct os_info_entry entry[2];
34 	u8	reserved[4024];
35 } __packed;
36 
37 void os_info_init(void);
38 void os_info_entry_add(int nr, void *ptr, u64 len);
39 void os_info_crashkernel_add(unsigned long base, unsigned long size);
40 u32 os_info_csum(struct os_info *os_info);
41 
42 #ifdef CONFIG_CRASH_DUMP
43 void *os_info_old_entry(int nr, unsigned long *size);
44 size_t copy_oldmem_iter(struct iov_iter *iter, unsigned long src, size_t count);
45 
46 static inline int copy_oldmem_kernel(void *dst, unsigned long src, size_t count)
47 {
48 	struct iov_iter iter;
49 	struct kvec kvec;
50 
51 	kvec.iov_base = dst;
52 	kvec.iov_len = count;
53 	iov_iter_kvec(&iter, WRITE, &kvec, 1, count);
54 	if (copy_oldmem_iter(&iter, src, count) < count)
55 		return -EFAULT;
56 	return 0;
57 }
58 #else
59 static inline void *os_info_old_entry(int nr, unsigned long *size)
60 {
61 	return NULL;
62 }
63 #endif
64 
65 #endif /* _ASM_S390_OS_INFO_H */
66