From nobody Sat Nov 15 16:38:36 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=htecgroup.com); dmarc=pass(p=reject dis=none) header.from=htecgroup.com ARC-Seal: i=2; a=rsa-sha256; t=1750249751; cv=pass; d=zohomail.com; s=zohoarc; b=EXhevsuMpWmZ69iIdF4J7w3GUQmqWhch7FFtQop7HFinopq5PtfZTwDwh6VuZNJf/do3lotEjMo01R4wspRHOYd2AFWDQwyqovAA1D2+ZaDjBi4pkYwizRcaF3ZJzVTMrnVODv6PhYrXSwTfsZWp9OQR5NtEw5r+RPdQRbsggTE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750249751; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H7Nqr7IDfMQivuLza3uTbtJQJdoU4RVT4CEqeIgbzLE=; b=c15VFn042nnm/ERhYZYvCW7oM35zQjIFkw87HI+5YbDYmZmHaLEc3tQp3PaHHeYHMTFhKbZ7JLiEX5IPnQDIvGu8xI3xuM6/c+jv74ekZHe2zRHCFdZO65naT98gARc9HhTxgkqD9NGBpbVQOY4nmw79TgCU8rnJdSbozDUk/M0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=htecgroup.com); dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750249751091444.7070773148944; Wed, 18 Jun 2025 05:29:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRrtV-000663-Gj; Wed, 18 Jun 2025 08:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uRrtS-00065P-Uh; Wed, 18 Jun 2025 08:27:55 -0400 Received: from mail-northeuropeazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c200::1] helo=DB3PR0202CU003.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uRrtQ-0005VZ-Ei; Wed, 18 Jun 2025 08:27:54 -0400 Received: from AS4PR09MB6518.eurprd09.prod.outlook.com (2603:10a6:20b:4fb::5) by AS1PR09MB6509.eurprd09.prod.outlook.com (2603:10a6:20b:482::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8835.26; Wed, 18 Jun 2025 12:27:47 +0000 Received: from AS4PR09MB6518.eurprd09.prod.outlook.com ([fe80::ad50:891a:847c:580a]) by AS4PR09MB6518.eurprd09.prod.outlook.com ([fe80::ad50:891a:847c:580a%3]) with mapi id 15.20.8857.016; Wed, 18 Jun 2025 12:27:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h+Rm3ItVeZ43mBXewLnndUNnraBFwDs+vn1XvrgyQSy71wMiRwiL6pQeRfNz++3W+jtOLuxM2SJisfMs0l4inRygky5NMJJs+VOlTMpYDqFHfhPFfsCCXzuiP01hTfAuhYwT/bi6CsDeBmFqB5u/QcBWPmzE5gBpbOF31amkzXyCo0mfKeCzVlmruNpDjMfJrH26SueCIFF+1cHxrTkoc9mVvlK0r47i8fFMpyyey7+vDnGXPRVxwIPPHzHKZrAA82Y7OQKj1B6dwBgEbF6R77KMSbbKso0fgF2VU4CPX+2h29D6GAP9kvZiSXjaFFr8bV7cBVGFT5F2reDcsVw6PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H7Nqr7IDfMQivuLza3uTbtJQJdoU4RVT4CEqeIgbzLE=; b=iG11eYE4pNGd+nZ/msK8QjoVo3KHADmuCd7GVj9lOJeMwXD1Anlqf+emHdQYdtMCB3n3G3JKfKBVG5VX5klxqipBM9nLs4/FoBVi8bSJZVBUimwFnz0wBa/ZgGSHjtg22kEchgrcD1wky19w5iPutcPRXCCvV9on94JkoxuAjhi7fVPvSNipFeeKbFuMx0iZSYqLMS/MH4U8glMqwIfYauOi+cHwbuMp6jY++pQY4OpL/zRsSeawpbcNzrdu5Nzjh6H7zk6r5T60fJJmFhXKnr/LP3YqS0aOXU/AAxwZYLEZIqqml/tkqYzS4TFZos5Qq8kPQ4gNEfJBG/DKFqjTwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=htecgroup.com; dmarc=pass action=none header.from=htecgroup.com; dkim=pass header.d=htecgroup.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=htecgroup.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H7Nqr7IDfMQivuLza3uTbtJQJdoU4RVT4CEqeIgbzLE=; b=IXldWF7cYtOQMGce0TDJqPWcUyeVstnytHaMx0d6clVbmLN7Dhw0QfkC4K25UnmlK2Y1FoP1bNunH51bEocQWi4UWI/TqWPjTc6k6jJD0EFnG7xMmZRElck2UE6gDg7Tr40sZY3GgVnOrDifvQtpl4WBhq/up5OVGXwF/6AjYzR4VFCe//gx0mCxzT1/2082LwOQHlo5HFFioC2bGmpDWpzkybYKWxI6y30LRv6SpwMU9cF1GlyUXvgobeP8fYUwKHL0O07CgNUhVAZFjag8jkDdBLm1NpCtfD5HUWig0K7sZZhKKWvlaPiSn2ONk/BcUYBMJkmPP5kqO5nZ4P94kw== From: Djordje Todorovic To: "qemu-devel@nongnu.org" CC: "qemu-riscv@nongnu.org" , "cfu@mips.com" , Djordje Todorovic Subject: [PATCH v3 04/10] target/riscv: Add MIPS P8700 CSRs Thread-Topic: [PATCH v3 04/10] target/riscv: Add MIPS P8700 CSRs Thread-Index: AQHb4ExmcradWaJ9/UmUKF+3FV1Eww== Date: Wed, 18 Jun 2025 12:27:47 +0000 Message-ID: <20250618122715.1929966-5-djordje.todorovic@htecgroup.com> References: <20250618122715.1929966-1-djordje.todorovic@htecgroup.com> In-Reply-To: <20250618122715.1929966-1-djordje.todorovic@htecgroup.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=htecgroup.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS4PR09MB6518:EE_|AS1PR09MB6509:EE_ x-ms-office365-filtering-correlation-id: ee475580-5681-45da-59c2-08ddae6388ef x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?mdBo+EHKoqn8tnU+GRqMqqavZOcg52eta82pLUBhB11IVxnGCGy0Ubq0vV?= =?iso-8859-1?Q?FtT3mmbhwKFfCpegHn96igPqC22YQPMfvlaxX7I0DJ49i0KICCfokxH8Z4?= =?iso-8859-1?Q?sNO8bBt3+oNn/MpCp8XMHEmKgFVQfHIfB/OQxK5W6WHJLDidoEy+Jm4cxi?= =?iso-8859-1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zeTAIF0qs1yEb+rio?= =?iso-8859-1?Q?ETP/JJnTcneG43UPssJUaDTtrySZ2vtxXiK4BqQnQaMZ4fF8EDKul/p7ls?= =?iso-8859-1?Q?5mnuXKs0DaOXDO3vCH6vrtEM0zrd5nxRoiOxjJNz7d7tnlgWCaMy9w6AAq?= =?iso-8859-1?Q?81sl8m3Rz+6ZXIXhtNke+8SyFYyXgkPvbLXSF9w4dBZYqeOqXUKcxaVMjY?= =?iso-8859-1?Q?EIIS6GD3ehmuRyRx4MfOxR1c5IRAgUItBmn6SRHMTRrLjtmBhueREzuivT?= =?iso-8859-1?Q?ZytQvYFvtHAOghBnCDX8vSFgjrK7qvuvISRdL/Yv0K4BUqo181PAxE9KFo?= =?iso-8859-1?Q?u7BuQS6LhaDKIK/w7dcTEoKCGiSiQZF33l3UQcYCcp1y3m1jRv7c2RKdgE?= =?iso-8859-1?Q?z3tgzrDTYGwXyzuu3/gxqS3kjBTcc9LYo9D1NPDaF/8B4fynkqiIV9GdZS?= =?iso-8859-1?Q?V0h3gdm8G2R+p3v7zoBJt8G6R5sCDYjP3LbLEPTpzSYw=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS4PR09MB6518.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?gg+WQuThgSJJYF0XXpcB0DeYhrtU4Lk1E1yNOdPOvOfLfUHVad8hH3nIHA?= =?iso-8859-1?Q?xkQrckNTnmPWkne00f4a0rXWPBid0MyppOO0dmzzsOJ1UmZlWC75adfpDS?= =?iso-8859-1?Q?XYMugoFtdtWBO/uKLNZx0szC52pDSwEIsgfVQfcji7kELfsaIeXTIsUj35?= =?iso-8859-1?Q?NPfb9cli9JzdbNG7vkSicJB9eo3KS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859-1?Q?7dMc+6UhIPjP1kMxRwLszt9nOxxTNzCp4eArSaL9ZnjjjWXc+o5P+YmgKq?= =?iso-8859-1?Q?y6SWl1E00eeAZO0ZqAozOuGaZrEwxzVL3gjJgeSnM//XPn0e+RmbliQ0zt?= =?iso-8859-1?Q?6kMPS1n8LiFqdNvXbYeUlaVnknRgHrUkZucyA56iLrz5CnSerCAV0lbl4r?= =?iso-8859-1?Q?j5YTUnUkbm3doEMvep3KIX5hG/jhLqosH5VPszkcuhZQDNqb188z7b9VSm?= =?iso-8859-1?Q?zr3kETBWbWv0pyV4K75qG6hrNUPQiu2apU9bk7q48pNJdgZEwBs8sVJ/3F?= =?iso-8859-1?Q?ndMloJPmZ9H+ydh3vZXgboYBPLAFjcmKDvX7pVkL6hsBaaTS+8CisYa0OK?= =?iso-8859-1?Q?4yQtqv2F7uegE6q+zJuX6mj2kM4l0Ls9NhUD3l+5IDBiy82dRaYVgd0N+N?= =?iso-8859-1?Q?aXWMaa1rKs8t6M4L+SVWNo6UZbupKqoXuxFD0sx81x32BxY9zTUzMSGdd7?= =?iso-8859-1?Q?UqYM3Bg3t9xh2OGGNdEADxyTqo1YS+ojApDNFmMDJa89CknhcYPktNL95Z?= =?iso-8859-1?Q?FnZACFE8U/V3+Hma+TUO39x7cqZdHG15V6zNARX2VPH3cmweurmJ4amkzq?= =?iso-8859-1?Q?+Bd1AXPebQAcoy8W2YY=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS4PR09MB6518.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee475580-5681-45da-59c2-08ddae6388ef X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jun 2025 12:27:47.7929 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f85665b-7efd-4776-9dfe-b6bfda2565ee X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OUaA6ZIJjYO2/X2KUSTkx6DSh6PVuNYxSnEOx/0hQgVRQqsftITPX15tycOXxVT75BbglomjxQM/XqqMHXHPoLC5JjH5RVAck0ATM563RDA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR09MB6509 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:111:f403:c200::1; envelope-from=Djordje.Todorovic@htecgroup.com; helo=DB3PR0202CU003.outbound.protection.outlook.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_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @htecgroup.com) X-ZM-MESSAGEID: 1750249752038116600 Content-Type: text/plain; charset="utf-8" Define MIPS CSRs used for P8700 CPU. Signed-off-by: Chao-ying Fu Signed-off-by: Djordje Todorovic --- target/riscv/cpu.c | 3 + target/riscv/cpu.h | 12 +++ target/riscv/meson.build | 1 + target/riscv/mips_csr.c | 219 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 235 insertions(+) create mode 100644 target/riscv/mips_csr.c diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index be362e1644..1e85a16971 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -3179,6 +3179,9 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .cfg.ext_zba =3D true, .cfg.ext_zbb =3D true, .cfg.marchid =3D 0x8000000000000201, +#ifndef CONFIG_USER_ONLY + .custom_csrs =3D mips_csr_list, +#endif ), =20 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index fba0b0506b..bf1a931e60 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -199,6 +199,13 @@ typedef struct PMUFixedCtrState { uint64_t counter_virt_prev[2]; } PMUFixedCtrState; =20 +struct MIPSCSR { + uint64_t tvec; + uint64_t config[12]; + uint64_t pmacfg[15]; +}; +typedef struct MIPSCSR MIPSCSR; + struct CPUArchState { target_ulong gpr[32]; target_ulong gprh[32]; /* 64 top bits of the 128-bit registers */ @@ -497,6 +504,8 @@ struct CPUArchState { target_ulong rnmip; uint64_t rnmi_irqvec; uint64_t rnmi_excpvec; + + MIPSCSR mips_csrs; }; =20 /* @@ -972,5 +981,8 @@ const char *satp_mode_str(uint8_t satp_mode, bool is_32= _bit); /* In th_csr.c */ extern const RISCVCSR th_csr_list[]; =20 +/* Implemented in mips_csr.c */ +extern const RISCVCSR mips_csr_list[]; + const char *priv_spec_to_str(int priv_version); #endif /* RISCV_CPU_H */ diff --git a/target/riscv/meson.build b/target/riscv/meson.build index a4bd61e52a..fbb6c8fb45 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -32,6 +32,7 @@ riscv_system_ss.add(files( 'debug.c', 'monitor.c', 'machine.c', + 'mips_csr.c', 'pmu.c', 'th_csr.c', 'time_helper.c', diff --git a/target/riscv/mips_csr.c b/target/riscv/mips_csr.c new file mode 100644 index 0000000000..aab7f832a0 --- /dev/null +++ b/target/riscv/mips_csr.c @@ -0,0 +1,219 @@ +/* + * MIPS-specific CSRs. + * + * Copyright (c) 2025 MIPS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "cpu_vendorid.h" + +/* MIPS CSR */ +#define CSR_MIPSTVEC 0x7c0 +#define CSR_MIPSCONFIG0 0x7d0 +#define CSR_MIPSCONFIG1 0x7d1 +#define CSR_MIPSCONFIG2 0x7d2 +#define CSR_MIPSCONFIG3 0x7d3 +#define CSR_MIPSCONFIG4 0x7d4 +#define CSR_MIPSCONFIG5 0x7d5 +#define CSR_MIPSCONFIG6 0x7d6 +#define CSR_MIPSCONFIG7 0x7d7 +#define CSR_MIPSCONFIG8 0x7d8 +#define CSR_MIPSCONFIG9 0x7d9 +#define CSR_MIPSCONFIG10 0x7da +#define CSR_MIPSCONFIG11 0x7db +#define CSR_MIPSPMACFG0 0x7e0 +#define CSR_MIPSPMACFG1 0x7e1 +#define CSR_MIPSPMACFG2 0x7e2 +#define CSR_MIPSPMACFG3 0x7e3 +#define CSR_MIPSPMACFG4 0x7e4 +#define CSR_MIPSPMACFG5 0x7e5 +#define CSR_MIPSPMACFG6 0x7e6 +#define CSR_MIPSPMACFG7 0x7e7 +#define CSR_MIPSPMACFG8 0x7e8 +#define CSR_MIPSPMACFG9 0x7e9 +#define CSR_MIPSPMACFG10 0x7ea +#define CSR_MIPSPMACFG11 0x7eb +#define CSR_MIPSPMACFG12 0x7ec +#define CSR_MIPSPMACFG13 0x7ed +#define CSR_MIPSPMACFG14 0x7ee +#define CSR_MIPSPMACFG15 0x7ef + +static RISCVException any(CPURISCVState *env, int csrno) +{ + return RISCV_EXCP_NONE; +} + +static RISCVException read_mipstvec(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->mips_csrs.tvec; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mipstvec(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) +{ + env->mips_csrs.tvec =3D val; + return RISCV_EXCP_NONE; +} + +static RISCVException read_mipsconfig(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->mips_csrs.config[csrno - CSR_MIPSCONFIG0]; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mipsconfig(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) +{ + env->mips_csrs.config[csrno - CSR_MIPSCONFIG0] =3D val; + return RISCV_EXCP_NONE; +} + +static RISCVException read_mipspmacfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->mips_csrs.pmacfg[csrno - CSR_MIPSPMACFG0]; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mipspmacfg(CPURISCVState *env, int csrno, + target_ulong val, uintptr_t ra) +{ + env->mips_csrs.pmacfg[csrno - CSR_MIPSPMACFG0] =3D val; + return RISCV_EXCP_NONE; +} + +const RISCVCSR mips_csr_list[] =3D { + { + .csrno =3D CSR_MIPSTVEC, + .csr_ops =3D { "mipstvec", any, read_mipstvec, write_mipstvec } + }, + { + .csrno =3D CSR_MIPSCONFIG0, + .csr_ops =3D { "mipsconfig0", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG1, + .csr_ops =3D { "mipsconfig1", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG2, + .csr_ops =3D { "mipsconfig2", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG3, + .csr_ops =3D { "mipsconfig3", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG4, + .csr_ops =3D { "mipsconfig4", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG5, + .csr_ops =3D { "mipsconfig5", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG6, + .csr_ops =3D { "mipsconfig6", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG7, + .csr_ops =3D { "mipsconfig7", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG8, + .csr_ops =3D { "mipsconfig8", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG9, + .csr_ops =3D { "mipsconfig9", any, read_mipsconfig, write_mipsconf= ig } + }, + { + .csrno =3D CSR_MIPSCONFIG10, + .csr_ops =3D { "mipsconfig10", any, read_mipsconfig, write_mipscon= fig } + }, + { + .csrno =3D CSR_MIPSCONFIG11, + .csr_ops =3D { "mipsconfig11", any, read_mipsconfig, write_mipscon= fig } + }, + { + .csrno =3D CSR_MIPSPMACFG0, + .csr_ops =3D { "mipspmacfg0", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG1, + .csr_ops =3D { "mipspmacfg1", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG2, + .csr_ops =3D { "mipspmacfg2", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG3, + .csr_ops =3D { "mipspmacfg3", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG4, + .csr_ops =3D { "mipspmacfg4", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG5, + .csr_ops =3D { "mipspmacfg5", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG6, + .csr_ops =3D { "mipspmacfg6", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG7, + .csr_ops =3D { "mipspmacfg7", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG8, + .csr_ops =3D { "mipspmacfg8", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG9, + .csr_ops =3D { "mipspmacfg9", any, read_mipspmacfg, write_mipspmac= fg } + }, + { + .csrno =3D CSR_MIPSPMACFG10, + .csr_ops =3D { "mipspmacfg10", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG11, + .csr_ops =3D { "mipspmacfg11", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG12, + .csr_ops =3D { "mipspmacfg12", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG13, + .csr_ops =3D { "mipspmacfg13", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG14, + .csr_ops =3D { "mipspmacfg14", any, read_mipspmacfg, write_mipspma= cfg } + }, + { + .csrno =3D CSR_MIPSPMACFG15, + .csr_ops =3D { "mipspmacfg15", any, read_mipspmacfg, write_mipspma= cfg } + }, + { }, +}; --=20 2.34.1