From patchwork Wed Feb 17 23:39:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 383934 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3218588jao; Wed, 17 Feb 2021 15:42:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2Vr7zyvbXMs/MWmaQotNNraoaieiTdO/PKvURbMf23dKxverammK0+pYh1jhMiPdGz/eK X-Received: by 2002:a25:7d84:: with SMTP id y126mr2718849ybc.179.1613605379742; Wed, 17 Feb 2021 15:42:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613605379; cv=none; d=google.com; s=arc-20160816; b=1IQHi1b3BhH9oXYWcl8gr2kqlWhG5ATmDVGeMuPPtEMmysUssY0l+mprQF9RtVb4Ic YyZoAeTxQmoLm56BCC1g46HViAFQvqsw8cnqoLZwO1Xoi7O7wRcuuQfkc+VssYHlUsaY i7yXLdKUMG+0huBqTDBTjOXBNRbmkEOkEQTgypYeG1uh8hscErSs8+cSSv1xKfhwdVwC 0mW+fYQhs3rlxGQ6sYLyofnstI5C2nTQLJWVT32nA9NgZ0wX5EYxxIVcmAwocSSVE9lr 0yHP0Y6mWC1Wpo+sn5FUFLQJrcOKvNsXpAeSekOQ70JSouK8bwHKhZH4g1LarDTmr6LY 9iTA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=efU7ifq9UHagxlnOIXBK9C1qiS3Jd4xMBPPTZVTIbDY=; b=G7/T+8tmONWiEYMltJC0p1TuwrdD45s1kB7TYxwh72hFhF73ssuOIz/o949G2An7v+ +Tu7KChNXXwDwPrVUmhO+nSndTTG2yAB4YUSEdSEKxcvo5cQLhWJIkl5loyOe2B49ldB cZN0AVycFxPWW5CP7JeJy4FoRFJ1WcDW8QB+V8GH9gwCZMcrXRx/hu5evZoQULqA0eRP Nh4uLbSWCisBmGf6seEpeQRjd3B4EWyXc6RLUWZQw3xDja52Kg3+ARuRSwG2Y609ThrT m7J08Yb7w+ylCkXnS05C1CNR8GxtJlQcglskQXfVe+kEHbAI3JqJ7kLM9SvEoCndZpm+ il0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gC3TM2ta; 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=pass (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 e3si3488218ybi.121.2021.02.17.15.42.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Feb 2021 15:42:59 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=gC3TM2ta; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCWTD-00031N-5c for patch@linaro.org; Wed, 17 Feb 2021 18:42:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCWR4-0007zS-JA for qemu-devel@nongnu.org; Wed, 17 Feb 2021 18:40:46 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:42141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCWR2-0004bZ-Hq for qemu-devel@nongnu.org; Wed, 17 Feb 2021 18:40:46 -0500 Received: by mail-pf1-x430.google.com with SMTP id w18so23441pfu.9 for ; Wed, 17 Feb 2021 15:40:44 -0800 (PST) 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=efU7ifq9UHagxlnOIXBK9C1qiS3Jd4xMBPPTZVTIbDY=; b=gC3TM2taN0e8jDaoxIN53fP4wOhxMGx7BstzVcAv82Ckc+cHsM9trud6XtuDwyCOy8 4u0RrjMGBpR0oPV2pkw7llQBPmD5S2rdTY+l77gxB5wqeB0DyfSBk6ChJ9bKBbqfJKdi Sa7J8Zll5V8nuwmg4iuRt9OWwjR6XufW4gzgTbDLQGTGhybbmuIa4kGynWI4khMxPGel w+VHt0YVsg3VgtXwqyKOLUFQKzhiMz0KLht/H708NJ9Wt15euYZhbGQd3Fi0XBXgqu08 aQ4dqDNIbs7zSjTYOy+U96G+rSfQbwfwWvsf/rkrZN8bdqLbwm3xeKht0p7nxRUzmWEd Aiug== 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=efU7ifq9UHagxlnOIXBK9C1qiS3Jd4xMBPPTZVTIbDY=; b=JC0QA318fvoJngvq22KeVsijosM5ntOpZBbIMq5ubfGNgE28LVsJI0nVlYmu7N7nh4 i/ihLDoRRfsnv3+l4B5mceRrO1k5Eb3GqFvqYkzjkgwuBhKxKzYG42+A91pHcZnBX+kn k1Z928DxjE9n11gprtefgasCcBW2b/zGih2JOS+OqTTzW8vFiGmmUpG40oMfTbGsA6FR fZgTeuOnsjvPe6tJGf2mdPS1W/aETM6hn+qX7EReyRnmIRpPTxS1HznX7ZFhs3Cy2pxx j8Ih92H+FFHPMurx5ZTu8EWQkTCOTg6nys/gvrLwUNOz0YlvE5W1QV9uTVkhX5OXAPwj 2D9g== X-Gm-Message-State: AOAM533/hD8qsqiWG6vk0q/J+Ul0m/JKH0kNJNlHnPx3z+05RmWlK++6 Fo1iKAKS9BsGdf0uW9Fdg0cY56UpptGOFg== X-Received: by 2002:a62:dd48:0:b029:1d5:e29c:621c with SMTP id w69-20020a62dd480000b02901d5e29c621cmr1534670pff.31.1613605240182; Wed, 17 Feb 2021 15:40:40 -0800 (PST) Received: from localhost.localdomain (047-051-160-125.biz.spectrum.com. [47.51.160.125]) by smtp.gmail.com with ESMTPSA id c21sm3950355pgh.0.2021.02.17.15.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 15:40:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/35] Hexagon (disas) disassembler Date: Wed, 17 Feb 2021 15:39:54 -0800 Message-Id: <20210217234023.1742406-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210217234023.1742406-1-richard.henderson@linaro.org> References: <20210217234023.1742406-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Taylor Simpson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Taylor Simpson Add hexagon to disas/meson.build Add disas/hexagon.c Add hexagon to include/disas/dis-asm.h Signed-off-by: Taylor Simpson Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Message-Id: <1612763186-18161-6-git-send-email-tsimpson@quicinc.com> Signed-off-by: Richard Henderson --- include/disas/dis-asm.h | 1 + disas/hexagon.c | 65 +++++++++++++++++++++++++++++++++++++++++ disas/meson.build | 1 + 3 files changed, 67 insertions(+) create mode 100644 disas/hexagon.c -- 2.25.1 diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index d1133a4e04..13fa1edd41 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -459,6 +459,7 @@ int print_insn_xtensa (bfd_vma, disassemble_info*); int print_insn_riscv32 (bfd_vma, disassemble_info*); int print_insn_riscv64 (bfd_vma, disassemble_info*); int print_insn_rx(bfd_vma, disassemble_info *); +int print_insn_hexagon(bfd_vma, disassemble_info *); #ifdef CONFIG_CAPSTONE bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size); diff --git a/disas/hexagon.c b/disas/hexagon.c new file mode 100644 index 0000000000..3c24e2a94a --- /dev/null +++ b/disas/hexagon.c @@ -0,0 +1,65 @@ +/* + * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * QEMU Hexagon Disassembler + */ + +#include "qemu/osdep.h" +#include "disas/dis-asm.h" +#include "target/hexagon/cpu_bits.h" + +/* + * We will disassemble a packet with up to 4 instructions, so we need + * a hefty size buffer. + */ +#define PACKET_BUFFER_LEN 1028 + +int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info) +{ + uint32_t words[PACKET_WORDS_MAX]; + bool found_end = false; + GString *buf = g_string_sized_new(PACKET_BUFFER_LEN); + int i, len; + + for (i = 0; i < PACKET_WORDS_MAX && !found_end; i++) { + int status = (*info->read_memory_func)(memaddr + i * sizeof(uint32_t), + (bfd_byte *)&words[i], + sizeof(uint32_t), info); + if (status) { + if (i > 0) { + break; + } + (*info->memory_error_func)(status, memaddr, info); + return status; + } + if (is_packet_end(words[i])) { + found_end = true; + } + } + + if (!found_end) { + (*info->fprintf_func)(info->stream, ""); + return PACKET_WORDS_MAX * sizeof(uint32_t); + } + + len = disassemble_hexagon(words, i, memaddr, buf); + (*info->fprintf_func)(info->stream, "%s", buf->str); + g_string_free(buf, true); + + return len; +} diff --git a/disas/meson.build b/disas/meson.build index da341a511e..4c8da01877 100644 --- a/disas/meson.build +++ b/disas/meson.build @@ -6,6 +6,7 @@ common_ss.add(when: 'CONFIG_ARM_A64_DIS', if_true: files('arm-a64.cc')) common_ss.add_all(when: 'CONFIG_ARM_A64_DIS', if_true: libvixl_ss) common_ss.add(when: 'CONFIG_ARM_DIS', if_true: files('arm.c')) common_ss.add(when: 'CONFIG_CRIS_DIS', if_true: files('cris.c')) +common_ss.add(when: 'CONFIG_HEXAGON_DIS', if_true: files('hexagon.c')) common_ss.add(when: 'CONFIG_HPPA_DIS', if_true: files('hppa.c')) common_ss.add(when: 'CONFIG_I386_DIS', if_true: files('i386.c')) common_ss.add(when: 'CONFIG_LM32_DIS', if_true: files('lm32.c'))