From patchwork Wed May 25 14:23:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 816332 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4PEOTt0000309 for ; Wed, 25 May 2011 14:24:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932958Ab1EYOYZ (ORCPT ); Wed, 25 May 2011 10:24:25 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=NxylA8kEFeUNiifjnRkrDhmoOKSmoV3F32IRREIS8po=; b=MLhIOSisHkQ02VpBg7nl/XxP3HYfEzaCVaj2wARXnITIOQB94MGVwAAatIPY1yMkTa 4lOyd/yiVjy3nGS89FyS0H5yYrlNOtz42TaBGwCVMjfAL6W3czclr+GEmC+SHOgtYESz SB9BGJP68yXLpBH3RCZXagJG5tKnvgEU13+9g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=dwiGqGIS/WdH4Gw6EAWAJ443p2M/qYjNgg7EuKiELBRTIwK+bWuPowlfs0Wxxq7je0 uzHjMG63sJr4MCAWsNe3XDLlnrQ5+qPbv8Y5paQwNZQLkL+kz+7mc2EVmyLbArjiDe40 PuwI/qBL046YIqSuFxzV1fyZi0bvmAUJ53HU0= Received: by 10.227.58.15 with SMTP id e15mr4753715wbh.28.1306333463370; Wed, 25 May 2011 07:24:23 -0700 (PDT) Received: from localhost.localdomain (bzq-109-66-201-145.red.bezeqint.net [109.66.201.145]) by mx.google.com with ESMTPS id m21sm404829wbh.25.2011.05.25.07.24.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 25 May 2011 07:24:23 -0700 (PDT) From: Sasha Levin 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 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> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> References: <1306333427-26186-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 25 May 2011 14:24:29 +0000 (UTC) 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;