Modified to build in AOSP

This commit is contained in:
Zhuowei Zhang
2015-12-27 19:18:40 -08:00
committed by jollaman999
parent 4eb231e1f8
commit 90efb1bc02
7 changed files with 1544 additions and 26 deletions

1
.gitignore vendored
View File

@@ -16,4 +16,3 @@
/config.status
/configure
/include/config.h.in
/include/config.h

71
Android.mk Normal file
View File

@@ -0,0 +1,71 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mrom_kdump_static
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := kdump/kdump.c
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_STATIC_LIBRARIES := libc
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := mrom_libutil_kt
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(LOCAL_PATH)/util_lib/include
LOCAL_SRC_FILES := util_lib/compute_ip_checksum.c util_lib/sha256.c
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mrom_kexec_static
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
$(LOCAL_PATH)/util_lib/include \
$(LOCAL_PATH)/kexec/libfdt \
external/zlib
LOCAL_SRC_FILES := kexec/kexec.c kexec/ifdown.c \
kexec/kexec-elf.c kexec/kexec-elf-exec.c \
kexec/kexec-elf-core.c \
kexec/kexec-elf-rel.c \
kexec/kexec-elf-boot.c \
kexec/kexec-iomem.c \
kexec/kexec-xen.c \
kexec/firmware_memmap.c \
kexec/crashdump.c kexec/crashdump-xen.c \
kexec/phys_arch.c kexec/lzma.c \
kexec/zlib.c kexec/proc_iomem.c \
kexec/add_buffer.c \
kexec/kexec-uImage.c kexec/purgatory.c \
kexec/fs2dt.c \
kexec/libfdt/fdt.c kexec/libfdt/fdt_ro.c \
kexec/libfdt/fdt_rw.c kexec/libfdt/fdt_strerror.c \
kexec/libfdt/fdt_sw.c kexec/libfdt/fdt_wip.c
ARM_SRC_FILES := kexec/arch/arm/phys_to_virt.c \
kexec/arch/arm/kexec-elf-rel-arm.c \
kexec/arch/arm/kexec-zImage-arm.c \
kexec/arch/arm/kexec-uImage-arm.c \
kexec/arch/arm/kexec-arm.c \
kexec/arch/arm/mach.c \
kexec/arch/arm/mach-hammerhead.c \
kexec/arch/arm/mach-m8.c \
kexec/arch/arm/mach-shamu.c \
kexec/arch/arm/crashdump-arm.c
ARM_C_INCLUDES := $(LOCAL_PATH)/kexec/arch/arm/include \
LOCAL_SRC_FILES += kexec/arch/arm64/kexec-arm64.c \
kexec/arch/arm64/kexec-image-arm64.c \
kexec/arch/arm64/kexec-gzip-image-arm64.c \
kexec/arch/arm64/kexec-elf-arm64.c \
kexec/arch/arm64/crashdump-arm64.c \
kexec/dt-ops.c
LOCAL_C_INCLUDES += $(LOCAL_PATH)/kexec/arch/arm64/include \
$(LOCAL_PATH)/kexec
LOCAL_CFLAGS += -include $(LOCAL_PATH)/kexec/arch/arm64/kexec-arm64.h \
-include $(LOCAL_PATH)/kexec/arch/arm64/crashdump-arm64.h
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_STATIC_LIBRARIES := mrom_libutil_kt libz libc
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)
include $(BUILD_EXECUTABLE)

65
include/config.h Normal file
View File

@@ -0,0 +1,65 @@
/* include/config.h. Generated from config.h.in by configure. */
/* include/config.h.in. Generated from configure.ac by autoheader. */
/* Define to build for BookE */
/* #undef CONFIG_BOOKE */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `lzma' library (-llzma). */
/* #undef HAVE_LIBLZMA */
/* Define to 1 if you have the `xenctrl' library (-lxenctrl). */
/* #undef HAVE_LIBXENCTRL */
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "kexec-tools"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "kexec-tools 2.0.12.git"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "kexec-tools"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.0.12.git"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to include gamecube support */
/* #undef WITH_GAMECUBE */

1
kexec/.gitignore vendored
View File

@@ -1 +0,0 @@
purgatory.c

View File

@@ -10,15 +10,17 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl";
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/errno.h>
#include <net/if.h>
#include <netinet/in.h>
#define MAX_IFS 64
/*
* First, we find all shaper devices and down them. Then we
* down all real interfaces. This is because the comment in the
@@ -27,45 +29,43 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl";
*/
int ifdown(void)
{
struct if_nameindex *ifa, *ifp;
struct ifreq ifr;
int fd, shaper;
struct ifreq ifr[MAX_IFS];
struct ifconf ifc;
int i, fd;
int numif;
int shaper;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
fprintf(stderr, "ifdown: ");
perror("socket");
return -1;
}
ifc.ifc_len = sizeof(ifr);
ifc.ifc_req = ifr;
if ((ifa = if_nameindex()) == NULL) {
if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
fprintf(stderr, "ifdown: ");
perror("if_nameindex");
perror("SIOCGIFCONF");
close(fd);
return -1;
}
numif = ifc.ifc_len / sizeof(struct ifreq);
for (shaper = 1; shaper >= 0; shaper--) {
for (ifp = ifa; ifp->if_index; ifp++) {
for (i = 0; i < numif; i++) {
if ((strncmp(ifp->if_name, "shaper", 6) == 0)
if ((strncmp(ifr[i].ifr_name, "shaper", 6) == 0)
!= shaper) continue;
if (strcmp(ifp->if_name, "lo") == 0)
continue;
if (strchr(ifp->if_name, ':') != NULL)
continue;
strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
if (strcmp(ifr[i].ifr_name, "lo") == 0)
continue;
if (strchr(ifr[i].ifr_name, ':') != NULL)
continue;
ifr[i].ifr_flags &= ~(IFF_UP);
if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
fprintf(stderr, "ifdown: shutdown ");
perror(ifp->if_name);
return -1;
perror(ifr[i].ifr_name);
}
ifr.ifr_flags &= ~(IFF_UP);
if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
fprintf(stderr, "ifdown: shutdown ");
perror(ifp->if_name);
return -1;
}
}
}
close(fd);

View File

@@ -279,7 +279,7 @@ extern void arch_reuse_initrd(void);
extern int ifdown(void);
extern char purgatory[];
extern const char purgatory[];
extern size_t purgatory_size;
#define BOOTLOADER "kexec"

1384
kexec/purgatory.c Normal file

File diff suppressed because it is too large Load Diff