From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id AC40B7803CC for ; Mon, 8 Jan 2024 11:37:07 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=jN5kn9ogogbqkALJax6dj5lnNasXWMAHZUWoAdl/dFU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704713826; v=1; b=RLxPFs33BCYvByimo2r1hzdiEdZSjKj7OnlTO2g+WqzUC+fCR4z5R5FwYEAR1pEO3CyJ4TWu F6J+Tcg//BBpM1tHUA68b1C1pW2gqYffLSZyGq8eMAexoqhGxMzPL7rMsEKBB7i1gqeZQFuoev4 9nSmJ5j5PnYx6E9aNyrODRbg= X-Received: by 127.0.0.2 with SMTP id vAofYY7687511xWfN5CYtxFg; Mon, 08 Jan 2024 03:37:06 -0800 X-Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mx.groups.io with SMTP id smtpd.web11.4720.1704713825872707279 for ; Mon, 08 Jan 2024 03:37:05 -0800 X-Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6d9e62ff056so1492074b3a.1 for ; Mon, 08 Jan 2024 03:37:05 -0800 (PST) X-Gm-Message-State: DtdGJrqZewlbnF7D8paNFnq1x7686176AA= X-Google-Smtp-Source: AGHT+IGpD8tG0VLllVBG+XCdrdzKuFKXtOUvK8mkYEhPIkTuf+EU56Pr8+dyRZwJPfl9GszHoGYSww== X-Received: by 2002:a05:6a00:4b43:b0:6d9:9ee8:9a2b with SMTP id kr3-20020a056a004b4300b006d99ee89a2bmr3925365pfb.13.1704713824458; Mon, 08 Jan 2024 03:37:04 -0800 (PST) X-Received: from localhost.localdomain ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id i12-20020aa787cc000000b006d9af59eecesm5846618pfo.20.2024.01.08.03.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:37:04 -0800 (PST) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Michael D Kinney , Liming Gao , Zhiguang Liu , Andrei Warkentin Subject: [edk2-devel] [PATCH v2 2/4] MdePkg/BaseLib: RISC-V: Add function to update stimecmp register Date: Mon, 8 Jan 2024 17:06:48 +0530 Message-Id: <20240108113650.454940-3-sunilvl@ventanamicro.com> In-Reply-To: <20240108113650.454940-1-sunilvl@ventanamicro.com> References: <20240108113650.454940-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sunilvl@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=RLxPFs33; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io stimecmp is a CSR supported only when Sstc extension is supported by the platform. This register can be used to set the timer interrupt directly in S-mode instead of going via SBI call. Add a function to update this register. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Andrei Warkentin Signed-off-by: Sunil V L --- MdePkg/Include/Library/BaseLib.h | 5 +++++ MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 3 +++ MdePkg/Library/BaseLib/RiscV64/ReadTimer.S | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h index b71e47f41b7f..ca0d06c7f335 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -191,6 +191,11 @@ RiscVReadTimer ( VOID ); +VOID +RiscVSetSupervisorTimeCompareRegister ( + IN UINT64 + ); + VOID RiscVEnableTimerInterrupt ( VOID diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h index 2bde8db478ff..8ccdea2f4fcd 100644 --- a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h @@ -96,6 +96,9 @@ /* Supervisor Protection and Translation */ #define CSR_SATP 0x180 +/* Sstc extension */ +#define CSR_STIMECMP 0x14D + /* Trap/Exception Causes */ #define CAUSE_MISALIGNED_FETCH 0x0 #define CAUSE_FETCH_ACCESS 0x1 diff --git a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S b/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S index 39a06efa51ef..36781c29c0b9 100644 --- a/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S +++ b/MdePkg/Library/BaseLib/RiscV64/ReadTimer.S @@ -21,3 +21,10 @@ ASM_FUNC (RiscVReadTimer) csrr a0, CSR_TIME ret + +// +// Set Supervisor Time Compare Register +// +ASM_FUNC (RiscVSetSupervisorTimeCompareRegister) + csrw CSR_STIMECMP, a0 + ret -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113383): https://edk2.groups.io/g/devel/message/113383 Mute This Topic: https://groups.io/mt/103595209/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-