From nobody Mon Feb 9 21:01:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544747057506335.1182888206673; Thu, 13 Dec 2018 16:24:17 -0800 (PST) Received: from localhost ([::1]:57554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXbH6-0004HC-8h for importer@patchew.org; Thu, 13 Dec 2018 19:24:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXbCK-0000nz-TD for qemu-devel@nongnu.org; Thu, 13 Dec 2018 19:19:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXbCH-00043C-6C for qemu-devel@nongnu.org; Thu, 13 Dec 2018 19:19:20 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:47870) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXbCG-0003wb-OG; Thu, 13 Dec 2018 19:19:17 -0500 Received: from mail-bn3nam04lp2051.outbound.protection.outlook.com (HELO NAM04-BN3-obe.outbound.protection.outlook.com) ([104.47.46.51]) by ob1.hgst.iphmx.com with ESMTP; 14 Dec 2018 08:19:14 +0800 Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0497.namprd04.prod.outlook.com (10.173.49.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.27; Fri, 14 Dec 2018 00:19:12 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%3]) with mapi id 15.20.1425.016; Fri, 14 Dec 2018 00:19:12 +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=1544746756; x=1576282756; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0xfZsehpV0W8v+k7Dpjq3lJP1A/uqDOChsflEOU/mgQ=; b=bz+t0gp1u3m9VPdfc13N+K6N15uQcPmxiHqQKB16Siz37kEDi8qywcRi Ev3Pur1Bz9XylNIHwgMhAHKa2aCQy7DB7IYGjPaj/qur+FnovnHuL3jOE 67NSH0V6sTfikoRRMrJNaA7hlBYdoXgQJAPMIwgON6i2uZbwINeRpdNK6 E7j7OSl93XH0zUabqmH3Jwi+Cy0PHogjxQtvEK+UeVh+fYHjGZmrI3Xoe kU2O3jgOzEGPIzyxY+pTKbTuYCGUTlz+mXnlV0EbbjhCXli1CgKbFLyE4 JMI4LmKw+gnTpOHzSi8RX2m/J52bLMwCEuserVfFa4TYAdEfR97KkRuZc g==; X-IronPort-AV: E=Sophos;i="5.56,350,1539619200"; d="scan'208";a="201220535" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Uf6OrYJOILHspQsDeumGcCOef/wZ4fS/HDvJpnxWPuk=; b=oGPzsABpVGDsXe6hwm4x8q0t9ewNpVepJkd/hHk6Prk0xhR6fRS9uWruMuA/xbRiRRXwinhfU6WttAaTWMEHSdU+9GTekkSxXLvDmlm/aoilZHYb/HK9Juo+Q2cveoHCJd53EJMPXXD/I+njmlavny05FhnYE9TIwoQiNMHcugM= From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v1 5/5] sifive_uart: Implement interrupt pending register Thread-Index: AQHUk0KjB57zG+zv8UmhY5caMT6++Q== Date: Fri, 14 Dec 2018 00:19:12 +0000 Message-ID: <3753d59b3a0f07fb6a678ffacd3d913f5fcb774d.1544746653.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0083.namprd07.prod.outlook.com (2603:10b6:a03:12b::24) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0497; 6:5CF+Au4/91LqIfn7gUitQsjV3Lw82/rBGZmjkctwdD1td+ofo/mrho91jHsWRXWO85afkk8IWPYVo6bzCSq6VfEbs/HY9SLSnMiNOHRFJFp93sddfayEGplYA6f5vATOHBoMg7ibdYEmSBLE20/CkNnaZ9xcb46meuX5XER/vtEjKMKXz888NbBtorH7OSmknWF4W8P2iVRRKx2/bDhHhFIUPwVzS+2kct8w5yoR8dvJdJPGJf123tSlJ1/gXY55FcaLvnp+vSSUvGLrOyH9y/qup5OOUU6pJiQvp5Yhxdvtt8LTUeoDKyWM7gcH141PaDIbC5+SYVb4RDm7VnblJYKNldpI4FLUiZTGkPfW+ZIb+q+gJqDK5IdGkRWBS3sOskfDRa3nNh9PtnhVUghwiT35wlLycrPaTEFdtYoEiCrUXeSYMmxSZV75FCilXsxm/hLegAPNrJ5kzytG+9ZI6g==; 5:xGSxmXiB15AH0qQqSiJBpP1iAzie6I+CkVS+DCSgYsO0PWrLhKZPZs4kMC3XFjuo7qjVcaM7V4gmNJ5tBr5vauoKZT1yus7flbF0Lu5913wY54aBRVl7g3ROUANtTeQP6sjFZ9J12bBoCQW6/npt3Z66Q2z707lKss67imZXoCI=; 7:sxmhwWD4/tCnCh1NpLMhqcYNecg4JJbB4eKMe5W2pCjcNVYmZyNhZZCSc1dGDRHWyzdWHMDZ69Wdbs25j5WzqyW//32zLzb5iNZHIhgCb5xef7ygRIeSZd0TR/hnhSOiwL25dXo/5fVesu+iAkHy8w== x-ms-office365-filtering-correlation-id: 376bf68f-fc78-41be-91f6-08d66159c64d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0497; x-ms-traffictypediagnostic: MWHPR04MB0497: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231475)(944501520)(52105112)(93006095)(93001095)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0497; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0497; x-forefront-prvs: 08864C38AC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(376002)(346002)(366004)(39850400004)(199004)(189003)(50226002)(106356001)(3846002)(81166006)(11346002)(5660300001)(81156014)(68736007)(8936002)(71190400001)(36756003)(71200400001)(105586002)(8676002)(14444005)(7736002)(256004)(2906002)(6436002)(72206003)(6486002)(478600001)(102836004)(53936002)(14454004)(305945005)(25786009)(6512007)(4326008)(476003)(52116002)(316002)(118296001)(54906003)(97736004)(66066001)(39060400002)(486006)(2616005)(2501003)(44832011)(6116002)(386003)(575784001)(76176011)(6506007)(186003)(86362001)(110136005)(26005)(446003)(99286004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0497; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: +mM4peyw1MWyki1V7kKr0w0OJ4jhP2KAkjWTjIMZxcwO3IR+8T2eP8JJKEsguM6EpEY/Qb6cjTjnCfNwp2Wq3bpA0OJHoXcHpFNESvWW7YQJhAs2bkK/ZC6gUoicl8qO5PuKXRw/pLwNFORSyk0s+hd8mEXaokvlCMBG3dWJoOkCFoVF1PNc+ETYc4awIUsUiA8/vjIdIP1Yrnr3Q44+bTXvi6tFXYlctPcXoTrHXJuG7TBzvzGG2WUsRZMminjkJdpz05O+q7K2KTo3bX3GC3b9/UFGob1O7Ph+KjVuc80KXVVjoktUdMQVkbXb0RUJ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 376bf68f-fc78-41be-91f6-08d66159c64d X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2018 00:19:12.8647 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0497 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [PATCH v1 5/5] sifive_uart: Implement interrupt pending register X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (found 2 invalid signatures) Content-Type: text/plain; charset="utf-8" From: Nathaniel Graff The watermark bits are set in the interrupt pending register according to the configuration of txcnt and rxcnt in the txctrl and rxctrl registers. Since the UART TX does not implement a FIFO, the txwm bit is set as long as the TX watermark level is greater than zero. Signed-off-by: Nathaniel Graff Reviewed-by: Michael Clark Reviewed-by: Alistair Francis Signed-off-by: Alistair Francis --- hw/riscv/sifive_uart.c | 24 +++++++++++++++++++----- include/hw/riscv/sifive_uart.h | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/riscv/sifive_uart.c b/hw/riscv/sifive_uart.c index b0c3798cf2..456a3d3697 100644 --- a/hw/riscv/sifive_uart.c +++ b/hw/riscv/sifive_uart.c @@ -28,12 +28,26 @@ * Not yet implemented: * * Transmit FIFO using "qemu/fifo8.h" - * SIFIVE_UART_IE_TXWM interrupts - * SIFIVE_UART_IE_RXWM interrupts must honor fifo watermark - * Rx FIFO watermark interrupt trigger threshold - * Tx FIFO watermark interrupt trigger threshold. */ =20 +/* Returns the state of the IP (interrupt pending) register */ +static uint64_t uart_ip(SiFiveUARTState *s) +{ + uint64_t ret =3D 0; + + uint64_t txcnt =3D SIFIVE_UART_GET_TXCNT(s->txctrl); + uint64_t rxcnt =3D SIFIVE_UART_GET_RXCNT(s->rxctrl); + + if (txcnt !=3D 0) { + ret |=3D SIFIVE_UART_IP_TXWM; + } + if (s->rx_fifo_len > rxcnt) { + ret |=3D SIFIVE_UART_IP_RXWM; + } + + return ret; +} + static void update_irq(SiFiveUARTState *s) { int cond =3D 0; @@ -69,7 +83,7 @@ uart_read(void *opaque, hwaddr addr, unsigned int size) case SIFIVE_UART_IE: return s->ie; case SIFIVE_UART_IP: - return s->rx_fifo_len ? SIFIVE_UART_IP_RXWM : 0; + return uart_ip(s); case SIFIVE_UART_TXCTRL: return s->txctrl; case SIFIVE_UART_RXCTRL: diff --git a/include/hw/riscv/sifive_uart.h b/include/hw/riscv/sifive_uart.h index 504f18a60f..c8dc1c57fd 100644 --- a/include/hw/riscv/sifive_uart.h +++ b/include/hw/riscv/sifive_uart.h @@ -43,6 +43,9 @@ enum { SIFIVE_UART_IP_RXWM =3D 2 /* Receive watermark interrupt pendin= g */ }; =20 +#define SIFIVE_UART_GET_TXCNT(txctrl) ((txctrl >> 16) & 0x7) +#define SIFIVE_UART_GET_RXCNT(rxctrl) ((rxctrl >> 16) & 0x7) + #define TYPE_SIFIVE_UART "riscv.sifive.uart" =20 #define SIFIVE_UART(obj) \ --=20 2.19.1