iPXE
|
ACPI MAC address. More...
#include <string.h>
#include <errno.h>
#include <ipxe/acpi.h>
#include <ipxe/base16.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/settings.h>
#include <ipxe/acpimac.h>
Go to the source code of this file.
Data Structures | |
struct | acpimac_extractor |
An ACPI MAC extraction mechanism. More... | |
Macros | |
#define | colour FADT_SIGNATURE |
Colour for debug messages. More... | |
#define | AMAC_SIGNATURE ACPI_SIGNATURE ( 'A', 'M', 'A', 'C' ) |
AMAC signature. More... | |
#define | MACA_SIGNATURE ACPI_SIGNATURE ( 'M', 'A', 'C', 'A' ) |
MACA signature. More... | |
#define | RTMA_SIGNATURE ACPI_SIGNATURE ( 'R', 'T', 'M', 'A' ) |
RTMA signature. More... | |
#define | ACPIMAC_MAX_SKIP 8 |
Maximum number of bytes to skip after ACPI signature. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | acpimac_decode_base16 (const char *mac, uint8_t *hw_addr) |
Decode Base16-encoded MAC address. More... | |
static int | acpimac_decode_raw (const char *mac, uint8_t *hw_addr) |
Decode raw MAC address. More... | |
static int | acpimac_extract (userptr_t zsdt, size_t len, size_t offset, void *data, struct acpimac_extractor *extractor) |
Extract MAC address from DSDT/SSDT. More... | |
static int | acpimac_extract_auxmac (userptr_t zsdt, size_t len, size_t offset, void *data) |
Extract "_AUXMAC_" MAC address from DSDT/SSDT. More... | |
static int | acpimac_extract_rtxmac (userptr_t zsdt, size_t len, size_t offset, void *data) |
Extract "_RTXMAC_" MAC address from DSDT/SSDT. More... | |
int | acpi_mac (uint8_t *hw_addr) |
Extract MAC address from DSDT/SSDT. More... | |
static int | sysmac_fetch (void *data, size_t len) |
Fetch system MAC address setting. More... | |
const struct setting sysmac_setting | __setting (SETTING_MISC, sysmac) |
System MAC address setting. More... | |
Variables | |
static struct acpimac_extractor | acpimac_auxmac |
"_AUXMAC_" extraction mechanism More... | |
static struct acpimac_extractor | acpimac_rtxmac |
"_RTXMAC_" extraction mechanism More... | |
struct builtin_setting sysmac_builtin_setting | __builtin_setting |
System MAC address built-in setting. More... | |
ACPI MAC address.
Definition in file acpimac.c.
#define colour FADT_SIGNATURE |
#define AMAC_SIGNATURE ACPI_SIGNATURE ( 'A', 'M', 'A', 'C' ) |
#define MACA_SIGNATURE ACPI_SIGNATURE ( 'M', 'A', 'C', 'A' ) |
#define RTMA_SIGNATURE ACPI_SIGNATURE ( 'R', 'T', 'M', 'A' ) |
#define ACPIMAC_MAX_SKIP 8 |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Decode Base16-encoded MAC address.
mac | Encoded MAC |
hw_addr | MAC address to fill in |
rc | Return status code |
Definition at line 81 of file acpimac.c.
References colour, DBGC, ETH_ALEN, len, mac, rc, and strerror().
|
static |
|
static |
Extract MAC address from DSDT/SSDT.
zsdt | DSDT or SSDT |
len | Length of DSDT/SSDT |
offset | Offset of signature within DSDT/SSDT |
data | Data buffer |
extractor | ACPI MAC address extractor |
rc | Return status code |
Some vendors provide a "system MAC address" within the DSDT/SSDT, to be used to override the MAC address for a USB docking station.
A full implementation would require an ACPI bytecode interpreter, since at least one OEM allows the MAC address to be constructed by executable ACPI bytecode (rather than a fixed data structure).
We instead attempt to extract a plausible-looking "_AUXMAC_#.....#" string that appears shortly after an "AMAC" or "MACA" signature. This should work for most implementations encountered in practice.
Definition at line 145 of file acpimac.c.
References ACPIMAC_MAX_SKIP, colour, copy_from_user(), data, DBGC, DBGC_HDA, acpimac_extractor::decode, EINVAL, ENOENT, eth_ntoa(), is_valid_ether_addr(), len, acpimac_extractor::len, mac, memcmp(), offset, acpimac_extractor::prefix, rc, and strlen().
Referenced by acpimac_extract_auxmac(), and acpimac_extract_rtxmac().
Extract "_AUXMAC_" MAC address from DSDT/SSDT.
zsdt | DSDT or SSDT |
len | Length of DSDT/SSDT |
offset | Offset of signature within DSDT/SSDT |
data | Data buffer |
rc | Return status code |
Definition at line 206 of file acpimac.c.
References acpimac_auxmac, acpimac_extract(), data, len, and offset.
Referenced by acpi_mac().
Extract "_RTXMAC_" MAC address from DSDT/SSDT.
zsdt | DSDT or SSDT |
len | Length of DSDT/SSDT |
offset | Offset of signature within DSDT/SSDT |
data | Data buffer |
rc | Return status code |
Definition at line 221 of file acpimac.c.
References acpimac_extract(), acpimac_rtxmac, data, len, and offset.
Referenced by acpi_mac().
int acpi_mac | ( | uint8_t * | hw_addr | ) |
Extract MAC address from DSDT/SSDT.
hw_addr | MAC address to fill in |
rc | Return status code |
Definition at line 233 of file acpimac.c.
References acpi_extract(), acpimac_extract_auxmac(), acpimac_extract_rtxmac(), AMAC_SIGNATURE, ENOENT, MACA_SIGNATURE, rc, and RTMA_SIGNATURE.
Referenced by ecm_fetch_mac(), sysmac_fetch(), and typeof().
|
static |
Fetch system MAC address setting.
data | Buffer to fill with setting data |
len | Length of buffer |
len | Length of setting data, or negative error |
Definition at line 261 of file acpimac.c.
References acpi_mac(), data, ETH_ALEN, len, mac, memcpy(), and rc.
const struct setting sysmac_setting __setting | ( | SETTING_MISC | , |
sysmac | |||
) |
System MAC address setting.
|
static |
"_AUXMAC_" extraction mechanism
Definition at line 111 of file acpimac.c.
Referenced by acpimac_extract_auxmac().
|
static |
"_RTXMAC_" extraction mechanism
Definition at line 118 of file acpimac.c.
Referenced by acpimac_extract_rtxmac().
struct builtin_setting sysmac_builtin_setting __builtin_setting |
System MAC address built-in setting.