From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH 2/9] kvm tools: Add basic ioport dynamic allocation Date: Wed, 25 May 2011 17:23:40 +0300 Message-ID: <1306333427-26186-2-git-send-email-levinsasha928@gmail.com> References: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> Cc: john@jfloren.net, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin To: penberg@kernel.org Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:59024 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932913Ab1EYOYY (ORCPT ); Wed, 25 May 2011 10:24:24 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so8540053wwa.1 for ; Wed, 25 May 2011 07:24:23 -0700 (PDT) In-Reply-To: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: Add a very simple allocation of ioports. This prevents the need to coordinate ioports between different modules. Signed-off-by: Sasha Levin --- 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