bump version
[buildroot.git] / package / kexec / kexec-tools-002-add-arch-arm.patch
blobeed57c3e4a570e780eb2a1724ace222bd1ec10b8
1 diff -rduNp kexec-tools-1.101.orig/configure kexec-tools-1.101/configure
2 --- kexec-tools-1.101.orig/configure 2006-09-20 04:39:38.000000000 +0200
3 +++ kexec-tools-1.101/configure 2007-01-22 15:54:14.000000000 +0100
4 @@ -1381,6 +1381,9 @@ case $host_cpu in
5 i?86 )
6 host_cpu="i386"
7 ;;
8 + arm* )
9 + host_cpu="arm"
10 + ;;
11 powerpc )
12 host_cpu="ppc"
14 @@ -1395,7 +1398,7 @@ case $host_cpu in
16 esac
17 case $host_cpu in
18 - i386|ppc|x86_64|alpha|ppc64|ia64|s390)
19 + i386|ppc|x86_64|alpha|ppc64|ia64|s390|arm)
21 * )
22 { { echo "$as_me:$LINENO: error: unsupported architecture $host_cpu" >&5
23 diff -rduNp kexec-tools-1.101.orig/kexec/arch/arm/Makefile kexec-tools-1.101/kexec/arch/arm/Makefile
24 --- kexec-tools-1.101.orig/kexec/arch/arm/Makefile 1970-01-01 01:00:00.000000000 +0100
25 +++ kexec-tools-1.101/kexec/arch/arm/Makefile 2007-01-22 15:54:14.000000000 +0100
26 @@ -0,0 +1,8 @@
28 +# kexec arm (linux booting linux)
30 +KEXEC_C_SRCS+= kexec/arch/arm/kexec-elf-rel-arm.c
31 +KEXEC_C_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
32 +KEXEC_C_SRCS+= kexec/arch/arm/kexec-arm.c
34 +KEXEC_S_SRCS+=
35 diff -rduNp kexec-tools-1.101.orig/kexec/arch/arm/include/arch/options.h kexec-tools-1.101/kexec/arch/arm/include/arch/options.h
36 --- kexec-tools-1.101.orig/kexec/arch/arm/include/arch/options.h 1970-01-01 01:00:00.000000000 +0100
37 +++ kexec-tools-1.101/kexec/arch/arm/include/arch/options.h 2007-01-22 15:54:14.000000000 +0100
38 @@ -0,0 +1,11 @@
39 +#ifndef KEXEC_ARCH_ARM_OPTIONS_H
40 +#define KEXEC_ARCH_ARM_OPTIONS_H
42 +#define OPT_ARCH_MAX (OPT_MAX+0)
44 +#define KEXEC_ARCH_OPTIONS \
45 + KEXEC_OPTIONS \
47 +#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
49 +#endif /* KEXEC_ARCH_ARM_OPTIONS_H */
50 diff -rduNp kexec-tools-1.101.orig/kexec/arch/arm/kexec-arm.c kexec-tools-1.101/kexec/arch/arm/kexec-arm.c
51 --- kexec-tools-1.101.orig/kexec/arch/arm/kexec-arm.c 1970-01-01 01:00:00.000000000 +0100
52 +++ kexec-tools-1.101/kexec/arch/arm/kexec-arm.c 2007-01-22 15:54:14.000000000 +0100
53 @@ -0,0 +1,130 @@
54 +/*
55 + * kexec: Linux boots Linux
56 + *
57 + * modified from kexec-ppc.c
58 + *
59 + */
61 +#define _GNU_SOURCE
62 +#include <stddef.h>
63 +#include <stdio.h>
64 +#include <errno.h>
65 +#include <stdint.h>
66 +#include <string.h>
67 +#include <getopt.h>
68 +#include <sys/utsname.h>
69 +#include "../../kexec.h"
70 +#include "../../kexec-syscall.h"
71 +#include "kexec-arm.h"
72 +#include <arch/options.h>
74 +#define MAX_MEMORY_RANGES 64
75 +#define MAX_LINE 160
76 +static struct memory_range memory_range[MAX_MEMORY_RANGES];
78 +/* Return a sorted list of available memory ranges. */
79 +int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long kexec_flags)
81 + const char iomem[]= "/proc/iomem";
82 + int memory_ranges = 0;
83 + char line[MAX_LINE];
84 + FILE *fp;
85 + fp = fopen(iomem, "r");
86 + if (!fp) {
87 + fprintf(stderr, "Cannot open %s: %s\n",
88 + iomem, strerror(errno));
89 + return -1;
90 + }
92 + while(fgets(line, sizeof(line), fp) != 0) {
93 + unsigned long long start, end;
94 + char *str;
95 + int type;
96 + int consumed;
97 + int count;
98 + if (memory_ranges >= MAX_MEMORY_RANGES)
99 + break;
100 + count = sscanf(line, "%Lx-%Lx : %n",
101 + &start, &end, &consumed);
102 + if (count != 2)
103 + continue;
104 + str = line + consumed;
105 + end = end + 1;
107 + if (memcmp(str, "System RAM\n", 11) == 0) {
108 + type = RANGE_RAM;
109 + }
110 + else if (memcmp(str, "reserved\n", 9) == 0) {
111 + type = RANGE_RESERVED;
113 + else {
114 + continue;
117 + memory_range[memory_ranges].start = start;
118 + memory_range[memory_ranges].end = end;
119 + memory_range[memory_ranges].type = type;
120 + memory_ranges++;
122 + fclose(fp);
123 + *range = memory_range;
124 + *ranges = memory_ranges;
125 + return 0;
128 +/* Supported file types and callbacks */
129 +struct file_type file_type[] = {
130 + {"zImage", zImage_arm_probe, zImage_arm_load, zImage_arm_usage},
132 +int file_types = sizeof(file_type) / sizeof(file_type[0]);
135 +void arch_usage(void)
139 +int arch_process_options(int argc, char **argv)
141 + static const struct option options[] = {
142 + KEXEC_ARCH_OPTIONS
143 + { 0, 0, NULL, 0 },
144 + };
145 + static const char short_options[] = KEXEC_ARCH_OPT_STR;
146 + int opt;
148 + opterr = 0; /* Don't complain about unrecognized options here */
149 + while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
150 + switch(opt) {
151 + default:
152 + break;
155 + /* Reset getopt for the next pass; called in other source modules */
156 + opterr = 1;
157 + optind = 1;
158 + return 0;
161 +int arch_compat_trampoline(struct kexec_info *info)
163 + int result;
164 + struct utsname utsname;
165 + result = uname(&utsname);
166 + if (result < 0) {
167 + fprintf(stderr, "uname failed: %s\n",
168 + strerror(errno));
169 + return -1;
171 + if (strncmp(utsname.machine, "arm",3) != 0)
173 + fprintf(stderr, "Unsupported machine type: %s\n",
174 + utsname.machine);
175 + return -1;
177 + return 0;
180 +void arch_update_purgatory(struct kexec_info *info)
184 diff -rduNp kexec-tools-1.101.orig/kexec/arch/arm/kexec-arm.h kexec-tools-1.101/kexec/arch/arm/kexec-arm.h
185 --- kexec-tools-1.101.orig/kexec/arch/arm/kexec-arm.h 1970-01-01 01:00:00.000000000 +0100
186 +++ kexec-tools-1.101/kexec/arch/arm/kexec-arm.h 2007-01-22 15:54:14.000000000 +0100
187 @@ -0,0 +1,9 @@
188 +#ifndef KEXEC_ARM_H
189 +#define KEXEC_ARM_H
191 +int zImage_arm_probe(const char *buf, off_t len);
192 +int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
193 + struct kexec_info *info);
194 +void zImage_arm_usage(void);
196 +#endif /* KEXEC_ARM_H */
197 diff -rduNp kexec-tools-1.101.orig/kexec/arch/arm/kexec-elf-rel-arm.c kexec-tools-1.101/kexec/arch/arm/kexec-elf-rel-arm.c
198 --- kexec-tools-1.101.orig/kexec/arch/arm/kexec-elf-rel-arm.c 1970-01-01 01:00:00.000000000 +0100
199 +++ kexec-tools-1.101/kexec/arch/arm/kexec-elf-rel-arm.c 2007-01-22 15:54:14.000000000 +0100
200 @@ -0,0 +1,35 @@
201 +#include <stdio.h>
202 +#include <elf.h>
203 +#include "../../kexec.h"
204 +#include "../../kexec-elf.h"
206 +int machine_verify_elf_rel(struct mem_ehdr *ehdr)
208 + if (ehdr->ei_data != ELFDATA2MSB) {
209 + return 0;
211 + if (ehdr->ei_class != ELFCLASS32) {
212 + return 0;
214 + if (ehdr->e_machine != EM_ARM)
216 + return 0;
218 + return 1;
221 +void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
222 + void *location, unsigned long address, unsigned long value)
224 + switch(r_type) {
225 + case R_ARM_ABS32:
226 + *((uint32_t *)location) += value;
227 + break;
228 + case R_ARM_REL32:
229 + *((uint32_t *)location) += value - address;
230 + break;
231 + default:
232 + die("Unknown rel relocation: %lu\n", r_type);
233 + break;
236 diff -rduNp kexec-tools-1.101.orig/kexec/arch/arm/kexec-zImage-arm.c kexec-tools-1.101/kexec/arch/arm/kexec-zImage-arm.c
237 --- kexec-tools-1.101.orig/kexec/arch/arm/kexec-zImage-arm.c 1970-01-01 01:00:00.000000000 +0100
238 +++ kexec-tools-1.101/kexec/arch/arm/kexec-zImage-arm.c 2007-01-22 15:54:14.000000000 +0100
239 @@ -0,0 +1,34 @@
240 +#define _GNU_SOURCE
241 +#include <stdio.h>
242 +#include <string.h>
243 +#include <stdlib.h>
244 +#include <errno.h>
245 +#include <limits.h>
246 +#include "../../kexec.h"
248 +int zImage_arm_probe(const char *buf, off_t len)
250 + /*
251 + * Only zImage loading is supported. Do not check if
252 + * the buffer is valid kernel image
253 + */
254 + return 0;
256 +void zImage_arm_usage(void)
259 +int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
260 + struct kexec_info *info)
262 + unsigned long base;
263 + unsigned int offset = 0x8000; /* 32k offset from memory start */
264 + base = locate_hole(info,len+offset,0,0,ULONG_MAX,INT_MAX);
265 + if (base == ULONG_MAX)
267 + return -1;
269 + base += offset;
270 + add_segment(info,buf,len,base,len);
271 + info->entry = (void*)base;
272 + return 0;
274 diff -rduNp kexec-tools-1.101.orig/kexec/kexec-syscall.h kexec-tools-1.101/kexec/kexec-syscall.h
275 --- kexec-tools-1.101.orig/kexec/kexec-syscall.h 2006-09-20 04:39:38.000000000 +0200
276 +++ kexec-tools-1.101/kexec/kexec-syscall.h 2007-01-22 15:54:14.000000000 +0100
277 @@ -43,6 +43,9 @@
278 #ifdef __s390__
279 #define __NR_kexec_load 277
280 #endif
281 +#ifdef __arm__
282 +#define __NR_kexec_load __NR_SYSCALL_BASE + 189
283 +#endif
284 #ifndef __NR_kexec_load
285 #error Unknown processor architecture. Needs a kexec_load syscall number.
286 #endif
287 @@ -74,6 +77,7 @@ static inline long kexec_reboot(void)
288 #define KEXEC_ARCH_PPC64 (21 << 16)
289 #define KEXEC_ARCH_IA_64 (50 << 16)
290 #define KEXEC_ARCH_S390 (22 << 16)
291 +#define KEXEC_ARCH_ARM (40 << 16)
293 #define KEXEC_MAX_SEGMENTS 16
295 diff -rduNp kexec-tools-1.101.orig/purgatory/arch/arm/Makefile kexec-tools-1.101/purgatory/arch/arm/Makefile
296 --- kexec-tools-1.101.orig/purgatory/arch/arm/Makefile 1970-01-01 01:00:00.000000000 +0100
297 +++ kexec-tools-1.101/purgatory/arch/arm/Makefile 2007-01-22 15:54:14.000000000 +0100
298 @@ -0,0 +1,7 @@
300 +# Purgatory arm
303 +PURGATORY_S_SRCS +=
304 +PURGATORY_C_SRCS +=
306 diff -rduNp kexec-tools-1.101.orig/purgatory/arch/arm/include/limits.h kexec-tools-1.101/purgatory/arch/arm/include/limits.h
307 --- kexec-tools-1.101.orig/purgatory/arch/arm/include/limits.h 1970-01-01 01:00:00.000000000 +0100
308 +++ kexec-tools-1.101/purgatory/arch/arm/include/limits.h 2007-01-22 15:54:14.000000000 +0100
309 @@ -0,0 +1,58 @@
310 +#ifndef LIMITS_H
311 +#define LIMITS_H 1
314 +/* Number of bits in a `char' */
315 +#define CHAR_BIT 8
317 +/* Minimum and maximum values a `signed char' can hold */
318 +#define SCHAR_MIN (-128)
319 +#define SCHAR_MAX 127
321 +/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */
322 +#define UCHAR_MAX 255
324 +/* Minimum and maximum values a `char' can hold */
325 +#define CHAR_MIN SCHAR_MIN
326 +#define CHAR_MAX SCHAR_MAX
328 +/* Minimum and maximum values a `signed short int' can hold */
329 +#define SHRT_MIN (-32768)
330 +#define SHRT_MAX 32767
332 +/* Maximum value an `unsigned short' can hold. (Minimum is 0.) */
333 +#define USHRT_MAX 65535
336 +/* Minimum and maximum values a `signed int' can hold */
337 +#define INT_MIN (-INT_MAX - 1)
338 +#define INT_MAX 2147483647
340 +/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
341 +#define UINT_MAX 4294967295U
344 +/* Minimum and maximum values a `signed int' can hold */
345 +#define INT_MIN (-INT_MAX - 1)
346 +#define INT_MAX 2147483647
348 +/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */
349 +#define UINT_MAX 4294967295U
351 +/* Minimum and maximum values a `signed long' can hold */
352 +#define LONG_MAX 2147483647L
353 +#define LONG_MIN (-LONG_MAX - 1L)
355 +/* Maximum value an `unsigned long' can hold. (Minimum is 0.) */
356 +#define ULONG_MAX 4294967295UL
358 +/* Minimum and maximum values a `signed long long' can hold */
359 +#define LLONG_MAX 9223372036854775807LL
360 +#define LLONG_MIN (-LONG_MAX - 1LL)
363 +/* Maximum value an `unsigned long long' can hold. (Minimum is 0.) */
364 +#define ULLONG_MAX 18446744073709551615ULL
367 +#endif /* LIMITS_H */
368 diff -rduNp kexec-tools-1.101.orig/purgatory/arch/arm/include/stdint.h kexec-tools-1.101/purgatory/arch/arm/include/stdint.h
369 --- kexec-tools-1.101.orig/purgatory/arch/arm/include/stdint.h 1970-01-01 01:00:00.000000000 +0100
370 +++ kexec-tools-1.101/purgatory/arch/arm/include/stdint.h 2007-01-22 15:54:14.000000000 +0100
371 @@ -0,0 +1,16 @@
372 +#ifndef STDINT_H
373 +#define STDINT_H
375 +typedef unsigned long size_t;
377 +typedef unsigned char uint8_t;
378 +typedef unsigned short uint16_t;
379 +typedef unsigned int uint32_t;
380 +typedef unsigned long long uint64_t;
382 +typedef signed char int8_t;
383 +typedef signed short int16_t;
384 +typedef signed int int32_t;
385 +typedef signed long long int64_t;
387 +#endif /* STDINT_H */