-
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.
Add an IPMI table entry to the SMBIOS. Signed-off-by: Corey Minyard <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
- Loading branch information
Showing
6 changed files
with
150 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
common-obj-$(CONFIG_SMBIOS) += smbios.o | ||
common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += smbios_type_38.o |
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,117 @@ | ||
/* | ||
* IPMI SMBIOS firmware handling | ||
* | ||
* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#include "qemu/osdep.h" | ||
#include "hw/ipmi/ipmi.h" | ||
#include "hw/smbios/ipmi.h" | ||
#include "hw/smbios/smbios.h" | ||
#include "qemu/error-report.h" | ||
#include "smbios_build.h" | ||
|
||
/* SMBIOS type 38 - IPMI */ | ||
struct smbios_type_38 { | ||
struct smbios_structure_header header; | ||
uint8_t interface_type; | ||
uint8_t ipmi_spec_revision; | ||
uint8_t i2c_slave_address; | ||
uint8_t nv_storage_device_address; | ||
uint64_t base_address; | ||
uint8_t base_address_modifier; | ||
uint8_t interrupt_number; | ||
} QEMU_PACKED; | ||
|
||
static void smbios_build_one_type_38(IPMIFwInfo *info) | ||
{ | ||
uint64_t baseaddr = info->base_address; | ||
SMBIOS_BUILD_TABLE_PRE(38, 0x3000, true); | ||
|
||
t->interface_type = info->interface_type; | ||
t->ipmi_spec_revision = ((info->ipmi_spec_major_revision << 4) | ||
| info->ipmi_spec_minor_revision); | ||
t->i2c_slave_address = info->i2c_slave_address; | ||
t->nv_storage_device_address = 0; | ||
|
||
assert(info->ipmi_spec_minor_revision <= 15); | ||
assert(info->ipmi_spec_major_revision <= 15); | ||
|
||
/* or 1 to set it to I/O space */ | ||
switch (info->memspace) { | ||
case IPMI_MEMSPACE_IO: | ||
baseaddr |= 1; | ||
break; | ||
case IPMI_MEMSPACE_MEM32: | ||
case IPMI_MEMSPACE_MEM64: | ||
break; | ||
case IPMI_MEMSPACE_SMBUS: | ||
baseaddr <<= 1; | ||
break; | ||
} | ||
|
||
t->base_address = cpu_to_le64(baseaddr); | ||
|
||
t->base_address_modifier = 0; | ||
if (info->irq_type == IPMI_LEVEL_IRQ) { | ||
t->base_address_modifier |= 1; | ||
} | ||
switch (info->register_spacing) { | ||
case 1: | ||
break; | ||
case 4: | ||
t->base_address_modifier |= 1 << 6; | ||
break; | ||
case 16: | ||
t->base_address_modifier |= 2 << 6; | ||
break; | ||
default: | ||
error_report("IPMI register spacing %d is not compatible with" | ||
" SMBIOS, ignoring this entry.", info->register_spacing); | ||
return; | ||
} | ||
t->interrupt_number = info->interrupt_number; | ||
|
||
SMBIOS_BUILD_TABLE_POST; | ||
} | ||
|
||
static void smbios_add_ipmi_devices(BusState *bus) | ||
{ | ||
BusChild *kid; | ||
|
||
QTAILQ_FOREACH(kid, &bus->children, sibling) { | ||
DeviceState *dev = kid->child; | ||
Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_IPMI_INTERFACE); | ||
BusState *childbus; | ||
|
||
if (obj) { | ||
IPMIInterface *ii; | ||
IPMIInterfaceClass *iic; | ||
IPMIFwInfo info; | ||
|
||
ii = IPMI_INTERFACE(obj); | ||
iic = IPMI_INTERFACE_GET_CLASS(obj); | ||
memset(&info, 0, sizeof(info)); | ||
iic->get_fwinfo(ii, &info); | ||
smbios_build_one_type_38(&info); | ||
continue; | ||
} | ||
|
||
QLIST_FOREACH(childbus, &dev->child_bus, sibling) { | ||
smbios_add_ipmi_devices(childbus); | ||
} | ||
} | ||
} | ||
|
||
void smbios_build_type_38_table(void) | ||
{ | ||
BusState *bus; | ||
|
||
bus = sysbus_get_default(); | ||
if (bus) { | ||
smbios_add_ipmi_devices(bus); | ||
} | ||
} |
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,15 @@ | ||
/* | ||
* IPMI SMBIOS firmware handling | ||
* | ||
* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#ifndef QEMU_SMBIOS_IPMI_H | ||
#define QEMU_SMBIOS_IPMI_H | ||
|
||
void smbios_build_type_38_table(void); | ||
|
||
#endif /* QEMU_SMBIOS_IPMI_H */ |
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,14 @@ | ||
/* | ||
* IPMI SMBIOS firmware handling | ||
* | ||
* Copyright (c) 2015,2016 Corey Minyard, MontaVista Software, LLC | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
*/ | ||
|
||
#include "hw/smbios/ipmi.h" | ||
|
||
void smbios_build_type_38_table(void) | ||
{ | ||
} |