|
@@ -34,14 +34,8 @@
|
|
|
#include "task.h"
|
|
|
#include "probe_roms.h"
|
|
|
|
|
|
-struct efi_variable {
|
|
|
- efi_char16_t VariableName[1024/sizeof(efi_char16_t)];
|
|
|
- efi_guid_t VendorGuid;
|
|
|
- unsigned long DataSize;
|
|
|
- __u8 Data[1024];
|
|
|
- efi_status_t Status;
|
|
|
- __u32 Attributes;
|
|
|
-} __attribute__((packed));
|
|
|
+static efi_char16_t isci_efivar_name[] =
|
|
|
+ {'R', 's', 't', 'S', 'c', 'u', 'O'};
|
|
|
|
|
|
struct isci_orom *isci_request_oprom(struct pci_dev *pdev)
|
|
|
{
|
|
@@ -169,62 +163,50 @@ struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmw
|
|
|
|
|
|
static struct efi *get_efi(void)
|
|
|
{
|
|
|
- #ifdef CONFIG_EFI
|
|
|
+#ifdef CONFIG_EFI
|
|
|
return &efi;
|
|
|
- #else
|
|
|
+#else
|
|
|
return NULL;
|
|
|
- #endif
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
struct isci_orom *isci_get_efi_var(struct pci_dev *pdev)
|
|
|
{
|
|
|
- struct efi_variable *evar;
|
|
|
efi_status_t status;
|
|
|
- struct isci_orom *rom = NULL;
|
|
|
+ struct isci_orom *rom;
|
|
|
struct isci_oem_hdr *oem_hdr;
|
|
|
u8 *tmp, sum;
|
|
|
int j;
|
|
|
- size_t copy_len;
|
|
|
+ ssize_t data_len;
|
|
|
+ u8 *efi_data;
|
|
|
+ u32 efi_attrib = 0;
|
|
|
|
|
|
- evar = devm_kzalloc(&pdev->dev,
|
|
|
- sizeof(struct efi_variable),
|
|
|
- GFP_KERNEL);
|
|
|
- if (!evar) {
|
|
|
+ data_len = 1024;
|
|
|
+ efi_data = devm_kzalloc(&pdev->dev, data_len, GFP_KERNEL);
|
|
|
+ if (!efi_data) {
|
|
|
dev_warn(&pdev->dev,
|
|
|
- "Unable to allocate memory for EFI var\n");
|
|
|
+ "Unable to allocate memory for EFI data\n");
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- rom = devm_kzalloc(&pdev->dev, sizeof(*rom), GFP_KERNEL);
|
|
|
- if (!rom) {
|
|
|
- dev_warn(&pdev->dev,
|
|
|
- "Unable to allocate memory for orom\n");
|
|
|
- return NULL;
|
|
|
- }
|
|
|
-
|
|
|
- for (j = 0; j < strlen(ISCI_EFI_VAR_NAME) + 1; j++)
|
|
|
- evar->VariableName[j] = ISCI_EFI_VAR_NAME[j];
|
|
|
-
|
|
|
- evar->DataSize = 1024;
|
|
|
- evar->VendorGuid = ISCI_EFI_VENDOR_GUID;
|
|
|
- evar->Attributes = ISCI_EFI_ATTRIBUTES;
|
|
|
+ rom = (struct isci_orom *)(efi_data + sizeof(struct isci_oem_hdr));
|
|
|
|
|
|
if (get_efi())
|
|
|
- status = get_efi()->get_variable(evar->VariableName,
|
|
|
- &evar->VendorGuid,
|
|
|
- &evar->Attributes,
|
|
|
- &evar->DataSize,
|
|
|
- evar->Data);
|
|
|
+ status = get_efi()->get_variable(isci_efivar_name,
|
|
|
+ &ISCI_EFI_VENDOR_GUID,
|
|
|
+ &efi_attrib,
|
|
|
+ &data_len,
|
|
|
+ efi_data);
|
|
|
else
|
|
|
status = EFI_NOT_FOUND;
|
|
|
|
|
|
if (status != EFI_SUCCESS) {
|
|
|
dev_warn(&pdev->dev,
|
|
|
- "Unable to obtain EFI variable for OEM parms\n");
|
|
|
+ "Unable to obtain EFI var data for OEM parms\n");
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- oem_hdr = (struct isci_oem_hdr *)evar->Data;
|
|
|
+ oem_hdr = (struct isci_oem_hdr *)efi_data;
|
|
|
|
|
|
if (memcmp(oem_hdr->sig, ISCI_OEM_SIG, ISCI_OEM_SIG_SIZE) != 0) {
|
|
|
dev_warn(&pdev->dev,
|
|
@@ -233,12 +215,8 @@ struct isci_orom *isci_get_efi_var(struct pci_dev *pdev)
|
|
|
}
|
|
|
|
|
|
/* calculate checksum */
|
|
|
- tmp = (u8 *)oem_hdr;
|
|
|
- for (j = 0, sum = 0; j < sizeof(oem_hdr); j++, tmp++)
|
|
|
- sum += *tmp;
|
|
|
-
|
|
|
- tmp = (u8 *)rom;
|
|
|
- for (j = 0; j < sizeof(*rom); j++, tmp++)
|
|
|
+ tmp = (u8 *)efi_data;
|
|
|
+ for (j = 0, sum = 0; j < (sizeof(*oem_hdr) + sizeof(*rom)); j++, tmp++)
|
|
|
sum += *tmp;
|
|
|
|
|
|
if (sum != 0) {
|
|
@@ -247,11 +225,6 @@ struct isci_orom *isci_get_efi_var(struct pci_dev *pdev)
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- copy_len = min_t(u16, evar->DataSize,
|
|
|
- min_t(u16, oem_hdr->len - sizeof(*oem_hdr), sizeof(*rom)));
|
|
|
-
|
|
|
- memcpy(rom, (char *)evar->Data + sizeof(*oem_hdr), copy_len);
|
|
|
-
|
|
|
if (memcmp(rom->hdr.signature,
|
|
|
ISCI_ROM_SIG,
|
|
|
ISCI_ROM_SIG_SIZE) != 0) {
|