From: Alexander Graf <alex@csgraf.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 7/9] Intel Mac machine
Date: Tue, 08 Jan 2008 16:22:57 +0100 [thread overview]
Message-ID: <47839551.2070804@csgraf.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 240 bytes --]
To leave the default behavior unchanged, this adds a "mac" machine
definition for x86 that automatically chooses the right hardware for an
emulated Intel Mac.
As x86 did not really know about models, the also adds a simple model
interface.
[-- Attachment #2: qemu-intelmac.patch --]
[-- Type: text/x-patch, Size: 8982 bytes --]
Index: qemu-snapshot-2008-01-08_05/hw/boards.h
===================================================================
--- qemu-snapshot-2008-01-08_05.orig/hw/boards.h
+++ qemu-snapshot-2008-01-08_05/hw/boards.h
@@ -23,6 +23,7 @@ int qemu_register_machine(QEMUMachine *m
extern QEMUMachine bareetraxfs_machine;
/* pc.c */
+extern QEMUMachine mac_machine;
extern QEMUMachine pc_machine;
extern QEMUMachine isapc_machine;
Index: qemu-snapshot-2008-01-08_05/hw/pc.c
===================================================================
--- qemu-snapshot-2008-01-08_05.orig/hw/pc.c
+++ qemu-snapshot-2008-01-08_05/hw/pc.c
@@ -57,6 +57,12 @@ static PITState *pit;
static IOAPICState *ioapic;
static PCIDevice *i440fx_state;
+enum pc_model {
+ MODEL_ISA = 0,
+ MODEL_PCI = 1,
+ MODEL_MAC = 2
+};
+
static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)
{
}
@@ -708,7 +714,7 @@ static void pc_init1(int ram_size, int v
const char *boot_device, DisplayState *ds,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename,
- int pci_enabled, const char *cpu_model)
+ int model, const char *cpu_model)
{
char buf[1024];
int ret, linux_boot, i;
@@ -730,11 +736,15 @@ static void pc_init1(int ram_size, int v
/* init CPUs */
if (cpu_model == NULL) {
+ if(model == MODEL_MAC) {
+ cpu_model = "coreduo";
+ } else {
#ifdef TARGET_X86_64
- cpu_model = "qemu64";
+ cpu_model = "qemu64";
#else
- cpu_model = "qemu32";
+ cpu_model = "qemu32";
#endif
+ }
}
for(i = 0; i < smp_cpus; i++) {
@@ -751,7 +761,7 @@ static void pc_init1(int ram_size, int v
}
register_savevm("cpu", i, 4, cpu_save, cpu_load, env);
qemu_register_reset(main_cpu_reset, env);
- if (pci_enabled) {
+ if (model > MODEL_ISA) {
apic_init(env);
}
vmport_init(env);
@@ -888,7 +898,7 @@ static void pc_init1(int ram_size, int v
i8259 = i8259_init(cpu_irq[0]);
ferr_irq = i8259[13];
- if (pci_enabled) {
+ if (model > MODEL_ISA) {
pci_bus = i440fx_init(&i440fx_state, i8259);
piix3_devfn = piix3_init(pci_bus, -1);
} else {
@@ -901,7 +911,7 @@ static void pc_init1(int ram_size, int v
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (cirrus_vga_enabled) {
- if (pci_enabled) {
+ if (model > MODEL_ISA) {
pci_cirrus_vga_init(pci_bus,
ds, phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size);
@@ -910,13 +920,13 @@ static void pc_init1(int ram_size, int v
vga_ram_addr, vga_ram_size);
}
} else if (vmsvga_enabled) {
- if (pci_enabled)
+ if (model > MODEL_ISA)
pci_vmsvga_init(pci_bus, ds, phys_ram_base + ram_size,
ram_size, vga_ram_size);
else
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
} else {
- if (pci_enabled) {
+ if (model > MODEL_ISA) {
pci_vga_init(pci_bus, ds, phys_ram_base + vga_ram_addr,
vga_ram_addr, vga_ram_size, 0, 0);
} else {
@@ -930,12 +940,18 @@ static void pc_init1(int ram_size, int v
register_ioport_read(0x92, 1, 1, ioport92_read, NULL);
register_ioport_write(0x92, 1, 1, ioport92_write, NULL);
- if (pci_enabled) {
- ioapic = ioapic_init();
+
+ switch(model) {
+ case MODEL_MAC:
+ applesmc_init();
+ lpc_init(pci_bus, piix3_devfn, i8259);
+ case MODEL_PCI:
+ ioapic = ioapic_init();
+ break;
}
pit = pit_init(0x40, i8259[0]);
pcspk_init(pit);
- if (pci_enabled) {
+ if (model > MODEL_ISA) {
pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
}
@@ -955,15 +971,21 @@ static void pc_init1(int ram_size, int v
for(i = 0; i < nb_nics; i++) {
nd = &nd_table[i];
if (!nd->model) {
- if (pci_enabled) {
- nd->model = "ne2k_pci";
- } else {
- nd->model = "ne2k_isa";
+ switch(model) {
+ case MODEL_ISA:
+ nd->model = "ne2k_isa";
+ break;
+ case MODEL_MAC:
+ nd->model = "rtl8139";
+ break;
+ default:
+ nd->model = "ne2k_pci";
+ break;
}
}
if (strcmp(nd->model, "ne2k_isa") == 0) {
pc_init_ne2k_isa(nd, i8259);
- } else if (pci_enabled) {
+ } else if (model > MODEL_ISA) {
if (strcmp(nd->model, "?") == 0)
fprintf(stderr, "qemu: Supported ISA NICs: ne2k_isa\n");
pci_nic_init(pci_bus, nd, -1);
@@ -989,19 +1011,25 @@ static void pc_init1(int ram_size, int v
hd[i] = NULL;
}
- if (pci_enabled) {
- pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1, i8259);
- } else {
- for(i = 0; i < MAX_IDE_BUS; i++) {
- isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
- hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
- }
+ switch(model) {
+ case MODEL_MAC:
+ pci_ich6_ide_init(pci_bus, hd, piix3_devfn + 1, i8259);
+ break;
+ case MODEL_PCI:
+ pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1, i8259);
+ break;
+ default:
+ for(i = 0; i < 2; i++) {
+ isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
+ hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
+ }
+ break;
}
i8042_init(i8259[1], i8259[12], 0x60);
DMA_init(0);
#ifdef HAS_AUDIO
- audio_init(pci_enabled ? pci_bus : NULL, i8259);
+ audio_init((model > MODEL_ISA) ? pci_bus : NULL, i8259);
#endif
for(i = 0; i < MAX_FD; i++) {
@@ -1015,11 +1043,11 @@ static void pc_init1(int ram_size, int v
cmos_init(ram_size, boot_device, hd);
- if (pci_enabled && usb_enabled) {
+ if ((model > MODEL_ISA) && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
}
- if (pci_enabled && acpi_enabled) {
+ if ((model > MODEL_ISA) && acpi_enabled) {
uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
i2c_bus *smbus;
@@ -1034,7 +1062,7 @@ static void pc_init1(int ram_size, int v
i440fx_init_memory_mappings(i440fx_state);
}
- if (pci_enabled) {
+ if (model > MODEL_ISA) {
int max_bus;
int bus, unit;
void *scsi;
@@ -1053,6 +1081,18 @@ static void pc_init1(int ram_size, int v
}
}
+static void pc_init_mac(int ram_size, int vga_ram_size,
+ const char *boot_device, DisplayState *ds,
+ const char *kernel_filename,
+ const char *kernel_cmdline,
+ const char *initrd_filename,
+ const char *cpu_model)
+{
+ pc_init1(ram_size, vga_ram_size, boot_device, ds,
+ kernel_filename, kernel_cmdline,
+ initrd_filename, MODEL_MAC, cpu_model);
+}
+
static void pc_init_pci(int ram_size, int vga_ram_size,
const char *boot_device, DisplayState *ds,
const char *kernel_filename,
@@ -1062,7 +1102,7 @@ static void pc_init_pci(int ram_size, in
{
pc_init1(ram_size, vga_ram_size, boot_device, ds,
kernel_filename, kernel_cmdline,
- initrd_filename, 1, cpu_model);
+ initrd_filename, MODEL_PCI, cpu_model);
}
static void pc_init_isa(int ram_size, int vga_ram_size,
@@ -1074,7 +1114,7 @@ static void pc_init_isa(int ram_size, in
{
pc_init1(ram_size, vga_ram_size, boot_device, ds,
kernel_filename, kernel_cmdline,
- initrd_filename, 0, cpu_model);
+ initrd_filename, MODEL_ISA, cpu_model);
}
QEMUMachine pc_machine = {
@@ -1083,6 +1123,12 @@ QEMUMachine pc_machine = {
pc_init_pci,
};
+QEMUMachine mac_machine = {
+ "mac",
+ "Intel-Mac",
+ pc_init_mac,
+};
+
QEMUMachine isapc_machine = {
"isapc",
"ISA-only PC",
Index: qemu-snapshot-2008-01-08_05/vl.c
===================================================================
--- qemu-snapshot-2008-01-08_05.orig/vl.c
+++ qemu-snapshot-2008-01-08_05/vl.c
@@ -7881,6 +7881,7 @@ static void register_machines(void)
{
#if defined(TARGET_I386)
qemu_register_machine(&pc_machine);
+ qemu_register_machine(&mac_machine);
qemu_register_machine(&isapc_machine);
#elif defined(TARGET_PPC)
qemu_register_machine(&heathrow_machine);
reply other threads:[~2008-01-08 15:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47839551.2070804@csgraf.de \
--to=alex@csgraf.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).