From patchwork Sat May 21 00:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 574936 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1f0e:0:0:0:0 with SMTP id hs14csp2679630mab; Fri, 20 May 2022 17:54:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeAlNTX7B55cx0++obyTKzCve26st3vn6Y85Y6/+5artGw6voXkBlu/l2RluHLcQra1Efl X-Received: by 2002:a0c:ee2c:0:b0:461:d4bd:39ff with SMTP id l12-20020a0cee2c000000b00461d4bd39ffmr9979810qvs.109.1653094476483; Fri, 20 May 2022 17:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653094476; cv=none; d=google.com; s=arc-20160816; b=jv/zE/Lz/AOz59W6B7Px0y0SMz/84YbJqldUO25aopVESpr7y6ZHpKot+Jt7D1FA39 jxcF/OmcPN246nPO3rRobP5RADZq9UrrMQkKcA8pfOE3pGewLkBvDPItSzR6XgQUjp8L g3kIHHWyC0ofQfr9v+QhwnSxtG2vHgcV8E9uEadtyL4P12mZjCXljncSdJ4YblYSwQ3L vQ4WxazMxOxHbbN69fJEgvo0owzzUftnzeMTGt3nZ9kc7b8sBmhZDtw76ihlSvzdChoq LlAMew9fsCDVyXwUy7b+5BP/EvTPaWfXIlr3l/2t7ZlqtPsHz0vxtu/SckXZ+5QL4fz+ h37w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=o7WLR0F1itSeL1D48lB12rI6iLH/uoOr7m0MR0rWKoM=; b=R1cWCAX6T1IhCXzfFldyArcKJBjdH5O3Whiq+4Ivo+nqalrJoniQAc4Zj8VskrSZMJ 5DdjGpjDbotlYoaF2BiDFtczw/RphNsJqwvQxjWPUHtAAFAWzvm5J7AknaaA8B35B77s bY9XAPd8ICwVxv0w0ho73CrL0rvBI8ZsenRf2DC4yk8wq5JNQit3n6rL4wE5qYObKZrk ro4rjINJKjr+uSoX/QSKE+ck+pJ/tt0r3AT9UsgwNa3BB7yU56ayVKTg4pKU3ybjRenb 5X/1sJ3ocEe4EoNcIh2NwTaUGz/jAUHEiVWXECNChdDrtgYozo2p1wyB00WSOVgjf6W5 Ip5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNUHDmDN; 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 u17-20020a05620a431100b006a012a715edsi400047qko.78.2022.05.20.17.54.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 May 2022 17:54:36 -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=pass header.i=@linaro.org header.s=google header.b=cNUHDmDN; 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]:35762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nsDO8-0007Ft-03 for patch@linaro.org; Fri, 20 May 2022 20:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nsCc6-0008CA-Ct for qemu-devel@nongnu.org; Fri, 20 May 2022 20:05:00 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:43761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nsCbY-000408-E0 for qemu-devel@nongnu.org; Fri, 20 May 2022 20:04:48 -0400 Received: by mail-pj1-x102b.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so9051593pjq.2 for ; Fri, 20 May 2022 17:04:21 -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=o7WLR0F1itSeL1D48lB12rI6iLH/uoOr7m0MR0rWKoM=; b=cNUHDmDNyq+Ai9EELn3N5NwNo+tJRt6FtwsKwSpJHHrWz96WETSqad8TWgt30bmTfN 8AsjlPzQIv0SFtW7EYJ2DXJr4tn2c3w2Cy6lqLISsUJ7b7gkfxqZNGfl9rZFUQ7JiM6Y AiOdbDSG7jV7Cd4jE4t2kvhpQJYTW6bya7/w4f/2HGYLe5jkIsNjZpPaW3eM1Y4c7u2K NS2YuJcGDBpLQtJye95oiKC0r4f8o+4+pQrh1pOYpki1hrFHhVMFpg6Ode0lmUlTv8WF QK68950tH2TViVw1zh9qs0mZOUO0ocwRCjYnsgkUmrjXxrDDZT8q9pCVk9wjB9vnnFQ6 UdkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o7WLR0F1itSeL1D48lB12rI6iLH/uoOr7m0MR0rWKoM=; b=1QrMHbqNS/HNl3rblYVO3Pbq+CTC1CL44hojux0l8jKm3tIHaBAD0G/PWpycKbi1ey oNc9TwSY6xgnMJvQJUjji/Zd3wjug79lLUaxGzonDvOIhnU7126ubZmYp5498fqshmOc UhmQKyFXGXYz21NvJ0KyuRmuQ0XnVaeDD6Rysm10hHlRDv+a/whChJy6WYjBuzia4m18 V6dTEO6YUtFQTFzJo6ePWwziHEXRWs+fLCNQLsWBhb9jQ+wPacCv/iRvYY6jqVBgGnnL 8OOcEP9ZzZY/6O7HJObSf80HJEMF9qkC3WYsYGaTsyMFJMH0+JezMafCPaIcPP7+H7ZW hRlA== X-Gm-Message-State: AOAM530ckQOlZOZ4JdfHUIWUTCvqKEOv4Mf0PXQ4nMd1B7itPxNOyI6Y Rby+Pu+xhQekVoEI3WHyN36XZ77scmck3w== X-Received: by 2002:a17:902:ea0a:b0:161:fb2f:ef9b with SMTP id s10-20020a170902ea0a00b00161fb2fef9bmr3301166plg.22.1653091460357; Fri, 20 May 2022 17:04:20 -0700 (PDT) Received: from stoup.. ([71.212.142.129]) by smtp.gmail.com with ESMTPSA id h8-20020a654808000000b003f9d1c020cbsm306369pgs.51.2022.05.20.17.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 17:04:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Subject: [PATCH v3 15/49] include/exec: Move gdb_stat and gdb_timeval to gdbstub.h Date: Fri, 20 May 2022 17:03:26 -0700 Message-Id: <20220521000400.454525-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220521000400.454525-1-richard.henderson@linaro.org> References: <20220521000400.454525-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have two copies of these structures, and require them in semihosting/ going forward. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Alex Bennée --- include/exec/gdbstub.h | 25 +++++++++++++++++++++++++ target/m68k/m68k-semi.c | 30 +++--------------------------- target/nios2/nios2-semi.c | 30 +++--------------------------- 3 files changed, 31 insertions(+), 54 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 2aaba9c723..33a262a5a3 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -20,6 +20,31 @@ #define GDB_O_TRUNC 0x400 #define GDB_O_EXCL 0x800 +/* For gdb file i/o stat/fstat. */ +typedef uint32_t gdb_mode_t; +typedef uint32_t gdb_time_t; + +struct gdb_stat { + uint32_t gdb_st_dev; /* device */ + uint32_t gdb_st_ino; /* inode */ + gdb_mode_t gdb_st_mode; /* protection */ + uint32_t gdb_st_nlink; /* number of hard links */ + uint32_t gdb_st_uid; /* user ID of owner */ + uint32_t gdb_st_gid; /* group ID of owner */ + uint32_t gdb_st_rdev; /* device type (if inode device) */ + uint64_t gdb_st_size; /* total size, in bytes */ + uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ + uint64_t gdb_st_blocks; /* number of blocks allocated */ + gdb_time_t gdb_st_atime; /* time of last access */ + gdb_time_t gdb_st_mtime; /* time of last modification */ + gdb_time_t gdb_st_ctime; /* time of last change */ +} QEMU_PACKED; + +struct gdb_timeval { + gdb_time_t tv_sec; /* second */ + uint64_t tv_usec; /* microsecond */ +} QEMU_PACKED; + #ifdef NEED_CPU_H #include "cpu.h" diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 475a6b13b7..da0186f3ef 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -45,30 +45,6 @@ #define HOSTED_ISATTY 12 #define HOSTED_SYSTEM 13 -typedef uint32_t gdb_mode_t; -typedef uint32_t gdb_time_t; - -struct m68k_gdb_stat { - uint32_t gdb_st_dev; /* device */ - uint32_t gdb_st_ino; /* inode */ - gdb_mode_t gdb_st_mode; /* protection */ - uint32_t gdb_st_nlink; /* number of hard links */ - uint32_t gdb_st_uid; /* user ID of owner */ - uint32_t gdb_st_gid; /* group ID of owner */ - uint32_t gdb_st_rdev; /* device type (if inode device) */ - uint64_t gdb_st_size; /* total size, in bytes */ - uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ - uint64_t gdb_st_blocks; /* number of blocks allocated */ - gdb_time_t gdb_st_atime; /* time of last access */ - gdb_time_t gdb_st_mtime; /* time of last modification */ - gdb_time_t gdb_st_ctime; /* time of last change */ -} QEMU_PACKED; - -struct gdb_timeval { - gdb_time_t tv_sec; /* second */ - uint64_t tv_usec; /* microsecond */ -} QEMU_PACKED; - static int translate_openflags(int flags) { int hf; @@ -90,9 +66,9 @@ static int translate_openflags(int flags) static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat *s) { - struct m68k_gdb_stat *p; + struct gdb_stat *p; - if (!(p = lock_user(VERIFY_WRITE, addr, sizeof(struct m68k_gdb_stat), 0))) + if (!(p = lock_user(VERIFY_WRITE, addr, sizeof(struct gdb_stat), 0))) /* FIXME - should this return an error code? */ return; p->gdb_st_dev = cpu_to_be32(s->st_dev); @@ -114,7 +90,7 @@ static void translate_stat(CPUM68KState *env, target_ulong addr, struct stat *s) p->gdb_st_atime = cpu_to_be32(s->st_atime); p->gdb_st_mtime = cpu_to_be32(s->st_mtime); p->gdb_st_ctime = cpu_to_be32(s->st_ctime); - unlock_user(p, addr, sizeof(struct m68k_gdb_stat)); + unlock_user(p, addr, sizeof(struct gdb_stat)); } static void m68k_semi_return_u32(CPUM68KState *env, uint32_t ret, uint32_t err) diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 0eec1f9a1c..3e504a6c5f 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -47,30 +47,6 @@ #define HOSTED_ISATTY 12 #define HOSTED_SYSTEM 13 -typedef uint32_t gdb_mode_t; -typedef uint32_t gdb_time_t; - -struct nios2_gdb_stat { - uint32_t gdb_st_dev; /* device */ - uint32_t gdb_st_ino; /* inode */ - gdb_mode_t gdb_st_mode; /* protection */ - uint32_t gdb_st_nlink; /* number of hard links */ - uint32_t gdb_st_uid; /* user ID of owner */ - uint32_t gdb_st_gid; /* group ID of owner */ - uint32_t gdb_st_rdev; /* device type (if inode device) */ - uint64_t gdb_st_size; /* total size, in bytes */ - uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ - uint64_t gdb_st_blocks; /* number of blocks allocated */ - gdb_time_t gdb_st_atime; /* time of last access */ - gdb_time_t gdb_st_mtime; /* time of last modification */ - gdb_time_t gdb_st_ctime; /* time of last change */ -} QEMU_PACKED; - -struct gdb_timeval { - gdb_time_t tv_sec; /* second */ - uint64_t tv_usec; /* microsecond */ -} QEMU_PACKED; - static int translate_openflags(int flags) { int hf; @@ -102,9 +78,9 @@ static int translate_openflags(int flags) static bool translate_stat(CPUNios2State *env, target_ulong addr, struct stat *s) { - struct nios2_gdb_stat *p; + struct gdb_stat *p; - p = lock_user(VERIFY_WRITE, addr, sizeof(struct nios2_gdb_stat), 0); + p = lock_user(VERIFY_WRITE, addr, sizeof(struct gdb_stat), 0); if (!p) { return false; @@ -128,7 +104,7 @@ static bool translate_stat(CPUNios2State *env, target_ulong addr, p->gdb_st_atime = cpu_to_be32(s->st_atime); p->gdb_st_mtime = cpu_to_be32(s->st_mtime); p->gdb_st_ctime = cpu_to_be32(s->st_ctime); - unlock_user(p, addr, sizeof(struct nios2_gdb_stat)); + unlock_user(p, addr, sizeof(struct gdb_stat)); return true; }