[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/15] macio: convert to pci_bar_map
From: |
Blue Swirl |
Subject: |
[Qemu-devel] [PATCH 05/15] macio: convert to pci_bar_map |
Date: |
Mon, 12 Jul 2010 18:40:41 +0000 |
Use pci_bar_map() instead of a mapping function.
Signed-off-by: Blue Swirl <address@hidden>
---
hw/macio.c | 107 ++++++++++++++++------------------------------------
hw/ppc_mac.h | 5 +-
hw/ppc_newworld.c | 2 +-
hw/ppc_oldworld.c | 4 +-
4 files changed, 39 insertions(+), 79 deletions(-)
diff --git a/hw/macio.c b/hw/macio.c
index 789ca55..8717bc0 100644
--- a/hw/macio.c
+++ b/hw/macio.c
@@ -27,83 +27,16 @@
#include "pci.h"
#include "escc.h"
-typedef struct macio_state_t macio_state_t;
-struct macio_state_t {
- int is_oldworld;
- int pic_mem_index;
- int dbdma_mem_index;
- int cuda_mem_index;
- int escc_mem_index;
- void *nvram;
- int nb_ide;
- int ide_mem_index[4];
-};
-
-static void macio_map (PCIDevice *pci_dev, int region_num,
- pcibus_t addr, pcibus_t size, int type)
-{
- macio_state_t *macio_state;
- int i;
-
- macio_state = (macio_state_t *)(pci_dev + 1);
- if (macio_state->pic_mem_index >= 0) {
- if (macio_state->is_oldworld) {
- /* Heathrow PIC */
- cpu_register_physical_memory(addr + 0x00000, 0x1000,
- macio_state->pic_mem_index);
- } else {
- /* OpenPIC */
- cpu_register_physical_memory(addr + 0x40000, 0x40000,
- macio_state->pic_mem_index);
- }
- }
- if (macio_state->dbdma_mem_index >= 0) {
- cpu_register_physical_memory(addr + 0x08000, 0x1000,
- macio_state->dbdma_mem_index);
- }
- if (macio_state->escc_mem_index >= 0) {
- cpu_register_physical_memory(addr + 0x13000, ESCC_SIZE << 4,
- macio_state->escc_mem_index);
- }
- if (macio_state->cuda_mem_index >= 0) {
- cpu_register_physical_memory(addr + 0x16000, 0x2000,
- macio_state->cuda_mem_index);
- }
- for (i = 0; i < macio_state->nb_ide; i++) {
- if (macio_state->ide_mem_index[i] >= 0) {
- cpu_register_physical_memory(addr + 0x1f000 + (i * 0x1000), 0x1000,
- macio_state->ide_mem_index[i]);
- }
- }
- if (macio_state->nvram != NULL)
- macio_nvram_map(macio_state->nvram, addr + 0x60000);
-}
-
void macio_init (PCIBus *bus, int device_id, int is_oldworld, int
pic_mem_index,
- int dbdma_mem_index, int cuda_mem_index, void *nvram,
- int nb_ide, int *ide_mem_index, int escc_mem_index)
+ int dbdma_mem_index, int cuda_mem_index, int nvram_size,
+ int nvram_mem_index, int nb_ide, int *ide_mem_index,
+ int escc_mem_index)
{
PCIDevice *d;
- macio_state_t *macio_state;
int i;
- d = pci_register_device(bus, "macio",
- sizeof(PCIDevice) + sizeof(macio_state_t),
- -1, NULL, NULL);
- macio_state = (macio_state_t *)(d + 1);
- macio_state->is_oldworld = is_oldworld;
- macio_state->pic_mem_index = pic_mem_index;
- macio_state->dbdma_mem_index = dbdma_mem_index;
- macio_state->cuda_mem_index = cuda_mem_index;
- macio_state->escc_mem_index = escc_mem_index;
- macio_state->nvram = nvram;
- if (nb_ide > 4)
- nb_ide = 4;
- macio_state->nb_ide = nb_ide;
- for (i = 0; i < nb_ide; i++)
- macio_state->ide_mem_index[i] = ide_mem_index[i];
- for (; i < 4; i++)
- macio_state->ide_mem_index[i] = -1;
+ d = pci_register_device(bus, "macio", sizeof(PCIDevice), -1, NULL, NULL);
+
/* Note: this code is strongly inspirated from the corresponding code
in PearPC */
@@ -113,6 +46,32 @@ void macio_init (PCIBus *bus, int device_id, int
is_oldworld, int pic_mem_index,
d->config[0x3d] = 0x01; // interrupt on pin 1
- pci_register_bar(d, 0, 0x80000,
- PCI_BASE_ADDRESS_SPACE_MEMORY, macio_map);
+ pci_register_bar(d, 0, 0x80000, PCI_BASE_ADDRESS_SPACE_MEMORY, NULL);
+ if (pic_mem_index >= 0) {
+ if (is_oldworld) {
+ /* Heathrow PIC */
+ pci_bar_map(d, 0, 0, 0x1000, 0, pic_mem_index);
+ } else {
+ /* OpenPIC */
+ pci_bar_map(d, 0, 0, 0x40000, 0x40000, pic_mem_index);
+ }
+ }
+ if (dbdma_mem_index >= 0) {
+ pci_bar_map(d, 0, 1, 0x8000, 0x1000, dbdma_mem_index);
+ }
+ if (escc_mem_index >= 0) {
+ pci_bar_map(d, 0, 2, 0x13000, ESCC_SIZE << 4, escc_mem_index);
+ }
+ if (cuda_mem_index >= 0) {
+ pci_bar_map(d, 0, 3, 0x16000, 0x2000, cuda_mem_index);
+ }
+ for (i = 0; i < nb_ide; i++) {
+ if (ide_mem_index[i] >= 0) {
+ pci_bar_map(d, 0, 4 + i, 0x1f000 + (i * 0x1000), 0x1000,
+ ide_mem_index[i]);
+ }
+ }
+ if (nvram_mem_index >= 0) {
+ pci_bar_map(d, 0, 4 + nb_ide, 0x60000, nvram_size, nvram_mem_index);
+ }
}
diff --git a/hw/ppc_mac.h b/hw/ppc_mac.h
index 89f96bb..6b3e27f 100644
--- a/hw/ppc_mac.h
+++ b/hw/ppc_mac.h
@@ -46,8 +46,9 @@ void cuda_init (int *cuda_mem_index, qemu_irq irq);
/* MacIO */
void macio_init (PCIBus *bus, int device_id, int is_oldworld, int
pic_mem_index,
- int dbdma_mem_index, int cuda_mem_index, void *nvram,
- int nb_ide, int *ide_mem_index, int escc_mem_index);
+ int dbdma_mem_index, int cuda_mem_index, int nvram_size,
+ int nvram_mem_index, int nb_ide, int *ide_mem_index,
+ int escc_mem_index);
/* Heathrow PIC */
qemu_irq *heathrow_pic_init(int *pmem_index,
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index fbba9b6..75fef3c 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -383,7 +383,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
adb_mouse_init(&adb_bus);
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
- dbdma_mem_index, cuda_mem_index, NULL, 3, ide_mem_index,
+ dbdma_mem_index, cuda_mem_index, -1, 0, 3, ide_mem_index,
escc_mem_index);
if (usb_enabled) {
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 6b3ab89..220dca7 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -366,8 +366,8 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
pmac_format_nvram_partition(nvr, 0x2000);
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index,
- dbdma_mem_index, cuda_mem_index, nvr, 2, ide_mem_index,
- escc_mem_index);
+ dbdma_mem_index, cuda_mem_index, nvram_mem_index, 0x2000,
+ 2, ide_mem_index, escc_mem_index);
if (usb_enabled) {
usb_ohci_init_pci(pci_bus, -1);
--
1.7.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 05/15] macio: convert to pci_bar_map,
Blue Swirl <=