mirror of https://gitee.com/openkylin/qemu.git
pc: make sata configurable
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com> Message-Id: <1478330391-74060-3-git-send-email-chao.p.peng@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
be232eb076
commit
272f042877
29
hw/i386/pc.c
29
hw/i386/pc.c
|
@ -400,13 +400,13 @@ static void pc_cmos_init_late(void *opaque)
|
||||||
int i, trans;
|
int i, trans;
|
||||||
|
|
||||||
val = 0;
|
val = 0;
|
||||||
if (ide_get_geometry(arg->idebus[0], 0,
|
if (arg->idebus[0] && ide_get_geometry(arg->idebus[0], 0,
|
||||||
&cylinders, &heads, §ors) >= 0) {
|
&cylinders, &heads, §ors) >= 0) {
|
||||||
cmos_init_hd(s, 0x19, 0x1b, cylinders, heads, sectors);
|
cmos_init_hd(s, 0x19, 0x1b, cylinders, heads, sectors);
|
||||||
val |= 0xf0;
|
val |= 0xf0;
|
||||||
}
|
}
|
||||||
if (ide_get_geometry(arg->idebus[0], 1,
|
if (arg->idebus[0] && ide_get_geometry(arg->idebus[0], 1,
|
||||||
&cylinders, &heads, §ors) >= 0) {
|
&cylinders, &heads, §ors) >= 0) {
|
||||||
cmos_init_hd(s, 0x1a, 0x24, cylinders, heads, sectors);
|
cmos_init_hd(s, 0x1a, 0x24, cylinders, heads, sectors);
|
||||||
val |= 0x0f;
|
val |= 0x0f;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,8 @@ static void pc_cmos_init_late(void *opaque)
|
||||||
geometry. It is always such that: 1 <= sects <= 63, 1
|
geometry. It is always such that: 1 <= sects <= 63, 1
|
||||||
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS
|
<= heads <= 16, 1 <= cylinders <= 16383. The BIOS
|
||||||
geometry can be different if a translation is done. */
|
geometry can be different if a translation is done. */
|
||||||
if (ide_get_geometry(arg->idebus[i / 2], i % 2,
|
if (arg->idebus[i / 2] &&
|
||||||
|
ide_get_geometry(arg->idebus[i / 2], i % 2,
|
||||||
&cylinders, &heads, §ors) >= 0) {
|
&cylinders, &heads, §ors) >= 0) {
|
||||||
trans = ide_get_bios_chs_trans(arg->idebus[i / 2], i % 2) - 1;
|
trans = ide_get_bios_chs_trans(arg->idebus[i / 2], i % 2) - 1;
|
||||||
assert((trans & ~3) == 0);
|
assert((trans & ~3) == 0);
|
||||||
|
@ -2172,6 +2173,20 @@ static void pc_machine_set_smbus(Object *obj, bool value, Error **errp)
|
||||||
pcms->smbus = value;
|
pcms->smbus = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool pc_machine_get_sata(Object *obj, Error **errp)
|
||||||
|
{
|
||||||
|
PCMachineState *pcms = PC_MACHINE(obj);
|
||||||
|
|
||||||
|
return pcms->sata;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pc_machine_set_sata(Object *obj, bool value, Error **errp)
|
||||||
|
{
|
||||||
|
PCMachineState *pcms = PC_MACHINE(obj);
|
||||||
|
|
||||||
|
pcms->sata = value;
|
||||||
|
}
|
||||||
|
|
||||||
static void pc_machine_initfn(Object *obj)
|
static void pc_machine_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
PCMachineState *pcms = PC_MACHINE(obj);
|
PCMachineState *pcms = PC_MACHINE(obj);
|
||||||
|
@ -2184,6 +2199,7 @@ static void pc_machine_initfn(Object *obj)
|
||||||
/* acpi build is enabled by default if machine supports it */
|
/* acpi build is enabled by default if machine supports it */
|
||||||
pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build;
|
pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build;
|
||||||
pcms->smbus = true;
|
pcms->smbus = true;
|
||||||
|
pcms->sata = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pc_machine_reset(void)
|
static void pc_machine_reset(void)
|
||||||
|
@ -2347,6 +2363,9 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
|
||||||
|
|
||||||
object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
|
object_class_property_add_bool(oc, PC_MACHINE_SMBUS,
|
||||||
pc_machine_get_smbus, pc_machine_set_smbus, &error_abort);
|
pc_machine_get_smbus, pc_machine_set_smbus, &error_abort);
|
||||||
|
|
||||||
|
object_class_property_add_bool(oc, PC_MACHINE_SATA,
|
||||||
|
pc_machine_get_sata, pc_machine_set_sata, &error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo pc_machine_info = {
|
static const TypeInfo pc_machine_info = {
|
||||||
|
|
|
@ -232,16 +232,20 @@ static void pc_q35_init(MachineState *machine)
|
||||||
/* connect pm stuff to lpc */
|
/* connect pm stuff to lpc */
|
||||||
ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms));
|
ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms));
|
||||||
|
|
||||||
/* ahci and SATA device, for q35 1 ahci controller is built-in */
|
if (pcms->sata) {
|
||||||
ahci = pci_create_simple_multifunction(host_bus,
|
/* ahci and SATA device, for q35 1 ahci controller is built-in */
|
||||||
PCI_DEVFN(ICH9_SATA1_DEV,
|
ahci = pci_create_simple_multifunction(host_bus,
|
||||||
ICH9_SATA1_FUNC),
|
PCI_DEVFN(ICH9_SATA1_DEV,
|
||||||
true, "ich9-ahci");
|
ICH9_SATA1_FUNC),
|
||||||
idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0");
|
true, "ich9-ahci");
|
||||||
idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1");
|
idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0");
|
||||||
g_assert(MAX_SATA_PORTS == ICH_AHCI(ahci)->ahci.ports);
|
idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1");
|
||||||
ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports);
|
g_assert(MAX_SATA_PORTS == ICH_AHCI(ahci)->ahci.ports);
|
||||||
ahci_ide_create_devs(ahci, hd);
|
ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports);
|
||||||
|
ahci_ide_create_devs(ahci, hd);
|
||||||
|
} else {
|
||||||
|
idebus[0] = idebus[1] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (machine_usb(machine)) {
|
if (machine_usb(machine)) {
|
||||||
/* Should we create 6 UHCI according to ich9 spec? */
|
/* Should we create 6 UHCI according to ich9 spec? */
|
||||||
|
|
|
@ -64,6 +64,7 @@ struct PCMachineState {
|
||||||
|
|
||||||
bool acpi_build_enabled;
|
bool acpi_build_enabled;
|
||||||
bool smbus;
|
bool smbus;
|
||||||
|
bool sata;
|
||||||
|
|
||||||
/* RAM information (sizes, addresses, configuration): */
|
/* RAM information (sizes, addresses, configuration): */
|
||||||
ram_addr_t below_4g_mem_size, above_4g_mem_size;
|
ram_addr_t below_4g_mem_size, above_4g_mem_size;
|
||||||
|
@ -90,6 +91,7 @@ struct PCMachineState {
|
||||||
#define PC_MACHINE_SMM "smm"
|
#define PC_MACHINE_SMM "smm"
|
||||||
#define PC_MACHINE_NVDIMM "nvdimm"
|
#define PC_MACHINE_NVDIMM "nvdimm"
|
||||||
#define PC_MACHINE_SMBUS "smbus"
|
#define PC_MACHINE_SMBUS "smbus"
|
||||||
|
#define PC_MACHINE_SATA "sata"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PCMachineClass:
|
* PCMachineClass:
|
||||||
|
|
Loading…
Reference in New Issue