1f83a40dcSAlexander Graf /* 2f83a40dcSAlexander Graf * QEMU AHCI Emulation 3f83a40dcSAlexander Graf * 4f83a40dcSAlexander Graf * Copyright (c) 2010 qiaochong@loongson.cn 5f83a40dcSAlexander Graf * Copyright (c) 2010 Roland Elek <elek.roland@gmail.com> 6f83a40dcSAlexander Graf * Copyright (c) 2010 Sebastian Herbszt <herbszt@gmx.de> 7f83a40dcSAlexander Graf * Copyright (c) 2010 Alexander Graf <agraf@suse.de> 8f83a40dcSAlexander Graf * 9f83a40dcSAlexander Graf * This library is free software; you can redistribute it and/or 10f83a40dcSAlexander Graf * modify it under the terms of the GNU Lesser General Public 11f83a40dcSAlexander Graf * License as published by the Free Software Foundation; either 12f83a40dcSAlexander Graf * version 2 of the License, or (at your option) any later version. 13f83a40dcSAlexander Graf * 14f83a40dcSAlexander Graf * This library is distributed in the hope that it will be useful, 15f83a40dcSAlexander Graf * but WITHOUT ANY WARRANTY; without even the implied warranty of 16f83a40dcSAlexander Graf * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17f83a40dcSAlexander Graf * Lesser General Public License for more details. 18f83a40dcSAlexander Graf * 19f83a40dcSAlexander Graf * You should have received a copy of the GNU Lesser General Public 20f83a40dcSAlexander Graf * License along with this library; if not, see <http://www.gnu.org/licenses/>. 21f83a40dcSAlexander Graf * 22f83a40dcSAlexander Graf */ 23f83a40dcSAlexander Graf 2470e23370SJohn Snow #ifndef HW_IDE_AHCI_H 2570e23370SJohn Snow #define HW_IDE_AHCI_H 2603c7a6a8SSebastian Herbszt 27a9c94277SMarkus Armbruster #include "hw/sysbus.h" 28*db1015e9SEduardo Habkost #include "qom/object.h" 295ea8b9c5SAlistair Francis 3070e23370SJohn Snow typedef struct AHCIDevice AHCIDevice; 3103c7a6a8SSebastian Herbszt 3270e23370SJohn Snow typedef struct AHCIControlRegs { 3370e23370SJohn Snow uint32_t cap; 3470e23370SJohn Snow uint32_t ghc; 3570e23370SJohn Snow uint32_t irqstatus; 3670e23370SJohn Snow uint32_t impl; 3770e23370SJohn Snow uint32_t version; 3870e23370SJohn Snow } AHCIControlRegs; 3903c7a6a8SSebastian Herbszt 4070e23370SJohn Snow typedef struct AHCIState { 4170e23370SJohn Snow DeviceState *container; 4203c7a6a8SSebastian Herbszt 4370e23370SJohn Snow AHCIDevice *dev; 4470e23370SJohn Snow AHCIControlRegs control_regs; 4570e23370SJohn Snow MemoryRegion mem; 4670e23370SJohn Snow MemoryRegion idp; /* Index-Data Pair I/O port space */ 4770e23370SJohn Snow unsigned idp_offset; /* Offset of index in I/O port space */ 4870e23370SJohn Snow uint32_t idp_index; /* Current IDP index */ 4970e23370SJohn Snow int32_t ports; 5070e23370SJohn Snow qemu_irq irq; 5170e23370SJohn Snow AddressSpace *as; 5270e23370SJohn Snow } AHCIState; 5303c7a6a8SSebastian Herbszt 5470e23370SJohn Snow typedef struct AHCIPCIState AHCIPCIState; 5503c7a6a8SSebastian Herbszt 56fd58922cSPeter Crosthwaite #define TYPE_ICH9_AHCI "ich9-ahci" 575e748ffbSEduardo Habkost #define ICH_AHCI(obj) \ 585e748ffbSEduardo Habkost OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH9_AHCI) 59fd58922cSPeter Crosthwaite 6070e23370SJohn Snow int32_t ahci_get_num_ports(PCIDevice *dev); 6170e23370SJohn Snow void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd); 6203c7a6a8SSebastian Herbszt 635ea8b9c5SAlistair Francis #define TYPE_SYSBUS_AHCI "sysbus-ahci" 64*db1015e9SEduardo Habkost typedef struct SysbusAHCIState SysbusAHCIState; 655e748ffbSEduardo Habkost #define SYSBUS_AHCI(obj) OBJECT_CHECK(SysbusAHCIState, (obj), TYPE_SYSBUS_AHCI) 665ea8b9c5SAlistair Francis 67*db1015e9SEduardo Habkost struct SysbusAHCIState { 6870e23370SJohn Snow /*< private >*/ 6970e23370SJohn Snow SysBusDevice parent_obj; 7070e23370SJohn Snow /*< public >*/ 7170e23370SJohn Snow 7270e23370SJohn Snow AHCIState ahci; 7370e23370SJohn Snow uint32_t num_ports; 74*db1015e9SEduardo Habkost }; 7570e23370SJohn Snow 76377e2145SPeter Crosthwaite #define TYPE_ALLWINNER_AHCI "allwinner-ahci" 77*db1015e9SEduardo Habkost typedef struct AllwinnerAHCIState AllwinnerAHCIState; 78dc15d9ebSEduardo Habkost #define ALLWINNER_AHCI(obj) \ 79dc15d9ebSEduardo Habkost OBJECT_CHECK(AllwinnerAHCIState, (obj), TYPE_ALLWINNER_AHCI) 80377e2145SPeter Crosthwaite 8170e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_OFF 0x80 8270e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_SIZE 0x80 8370e23370SJohn Snow 84*db1015e9SEduardo Habkost struct AllwinnerAHCIState { 8570e23370SJohn Snow /*< private >*/ 8670e23370SJohn Snow SysbusAHCIState parent_obj; 8770e23370SJohn Snow /*< public >*/ 8870e23370SJohn Snow 8970e23370SJohn Snow MemoryRegion mmio; 9070e23370SJohn Snow uint32_t regs[ALLWINNER_AHCI_MMIO_SIZE/4]; 91*db1015e9SEduardo Habkost }; 9270e23370SJohn Snow 9303c7a6a8SSebastian Herbszt #endif /* HW_IDE_AHCI_H */ 94