/*1* ioreq.h: I/O request definitions for device models2* Copyright (c) 2004, Intel Corporation.3*4* Permission is hereby granted, free of charge, to any person obtaining a copy5* of this software and associated documentation files (the "Software"), to6* deal in the Software without restriction, including without limitation the7* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or8* sell copies of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#ifndef _IOREQ_H_24#define _IOREQ_H_2526#define IOREQ_READ 127#define IOREQ_WRITE 02829#define STATE_IOREQ_NONE 030#define STATE_IOREQ_READY 131#define STATE_IOREQ_INPROCESS 232#define STATE_IORESP_READY 33334#define IOREQ_TYPE_PIO 0 /* pio */35#define IOREQ_TYPE_COPY 1 /* mmio ops */36#define IOREQ_TYPE_PCI_CONFIG 237#define IOREQ_TYPE_TIMEOFFSET 738#define IOREQ_TYPE_INVALIDATE 8 /* mapcache */3940/*41* VMExit dispatcher should cooperate with instruction decoder to42* prepare this structure and notify service OS and DM by sending43* virq.44*45* For I/O type IOREQ_TYPE_PCI_CONFIG, the physical address is formatted46* as follows:47*48* 63....48|47..40|39..35|34..32|31........049* SEGMENT |BUS |DEV |FN |OFFSET50*/51struct ioreq {52uint64_t addr; /* physical address */53uint64_t data; /* data (or paddr of data) */54uint32_t count; /* for rep prefixes */55uint32_t size; /* size in bytes */56uint32_t vp_eport; /* evtchn for notifications to/from device model */57uint16_t _pad0;58uint8_t state:4;59uint8_t data_is_ptr:1; /* if 1, data above is the guest paddr60* of the real data to use. */61uint8_t dir:1; /* 1=read, 0=write */62uint8_t df:1;63uint8_t _pad1:1;64uint8_t type; /* I/O type */65};66typedef struct ioreq ioreq_t;6768struct shared_iopage {69struct ioreq vcpu_ioreq[1];70};71typedef struct shared_iopage shared_iopage_t;7273struct buf_ioreq {74uint8_t type; /* I/O type */75uint8_t pad:1;76uint8_t dir:1; /* 1=read, 0=write */77uint8_t size:2; /* 0=>1, 1=>2, 2=>4, 3=>8. If 8, use two buf_ioreqs */78uint32_t addr:20;/* physical address */79uint32_t data; /* data */80};81typedef struct buf_ioreq buf_ioreq_t;8283#define IOREQ_BUFFER_SLOT_NUM 511 /* 8 bytes each, plus 2 4-byte indexes */84struct buffered_iopage {85#ifdef __XEN__86union bufioreq_pointers {87struct {88#endif89uint32_t read_pointer;90uint32_t write_pointer;91#ifdef __XEN__92};93uint64_t full;94} ptrs;95#endif96buf_ioreq_t buf_ioreq[IOREQ_BUFFER_SLOT_NUM];97}; /* NB. Size of this structure must be no greater than one page. */98typedef struct buffered_iopage buffered_iopage_t;99100/*101* ACPI Control/Event register locations. Location is controlled by a102* version number in HVM_PARAM_ACPI_IOPORTS_LOCATION.103*/104105/*106* Version 0 (default): Traditional (obsolete) Xen locations.107*108* These are now only used for compatibility with VMs migrated109* from older Xen versions.110*/111#define ACPI_PM1A_EVT_BLK_ADDRESS_V0 0x1f40112#define ACPI_PM1A_CNT_BLK_ADDRESS_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 0x04)113#define ACPI_PM_TMR_BLK_ADDRESS_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0 + 0x08)114#define ACPI_GPE0_BLK_ADDRESS_V0 (ACPI_PM_TMR_BLK_ADDRESS_V0 + 0x20)115#define ACPI_GPE0_BLK_LEN_V0 0x08116117/* Version 1: Locations preferred by modern Qemu (including Qemu-trad). */118#define ACPI_PM1A_EVT_BLK_ADDRESS_V1 0xb000119#define ACPI_PM1A_CNT_BLK_ADDRESS_V1 (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 0x04)120#define ACPI_PM_TMR_BLK_ADDRESS_V1 (ACPI_PM1A_EVT_BLK_ADDRESS_V1 + 0x08)121#define ACPI_GPE0_BLK_ADDRESS_V1 0xafe0122#define ACPI_GPE0_BLK_LEN_V1 0x04123124/* Compatibility definitions for the default location (version 0). */125#define ACPI_PM1A_EVT_BLK_ADDRESS ACPI_PM1A_EVT_BLK_ADDRESS_V0126#define ACPI_PM1A_CNT_BLK_ADDRESS ACPI_PM1A_CNT_BLK_ADDRESS_V0127#define ACPI_PM_TMR_BLK_ADDRESS ACPI_PM_TMR_BLK_ADDRESS_V0128#define ACPI_GPE0_BLK_ADDRESS ACPI_GPE0_BLK_ADDRESS_V0129#define ACPI_GPE0_BLK_LEN ACPI_GPE0_BLK_LEN_V0130131132#endif /* _IOREQ_H_ */133134/*135* Local variables:136* mode: C137* c-file-style: "BSD"138* c-basic-offset: 4139* tab-width: 4140* indent-tabs-mode: nil141* End:142*/143144145