Deleted Added
full compact
inout.c (257293) inout.c (264648)
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/usr.sbin/bhyve/inout.c 257293 2013-10-29 00:18:11Z neel $
26 * $FreeBSD: head/usr.sbin/bhyve/inout.c 264648 2014-04-18 15:22:56Z tychon $
27 */
28
29#include <sys/cdefs.h>
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/inout.c 257293 2013-10-29 00:18:11Z neel $");
30__FBSDID("$FreeBSD: head/usr.sbin/bhyve/inout.c 264648 2014-04-18 15:22:56Z tychon $");
31
32#include <sys/param.h>
33#include <sys/linker_set.h>
34
35#include <stdio.h>
36#include <string.h>
37#include <assert.h>
38

--- 51 unchanged lines hidden (view full) ---

90 register_inout(&iop);
91}
92
93int
94emulate_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
95 uint32_t *eax, int strict)
96{
97 int flags;
31
32#include <sys/param.h>
33#include <sys/linker_set.h>
34
35#include <stdio.h>
36#include <string.h>
37#include <assert.h>
38

--- 51 unchanged lines hidden (view full) ---

90 register_inout(&iop);
91}
92
93int
94emulate_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes,
95 uint32_t *eax, int strict)
96{
97 int flags;
98 uint32_t mask;
98 uint32_t mask, val;
99 inout_func_t handler;
100 void *arg;
99 inout_func_t handler;
100 void *arg;
101 int error;
101
102 assert(port < MAX_IOPORTS);
103
104 handler = inout_handlers[port].handler;
105
106 if (strict && handler == default_inout)
107 return (-1);
108

--- 4 unchanged lines hidden (view full) ---

113 break;
114 case 2:
115 mask = 0xffff;
116 break;
117 default:
118 mask = 0xffffffff;
119 break;
120 }
102
103 assert(port < MAX_IOPORTS);
104
105 handler = inout_handlers[port].handler;
106
107 if (strict && handler == default_inout)
108 return (-1);
109

--- 4 unchanged lines hidden (view full) ---

114 break;
115 case 2:
116 mask = 0xffff;
117 break;
118 default:
119 mask = 0xffffffff;
120 break;
121 }
121 *eax = *eax & mask;
122 val = *eax & mask;
122 }
123
124 flags = inout_handlers[port].flags;
125 arg = inout_handlers[port].arg;
126
127 if ((in && (flags & IOPORT_F_IN)) || (!in && (flags & IOPORT_F_OUT)))
123 }
124
125 flags = inout_handlers[port].flags;
126 arg = inout_handlers[port].arg;
127
128 if ((in && (flags & IOPORT_F_IN)) || (!in && (flags & IOPORT_F_OUT)))
128 return ((*handler)(ctx, vcpu, in, port, bytes, eax, arg));
129 error = (*handler)(ctx, vcpu, in, port, bytes, &val, arg);
129 else
130 else
130 return (-1);
131 error = -1;
132
133 if (!error && in) {
134 switch (bytes) {
135 case 1:
136 mask = 0xff;
137 break;
138 case 2:
139 mask = 0xffff;
140 break;
141 default:
142 mask = 0xffffffff;
143 break;
144 }
145 *eax &= ~mask;
146 *eax |= val & mask;
147 }
148
149 return (error);
131}
132
133void
134init_inout(void)
135{
136 struct inout_port **iopp, *iop;
137
138 /*

--- 56 unchanged lines hidden ---
150}
151
152void
153init_inout(void)
154{
155 struct inout_port **iopp, *iop;
156
157 /*

--- 56 unchanged lines hidden ---