ia64/xen-unstable

view xen/include/asm-x86/hvm/io.h @ 16381:d1ac500f77c1

x86, hvm: Allow stdvga acceleration to work with 32-bit x86.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Nov 16 14:40:22 2007 +0000 (2007-11-16)
parents 4034317507de
children bb961bda7eff
line source
1 /*
2 * io.h: HVM IO support
3 *
4 * Copyright (c) 2004, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 */
20 #ifndef __ASM_X86_HVM_IO_H__
21 #define __ASM_X86_HVM_IO_H__
23 #include <asm/hvm/vpic.h>
24 #include <asm/hvm/vioapic.h>
25 #include <public/hvm/ioreq.h>
26 #include <public/event_channel.h>
28 #define operand_size(operand) \
29 ((operand >> 24) & 0xFF)
31 #define operand_index(operand) \
32 ((operand >> 16) & 0xFF)
34 /* for instruction.operand[].size */
35 #define BYTE 1
36 #define WORD 2
37 #define LONG 4
38 #define QUAD 8
39 #define BYTE_64 16
41 /* for instruction.operand[].flag */
42 #define REGISTER 0x1
43 #define MEMORY 0x2
44 #define IMMEDIATE 0x4
46 /* for instruction.flags */
47 #define REPZ 0x1
48 #define REPNZ 0x2
49 #define OVERLAP 0x4
51 /* instruction type */
52 #define INSTR_PIO 1
53 #define INSTR_OR 2
54 #define INSTR_AND 3
55 #define INSTR_XOR 4
56 #define INSTR_CMP 5
57 #define INSTR_MOV 6
58 #define INSTR_MOVS 7
59 #define INSTR_MOVZX 8
60 #define INSTR_MOVSX 9
61 #define INSTR_STOS 10
62 #define INSTR_LODS 11
63 #define INSTR_TEST 12
64 #define INSTR_BT 13
65 #define INSTR_XCHG 14
66 #define INSTR_SUB 15
67 #define INSTR_ADD 16
68 #define INSTR_PUSH 17
70 #define MAX_INST_LEN 15 /* Maximum instruction length = 15 bytes */
72 struct hvm_io_op {
73 unsigned int instr; /* instruction */
74 unsigned int flags;
75 unsigned long addr; /* virt addr for overlap PIO/MMIO */
76 struct {
77 unsigned int operand[2]; /* operands */
78 unsigned long immediate; /* immediate portion */
79 };
80 struct cpu_user_regs io_context; /* current context */
81 };
83 #define MAX_IO_HANDLER 12
85 #define HVM_PORTIO 0
86 #define HVM_MMIO 1
87 #define HVM_BUFFERED_IO 2
89 typedef int (*intercept_action_t)(ioreq_t *);
90 typedef unsigned long (*hvm_mmio_read_t)(struct vcpu *v,
91 unsigned long addr,
92 unsigned long length);
94 typedef void (*hvm_mmio_write_t)(struct vcpu *v,
95 unsigned long addr,
96 unsigned long length,
97 unsigned long val);
99 typedef int (*hvm_mmio_check_t)(struct vcpu *v, unsigned long addr);
101 struct io_handler {
102 int type;
103 unsigned long addr;
104 unsigned long size;
105 intercept_action_t action;
106 };
108 struct hvm_io_handler {
109 int num_slot;
110 struct io_handler hdl_list[MAX_IO_HANDLER];
111 };
113 struct hvm_mmio_handler {
114 hvm_mmio_check_t check_handler;
115 hvm_mmio_read_t read_handler;
116 hvm_mmio_write_t write_handler;
117 };
119 /* global io interception point in HV */
120 extern int hvm_io_intercept(ioreq_t *p, int type);
121 extern int register_io_handler(
122 struct domain *d, unsigned long addr, unsigned long size,
123 intercept_action_t action, int type);
125 static inline int hvm_portio_intercept(ioreq_t *p)
126 {
127 return hvm_io_intercept(p, HVM_PORTIO);
128 }
130 static inline int hvm_buffered_io_intercept(ioreq_t *p)
131 {
132 return hvm_io_intercept(p, HVM_BUFFERED_IO);
133 }
135 extern int hvm_mmio_intercept(ioreq_t *p);
136 extern int hvm_buffered_io_send(ioreq_t *p);
138 static inline int register_portio_handler(
139 struct domain *d, unsigned long addr,
140 unsigned long size, intercept_action_t action)
141 {
142 return register_io_handler(d, addr, size, action, HVM_PORTIO);
143 }
145 static inline int register_buffered_io_handler(
146 struct domain *d, unsigned long addr,
147 unsigned long size, intercept_action_t action)
148 {
149 return register_io_handler(d, addr, size, action, HVM_BUFFERED_IO);
150 }
152 extern void send_pio_req(unsigned long port, unsigned long count, int size,
153 paddr_t value, int dir, int df, int value_is_ptr);
154 void send_timeoffset_req(unsigned long timeoff);
155 void send_invalidate_req(void);
156 extern void handle_mmio(unsigned long gpa);
157 extern void hvm_interrupt_post(struct vcpu *v, int vector, int type);
158 extern void hvm_io_assist(void);
159 extern void hvm_dpci_eoi(struct domain *d, unsigned int guest_irq,
160 union vioapic_redir_entry *ent);
162 struct hvm_hw_stdvga {
163 uint8_t sr_index;
164 uint8_t sr[0x18];
165 uint8_t gr_index;
166 uint8_t gr[256];
167 uint32_t latch;
168 int stdvga;
169 int cache;
170 struct page_info *vram_page[64]; /* shadow of 0xa0000-0xaffff */
171 spinlock_t lock;
172 };
174 void stdvga_init(struct domain *d);
175 void stdvga_deinit(struct domain *d);
177 #endif /* __ASM_X86_HVM_IO_H__ */