diff --git a/Android.mk b/Android.mk index ab18a86..39d18d0 100755 --- a/Android.mk +++ b/Android.mk @@ -94,3 +94,17 @@ LOCAL_CFLAGS := $(EFIWRAPPER_CFLAGS) LOCAL_SRC_FILES := \ main.c include $(BUILD_IAFW_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_PATH := $(EFIWRAPPER_LOCAL_PATH) +LOCAL_MODULE := efiwrapper-cd-$(TARGET_BUILD_VARIANT) +LOCAL_STATIC_LIBRARIES := \ + libefiwrapper-cd-$(TARGET_BUILD_VARIANT) \ + libgnuefi \ + libefi \ + libefiwrapper_drivers-cd-$(TARGET_BUILD_VARIANT) +LOCAL_CFLAGS := $(EFIWRAPPER_CFLAGS) +LOCAL_CFLAGS += -D__CRASH_DUMP +LOCAL_SRC_FILES := \ + main.c +include $(BUILD_IAFW_STATIC_LIBRARY) \ No newline at end of file diff --git a/drivers/Android.mk b/drivers/Android.mk index c0bc20b..c075e99 100644 --- a/drivers/Android.mk +++ b/drivers/Android.mk @@ -40,3 +40,42 @@ LOCAL_CFLAGS := $(EFIWRAPPER_CFLAGS) LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include/hardware LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/coreboot/payloads/libpayload/include include $(BUILD_IAFW_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libefiwrapper_drivers-cd-$(TARGET_BUILD_VARIANT) +LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_STATIC_LIBRARIES := \ + libpayload \ + libefiwrapper-cd-$(TARGET_BUILD_VARIANT) \ + libgnuefi \ + libefi +LOCAL_SRC_FILES := \ + $(foreach drv, $(LIBEFIWRAPPER_DRIVERS_CD), \ + $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/$(drv)/*.c))) +GEN := $(local-generated-sources-dir)/drivers.c +ifeq ($(LIBEFIWRAPPER_DRIVERS_CD),) +$(GEN): + $(hide) mkdir -p $(dir $@) + $(hide) echo "/* Do not modify this auto-generated file. */" > $@ + $(hide) echo "#error \"no driver selected. Cf. LIBEFIWRAPPER_DRIVERS_CD Makefile variable.\"" >> $@ +else +$(GEN): + $(hide) mkdir -p $(dir $@) + $(hide) echo "/* Do not modify this auto-generated file. */" > $@ + $(hide) echo "#include \"ewdrv.h\"" >> $@ + $(hide) $(foreach drv, $(LIBEFIWRAPPER_DRIVERS_CD), echo "#include" \"$(drv)/$(drv).h\" >> $@;) + $(hide) echo "" >> $@ + $(hide) echo "static ewdrv_t *drivers[] = {" >> $@ + $(hide) $(foreach drv, $(LIBEFIWRAPPER_DRIVERS_CD), echo "&"$(drv)_drv, >> $@;) + $(hide) echo "NULL" >> $@ + $(hide) echo "};" >> $@ + $(hide) echo "" >> $@ + $(hide) echo "ewdrv_t **ew_drivers = drivers;" >> $@ +endif +LOCAL_GENERATED_SOURCES := $(GEN) +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) +LOCAL_CFLAGS := $(EFIWRAPPER_CFLAGS) +LOCAL_CFLAGS += -D__CRASH_DUMP +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include/hardware +LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/coreboot/payloads/libpayload/include +include $(BUILD_IAFW_STATIC_LIBRARY) diff --git a/drivers/lpmemmap/lpmemmap.c b/drivers/lpmemmap/lpmemmap.c index ed23833..e9e6e9c 100644 --- a/drivers/lpmemmap/lpmemmap.c +++ b/drivers/lpmemmap/lpmemmap.c @@ -46,6 +46,7 @@ static EFI_MEMORY_DESCRIPTOR *efimemmap; #define E820_ACPI 3 #define E820_NVS 4 #define E820_UNUSABLE 5 +#define E820_VENDOR_RSVD 6 #define EFI_MAX_ADDRESS ((UINTN)~0) static EFI_STATUS e820_to_efi(unsigned int e820, UINT32 *efi) @@ -71,6 +72,10 @@ static EFI_STATUS e820_to_efi(unsigned int e820, UINT32 *efi) *efi = EfiUnusableMemory; return EFI_SUCCESS; + case E820_VENDOR_RSVD: + *efi = EfiLoaderCode; + return EFI_SUCCESS; + default: return EFI_NOT_FOUND; } @@ -400,7 +405,9 @@ static EFI_GET_MEMORY_MAP saved_memmap_bs; static EFI_STATUS lpmemmap_init(EFI_SYSTEM_TABLE *st) { EFI_STATUS ret; +#ifndef __CRASH_DUMP EFI_PHYSICAL_ADDRESS start, data, end; +#endif if (!st) return EFI_INVALID_PARAMETER; @@ -413,6 +420,7 @@ static EFI_STATUS lpmemmap_init(EFI_SYSTEM_TABLE *st) if (EFI_ERROR(ret)) return ret; +#ifndef __CRASH_DUMP start = ALIGN_DOWN((EFI_PHYSICAL_ADDRESS)(UINTN)_start, EFI_PAGE_SIZE); data = ALIGN_UP((EFI_PHYSICAL_ADDRESS)(UINTN)_heap, EFI_PAGE_SIZE); ret = insert_mem_descr(start, data, EfiLoaderCode); @@ -423,7 +431,7 @@ static EFI_STATUS lpmemmap_init(EFI_SYSTEM_TABLE *st) ret = insert_mem_descr(data, end, EfiLoaderData); if (EFI_ERROR(ret)) goto err; - +#endif saved_memmap_bs = st->BootServices->GetMemoryMap; st->BootServices->GetMemoryMap = get_memory_map; st->BootServices->AllocatePages = allocate_pages; @@ -432,9 +440,11 @@ static EFI_STATUS lpmemmap_init(EFI_SYSTEM_TABLE *st) return EFI_SUCCESS; +#ifndef __CRASH_DUMP err: free_efimemmap(); return ret; +#endif } static EFI_STATUS lpmemmap_exit(EFI_SYSTEM_TABLE *st) diff --git a/drivers/nvme/NvmExpressBlockIo.c b/drivers/nvme/NvmExpressBlockIo.c index a045b1f..7da5829 100644 --- a/drivers/nvme/NvmExpressBlockIo.c +++ b/drivers/nvme/NvmExpressBlockIo.c @@ -482,8 +482,10 @@ NvmeBlockIoWriteBlocks ( if (MediaId != Media->MediaId) return EFI_MEDIA_CHANGED; - if (Buffer == NULL) +#ifndef __CRASH_DUMP // crash dump will dump from the address 0 + if (Buffer == NULL) //remove this check, allow to write content of zero address to nvme return EFI_INVALID_PARAMETER; +#endif if (BufferSize == 0) return EFI_SUCCESS; diff --git a/drivers/nvme/NvmExpressPassthru.c b/drivers/nvme/NvmExpressPassthru.c index f03ddd6..edd04b5 100644 --- a/drivers/nvme/NvmExpressPassthru.c +++ b/drivers/nvme/NvmExpressPassthru.c @@ -635,6 +635,7 @@ NvmExpressPassThru ( Status = EFI_SUCCESS; else { Status = EFI_DEVICE_ERROR; + DEBUG_NVME ((EFI_D_ERROR, "NvmExpressPassThru:Cq->Sct = %d, Cq->Sc = %d\n",Cq->Sct,Cq->Sc )); // // Copy the Respose Queue entry for this command to the callers response buffer // diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 080bebd..98607cb 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -39,6 +39,9 @@ static struct supported_device { u16 did; } SUPPORTED_DEVICES[] = { { .vid = 0x144d, .did = NVME_PCI_DID }, + { .vid = 0x144d, .did = 0xA808 }, + { .vid = 0x15b7, .did = 0x5019 }, + { .vid = 0x1344, .did = 0x6001 }, // for Micron device { .vid = 0x8086, .did = 0xF1A6 }, }; diff --git a/libefiwrapper/Android.mk b/libefiwrapper/Android.mk index 4563d48..39cdd1f 100644 --- a/libefiwrapper/Android.mk +++ b/libefiwrapper/Android.mk @@ -48,3 +48,18 @@ LOCAL_C_INCLUDES := \ LOCAL_MODULE_HOST_ARCH := $(EFIWRAPPER_HOST_ARCH) LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libefiwrapper include $(BUILD_HOST_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE := libefiwrapper-cd-$(TARGET_BUILD_VARIANT) +LOCAL_STATIC_LIBRARIES := \ + libgnuefi \ + libefi +LOCAL_SRC_FILES := $(LIBEFIWRAPPER_SRC_FILES) +LOCAL_CFLAGS := $(EFIWRAPPER_CFLAGS) +LOCAL_CFLAGS += -D__CRASH_DUMP +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/libefiwrapper \ + $(LOCAL_PATH)/../../external/gnu-efi/gnu-efi-3.0/inc \ + $(LOCAL_PATH)/../../external/gnu-efi/gnu-efi-3.0/inc/$(TARGET_EFI_ARCH_NAME) \ + $(LOCAL_PATH)/../../external/gnu-efi/gnu-efi-3.0/inc/protocol +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../include/libefiwrapper +include $(BUILD_IAFW_STATIC_LIBRARY) \ No newline at end of file diff --git a/libefiwrapper/diskio.c b/libefiwrapper/diskio.c index ba86efc..e48c3e9 100644 --- a/libefiwrapper/diskio.c +++ b/libefiwrapper/diskio.c @@ -134,7 +134,11 @@ diskio_write(_EFI_DISK_IO *This, unsigned char *buf = Buffer, *block; media_t *media; - if (!This || !Buffer) +#ifndef __CRASH_DUMP + if (!This && !Buffer) +#else // crash dump need dump the address 0 + if (!This) +#endif return EFI_INVALID_PARAMETER; if (!diskio->media)