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" 285ea8b9c5SAlistair Francis 2970e23370SJohn Snow typedef struct AHCIDevice AHCIDevice; 3003c7a6a8SSebastian Herbszt 3170e23370SJohn Snow typedef struct AHCIControlRegs { 3270e23370SJohn Snow uint32_t cap; 3370e23370SJohn Snow uint32_t ghc; 3470e23370SJohn Snow uint32_t irqstatus; 3570e23370SJohn Snow uint32_t impl; 3670e23370SJohn Snow uint32_t version; 3770e23370SJohn Snow } AHCIControlRegs; 3803c7a6a8SSebastian Herbszt 3970e23370SJohn Snow typedef struct AHCIState { 4070e23370SJohn Snow DeviceState *container; 4103c7a6a8SSebastian Herbszt 4270e23370SJohn Snow AHCIDevice *dev; 4370e23370SJohn Snow AHCIControlRegs control_regs; 4470e23370SJohn Snow MemoryRegion mem; 4570e23370SJohn Snow MemoryRegion idp; /* Index-Data Pair I/O port space */ 4670e23370SJohn Snow unsigned idp_offset; /* Offset of index in I/O port space */ 4770e23370SJohn Snow uint32_t idp_index; /* Current IDP index */ 4870e23370SJohn Snow int32_t ports; 4970e23370SJohn Snow qemu_irq irq; 5070e23370SJohn Snow AddressSpace *as; 5170e23370SJohn Snow } AHCIState; 5203c7a6a8SSebastian Herbszt 5370e23370SJohn Snow typedef struct AHCIPCIState AHCIPCIState; 5403c7a6a8SSebastian Herbszt 55fd58922cSPeter Crosthwaite #define TYPE_ICH9_AHCI "ich9-ahci" 565e748ffbSEduardo Habkost #define ICH_AHCI(obj) \ 575e748ffbSEduardo Habkost OBJECT_CHECK(AHCIPCIState, (obj), TYPE_ICH9_AHCI) 58fd58922cSPeter Crosthwaite 5970e23370SJohn Snow int32_t ahci_get_num_ports(PCIDevice *dev); 6070e23370SJohn Snow void ahci_ide_create_devs(PCIDevice *dev, DriveInfo **hd); 6103c7a6a8SSebastian Herbszt 625ea8b9c5SAlistair Francis #define TYPE_SYSBUS_AHCI "sysbus-ahci" 635e748ffbSEduardo Habkost #define SYSBUS_AHCI(obj) OBJECT_CHECK(SysbusAHCIState, (obj), TYPE_SYSBUS_AHCI) 645ea8b9c5SAlistair Francis 6570e23370SJohn Snow typedef struct SysbusAHCIState { 6670e23370SJohn Snow /*< private >*/ 6770e23370SJohn Snow SysBusDevice parent_obj; 6870e23370SJohn Snow /*< public >*/ 6970e23370SJohn Snow 7070e23370SJohn Snow AHCIState ahci; 7170e23370SJohn Snow uint32_t num_ports; 7270e23370SJohn Snow } SysbusAHCIState; 7370e23370SJohn Snow 74377e2145SPeter Crosthwaite #define TYPE_ALLWINNER_AHCI "allwinner-ahci" 75*dc15d9ebSEduardo Habkost #define ALLWINNER_AHCI(obj) \ 76*dc15d9ebSEduardo Habkost OBJECT_CHECK(AllwinnerAHCIState, (obj), TYPE_ALLWINNER_AHCI) 77377e2145SPeter Crosthwaite 7870e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_OFF 0x80 7970e23370SJohn Snow #define ALLWINNER_AHCI_MMIO_SIZE 0x80 8070e23370SJohn Snow 81a8b56ec8SPhilippe Mathieu-Daudé typedef struct AllwinnerAHCIState { 8270e23370SJohn Snow /*< private >*/ 8370e23370SJohn Snow SysbusAHCIState parent_obj; 8470e23370SJohn Snow /*< public >*/ 8570e23370SJohn Snow 8670e23370SJohn Snow MemoryRegion mmio; 8770e23370SJohn Snow uint32_t regs[ALLWINNER_AHCI_MMIO_SIZE/4]; 88a8b56ec8SPhilippe Mathieu-Daudé } AllwinnerAHCIState; 8970e23370SJohn Snow 9003c7a6a8SSebastian Herbszt #endif /* HW_IDE_AHCI_H */ 91