public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu,
	asias.hejun@gmail.com, gorcunov@gmail.com,
	prasadjoshi124@gmail.com, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH 2/9] kvm tools: Add basic ioport dynamic allocation
Date: Wed, 25 May 2011 17:23:40 +0300	[thread overview]
Message-ID: <1306333427-26186-2-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com>

Add a very simple allocation of ioports.

This prevents the need to coordinate ioports between different
modules.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/include/kvm/ioport.h |    5 +++++
 tools/kvm/ioport.c             |    7 +++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/include/kvm/ioport.h b/tools/kvm/include/kvm/ioport.h
index 2a8d74d..bc7ea02 100644
--- a/tools/kvm/include/kvm/ioport.h
+++ b/tools/kvm/include/kvm/ioport.h
@@ -7,6 +7,9 @@
 
 /* some ports we reserve for own use */
 #define IOPORT_DBG			0xe0
+#define IOPORT_START			0x6200
+#define IOPORT_SIZE			0x400
+
 #define IOPORT_VESA			0xa200
 #define IOPORT_VESA_SIZE		256
 #define IOPORT_VIRTIO_P9		0xb200	/* Virtio 9P device */
@@ -34,6 +37,8 @@ void ioport__setup_legacy(void);
 void ioport__register(u16 port, struct ioport_operations *ops, int count);
 void ioport__register_param(u16 port, struct ioport_operations *ops, int count, void *param);
 
+u16 ioport__find_free_range(void);
+
 static inline u8 ioport__read8(u8 *data)
 {
 	return *data;
diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c
index 159d089..0db5a87 100644
--- a/tools/kvm/ioport.c
+++ b/tools/kvm/ioport.c
@@ -126,6 +126,13 @@ static void ioport_error(u16 port, void *data, int direction, int size, u32 coun
 	fprintf(stderr, "IO error: %s port=%x, size=%d, count=%u\n", to_direction(direction), port, size, count);
 }
 
+u16 ioport__find_free_range(void)
+{
+	static u16 cur_loc;
+
+	return IOPORT_START + (cur_loc++ * IOPORT_SIZE);
+}
+
 bool kvm__emulate_io(struct kvm *kvm, u16 port, void *data, int direction, int size, u32 count)
 {
 	struct ioport_operations *ops;
-- 
1.7.5.rc3


  reply	other threads:[~2011-05-25 14:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-25 14:23 [PATCH 1/9] kvm tools: Add optional parameter used in ioport callbacks Sasha Levin
2011-05-25 14:23 ` Sasha Levin [this message]
2011-05-25 14:34   ` [PATCH 2/9] kvm tools: Add basic ioport dynamic allocation Ingo Molnar
2011-05-25 14:23 ` [PATCH 3/9] kvm tools: Use ioport context to control blk devices Sasha Levin
2011-05-25 14:23 ` [PATCH 4/9] kvm tools: Add support for multiple virtio-rng devices Sasha Levin
2011-05-25 14:23 ` [PATCH 5/9] kvm tools: Use dynamic IO port allocation in vesa driver Sasha Levin
2011-05-25 14:23 ` [PATCH 6/9] kvm tools: Use dynamic IO port allocation in 9p driver Sasha Levin
2011-05-25 14:23 ` [PATCH 7/9] kvm tools: Use dynamic IO port allocation in virtio-console driver Sasha Levin
2011-05-25 14:42   ` Ingo Molnar
2011-05-25 15:35     ` Sasha Levin
2011-05-25 14:23 ` [PATCH 8/9] kvm tools: Use dynamic IO port allocation in virtio-net driver Sasha Levin
2011-05-25 14:23 ` [PATCH 9/9] kvm tools: Remove static ioport allocations Sasha Levin
2011-05-25 14:43   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1306333427-26186-2-git-send-email-levinsasha928@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=john@jfloren.net \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@kernel.org \
    --cc=prasadjoshi124@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox