From patchwork Mon Dec 14 08:41:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvise Rigo X-Patchwork-Id: 556323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E6FA5140216 for ; Mon, 14 Dec 2015 19:43:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=virtualopensystems-com.20150623.gappssmtp.com header.i=@virtualopensystems-com.20150623.gappssmtp.com header.b=sso8hU/I; dkim-atps=neutral Received: from localhost ([::1]:58474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8Oim-0007W1-Ra for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2015 03:43:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8Ohm-0005i9-2M for qemu-devel@nongnu.org; Mon, 14 Dec 2015 03:42:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8Ohk-0001vs-26 for qemu-devel@nongnu.org; Mon, 14 Dec 2015 03:42:01 -0500 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:33295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8Ohj-0001vg-Ow for qemu-devel@nongnu.org; Mon, 14 Dec 2015 03:41:59 -0500 Received: by mail-wm0-x233.google.com with SMTP id n186so34441774wmn.0 for ; Mon, 14 Dec 2015 00:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cMzzzPkgWa+oKC2D2ikvYh4DBZeZZiS5KCulRq6pXBM=; b=sso8hU/Imq7OjqmMaWC/IPk9T1Zg99ShL+/cyEiq93KJW4oOR+mOi5BhBqBvmtLMkh BjSIoX5O1vnSBzf9zye046KIlkrejfogQkkfE5ZNvDMmTX9zMs9/YdEXpGZwDZDScZ+o c1/yNtFqQL2A0SL47EwBhb6fzEMgQs2rdgMg9IDcq6ZRCIguoF1fKIozwHWzb0fyjy9V JeideDE0AdYdwhf9y8KnJWjuprBK/3UCMVEj3Hod7VEYeYm3iNeMmw/mammaqL5ntq1r tSq8Tg01w3YUzpCi5Dr+9En0lHfsmUL0GDMfsbRnYHdsRGZlBJ7G6WWNqSOxtj/c7pjL l19A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cMzzzPkgWa+oKC2D2ikvYh4DBZeZZiS5KCulRq6pXBM=; b=Jg/WxhswapcIH6jcX2R6QKcMo/JX+U7VbSDZ6Q1egknFnQByBOuEyiqkVxHTxp27pK sprLwbkXala2N7eF97b0BXGwds1gFY0biziShM7bWlidywTnkFHZnKg+BxLEyc0GimfA IFXc0DeDoeiXL7pmPv0lNnncbVconOT4eUNOGbg1GAQKYFiKzhETJJIp99Daha559YqY WhuEcKQpCDwoaj22eQQA5D6W9aZCA5YDWLSP6XLcvAdemNb8ZGZILxu0cyhdPf1kusW9 9iWyyK/ce7vybKAZ7i+CywekKBM+4FS8SNMRLgKGb1qS8WOHWBX13OKvQdrAyWYvHJvN 5gfA== X-Gm-Message-State: ALoCoQk3Xoj7vsc7TDRu0DaaiHFK5MbjYudObcI1oUuoL/JNpVpwQ4t8K53eNpoh4puTQ+KDbhNcEiUdocoRQoh8Hwd+dNleVA== X-Received: by 10.28.13.205 with SMTP id 196mr8651692wmn.75.1450082519225; Mon, 14 Dec 2015 00:41:59 -0800 (PST) Received: from localhost.localdomain (LPuteaux-656-1-278-113.w80-15.abo.wanadoo.fr. [80.15.154.113]) by smtp.googlemail.com with ESMTPSA id xs9sm1100526wjc.43.2015.12.14.00.41.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Dec 2015 00:41:58 -0800 (PST) From: Alvise Rigo To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Date: Mon, 14 Dec 2015 09:41:35 +0100 Message-Id: <1450082498-27109-12-git-send-email-a.rigo@virtualopensystems.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1450082498-27109-1-git-send-email-a.rigo@virtualopensystems.com> References: <1450082498-27109-1-git-send-email-a.rigo@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::233 Cc: claudio.fontana@huawei.com, pbonzini@redhat.com, jani.kokkonen@huawei.com, tech@virtualopensystems.com, alex.bennee@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [RFC v6 11/14] softmmu: Simplify helper_*_st_name, wrap MMIO code 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 Attempting to simplify the helper_*_st_name, wrap the MMIO code into an inline function. Suggested-by: Jani Kokkonen Suggested-by: Claudio Fontana Signed-off-by: Alvise Rigo --- softmmu_template.h | 64 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/softmmu_template.h b/softmmu_template.h index 92f92b1..2ebf527 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -396,6 +396,26 @@ static inline void glue(helper_le_st_name, _do_unl_access)(CPUArchState *env, } } +static inline void glue(helper_le_st_name, _do_mmio_access)(CPUArchState *env, + DATA_TYPE val, + target_ulong addr, + TCGMemOpIdx oi, + unsigned mmu_idx, + int index, + uintptr_t retaddr) +{ + CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; + + if ((addr & (DATA_SIZE - 1)) != 0) { + glue(helper_le_st_name, _do_unl_access)(env, val, addr, mmu_idx, + oi, retaddr); + } + /* ??? Note that the io helpers always read data in the target + byte ordering. We should push the LE/BE request down into io. */ + val = TGT_LE(val); + glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); +} + void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) { @@ -458,16 +478,8 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, return; } else { - if ((addr & (DATA_SIZE - 1)) != 0) { - glue(helper_le_st_name, _do_unl_access)(env, val, addr, mmu_idx, - oi, retaddr); - } - iotlbentry = &env->iotlb[mmu_idx][index]; - - /* ??? Note that the io helpers always read data in the target - byte ordering. We should push the LE/BE request down into io. */ - val = TGT_LE(val); - glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); + glue(helper_le_st_name, _do_mmio_access)(env, val, addr, oi, + mmu_idx, index, retaddr); return; } } @@ -523,6 +535,26 @@ static inline void glue(helper_be_st_name, _do_unl_access)(CPUArchState *env, } } +static inline void glue(helper_be_st_name, _do_mmio_access)(CPUArchState *env, + DATA_TYPE val, + target_ulong addr, + TCGMemOpIdx oi, + unsigned mmu_idx, + int index, + uintptr_t retaddr) +{ + CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; + + if ((addr & (DATA_SIZE - 1)) != 0) { + glue(helper_be_st_name, _do_unl_access)(env, val, addr, mmu_idx, + oi, retaddr); + } + /* ??? Note that the io helpers always read data in the target + byte ordering. We should push the LE/BE request down into io. */ + val = TGT_BE(val); + glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); +} + void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, TCGMemOpIdx oi, uintptr_t retaddr) { @@ -585,16 +617,8 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, return; } else { - if ((addr & (DATA_SIZE - 1)) != 0) { - glue(helper_be_st_name, _do_unl_access)(env, val, addr, mmu_idx, - oi, retaddr); - } - iotlbentry = &env->iotlb[mmu_idx][index]; - - /* ??? Note that the io helpers always read data in the target - byte ordering. We should push the LE/BE request down into io. */ - val = TGT_BE(val); - glue(io_write, SUFFIX)(env, iotlbentry, val, addr, retaddr); + glue(helper_be_st_name, _do_mmio_access)(env, val, addr, oi, + mmu_idx, index, retaddr); return; } }