diff options
author | tychon <tychon@FreeBSD.org> | 2014-04-22 16:13:56 +0000 |
---|---|---|
committer | tychon <tychon@FreeBSD.org> | 2014-04-22 16:13:56 +0000 |
commit | f44a06b5a19d704e24ea6aa5722da505a0bfa005 (patch) | |
tree | 9fb7228ca6f2fc25f7f8cafc59fa33927451f0b4 /usr.sbin | |
parent | 5022630d02f5b911fe694cc20729470ba0fd4ba9 (diff) | |
download | FreeBSD-src-f44a06b5a19d704e24ea6aa5722da505a0bfa005.zip FreeBSD-src-f44a06b5a19d704e24ea6aa5722da505a0bfa005.tar.gz |
Factor out common ioport handler code for better hygiene -- pointed
out by neel@.
Approved by: neel (co-mentor)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/inout.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/usr.sbin/bhyve/inout.c b/usr.sbin/bhyve/inout.c index 9fec70a..5fbe99b 100644 --- a/usr.sbin/bhyve/inout.c +++ b/usr.sbin/bhyve/inout.c @@ -107,18 +107,19 @@ emulate_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes, if (strict && handler == default_inout) return (-1); + switch (bytes) { + case 1: + mask = 0xff; + break; + case 2: + mask = 0xffff; + break; + default: + mask = 0xffffffff; + break; + } + if (!in) { - switch (bytes) { - case 1: - mask = 0xff; - break; - case 2: - mask = 0xffff; - break; - default: - mask = 0xffffffff; - break; - } val = *eax & mask; } @@ -131,17 +132,6 @@ emulate_inout(struct vmctx *ctx, int vcpu, int in, int port, int bytes, error = -1; if (!error && in) { - switch (bytes) { - case 1: - mask = 0xff; - break; - case 2: - mask = 0xffff; - break; - default: - mask = 0xffffffff; - break; - } *eax &= ~mask; *eax |= val & mask; } |