2 * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "xlat/kexec_load_flags.h"
31 #include "xlat/kexec_arch_values.h"
33 #ifndef KEXEC_ARCH_MASK
34 # define KEXEC_ARCH_MASK 0xffff0000
36 #ifndef KEXEC_SEGMENT_MAX
37 # define KEXEC_SEGMENT_MAX 16
41 print_seg(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
43 const unsigned long *seg;
44 unsigned long seg_buf[4];
46 if (elem_size < sizeof(seg_buf)) {
49 for (i = 0; i < ARRAY_SIZE(seg_buf); ++i)
50 seg_buf[i] = ((unsigned int *) elem_buf)[i];
58 tprintf(", %lu, ", seg[1]);
60 tprintf(", %lu}", seg[3]);
66 print_kexec_segments(struct tcb *tcp, const unsigned long addr,
67 const unsigned long len)
69 if (len > KEXEC_SEGMENT_MAX) {
75 const size_t sizeof_seg = ARRAY_SIZE(seg) * current_wordsize;
77 print_array(tcp, addr, len, seg, sizeof_seg,
78 umoven_or_printaddr, print_seg, 0);
83 /* entry, nr_segments */
84 printaddr(tcp->u_arg[0]);
85 tprintf(", %lu, ", tcp->u_arg[1]);
88 print_kexec_segments(tcp, tcp->u_arg[2], tcp->u_arg[1]);
92 unsigned long n = tcp->u_arg[3];
93 printxval_long(kexec_arch_values, n & KEXEC_ARCH_MASK, "KEXEC_ARCH_???");
94 n &= ~KEXEC_ARCH_MASK;
97 printflags_long(kexec_load_flags, n, "KEXEC_???");
103 #include "xlat/kexec_file_load_flags.h"
105 SYS_FUNC(kexec_file_load)
108 printfd(tcp, tcp->u_arg[0]);
111 printfd(tcp, tcp->u_arg[1]);
114 tprintf("%lu, ", tcp->u_arg[2]);
116 printstr(tcp, tcp->u_arg[3], tcp->u_arg[2]);
119 printflags_long(kexec_file_load_flags, tcp->u_arg[4], "KEXEC_FILE_???");