From patchwork Tue Aug 20 12:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuriy Kolerov X-Patchwork-Id: 96152 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5ACA38449C8 for ; Tue, 20 Aug 2024 12:13:32 +0000 (GMT) X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mx0b-00230701.pphosted.com (mx0b-00230701.pphosted.com [148.163.158.9]) by sourceware.org (Postfix) with ESMTPS id E9AFD384A47F for ; Tue, 20 Aug 2024 12:11:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9AFD384A47F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=synopsys.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=synopsys.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E9AFD384A47F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724155897; cv=none; b=gsv83HuNcFOOixYLIsfEl7CfRCSa9XWxswilQKGRpA24S2UOKjXZ8ve6VeU0TFAi6CX6ygJwkociuHtu02F41VKhpDu2Lo7UkcEmN8pDU3A5bZ7kMSk72Ge3B4wG30YqD7DRYuf5gpw7tItXowEq7P5CVS8mFb3y/K1NCpRq0So= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724155897; c=relaxed/simple; bh=+o6av86t0JFeJLlmiDAHY0C1D5iyM9MIFwVwPUcE1OY=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=j8n8whcJV1vPMW5ZMcrPYxoJiIHic8NwxS7ppf8fHG3GAico7QcqV6l0bDM1zxnTBUHXcPDTvwkcKt9iYOm30eu3ON3wLVBnENSdgefPqqlx2Wn5Gx6BiAmncbFrWqYjwOc+GVMhtPyVYOQoLv+LVloKVz5iOaw6MfoZ5lCOPc4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0098572.ppops.net [127.0.0.1]) by mx0b-00230701.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47KBaLPq007967 for ; Tue, 20 Aug 2024 05:11:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=synopsys.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pfptdkimsnps; bh=2YLVfRgO Eu55oi6DkxVgB1wdUmyfqwoUT2EsjE96pnw=; b=BYjU4KCs3jKwlqatHG0MkhYB v6FCAmYcLOqD1NFHmSSfYq+8QwWgFX3PhdUqGbpWzOow1PGnr4SjvXeoLorvxlQD 0Tlg+VyFqqaoAdGNrBgJv4IaqCAIokl7e6IYf16kA9mxe7rKnSR328re1uuC6vqA 7rOhORJQjJtmsyPGL729zD3j8DW6i7Mjl3NlcT6yYYctIri20sf4YLS1ZoNyTL9f xE9uNd1s45mNOPavHUgqpr82rYnxBH3oLG5abcDEZ48v7Y5dBNRk9agI/17CXH0F D0wlxXvQ7ntLvyA0AYRnOiOScMGFkTwzG2NMHonNaappUSx1LM+0GJGAH/sRmA== Received: from smtprelay-out1.synopsys.com (smtprelay-out1.synopsys.com [149.117.73.133]) by mx0b-00230701.pphosted.com (PPS) with ESMTPS id 414g8k2rcy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 20 Aug 2024 05:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1724155893; bh=+o6av86t0JFeJLlmiDAHY0C1D5iyM9MIFwVwPUcE1OY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a7jJkqPykIkrYJrhmx2/Clt01Ja0U4mUNvaJzuL3Y86ieIXI/X6BQIq/96E2C1ZRu o3fgkyt4z7xk1tTpufyOEAoMBD7YivtopfoIP4f3XvhbYkellKUn4eLAyfoFWFmZvF VTS602Kq+GUMrc9PjHf10LbQCr4oDpguenZusOS9tKw/NMQkqVEQTukz95PvFzaCms z+20N/fF9ERkPJCN5ez46Y+Mkj/fPdqkgJLznkAWpIgm0a6gHboz49jiRJjbKsCKGh B4tPs+fj+AR0LEZkT+AtTMcq1AkC95YmqU/KDX1XeoVllmU7B/+SeICDTOcjiP/iAV BgTUkSQaTxcRg== Received: from mailhost.synopsys.com (eudc-mailhost2.synopsys.com [10.213.161.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) client-signature RSA-PSS (2048 bits)) (Client CN "mailhost.synopsys.com", Issuer "SNPSica2" (verified OK)) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 1DD1D4048B for ; Tue, 20 Aug 2024 12:11:33 +0000 (UTC) Received: from SNPS-HRlPxd6IgG.internal.synopsys.com (snps-hrlpxd6igg.internal.synopsys.com [10.120.15.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by mailhost.synopsys.com (Postfix) with ESMTPSA id AB6D2C0CBA; Tue, 20 Aug 2024 12:11:31 +0000 (UTC) X-SNPS-Relay: synopsys.com From: Yuriy.Kolerov@synopsys.com To: newlib@sourceware.org Cc: Yuriy Kolerov Subject: [PATCH 8/8] arc: libgloss: Prepare for porting to ARCv3 Date: Tue, 20 Aug 2024 15:10:43 +0300 Message-Id: <20240820121043.1605628-9-ykolerov@synopsys.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820121043.1605628-1-ykolerov@synopsys.com> References: <20240820121043.1605628-1-ykolerov@synopsys.com> MIME-Version: 1.0 X-Authority-Analysis: v=2.4 cv=bpgeB1ai c=1 sm=1 tr=0 ts=66c487f6 cx=c_pps a=8EbXvwLXkpGsT4ql/pYRAw==:117 a=8EbXvwLXkpGsT4ql/pYRAw==:17 a=yoJbH4e0A30A:10 a=jIQo8A4GAAAA:8 a=wcNbVyCmb0o-XqfLdlsA:9 a=OSEWBN1MTu-9z82vAJ5Y:22 a=Lf5xNeLK5dgiOs8hzIjU:22 X-Proofpoint-GUID: PmagYsImtggCbHWosezTvVAfRFw3FLmH X-Proofpoint-ORIG-GUID: PmagYsImtggCbHWosezTvVAfRFw3FLmH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-20_09,2024-08-19_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_active_cloned_notspam policy=outbound_active_cloned score=0 suspectscore=0 impostorscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 malwarescore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408200090 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org From: Yuriy Kolerov There are 3 families of Synopsys DeisgnWare ARC processors: ARCompact/ARCv1 (32-bit), ARCv2 (32-bit) and ARCv3 (32-bit and 64-bit targets). Upstream Newlib supports only ARCv1/2. This commit prepares ARCv1/2 libgloss port to be reused by ARCv3 port (except crt* files). Note that __ARC64__ macro stands for all ARCv3 targets. Signed-off-by: Yuriy Kolerov --- libgloss/arc/hl-stub.c | 14 ++++++++++++++ libgloss/arc/hl/hl_gw.c | 9 +++++++++ libgloss/arc/hl/hl_toolchain.h | 10 ++++++++++ libgloss/arc/nsim-syscalls.c | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/libgloss/arc/hl-stub.c b/libgloss/arc/hl-stub.c index 7f5b9facc..c4d6ee67b 100644 --- a/libgloss/arc/hl-stub.c +++ b/libgloss/arc/hl-stub.c @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -44,6 +45,19 @@ _getpid (void) return __MYPID; } +/* We do not have 64-bit compatible hostlink fstat. */ +#if defined (__ARC64__) +int +_fstat (int fd, struct stat *st) +{ + memset (st, 0, sizeof (*st)); + st->st_mode = S_IFCHR; + st->st_blksize = 1024; + + return 0; +} +#endif + /* hostlink backend has only fstat(), so use fstat() in stat(). */ int diff --git a/libgloss/arc/hl/hl_gw.c b/libgloss/arc/hl/hl_gw.c index f576f097e..4a8f8780f 100644 --- a/libgloss/arc/hl/hl_gw.c +++ b/libgloss/arc/hl/hl_gw.c @@ -15,6 +15,7 @@ * */ +#include #include "hl_gw.h" #define HL_VERSION 1 @@ -134,7 +135,15 @@ _hl_send (volatile __uncached void *p) _hl_pkt_init (pkt_hdr, _hl_payload_used (p)); +#if defined (__ARC64__) + /* + * Here we pass only low 4 bytes of the packet address (pkt_hdr). + * The high part of the address is obtained from __HOSTLINK__ address. + */ + hdr->buf_addr = (uintptr_t) pkt_hdr & 0xFFFFFFFF; +#else hdr->buf_addr = (uint32_t) pkt_hdr; +#endif hdr->payload_size = _hl_payload_size (); hdr->host2target_addr = HL_NOADDRESS; hdr->version = HL_VERSION; diff --git a/libgloss/arc/hl/hl_toolchain.h b/libgloss/arc/hl/hl_toolchain.h index bf884bf3f..946061718 100644 --- a/libgloss/arc/hl/hl_toolchain.h +++ b/libgloss/arc/hl/hl_toolchain.h @@ -19,7 +19,12 @@ #define _HL_TOOLCHAIN_H #ifndef __uncached +#if defined (__ARC64__) + /* TODO: Uncached attribute is not implemented for ARCv3 yet. */ + #define __uncached +#else #define __uncached __attribute__((uncached)) +#endif #endif /* __uncached */ #ifndef __aligned @@ -43,7 +48,12 @@ #endif /* __noreturn */ #ifndef __longcall +#if defined (__ARC64__) + /* TODO: Long call attribute is not implemented for ARCv3 yet. */ + #define __longcall +#else #define __longcall __attribute__((long_call)) +#endif #endif /* __longcall */ #define HL_MAX_DCACHE_LINE 256 diff --git a/libgloss/arc/nsim-syscalls.c b/libgloss/arc/nsim-syscalls.c index 807f95cd0..0a99ad59c 100644 --- a/libgloss/arc/nsim-syscalls.c +++ b/libgloss/arc/nsim-syscalls.c @@ -100,7 +100,12 @@ _open (const char * pathname, int flags, int mode) } /* Should be provided by crt0.S. */ +#if defined (__ARC64__) +/* TODO: long_call is not implemented yet in GCC. Fix this when implemented. */ +extern void __attribute__((noreturn)) _exit_halt (int ret); +#else extern void __attribute__((noreturn, long_call)) _exit_halt (int ret); +#endif void __attribute__((noreturn))