From patchwork Tue May 28 09:49:30 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: 165272 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp8247488ili; Tue, 28 May 2019 02:50:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyImDRTbgyEdPuhOLUozwPfxTy8Fcjl/0v2DoUKvl9y8axWtPhITXV8heivdunuUlrAe5Cg X-Received: by 2002:a37:6086:: with SMTP id u128mr7827663qkb.270.1559037029286; Tue, 28 May 2019 02:50:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559037029; cv=none; d=google.com; s=arc-20160816; b=PYj3FdnubN/MenFaRuPOSltjAIcwUhmF/zNRVj3JpWhCUEMKP1moMkznrEp9NSLdx+ nO1TtlvO5Y6GgyAsnoTiBefh3Nf81LcQFc+/zkCMLncFJ/wAdRaSpe+xAG6eDfHvSubu fwPA8ku/kmIAi5W/sezoPd5nIXXZIgH/2/OdPRLqf6VSt6MeAG93aWXNEGzFJRl9KmAz FiVu3gzM7ayTGa9CxpuWvJik2QWtZ9Bt/HHd49xI/+mALohdDGdlYC5h8eZJFGzlBsvQ k8InJD7zkEjYbTlGndBaQus+2uchc24R1RD/wcNk6Yb5IX0mq0J5CHRFVV8wFRu9OPCY gTsQ== 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=qqKC0aSbOxnvRt4Ak9385i5tuKqObKaJREy1yTVl17E=; b=ORix1/FN7jWoJ9MnuR+knRgiqA4SjJ1xvFNKazl7VP9GaOuFmDsMmWJpQIsPOzciOd 1yDgIKmm3lwS8gZ5edIxmyN8hE5jms08AMUeAd9SGH0xshQakz6miSuge/Yhcl/wvZ/S nalswQCBUKRcZ7at/2Aq26VBG9HchYv6Dc9CRdVv4N5PGxklv1Zmf0BzhoV0oi/dsXzj o6lcL917sUR6K1l1Jc7gZOTze9HgjcgFVhV7+cQo6NY5hvTOJZOK2oOMLMo0kynTy128 7dHpwfzE8i5eVICpihR0AtsCr8M0bAZdKNJ9WsVv7rZ7aJ2ftiDZgHDfDfvGV3LfcNed 32YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Nl6xhjdL; 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 16si6440267qta.329.2019.05.28.02.50.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 28 May 2019 02:50:29 -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=Nl6xhjdL; 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]:59913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVYkW-0006GI-Lm for patch@linaro.org; Tue, 28 May 2019 05:50:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVYk4-0006EN-PQ for qemu-devel@nongnu.org; Tue, 28 May 2019 05:50:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVYk2-0008UE-W3 for qemu-devel@nongnu.org; Tue, 28 May 2019 05:50:00 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:38633) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hVYk2-0008Sp-Pc for qemu-devel@nongnu.org; Tue, 28 May 2019 05:49:58 -0400 Received: by mail-wr1-x42c.google.com with SMTP id d18so19473046wrs.5 for ; Tue, 28 May 2019 02:49:58 -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=qqKC0aSbOxnvRt4Ak9385i5tuKqObKaJREy1yTVl17E=; b=Nl6xhjdLBBjo4hXQwpFtEexyaLdc65OHvYSdnKssLUGAYLOeJj1FapYcBQcViqvFw1 W2xCQTjL9T3faRzIwKHYXlU3kRhy8fwx/JUjr1uMuL71o+R9/iickq6npGpbz2iEW2GR tU3ipx6/MPw6f7Z0A9yjs3UBCiRW+Cxk28oRYhRP4LPY7rD5xDgU6TPrr5GqbWJPM8kv GY9ELYN8B+GCNIwHg7W8L/saE6nUY8UGWTjI9I2ZN8japezxXJrOatQ+tGEbv1rWRuDc KfZHjm9d6eksvENNaqrnRA9SMrxMQp5INwl1gDwTsnvoaUSWo7NlU61/TFrw1E5eUn8j iqoA== 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=qqKC0aSbOxnvRt4Ak9385i5tuKqObKaJREy1yTVl17E=; b=UkZkYD7w6V6mpRdNHs8jzWCjlNyx6NvnskBbhbw7kXX72Z9DqjHTgBxiGkYs02+bOL xEvpRSDgcbH+4m5H3+jbnnGl7Nm8cCMDB8KhmC2OGgbzSAJLfNPUozIZa030CumCe5Of eEUTA1qeRTrHd7v43sFRpjfbcux3AzaLfDZ3MwSYjtaLZFyEm5xaPL4kMz686KDHUrse TqWD3TyWeBXj/YproDa5FS8IgDVOfyzm0qYMLJayFN282ocyhGxfwFq/75thQEmK9tqd jYNJej7ZhpU9DdlLHw5iCg8JzzOewRlY8m6n+Rb0qMhESoAYbyz24YgJuUYiXt+eWQa4 X+aQ== X-Gm-Message-State: APjAAAUaZ90T2eLCliP0ytUixFuDVMsGkkwgCg9i8uIuwdq7eOWrb1jn wcvn74YGDdBgvlUe0T5D812VEA== X-Received: by 2002:a5d:4581:: with SMTP id p1mr5980478wrq.228.1559036997603; Tue, 28 May 2019 02:49:57 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id s13sm1917474wmh.31.2019.05.28.02.49.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 May 2019 02:49:56 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DDB9C1FF92; Tue, 28 May 2019 10:49:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 28 May 2019 10:49:30 +0100 Message-Id: <20190528094953.14898-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528094953.14898-1-alex.bennee@linaro.org> References: <20190528094953.14898-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::42c Subject: [Qemu-devel] [PULL 05/28] 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "open list:ARM" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org 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 Reviewed-by: Philippe Mathieu-Daudé -- 2.20.1 diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index a99049c7d58..d812eef1519 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" @@ -239,6 +244,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); @@ -509,14 +523,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; } @@ -570,8 +586,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; @@ -619,7 +637,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. */ @@ -632,14 +651,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. */