From patchwork Mon Sep 12 14:43:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 4025 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5DA0323EF5 for ; Mon, 12 Sep 2011 14:43:34 +0000 (UTC) Received: from mail-ew0-f52.google.com (mail-ew0-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id 549AFA18082 for ; Mon, 12 Sep 2011 14:43:34 +0000 (UTC) Received: by ewy28 with SMTP id 28so1973575ewy.11 for ; Mon, 12 Sep 2011 07:43:34 -0700 (PDT) Received: by 10.223.63.8 with SMTP id z8mr3509905fah.84.1315838613993; Mon, 12 Sep 2011 07:43:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs2358lab; Mon, 12 Sep 2011 07:43:33 -0700 (PDT) Received: by 10.216.229.149 with SMTP id h21mr3002096weq.47.1315838613206; Mon, 12 Sep 2011 07:43:33 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id m3si13426104wed.99.2011.09.12.07.43.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Sep 2011 07:43:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1R37jP-0007Ik-9b; Mon, 12 Sep 2011 15:43:31 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH v2] hw/integratorcp: Fix bugs in writes to CM_CTRL system register Date: Mon, 12 Sep 2011 15:43:31 +0100 Message-Id: <1315838611-28043-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 Fix a number of bugs in the implementation of writes to the CM_CTRL system register: * write to cm_ctrl, not cm_init ! * an '&' vs '^' typo meant we would write the inverse of the bits * handling the LED via printf() meant we spew lots of output to stdout when Linux uses the LED as a heartbeat indicator * we would hw_error() if a reset was requested rather than actually resetting Signed-off-by: Peter Maydell --- This is just a retransmit rebased following some of Avi's MemoryRegion patches landing, no other changes from v1. hw/integratorcp.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/integratorcp.c b/hw/integratorcp.c index 3c8982e..9a289b4 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -14,6 +14,7 @@ #include "arm-misc.h" #include "net.h" #include "exec-memory.h" +#include "sysemu.h" typedef struct { SysBusDevice busdev; @@ -126,15 +127,20 @@ static void integratorcm_do_remap(integratorcm_state *s, int flash) static void integratorcm_set_ctrl(integratorcm_state *s, uint32_t value) { if (value & 8) { - hw_error("Board reset\n"); + qemu_system_reset_request(); } - if ((s->cm_init ^ value) & 4) { + if ((s->cm_ctrl ^ value) & 4) { integratorcm_do_remap(s, (value & 4) == 0); } - if ((s->cm_init ^ value) & 1) { - printf("Green LED %s\n", (value & 1) ? "on" : "off"); + if ((s->cm_ctrl ^ value) & 1) { + /* (value & 1) != 0 means the green "MISC LED" is lit. + * We don't have any nice place to display LEDs. printf is a bad + * idea because Linux uses the LED as a heartbeat and the output + * will swamp anything else on the terminal. + */ } - s->cm_init = (s->cm_init & ~ 5) | (value ^ 5); + /* Note that the RESET bit [3] always reads as zero */ + s->cm_ctrl = (s->cm_ctrl & ~5) | (value & 5); } static void integratorcm_update(integratorcm_state *s)