From patchwork Tue May 14 15:52:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 164217 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2794149ili; Tue, 14 May 2019 08:55:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrNuKM51SDqv8w1/bpWQAp6pdZtjrrixScSn93RlkFXrxpCL+lJblBuO5zn5rdiA5dRaju X-Received: by 2002:a17:906:a4b:: with SMTP id x11mr28559604ejf.200.1557849333629; Tue, 14 May 2019 08:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557849333; cv=none; d=google.com; s=arc-20160816; b=AOCNsoGopnKAG05m9gLCwoAYKgDYTwI+TLVY8MVoVXUZhLtDn2sOb0USXo8RaPqTfY V/8vYmTGlV0YkWUYkP/hRFc9nXzsNIw4YzNL0uW5PTWBOMqbcJscF43X1SNddrDYisnu BTWpr2VPmVQVLUs1F2DVaj//YEihbwR0A7nZ2ek50jDO9BdbvQ8+thV4CiUidlCYnM/Y /aOnVUsSX5uZgUEIefLDRpatje7xsQfQfdSBZFDnkyTl20YrRRlS++pP03pQeveVb7FS i7UFw+4goXJUorK/zZM+QA7hg39wDduWN6lRuCNQagZX3gEpxsIzuMoNJFEmSGcRFq0/ 95cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=8P0Lit3+ogalzWIYoV9bDuQCb6yqzuLD2GL2ck9k72U=; b=nuIZO00fgp+QHZSKjkk2geOdv77STBcNz9/8l1I2aLA/ALNsjr7M0MZyDDvxlRV+Ww iu9uPFMsbbPpMwrZTN0c9kNjtsZ9SrJmIYbjL4B5GdZyWPCYaAxiHwYG22PkmBdy5AUI lNMvDvcTslkKKRTqRAgzjF9yNDnIfb7XRimMIn2BEI5KZ2FNurmyJrBUTHPaZMrFr6C9 qOoeaSulMDoFr70eRo+dYs15fYebQwbCYb4w/yIE5tMq2uNvWNsWG3UWnJtLvDMPSVGM R/U9P9SgekQpTFGLANkyK/i7lOLhXh4qaJcN1yCkmbUElAqrgyx7zXYRwBi1zQX5Dbyj LZ+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=m8XjDVZf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t4si9927750ejq.180.2019.05.14.08.55.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2019 08:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=m8XjDVZf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:50198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQZm8-0006Zo-Cj for patch@linaro.org; Tue, 14 May 2019 11:55:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQZjp-0004l8-Am for qemu-devel@nongnu.org; Tue, 14 May 2019 11:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQZjo-0006DS-0S for qemu-devel@nongnu.org; Tue, 14 May 2019 11:53:09 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51780) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQZjn-0006C8-PX for qemu-devel@nongnu.org; Tue, 14 May 2019 11:53:07 -0400 Received: by mail-wm1-x341.google.com with SMTP id o189so3432113wmb.1 for ; Tue, 14 May 2019 08:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8P0Lit3+ogalzWIYoV9bDuQCb6yqzuLD2GL2ck9k72U=; b=m8XjDVZfHoOqs814AqYdCoaJljUHvUN91Ybm1Nij/tU9WxajK7mp8Ae6guBr6m6WRt zDiGm0Zaeu4suWI8/IE5WsPbTYfyfH58WZMuMhurxZKGV8zY6Gl7cu+4r2P7Bddkd52l qeoQDqk+22weMucKa66/pPwK4LLgBoQ6KSSKoAWF0khlILdnEugDDyC24CH93FucPK1s qn84AoZA/N3TNGGqByzcFZe7LzME2gYNHai3cm2yckxlVvBpjjspln5LU8pVAxoT5rwr fgFRTqPv77KiUo72SKf9TxVli8rh+a3YvDEfT+EE40Jh/i1iEDS3OVcQLE5+30dRXhr/ Wdgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8P0Lit3+ogalzWIYoV9bDuQCb6yqzuLD2GL2ck9k72U=; b=ffbMGjW+msTiyKSp+h77AQK3TUIPPP8reuxqpqU9sP9yNjGACgRPcEUfr7zH6JG2K1 xlA8kPWcFgpdLYxPQmVsTjOtSe0jiYC3vEhBvpwN5tGKwdn4F5QETGD1NNC7FI4lf5f5 aZt3sJT66NBrUYFDt+9ckuR7iHJnZJntodeLGCzYj1ht3YNORJQrKaebIfkUHS+E8Foc fzJJNcfmntVRuZsT/Wio9M0FdfRQFty0POZ+49ylSPcp7mNnjSinaS/LP5psi5LkLrHV G/TgJYCEEjloLwJQRpjdWSR59ucvCu3QK57hZD2s9lNTyyP5nUYNIiLuLl6itasK51Dl 3ACw== X-Gm-Message-State: APjAAAVjni1nXZOzQAg3yS+RPat2it10pTDaKi75S0gPq+n+nYH/65x6 opf+gIwd6ECwP109hIlLQliB8Q== X-Received: by 2002:a05:600c:551:: with SMTP id k17mr5368389wmc.119.1557849186612; Tue, 14 May 2019 08:53:06 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g6sm14700712wro.29.2019.05.14.08.53.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2019 08:53:05 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7834B1FF92; Tue, 14 May 2019 16:53:02 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 14 May 2019 16:52:55 +0100 Message-Id: <20190514155301.16123-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190514155301.16123-1-alex.bennee@linaro.org> References: <20190514155301.16123-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [RFC PATCH 05/11] target/arm: fixup some of the commentary for arm-semi X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This cleans up a number of the block comments to fit the proper style. While we are at it we also reference the official specification and document what the return register value can be. Signed-off-by: Alex Bennée --- target/arm/arm-semi.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index 3273306c8ea..9e5a414dd89 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -2,6 +2,7 @@ * Arm "Angel" semihosting syscalls * * Copyright (c) 2005, 2007 CodeSourcery. + * Copyright (c) 2019 Linaro * Written by Paul Brook. * * This program is free software; you can redistribute it and/or modify @@ -16,6 +17,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, see . + * + * ARM Semihosting is documented in: + * Semihosting for AArch32 and AArch64 Release 2.0 + * https://static.docs.arm.com/100863/0200/semihosting.pdf */ #include "qemu/osdep.h" @@ -240,6 +245,15 @@ static target_ulong arm_gdb_syscall(ARMCPU *cpu, gdb_syscall_complete_cb cb, put_user_u64(val, args + (n) * 8) : \ put_user_u32(val, args + (n) * 4)) +/* + * Do a semihosting call. + * + * The specification always says that the "return register" either + * returns a specific value or is corrupted, so we don't need to + * report to our caller whether we are returning a value or trying to + * leave the register unchanged. We use 0xdeadbeef as the return value + * when there isn't a defined return value for the call. + */ target_ulong do_arm_semihosting(CPUARMState *env) { ARMCPU *cpu = arm_env_get_cpu(env); @@ -510,14 +524,16 @@ target_ulong do_arm_semihosting(CPUARMState *env) output_size = ts->info->arg_end - ts->info->arg_start; if (!output_size) { - /* We special-case the "empty command line" case (argc==0). - Just provide the terminating 0. */ + /* + * We special-case the "empty command line" case (argc==0). + * Just provide the terminating 0. + */ output_size = 1; } #endif if (output_size > input_size) { - /* Not enough space to store command-line arguments. */ + /* Not enough space to store command-line arguments. */ return -1; } @@ -571,8 +587,10 @@ target_ulong do_arm_semihosting(CPUARMState *env) GET_ARG(0); #ifdef CONFIG_USER_ONLY - /* Some C libraries assume the heap immediately follows .bss, so - allocate it using sbrk. */ + /* + * Some C libraries assume the heap immediately follows .bss, so + * allocate it using sbrk. + */ if (!ts->heap_limit) { abi_ulong ret; @@ -620,7 +638,8 @@ target_ulong do_arm_semihosting(CPUARMState *env) } case TARGET_SYS_EXIT: if (is_a64(env)) { - /* The A64 version of this call takes a parameter block, + /* + * The A64 version of this call takes a parameter block, * so the application-exit type can return a subcode which * is the exit status code from the application. */ @@ -633,14 +652,17 @@ target_ulong do_arm_semihosting(CPUARMState *env) ret = 1; } } else { - /* ARM specifies only Stopped_ApplicationExit as normal - * exit, everything else is considered an error */ + /* + * ARM specifies only Stopped_ApplicationExit as normal + * exit, everything else is considered an error + */ ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1; } gdb_exit(env, ret); exit(ret); case TARGET_SYS_SYNCCACHE: - /* Clean the D-cache and invalidate the I-cache for the specified + /* + * Clean the D-cache and invalidate the I-cache for the specified * virtual address range. This is a nop for us since we don't * implement caches. This is only present on A64. */