Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celadon/u/mr0/master #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
39 changes: 39 additions & 0 deletions drivers/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 11 additions & 1 deletion drivers/lpmemmap/lpmemmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion drivers/nvme/NvmExpressBlockIo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/nvme/NvmExpressPassthru.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
3 changes: 3 additions & 0 deletions drivers/nvme/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
};

Expand Down
15 changes: 15 additions & 0 deletions libefiwrapper/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion libefiwrapper/diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down