From patchwork Mon Mar 4 09:01:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 224639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75FD02C030D for ; Mon, 4 Mar 2013 20:03:49 +1100 (EST) Received: from localhost ([::1]:42792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCRJD-0005JK-M6 for incoming@patchwork.ozlabs.org; Mon, 04 Mar 2013 04:03:47 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCRIv-0005GW-RW for qemu-devel@nongnu.org; Mon, 04 Mar 2013 04:03:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UCRIr-0006vj-OF for qemu-devel@nongnu.org; Mon, 04 Mar 2013 04:03:29 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:50778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UCRIr-0006vd-II for qemu-devel@nongnu.org; Mon, 04 Mar 2013 04:03:25 -0500 Received: by mail-pa0-f54.google.com with SMTP id fa10so3043388pad.27 for ; Mon, 04 Mar 2013 01:03:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:x-gm-message-state; bh=MBzo3JZbVUkYnD61elz8WArrIsfWenuYd7kJy9DsFYI=; b=bL5vkhZMRJ+6gTsx5G0RjWtgCximRFG1W8Ffz4b+qufd+HJpQN1Oy/NvUKknYV7xiS lAIIzgMGjTiuvwEnvuc1Z0Yl0c32JTPOa+CqPapWV6a8BKB3Gp3IrdfgZR7XZR/LNpsF LfvYiTEkk1ThmojZ23kke5fP3/mbI1ibQQZYcUuGPjxXqH/CLdgtVrFrIv1dKyVhr0cm jtf4/yB7AP9wv0i7c9flzZIYD1dCQFy8ZGU4wj2ts+QZKbym9+v2C9pXoapd7nsBDo8d nSEyKKgU/L1D+VmdvljaKpLKIByKrA8FCOzs5voo2x+9AoL4QB7fVj3pvo3ihAOsLj4J IRFg== X-Received: by 10.66.230.234 with SMTP id tb10mr30673325pac.182.1362387804820; Mon, 04 Mar 2013 01:03:24 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPS id ol7sm21661819pbb.14.2013.03.04.01.03.22 (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 04 Mar 2013 01:03:23 -0800 (PST) From: Peter Crosthwaite To: qemu-devel@nongnu.org Date: Mon, 4 Mar 2013 19:01:33 +1000 Message-Id: <869b19f37ca7908ee01a84723c3c38a512b9e5c3.1362387545.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQngu12akEWLbhQ9P4pOxQOb+WpXVW6eEdaL7wrxPDzqDZB8POPBozqK5YLjHgxaFZs4pcns X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.54 Cc: Peter Crosthwaite , andreas.faerber@suse.de, dantesu@faraday-tech.com Subject: [Qemu-devel] [RFC PATCH v1 1/7] qdev: Define halting API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Define APIs on the device level for halting and un-halting a device. The semantic is the device freezes its state and does not respond to any form of transaction. The main intended use cases is to implement clock gating and power down. clock gating is just a halt, whereas power down is a reset() and halt(). Unhalt is then used to ungate the clock or power up the device. Signed-off-by: Peter Crosthwaite --- hw/qdev-core.h | 17 +++++++++++++++++ hw/qdev.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/hw/qdev-core.h b/hw/qdev-core.h index 2486f36..1fee53a 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -87,6 +87,9 @@ typedef struct DeviceClass { /* callbacks */ void (*reset)(DeviceState *dev); + void (*halt)(DeviceState *dev); + void (*unhalt)(DeviceState *dev); + DeviceRealize realize; DeviceUnrealize unrealize; @@ -280,6 +283,20 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); +/** + * @device_halt + * + * Halt a single device (by calling the halt method). + */ +void device_halt(DeviceState *dev); + +/** + * @device_unhalt + * + * Unhalt a single device (by calling the unhalt method). + */ +void device_unhalt(DeviceState *dev); + const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); const char *qdev_fw_name(DeviceState *dev); diff --git a/hw/qdev.c b/hw/qdev.c index 689cd54..c338b74 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -797,6 +797,24 @@ void device_reset(DeviceState *dev) } } +void device_halt(DeviceState *dev) +{ + DeviceClass *klass = DEVICE_GET_CLASS(dev); + + if (klass->halt) { + klass->halt(dev); + } +} + +void device_unhalt(DeviceState *dev) +{ + DeviceClass *klass = DEVICE_GET_CLASS(dev); + + if (klass->halt) { + klass->unhalt(dev); + } +} + Object *qdev_get_machine(void) { static Object *dev;