Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/smbios/smbios.c
Show All 28 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#if defined(__amd64__) || defined(__aarch64__) | |||||
vangyzen: It would be nice to spell this `#if ARCH_MAY_USE_EFI` so this condition doesn't proliferate. | |||||
dabUnsubmitted Not Done Inline Actions+1 dab: +1 | |||||
#include <sys/efi.h> | |||||
#endif | |||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <machine/resource.h> | #include <machine/resource.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#if defined(__amd64__) || defined(__i386__) | #if defined(__amd64__) || defined(__i386__) | ||||
Not Done Inline Actions<sys/efi.h> already includes <machine/efi.h>, so this is not needed. vangyzen: `<sys/efi.h>` already includes `<machine/efi.h>`, so this is not needed. | |||||
#include <machine/pc/bios.h> | #include <machine/pc/bios.h> | ||||
#endif | #endif | ||||
#include <dev/smbios/smbios.h> | #include <dev/smbios/smbios.h> | ||||
/* | /* | ||||
* System Management BIOS Reference Specification, v2.4 Final | * System Management BIOS Reference Specification, v2.4 Final | ||||
* http://www.dmtf.org/standards/published_documents/DSP0134.pdf | * http://www.dmtf.org/standards/published_documents/DSP0134.pdf | ||||
*/ | */ | ||||
Show All 16 Lines | |||||
static int smbios_detach (device_t); | static int smbios_detach (device_t); | ||||
static int smbios_modevent (module_t, int, void *); | static int smbios_modevent (module_t, int, void *); | ||||
static int smbios_cksum (struct smbios_eps *); | static int smbios_cksum (struct smbios_eps *); | ||||
static void | static void | ||||
smbios_identify (driver_t *driver, device_t parent) | smbios_identify (driver_t *driver, device_t parent) | ||||
{ | { | ||||
#if defined(__amd64__) || defined(__aarch64__) | |||||
static struct uuid efi_smbios = EFI_TABLE_SMBIOS; | |||||
vangyzenUnsubmitted Not Done Inline ActionsI would prefer to put this on the stack instead of permanently wasting 16 bytes. vangyzen: I would prefer to put this on the stack instead of permanently wasting 16 bytes. | |||||
#endif | |||||
struct smbios_eps *eps; | struct smbios_eps *eps; | ||||
device_t child; | device_t child; | ||||
vm_paddr_t addr; | vm_paddr_t addr = 0; | ||||
void *addr_efi; | |||||
vangyzenUnsubmitted Not Done Inline ActionsThis should go under the same #if as efi_smbios. vangyzen: This should go under the same `#if` as `efi_smbios`. | |||||
int length; | int length; | ||||
int rid; | int rid; | ||||
if (!device_is_alive(parent)) | if (!device_is_alive(parent)) | ||||
return; | return; | ||||
#if defined(__amd64__) || defined(__aarch64__) | |||||
if (!efi_get_table(&efi_smbios, &addr_efi)) | |||||
addr = (vm_paddr_t)addr_efi; | |||||
#endif | |||||
#if defined(__amd64__) || defined(__i386__) | #if defined(__amd64__) || defined(__i386__) | ||||
if (addr == 0) | |||||
addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, | addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, | ||||
SMBIOS_STEP, SMBIOS_OFF); | SMBIOS_STEP, SMBIOS_OFF); | ||||
#else | |||||
addr = 0; | |||||
#endif | #endif | ||||
if (addr != 0) { | if (addr != 0) { | ||||
eps = pmap_mapbios(addr, 0x1f); | eps = pmap_mapbios(addr, 0x1f); | ||||
rid = 0; | rid = 0; | ||||
length = eps->length; | length = eps->length; | ||||
if (length != 0x1f) { | if (length != 0x1f) { | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | |||||
static driver_t smbios_driver = { | static driver_t smbios_driver = { | ||||
"smbios", | "smbios", | ||||
smbios_methods, | smbios_methods, | ||||
sizeof(struct smbios_softc), | sizeof(struct smbios_softc), | ||||
}; | }; | ||||
DRIVER_MODULE(smbios, nexus, smbios_driver, smbios_devclass, smbios_modevent, 0); | DRIVER_MODULE(smbios, nexus, smbios_driver, smbios_devclass, smbios_modevent, 0); | ||||
#if defined(__amd64__) || defined(__aarch64__) | |||||
MODULE_DEPEND(smbios, efirt, 1, 1, 1); | |||||
#endif | |||||
MODULE_VERSION(smbios, 1); | MODULE_VERSION(smbios, 1); | ||||
static int | static int | ||||
smbios_cksum (struct smbios_eps *e) | smbios_cksum (struct smbios_eps *e) | ||||
{ | { | ||||
u_int8_t *ptr; | u_int8_t *ptr; | ||||
u_int8_t cksum; | u_int8_t cksum; | ||||
int i; | int i; | ||||
Show All 9 Lines |
It would be nice to spell this #if ARCH_MAY_USE_EFI so this condition doesn't proliferate. Every arch already has <machine/efi.h>, so it would be easy to add.