From patchwork Mon Aug 24 13:52:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1350390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=PgIOQSZy; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=UeR31cBH; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=qzoncOs4; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BZtr82DSSz9sTF for ; Mon, 24 Aug 2020 23:53:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5QCWv9QYRg4+IdG46C0GLg9O7VAiBwhmiOYL/I35IPc=; b=PgIOQSZyfafPTHy12iTmzlFhT MCP6tufLE5lIoLsrBGNNQBOoQcQYFprAvpH0w8d4nWgv45wRXHesfVaGkXrxurspKg0A/iETzbsPO F5xaHWQixIjFBx6ebw3XTJcTDMJXNyFvU8KJ45KBhXz3YIxP39UTM5RSN7M9T+cw3MUSclmOuQLFv 2GHPJ3OUJdjOfFIiM5/BruBDTiz6OyfzoV2qpyXiAf+FBf2e4qEJcKRRdBanS1cvrH14xumfv0OcK 6HVigAgftQv4Ppcyk84WhOIKUOrf+4y+EgJ5kz2KxzGSgvxneAE+9CV8O0Mx7HiqkkQrUTaejkMcv kB3A/Pxng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kACuX-0006Hp-QN; Mon, 24 Aug 2020 13:53:21 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kACuT-0006Dz-Mx for opensbi@lists.infradead.org; Mon, 24 Aug 2020 13:53:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1598277198; x=1629813198; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xZX3GTqbZUB9o2DRDBGqCRWZquoCSzAcpPOqxsOSD4g=; b=UeR31cBHC1vtT6obpdnV20xgqWRbh+l3DMtvFUMf2vRUlmznE8Uju3xl tZVhBFu1dAzSo4dSwt/x1M5uAGpTYucr47fga+zaZxEUl8SPyFhb4Y3tz 8O6aroXvh62iarwwf/ugqJ1Zea2nQdbGY8b4m4F+1WOWOl1dAxfGidh6s f3nM9+XivqLXT8nsow8vY0gtNmzHUM4/57rTTYZSZ0aW9aQettt/0mC6O UXMIrIlUqDXE71swoAls0OO/Tkvy8w69PzDQUdcitHq4aeklxRnTcP60+ kImM8eIMQwpfM1XpgvQYQZbgxV3Ml25/0OrMkKPdQ0RyakJH9LV/Y6eg9 A==; IronPort-SDR: Wt+LDRWjVgPSpcwWIyHgi6Yhne682lHBMTwk4y69h8olvQ6ksFWzif6U78MSfIUF/BGIL2Tf6x l3OGBfr9YAhfovVLESA3u+9ox2Fi79tMskyYm39FWTxSAjZ8WaYGKYRWLbXd6fP78N7nGRZQJk 2W4HvygNCArAOz9PI2zQX3Y4EZFjqRZlyV7DxwDt3n3+rMtzkzwngJARw674ubJawjK0HgQeMv riB0ul1yrMMPWwHM/Tu6jMUMbMlxVwkurfFVphqpxZ3vCJTErfnyoHIcpB/cgP4SZ5LnlUZtmh zkw= X-IronPort-AV: E=Sophos;i="5.76,348,1592841600"; d="scan'208";a="145693975" Received: from mail-co1nam11lp2176.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.176]) by ob1.hgst.iphmx.com with ESMTP; 24 Aug 2020 21:53:17 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NbKscgFkkq0t+0oGyblIk2A+XF0mC2kJAhmVE43gZ5HarQKUujb8NI8t4w0mr8974DUcncBmMQpgaZmelAedqbwibAIs2Sb2LiCuFFKPhz3LD0p2SVdecQZ28HAsLmrgQ+AbreMa/MBKWlEdbOqNMbunwfNK+eTamlqc0yRSnq8gOzZNqaWhIy9NXdBt8TyPoYI3okXlvtmjJVlCc+fvLaE4h7TU27fgcloTnDpfaC74F7Hk1Tv07dmcwkxwNvsIZ6qZ1WajPFp9bzZB2Frh5fnfEAWR7BIt58xlrmTgnh34EhqIbOGkLLTw7H7JBFr9xSXSqbm5vlQ5NWIuxs6mdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HtRIO22Zp88y0aKVuvK8duE1wFW647Uw8H6+8s+eybw=; b=MiiDGNjwdI2BUgAB1T+WYczcXo2KIraJj5sZwWIY2+5WMpdIJodNxNV9VgzroQqK+m95RMKsca3CzPYdkUOyW1cYMSgY/XRx5zYz2D4MIm7IyJzzcoB+y3Z8TTkn4CZuEDbwc9MMbygaLQjC5Td4YYd2pmWwz+OHLGHEPRXQoRxvNS0Itycq4sb1BrYA/ub7+6w8ZAYImYEYpuf9a8PlZbnHKY48YdXZbVCFNZS8BwntF+lCVgXxsqVngbHycF1xmLjvrLFCI4Y6Uqizm9x19mBP7ZXC/hfA/iwyxWepKMGm3xC9rME6VntDB/OKtpMuRtOfwBYWz+OjhcmZfh3AEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HtRIO22Zp88y0aKVuvK8duE1wFW647Uw8H6+8s+eybw=; b=qzoncOs4wrHjaGKEr137na3Z+NxfvM4UWulRJ0BWNlR8gxuK71ACfDbEdX8CmkhK+MFKNc0//VemtguRYadAqn+RQlJOqIUEREdkt610bJ4DVVX8GBIv0sGsHOfOle0aE/cC3dMVew9E/bhw9kRQSN+1XMnIB0H+bfLpJyCoJjk= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5962.namprd04.prod.outlook.com (2603:10b6:5:130::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24; Mon, 24 Aug 2020 13:53:16 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3305.026; Mon, 24 Aug 2020 13:53:16 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 4/5] include: sbi: Few cosmetic changes in riscv_encoding.h Date: Mon, 24 Aug 2020 19:22:42 +0530 Message-Id: <20200824135243.136769-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200824135243.136769-1-anup.patel@wdc.com> References: <20200824135243.136769-1-anup.patel@wdc.com> X-ClientProxiedBy: BM1PR0101CA0010.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::20) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by BM1PR0101CA0010.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24 via Frontend Transport; Mon, 24 Aug 2020 13:53:14 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [103.20.29.219] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 50509b07-d9af-4f16-028f-08d848350cce X-MS-TrafficTypeDiagnostic: DM6PR04MB5962: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oIeGr7FQVsjC8Faau92qlGgvXY/B5mf6LFgtdHLG91PubYgyzsSgAqcyBiZ3Z7ZzdpKwOyYiX2VWX6bfOxGVs6CTCac+ZVWFf+sfNtBg/j4TKQX4KjrQELyTVXHOogZhXaERVhBocg5v07N/LW9KnK/s2EVbXzH0vmYuQJo+fHlJrFvL1Bs2GDUVOkANJa2iM4yR7tKf81Zb+DfWuZa/MMy/FJChRZgCwv6HPivcjdAGQtHldYcFBYICMjvnNbO4ZaqmRKsUAurpbZYdxSRHQsZagUP6pmGDFXiBd8g3iysCINoaXbDbcBN+wwL8kVA9d1YpQHwfLXSnaqHx+Qd/aA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(346002)(396003)(39860400002)(376002)(1076003)(8936002)(2906002)(86362001)(2616005)(66476007)(66556008)(478600001)(66946007)(186003)(956004)(54906003)(110136005)(6636002)(26005)(316002)(36756003)(16576012)(5660300002)(83380400001)(4326008)(44832011)(6486002)(8676002)(6666004)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 3qpCTvGMAOR5t3Ke2i0ahTbFJ7uJgkSQ2avIprlv44dRKLcPg8tMCBlhLnws+GNzPu2Dss7yRZrD8TPoOlilAf2QdYcj9YxMRXRD+gE41Tc0osd/1MSZjGmcW/EWkGQnDC/1sIjXGJi49HZP7gLdAbBzYmzzpKmp1lLsPhxt/1WBTQjhHzLxsRJxNrCSmiGzamw0Tot4TVSfhH2h1KkyGwMQSkyrThxow0QXohoHtI9ZtlGF46auYdJqj8BPxWuNk+oeu9Ji+q6GMcOxNk3SRBpfPx81pjx8qgy0v9rD7xtlTPJFPz6aX7qlUR3grXbx6ZWM5gfhybIh5CKVJ4meuAc2LPmVdvo5FBdwWlrxoUg/B3kn1rhznyvXslgJFo0gxy3OHKYFVDTYcGXEHL90phFCuDcnqNl1JCCsqUA0+8vAnWdno/Sn59MsEpNIJ+kglMkRZ654Ci2+QMPDoHA4aXDfNjrZquoGWqultF5NTThyOI2z8Kh167Xj4xnz2BEj5o3wQW9oDYx9mNS1ikdSOx8mPLhLJu/4FT0abJHr9Mmt1isZUUD+8+6Vv9MglbHt6rG6ujvH3HvoGOuHdLjnnYLFuNFKB2VqNN26GIozW/xbFT34upd5ffhyliznmpyL3ipDcnCW78mDuNQ5S8taxA== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50509b07-d9af-4f16-028f-08d848350cce X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2020 13:53:16.2766 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ozBUDh3mWYZSH+BrhVQYFk/AjL7smnhmx0F4gof8ADt44rCatK8XSHmOecAp81P4m1wweYbqGkGONPl/m9UXaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5962 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200824_095318_058471_DD7E7DA6 X-CRM114-Status: GOOD ( 13.25 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.144 listed in list.dnswl.org] 1.3 RCVD_ILLEGAL_IP Received: contains illegal IP address -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch does following cosmentic changes to riscv_encoding.h: 1. Re-organize CSR defines to match CSR listing in latest RISC-V privilege spec 2. Rename CSR_HCOUNTERNEN to CSR_HCOUNTEREN Signed-off-by: Anup Patel --- include/sbi/riscv_encoding.h | 226 +++++++++++++++++++++-------------- 1 file changed, 139 insertions(+), 87 deletions(-) diff --git a/include/sbi/riscv_encoding.h b/include/sbi/riscv_encoding.h index 073261f..ccd2c69 100644 --- a/include/sbi/riscv_encoding.h +++ b/include/sbi/riscv_encoding.h @@ -171,18 +171,27 @@ #define HGATP_MODE_SHIFT HGATP32_MODE_SHIFT #endif -#define CSR_USTATUS 0x0 -#define CSR_FFLAGS 0x1 -#define CSR_FRM 0x2 -#define CSR_FCSR 0x3 +/* ===== User-level CSRs ===== */ + +/* User Trap Setup (N-extension) */ +#define CSR_USTATUS 0x000 +#define CSR_UIE 0x004 +#define CSR_UTVEC 0x005 + +/* User Trap Handling (N-extension) */ +#define CSR_USCRATCH 0x040 +#define CSR_UEPC 0x041 +#define CSR_UCAUSE 0x042 +#define CSR_UTVAL 0x043 +#define CSR_UIP 0x044 + +/* User Floating-point CSRs */ +#define CSR_FFLAGS 0x001 +#define CSR_FRM 0x002 +#define CSR_FCSR 0x003 + +/* User Counters/Timers */ #define CSR_CYCLE 0xc00 -#define CSR_UIE 0x4 -#define CSR_UTVEC 0x5 -#define CSR_USCRATCH 0x40 -#define CSR_UEPC 0x41 -#define CSR_UCAUSE 0x42 -#define CSR_UTVAL 0x43 -#define CSR_UIP 0x44 #define CSR_TIME 0xc01 #define CSR_INSTRET 0xc02 #define CSR_HPMCOUNTER3 0xc03 @@ -214,31 +223,84 @@ #define CSR_HPMCOUNTER29 0xc1d #define CSR_HPMCOUNTER30 0xc1e #define CSR_HPMCOUNTER31 0xc1f +#define CSR_CYCLEH 0xc80 +#define CSR_TIMEH 0xc81 +#define CSR_INSTRETH 0xc82 +#define CSR_HPMCOUNTER3H 0xc83 +#define CSR_HPMCOUNTER4H 0xc84 +#define CSR_HPMCOUNTER5H 0xc85 +#define CSR_HPMCOUNTER6H 0xc86 +#define CSR_HPMCOUNTER7H 0xc87 +#define CSR_HPMCOUNTER8H 0xc88 +#define CSR_HPMCOUNTER9H 0xc89 +#define CSR_HPMCOUNTER10H 0xc8a +#define CSR_HPMCOUNTER11H 0xc8b +#define CSR_HPMCOUNTER12H 0xc8c +#define CSR_HPMCOUNTER13H 0xc8d +#define CSR_HPMCOUNTER14H 0xc8e +#define CSR_HPMCOUNTER15H 0xc8f +#define CSR_HPMCOUNTER16H 0xc90 +#define CSR_HPMCOUNTER17H 0xc91 +#define CSR_HPMCOUNTER18H 0xc92 +#define CSR_HPMCOUNTER19H 0xc93 +#define CSR_HPMCOUNTER20H 0xc94 +#define CSR_HPMCOUNTER21H 0xc95 +#define CSR_HPMCOUNTER22H 0xc96 +#define CSR_HPMCOUNTER23H 0xc97 +#define CSR_HPMCOUNTER24H 0xc98 +#define CSR_HPMCOUNTER25H 0xc99 +#define CSR_HPMCOUNTER26H 0xc9a +#define CSR_HPMCOUNTER27H 0xc9b +#define CSR_HPMCOUNTER28H 0xc9c +#define CSR_HPMCOUNTER29H 0xc9d +#define CSR_HPMCOUNTER30H 0xc9e +#define CSR_HPMCOUNTER31H 0xc9f + +/* ===== Supervisor-level CSRs ===== */ + +/* Supervisor Trap Setup */ #define CSR_SSTATUS 0x100 +#define CSR_SEDELEG 0x102 +#define CSR_SIDELEG 0x103 #define CSR_SIE 0x104 #define CSR_STVEC 0x105 #define CSR_SCOUNTEREN 0x106 + +/* Supervisor Trap Handling */ #define CSR_SSCRATCH 0x140 #define CSR_SEPC 0x141 #define CSR_SCAUSE 0x142 #define CSR_STVAL 0x143 #define CSR_SIP 0x144 + +/* Supervisor Protection and Translation */ #define CSR_SATP 0x180 +/* ===== Hypervisor-level CSRs ===== */ + +/* Hypervisor Trap Setup (H-extension) */ #define CSR_HSTATUS 0x600 #define CSR_HEDELEG 0x602 #define CSR_HIDELEG 0x603 #define CSR_HIE 0x604 -#define CSR_HTIMEDELTA 0x605 -#define CSR_HTIMEDELTAH 0x615 -#define CSR_HCOUNTERNEN 0x606 +#define CSR_HCOUNTEREN 0x606 #define CSR_HGEIE 0x607 + +/* Hypervisor Trap Handling (H-extension) */ #define CSR_HTVAL 0x643 #define CSR_HIP 0x644 +#define CSR_HVIP 0x645 #define CSR_HTINST 0x64a +#define CSR_HGEIP 0xe12 + +/* Hypervisor Protection and Translation (H-extension) */ #define CSR_HGATP 0x680 -#define CSR_HGEIP 0xe07 +/* Hypervisor Counter/Timer Virtualization Registers (H-extension) */ +#define CSR_HTIMEDELTA 0x605 +#define CSR_HTIMEDELTAH 0x615 + +/* Virtual Supervisor Registers (H-extension) */ #define CSR_VSSTATUS 0x200 #define CSR_VSIE 0x204 #define CSR_VSTVEC 0x205 @@ -249,6 +311,15 @@ #define CSR_VSIP 0x244 #define CSR_VSATP 0x280 +/* ===== Machine-level CSRs ===== */ + +/* Machine Information Registers */ +#define CSR_MVENDORID 0xf11 +#define CSR_MARCHID 0xf12 +#define CSR_MIMPID 0xf13 +#define CSR_MHARTID 0xf14 + +/* Machine Trap Setup */ #define CSR_MSTATUS 0x300 #define CSR_MISA 0x301 #define CSR_MEDELEG 0x302 @@ -257,6 +328,8 @@ #define CSR_MTVEC 0x305 #define CSR_MCOUNTEREN 0x306 #define CSR_MSTATUSH 0x310 + +/* Machine Trap Handling */ #define CSR_MSCRATCH 0x340 #define CSR_MEPC 0x341 #define CSR_MCAUSE 0x342 @@ -264,6 +337,8 @@ #define CSR_MIP 0x344 #define CSR_MTINST 0x34a #define CSR_MTVAL2 0x34b + +/* Machine Memory Protection */ #define CSR_PMPCFG0 0x3a0 #define CSR_PMPCFG1 0x3a1 #define CSR_PMPCFG2 0x3a2 @@ -344,14 +419,8 @@ #define CSR_PMPADDR61 0x3ed #define CSR_PMPADDR62 0x3ee #define CSR_PMPADDR63 0x3ef -#define CSR_TSELECT 0x7a0 -#define CSR_TDATA1 0x7a1 -#define CSR_TDATA2 0x7a2 -#define CSR_TDATA3 0x7a3 -#define CSR_DCSR 0x7b0 -#define CSR_DPC 0x7b1 -#define CSR_DSCRATCH 0x7b2 +/* Machine Counters/Timers */ #define CSR_MCYCLE 0xb00 #define CSR_MINSTRET 0xb02 #define CSR_MHPMCOUNTER3 0xb03 @@ -383,71 +452,6 @@ #define CSR_MHPMCOUNTER29 0xb1d #define CSR_MHPMCOUNTER30 0xb1e #define CSR_MHPMCOUNTER31 0xb1f -#define CSR_MHPMEVENT3 0x323 -#define CSR_MHPMEVENT4 0x324 -#define CSR_MHPMEVENT5 0x325 -#define CSR_MHPMEVENT6 0x326 -#define CSR_MHPMEVENT7 0x327 -#define CSR_MHPMEVENT8 0x328 -#define CSR_MHPMEVENT9 0x329 -#define CSR_MHPMEVENT10 0x32a -#define CSR_MHPMEVENT11 0x32b -#define CSR_MHPMEVENT12 0x32c -#define CSR_MHPMEVENT13 0x32d -#define CSR_MHPMEVENT14 0x32e -#define CSR_MHPMEVENT15 0x32f -#define CSR_MHPMEVENT16 0x330 -#define CSR_MHPMEVENT17 0x331 -#define CSR_MHPMEVENT18 0x332 -#define CSR_MHPMEVENT19 0x333 -#define CSR_MHPMEVENT20 0x334 -#define CSR_MHPMEVENT21 0x335 -#define CSR_MHPMEVENT22 0x336 -#define CSR_MHPMEVENT23 0x337 -#define CSR_MHPMEVENT24 0x338 -#define CSR_MHPMEVENT25 0x339 -#define CSR_MHPMEVENT26 0x33a -#define CSR_MHPMEVENT27 0x33b -#define CSR_MHPMEVENT28 0x33c -#define CSR_MHPMEVENT29 0x33d -#define CSR_MHPMEVENT30 0x33e -#define CSR_MHPMEVENT31 0x33f -#define CSR_MVENDORID 0xf11 -#define CSR_MARCHID 0xf12 -#define CSR_MIMPID 0xf13 -#define CSR_MHARTID 0xf14 -#define CSR_CYCLEH 0xc80 -#define CSR_TIMEH 0xc81 -#define CSR_INSTRETH 0xc82 -#define CSR_HPMCOUNTER3H 0xc83 -#define CSR_HPMCOUNTER4H 0xc84 -#define CSR_HPMCOUNTER5H 0xc85 -#define CSR_HPMCOUNTER6H 0xc86 -#define CSR_HPMCOUNTER7H 0xc87 -#define CSR_HPMCOUNTER8H 0xc88 -#define CSR_HPMCOUNTER9H 0xc89 -#define CSR_HPMCOUNTER10H 0xc8a -#define CSR_HPMCOUNTER11H 0xc8b -#define CSR_HPMCOUNTER12H 0xc8c -#define CSR_HPMCOUNTER13H 0xc8d -#define CSR_HPMCOUNTER14H 0xc8e -#define CSR_HPMCOUNTER15H 0xc8f -#define CSR_HPMCOUNTER16H 0xc90 -#define CSR_HPMCOUNTER17H 0xc91 -#define CSR_HPMCOUNTER18H 0xc92 -#define CSR_HPMCOUNTER19H 0xc93 -#define CSR_HPMCOUNTER20H 0xc94 -#define CSR_HPMCOUNTER21H 0xc95 -#define CSR_HPMCOUNTER22H 0xc96 -#define CSR_HPMCOUNTER23H 0xc97 -#define CSR_HPMCOUNTER24H 0xc98 -#define CSR_HPMCOUNTER25H 0xc99 -#define CSR_HPMCOUNTER26H 0xc9a -#define CSR_HPMCOUNTER27H 0xc9b -#define CSR_HPMCOUNTER28H 0xc9c -#define CSR_HPMCOUNTER29H 0xc9d -#define CSR_HPMCOUNTER30H 0xc9e -#define CSR_HPMCOUNTER31H 0xc9f #define CSR_MCYCLEH 0xb80 #define CSR_MINSTRETH 0xb82 #define CSR_MHPMCOUNTER3H 0xb83 @@ -480,6 +484,52 @@ #define CSR_MHPMCOUNTER30H 0xb9e #define CSR_MHPMCOUNTER31H 0xb9f +/* Machine Counter Setup */ +#define CSR_MCOUNTINHIBIT 0x320 +#define CSR_MHPMEVENT3 0x323 +#define CSR_MHPMEVENT4 0x324 +#define CSR_MHPMEVENT5 0x325 +#define CSR_MHPMEVENT6 0x326 +#define CSR_MHPMEVENT7 0x327 +#define CSR_MHPMEVENT8 0x328 +#define CSR_MHPMEVENT9 0x329 +#define CSR_MHPMEVENT10 0x32a +#define CSR_MHPMEVENT11 0x32b +#define CSR_MHPMEVENT12 0x32c +#define CSR_MHPMEVENT13 0x32d +#define CSR_MHPMEVENT14 0x32e +#define CSR_MHPMEVENT15 0x32f +#define CSR_MHPMEVENT16 0x330 +#define CSR_MHPMEVENT17 0x331 +#define CSR_MHPMEVENT18 0x332 +#define CSR_MHPMEVENT19 0x333 +#define CSR_MHPMEVENT20 0x334 +#define CSR_MHPMEVENT21 0x335 +#define CSR_MHPMEVENT22 0x336 +#define CSR_MHPMEVENT23 0x337 +#define CSR_MHPMEVENT24 0x338 +#define CSR_MHPMEVENT25 0x339 +#define CSR_MHPMEVENT26 0x33a +#define CSR_MHPMEVENT27 0x33b +#define CSR_MHPMEVENT28 0x33c +#define CSR_MHPMEVENT29 0x33d +#define CSR_MHPMEVENT30 0x33e +#define CSR_MHPMEVENT31 0x33f + +/* Debug/Trace Registers */ +#define CSR_TSELECT 0x7a0 +#define CSR_TDATA1 0x7a1 +#define CSR_TDATA2 0x7a2 +#define CSR_TDATA3 0x7a3 + +/* Debug Mode Registers */ +#define CSR_DCSR 0x7b0 +#define CSR_DPC 0x7b1 +#define CSR_DSCRATCH0 0x7b2 +#define CSR_DSCRATCH1 0x7b3 + +/* ===== Trap/Exception Causes ===== */ + #define CAUSE_MISALIGNED_FETCH 0x0 #define CAUSE_FETCH_ACCESS 0x1 #define CAUSE_ILLEGAL_INSTRUCTION 0x2 @@ -500,6 +550,8 @@ #define CAUSE_VIRTUAL_INST_FAULT 0x16 #define CAUSE_STORE_GUEST_PAGE_FAULT 0x17 +/* ===== Instruction Encodings ===== */ + #define INSN_MATCH_LB 0x3 #define INSN_MASK_LB 0x707f #define INSN_MATCH_LH 0x1003