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 24*70e23370SJohn Snow #ifndef HW_IDE_AHCI_H 25*70e23370SJohn Snow #define HW_IDE_AHCI_H 2603c7a6a8SSebastian Herbszt 27a9c94277SMarkus Armbruster #include "hw/sysbus.h" 285ea8b9c5SAlistair Francis 29*70e23370SJohn Snow typedef struct AHCIDevice AHCIDevice; 3003c7a6a8SSebastian Herbszt 31*70e23370SJohn Snow typedef struct AHCIControlRegs { 32*70e23370SJohn Snow uint32_t cap; 33*70e23370SJohn Snow uint32_t ghc; 34*70e23370SJohn Snow uint32_t irqstatus; 35*70e23370SJohn Snow uint32_t impl; 36*70e23370SJohn Snow uint32_t version; 37*70e23370SJohn Snow } AHCIControlRegs; 3803c7a6a8SSebastian Herbszt 39*70e23370SJohn Snow typedef struct AHCIState { 40*70e23370SJohn Snow DeviceState *container; 4103c7a6a8SSebastian Herbszt 42*70e23370SJohn Snow AHCIDevice *dev; 43*70e23370SJohn Snow AHCIControlRegs control_regs; 44*70e23370SJohn Snow MemoryRegion mem; 45*70e23370SJohn Snow MemoryRegion idp; /* Index-Data Pair I/O port space */ 46*70e23370SJohn Snow unsigned idp_offset; /* Offset of index in I/O port space */ 47*70e23370SJohn Snow uint32_t idp_index; /* Current IDP index */ 48*70e23370SJohn Snow int32_t ports; 49*70e23370SJohn Snow qemu_irq irq; 50*70e23370SJohn Snow AddressSpace *as; 51*70e23370SJohn Snow } AHCIState; 5203c7a6a8SSebastian Herbszt 53*70e23370SJohn Snow typedef struct AHCIPCIState AHCIPCIState; 5403c7a6a8SSebastian Herbszt 55fd58922cSPeter Crosthwaite #define TYPE_ICH9_AHCI "ich9-ahci" 56fd58922cSPeter Crosthwaite 57fd58922cSPeter Crosthwaite #define ICH_AHCI(obj) \ 58fd58922cSPeter Crosthwaite OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH9_AHCI) 59fd58922cSPeter Crosthwaite 60*70e23370SJohn Snow int32_t ahci_get_num_ports(PCIDevice *dev); 61*70e23370SJohn Snow void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd); 6203c7a6a8SSebastian Herbszt 635ea8b9c5SAlistair Francis #define TYPE_SYSBUS_AHCI "sysbus-ahci" 645ea8b9c5SAlistair Francis #define SYSBUS_AHCI(obj) OBJECT_CHECK(SysbusAHCIState, (obj), TYPE_SYSBUS_AHCI) 655ea8b9c5SAlistair Francis 66*70e23370SJohn Snow typedef struct SysbusAHCIState { 67*70e23370SJohn Snow /*< private >*/ 68*70e23370SJohn Snow SysBusDevice parent_obj; 69*70e23370SJohn Snow /*< public >*/ 70*70e23370SJohn Snow 71*70e23370SJohn Snow AHCIState ahci; 72*70e23370SJohn Snow uint32_t num_ports; 73*70e23370SJohn Snow } SysbusAHCIState; 74*70e23370SJohn Snow 75377e2145SPeter Crosthwaite #define TYPE_ALLWINNER_AHCI "allwinner-ahci" 76377e2145SPeter Crosthwaite #define ALLWINNER_AHCI(obj) OBJECT_CHECK(AllwinnerAHCIState, (obj), \ 77377e2145SPeter Crosthwaite TYPE_ALLWINNER_AHCI) 78377e2145SPeter Crosthwaite 79*70e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_OFF 0x80 80*70e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_SIZE 0x80 81*70e23370SJohn Snow 82*70e23370SJohn Snow struct AllwinnerAHCIState { 83*70e23370SJohn Snow /*< private >*/ 84*70e23370SJohn Snow SysbusAHCIState parent_obj; 85*70e23370SJohn Snow /*< public >*/ 86*70e23370SJohn Snow 87*70e23370SJohn Snow MemoryRegion mmio; 88*70e23370SJohn Snow uint32_t regs[ALLWINNER_AHCI_MMIO_SIZE/4]; 89*70e23370SJohn Snow }; 90*70e23370SJohn Snow 9103c7a6a8SSebastian Herbszt #endif /* HW_IDE_AHCI_H */ 92