-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iwlwifi: move UEFI code to a separate file
We are going to read more variables from UEFI, so it's cleaner to have all the code that handles UEFI variables in a separate file. Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Link: https://lore.kernel.org/r/iwlwifi.20210621103449.c705ac86f2e9.Ia7421c17fe52929e4098b4f0cf070809ed3ef906@changeid Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
- Loading branch information
Luca Coelho
committed
Jun 22, 2021
1 parent
5c15794
commit 84c3c99
Showing
4 changed files
with
114 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause | ||
/* | ||
* Copyright(c) 2021 Intel Corporation | ||
*/ | ||
|
||
#include "iwl-drv.h" | ||
#include "pnvm.h" | ||
#include "iwl-prph.h" | ||
#include "iwl-io.h" | ||
|
||
#include "fw/uefi.h" | ||
#include <linux/efi.h> | ||
|
||
#define IWL_EFI_VAR_GUID EFI_GUID(0x92daaf2f, 0xc02b, 0x455b, \ | ||
0xb2, 0xec, 0xf5, 0xa3, \ | ||
0x59, 0x4f, 0x4a, 0xea) | ||
|
||
void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len) | ||
{ | ||
struct efivar_entry *pnvm_efivar; | ||
void *data; | ||
unsigned long package_size; | ||
int err; | ||
|
||
pnvm_efivar = kzalloc(sizeof(*pnvm_efivar), GFP_KERNEL); | ||
if (!pnvm_efivar) | ||
return ERR_PTR(-ENOMEM); | ||
|
||
memcpy(&pnvm_efivar->var.VariableName, IWL_UEFI_OEM_PNVM_NAME, | ||
sizeof(IWL_UEFI_OEM_PNVM_NAME)); | ||
pnvm_efivar->var.VendorGuid = IWL_EFI_VAR_GUID; | ||
|
||
/* | ||
* TODO: we hardcode a maximum length here, because reading | ||
* from the UEFI is not working. To implement this properly, | ||
* we have to call efivar_entry_size(). | ||
*/ | ||
package_size = IWL_HARDCODED_PNVM_SIZE; | ||
|
||
data = kmalloc(package_size, GFP_KERNEL); | ||
if (!data) { | ||
data = ERR_PTR(-ENOMEM); | ||
*len = 0; | ||
goto out; | ||
} | ||
|
||
err = efivar_entry_get(pnvm_efivar, NULL, &package_size, data); | ||
if (err) { | ||
IWL_DEBUG_FW(trans, | ||
"PNVM UEFI variable not found %d (len %zd)\n", | ||
err, package_size); | ||
kfree(data); | ||
data = ERR_PTR(err); | ||
goto out; | ||
} | ||
|
||
IWL_DEBUG_FW(trans, "Read PNVM from UEFI with size %zd\n", package_size); | ||
*len = package_size; | ||
|
||
out: | ||
kfree(pnvm_efivar); | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ | ||
/* | ||
* Copyright(c) 2021 Intel Corporation | ||
*/ | ||
|
||
|
||
#define IWL_UEFI_OEM_PNVM_NAME L"UefiCnvWlanOemSignedPnvm" | ||
|
||
/* | ||
* TODO: we have these hardcoded values that the caller must pass, | ||
* because reading from the UEFI is not working. To implement this | ||
* properly, we have to change iwl_pnvm_get_from_uefi() to call | ||
* efivar_entry_size() and return the value to the caller instead. | ||
*/ | ||
#define IWL_HARDCODED_PNVM_SIZE 4096 | ||
|
||
#ifdef CONFIG_EFI | ||
void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len); | ||
#else /* CONFIG_EFI */ | ||
static inline | ||
void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len) | ||
{ | ||
return ERR_PTR(-EOPNOTSUPP); | ||
} | ||
#endif /* CONFIG_EFI */ |