Debian Codegraph @

purgatory/arch/i386/crashdump_backup.c

raw
1 /*
2 * kexec: Linux boots Linux
3 *
4 * Created by: Vivek goyal ([email protected])
5 * Copyright (C) IBM Corporation, 2005. All rights reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation (version 2 of the License).
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <stdint.h>
22 #include <string.h>
23
24 /* Backup region start gets set after /proc/iomem has been parsed. */
25 /* We reuse the same code for x86_64 also so changing backup_start to
26 unsigned long */
27 unsigned long backup_start = 0;
28
29 unsigned long backup_src_start = 0;
30 unsigned long backup_src_size = 0;
31
32 /* Backup first 640K of memory to backup region as reserved by kexec.
33 * Assuming first 640K has to be present on i386 machines and no address
34 * validity checks have to be performed. */
35
36 void crashdump_backup_memory(void)
37 {
38 void *dest, *src;
39 size_t size;
40
41 src = (void *) backup_src_start;
42 size = (size_t) backup_src_size;
43
44 if (!size)
45 return;
46
47 if (backup_start) {
48 dest = (void *)(backup_start);
49 memcpy(dest, src, size);
50 }
51 }