Permalink
Browse files

Add dummy target

  • Loading branch information...
1 parent d722eba commit 3aa06150efd17d5765b8b73a8de7e8158579e9ae Matthew Garrett committed Dec 3, 2013
View
@@ -2,11 +2,16 @@
# kexec (linux booting linux)
#
PURGATORY_HEX_C = kexec/purgatory.c
+DUMMY_PURGATORY_HEX_C = kexec/dummy_purgatory.c
$(PURGATORY_HEX_C): $(PURGATORY) $(BIN_TO_HEX)
$(MKDIR) -p $(@D)
$(BIN_TO_HEX) purgatory < $(PURGATORY) > $@
+$(DUMMY_PURGATORY_HEX_C): $(DUMMY_PURGATORY) $(BIN_TO_HEX)
+ $(MKDIR) -p $(@D)
+ $(BIN_TO_HEX) dummy_purgatory < $(DUMMY_PURGATORY) > $@
+
KEXEC_SRCS = $(KEXEC_SRCS_base)
KEXEC_GENERATED_SRCS =
@@ -27,6 +32,7 @@ KEXEC_SRCS_base += kexec/lzma.c
KEXEC_SRCS_base += kexec/zlib.c
KEXEC_GENERATED_SRCS += $(PURGATORY_HEX_C)
+KEXEC_GENERATED_SRCS += $(DUMMY_PURGATORY_HEX_C)
dist += kexec/Makefile $(KEXEC_GENERATED_SRCS) \
$(KEXEC_SRCS_base) kexec/crashdump-elf.c \
View
@@ -9,6 +9,7 @@ i386_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
i386_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
+i386_KEXEC_SRCS += kexec/arch/i386/kexec-dummy.c
i386_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
i386_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c
@@ -29,6 +29,8 @@
#define OPT_MOD (OPT_ARCH_MAX+7)
#define OPT_VGA (OPT_ARCH_MAX+8)
#define OPT_REAL_MODE (OPT_ARCH_MAX+9)
+#define OPT_ADDRESS (OPT_ARCH_MAX+10)
+#define OPT_VALUE (OPT_ARCH_MAX+11)
/* Options relevant to the architecture (excluding loader-specific ones): */
#define KEXEC_ARCH_OPTIONS \
@@ -68,7 +70,9 @@
{ "args-linux", 0, NULL, OPT_ARGS_LINUX }, \
{ "args-none", 0, NULL, OPT_ARGS_NONE }, \
{ "module", 1, 0, OPT_MOD }, \
- { "real-mode", 0, NULL, OPT_REAL_MODE },
+ { "real-mode", 0, NULL, OPT_REAL_MODE }, \
+ { "address", 1, 0, OPT_ADDRESS }, \
+ { "value", 1, 0, OPT_VALUE },
#define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR
@@ -0,0 +1,70 @@
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <elf.h>
+#include <boot/elf_boot.h>
+#include <ip_checksum.h>
+#include <x86/x86-linux.h>
+#include "../../kexec.h"
+#include "../../kexec-elf.h"
+#include "../../kexec-syscall.h"
+#include "kexec-x86.h"
+#include "x86-linux-setup.h"
+#include "crashdump-x86.h"
+#include <arch/options.h>
+
+int dummy_probe(const char *buf, off_t len)
+{
+ return 0;
+}
+
+void dummy_usage(void)
+{
+ return;
+}
+
+int dummy_load(int argc, char **argv, const char *buf, off_t len,
+ struct kexec_info *info)
+{
+ long long address;
+ long long value;
+ int opt;
+
+ static const struct option options[] = {
+ KEXEC_ARCH_OPTIONS
+ { "address", 1, 0, OPT_ADDRESS },
+ { "value", 1, 0, OPT_VALUE },
+ { 0, 0, 0, 0 },
+ };
+ static const char short_options[] = "";
+
+ while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
+ switch(opt) {
+ default:
+ /* Ignore core options */
+ if (opt < OPT_ARCH_MAX) {
+ break;
+ }
+ case OPT_ADDRESS:
+ address = strtoll(optarg, NULL, 0);
+ break;
+ case OPT_VALUE:
+ value = strtoll(optarg, NULL, 0);
+ break;
+ }
+ }
+
+ elf_rel_build_load(info, &info->rhdr, dummy_purgatory,
+ dummy_purgatory_size, 0x3000, 640*1024, -1, 0);
+ elf_rel_set_symbol(&info->rhdr, "hack_address", &address, sizeof(address));
+ elf_rel_set_symbol(&info->rhdr, "hack_value", &value, sizeof(value));
+ return 0;
+}
+
@@ -82,5 +82,10 @@ int nbi_load(int argc, char **argv, const char *buf, off_t len,
struct kexec_info *info);
void nbi_usage(void);
+int dummy_probe(const char *buf, off_t len);
+int dummy_load(int argc, char **argv, const char *buf, off_t len,
+ struct kexec_info *info);
+void dummy_usage(void);
+
extern unsigned xen_e820_to_kexec_type(uint32_t type);
#endif /* KEXEC_X86_H */
@@ -6,6 +6,7 @@ x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
+x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-dummy.c
x86_64_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
x86_64_KEXEC_SRCS += kexec/arch/i386/kexec-x86-common.c
x86_64_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c
@@ -40,6 +40,7 @@ struct file_type file_type[] = {
{ "bzImage", bzImage_probe, bzImage_load, bzImage_usage },
{ "beoboot-x86", beoboot_probe, beoboot_load, beoboot_usage },
{ "nbi-x86", nbi_probe, nbi_load, nbi_usage },
+ { "dummy", dummy_probe, dummy_load, dummy_usage },
};
int file_types = sizeof(file_type)/sizeof(file_type[0]);
View
@@ -252,6 +252,9 @@ extern int ifdown(void);
extern char purgatory[];
extern size_t purgatory_size;
+extern char dummy_purgatory[];
+extern size_t dummy_purgatory_size;
+
#define BOOTLOADER "kexec"
#define BOOTLOADER_VERSION PACKAGE_VERSION
View
@@ -13,6 +13,8 @@ PURGATORY_SRCS += purgatory/purgatory.c
PURGATORY_SRCS += purgatory/printf.c
PURGATORY_SRCS += purgatory/string.c
+DUMMY_PURGATORY = purgatory/dummy_purgatory.ro
+
dist += purgatory/Makefile $(PURGATORY_SRCS) \
purgatory/include/purgatory.h purgatory/include/string.h
@@ -27,14 +29,19 @@ include $(srcdir)/purgatory/arch/s390/Makefile
include $(srcdir)/purgatory/arch/sh/Makefile
include $(srcdir)/purgatory/arch/x86_64/Makefile
-PURGATORY_SRCS+=$($(ARCH)_PURGATORY_SRCS)
+REAL_PURGATORY_SRCS+=$(PURGATORY_SRCS) $($(ARCH)_PURGATORY_SRCS) $($(ARCH)_PURGATORY_SETUP)
+DUMMY_PURGATORY_SRCS+=$(PURGATORY_SRCS) $($(ARCH)_PURGATORY_SRCS) $($(ARCH)_DUMMY_PURGATORY_SETUP)
-PURGATORY_OBJS = $(call objify, $(PURGATORY_SRCS)) purgatory/sha256.o
+PURGATORY_OBJS = $(call objify, $(REAL_PURGATORY_SRCS)) purgatory/sha256.o
PURGATORY_DEPS = $(call depify, $(PURGATORY_OBJS))
-clean += $(PURGATORY_OBJS) $(PURGATORY_DEPS) $(PURGATORY)
+DUMMY_PURGATORY_OBJS = $(call objify, $(DUMMY_PURGATORY_SRCS)) purgatory/sha256.o
+DUMMY_PURGATORY_DEPS = $(call depify, $(DUMMY_PURGATORY_OBJS))
+
+clean += $(PURGATORY_OBJS) $(PURGATORY_DEPS) $(PURGATORY) $(DUMMY_PURGATORY_OBJS) $(DUMMY_PURGATORY_DEPS) $(DUMMY_PURGATORY)
-include $(PURGATORY_DEPS)
+-include $(DUMMY_PURGATORY_DEPS)
# sha256.c needs to be compiled without optimization, else
# purgatory fails to execute on ia64.
@@ -59,13 +66,35 @@ $(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
-Wl,--no-undefined -nostartfiles -nostdlib \
-nodefaultlibs -e purgatory_start -r
+$(DUMMY_PURGATORY): CC=$(TARGET_CC)
+$(DUMMY_PURGATORY): CFLAGS+=$(PURGATORY_EXTRA_CFLAGS) \
+ $($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+ -Os -fno-builtin -ffreestanding
+
+$(DUMMY_PURGATORY): CPPFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS) \
+ -I$(srcdir)/purgatory/include \
+ -I$(srcdir)/purgatory/arch/$(ARCH)/include \
+ -I$(srcdir)/util_lib/include \
+ -I$(srcdir)/include \
+ -I$(shell $(CC) -print-file-name=include)
+$(DUMMY_PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
+ -Wl,--no-undefined -nostartfiles -nostdlib \
+ -nodefaultlibs -e dummy_purgatory_start -r
+
$(PURGATORY): $(PURGATORY_OBJS)
$(MKDIR) -p $(@D)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
$(STRIP) --strip-debug $@
+$(DUMMY_PURGATORY): $(DUMMY_PURGATORY_OBJS)
+ $(MKDIR) -p $(@D)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+# $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) --no-undefined -e purgatory_start -r -o $@ $(PURGATORY_OBJS) $(UTIL_LIB)
+ $(STRIP) --strip-debug $@
+
echo::
@echo "PURGATORY_SRCS $(PURGATORY_SRCS)"
@echo "PURGATORY_DEPS $(PURGATORY_DEPS)"
@@ -4,16 +4,19 @@
x86_64_PURGATORY_SRCS_native = purgatory/arch/x86_64/entry64-32.S
x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/entry64.S
-x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/setup-x86_64.S
x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/stack.S
x86_64_PURGATORY_SRCS_native += purgatory/arch/x86_64/purgatory-x86_64.c
x86_64_PURGATORY_SRCS += $(x86_64_PURGATORY_SRCS_native)
+x86_64_PURGATORY_SETUP = purgatory/arch/x86_64/setup-x86_64.S
+x86_64_DUMMY_PURGATORY_SETUP = purgatory/arch/x86_64/dummy-setup-x86_64.S
dist += purgatory/arch/x86_64/Makefile $(x86_64_PURGATORY_SRCS_native) \
purgatory/arch/x86_64/include/arch/io.h \
purgatory/arch/x86_64/include/arch/debug.h \
- purgatory/arch/x86_64/purgatory-x86_64.h
+ purgatory/arch/x86_64/purgatory-x86_64.h \
+ purgatory/arch/x86_64/setup-x86_64.S \
+ purgatory/arch/x86_64/dummy-setup-x86_64.S
# Don't add sources in i386/ to dist, as i386/Makefile adds them
x86_64_PURGATORY_SRCS += purgatory/arch/i386/entry32-16.S
@@ -0,0 +1,44 @@
+/*
+ * purgatory: setup code
+ *
+ * Copyright (C) 2003,2004 Eric Biederman (ebiederm@xmission.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation (version 2 of the License).
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#undef i386
+
+ .text
+ .globl dummy_purgatory_start, hack_address, hack_value
+ .balign 16
+dummy_purgatory_start:
+ .code64
+
+ leaq hack_address(%rip), %rax
+ movq (%rax), %rax
+ leaq hack_value(%rip), %rbx
+ movq (%rbx), %rbx
+ movb %bl, (%rax)
+ xor %rax, %rax
+ xor %rbx, %rbx
+ ret
+
+ .data
+ .balign 4
+hack_address: .quad 0x00000000
+ .size hack_address, . - hack_address
+hack_value: .quad 0x00000000
+ .size hack_value, . - hack_value
+

0 comments on commit 3aa0615

Please sign in to comment.