From nobody Thu Apr 25 12:04:45 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584975684; cv=none; d=zohomail.com; s=zohoarc; b=BM+glsu33JBYVucTeLTJTJQEEiY3NHo6OskJS11ygmiwimIpbBoqRwYZcof95AXGEUiN9TKZMCfrwYfTYdb5AJ/Zjx+aJVRCBt01MJEkYVlL9GN+nFx4exK3NK9JxxDgIdkpE/sk2ckwRNSrea7Q2EbGRSL+rNKp7JOLYe2K5UQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584975684; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=ruSeK9nZ4Hif7Q+Eff3rSEgyPgjh13hmH6dL1i25g1s=; b=GQ7ZwTFaKiWRBdf8fmViM0X7lUHPkp1h3Houi3qAoGqzcN05Hx8UM4tU689+8BUZJABgRfjvym4+36dTjfEWwsRYKraCd+iLc73a40bVg73qixFvdrzfZcB6efXwMHdY4Nmtp+LNacGzf29kh0ra3W3HAfazTHAZxrGAouPvD2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1584975684626383.53149910566754; Mon, 23 Mar 2020 08:01:24 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 7603BB016A6; Mon, 23 Mar 2020 15:01:19 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id B7917B0015A for ; Mon, 23 Mar 2020 15:01:02 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-kfgYGBYBO3Kpxte4ezF8BQ-1; Mon, 23 Mar 2020 10:59:30 -0400 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77FD5802CB9 for ; Mon, 23 Mar 2020 14:59:20 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.corp.redhat.com (Postfix) with ESMTP id 373DD60C84; Mon, 23 Mar 2020 14:59:13 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 57A529D43; Mon, 23 Mar 2020 15:59:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584975661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=og6bgH28tnxPmFLyxgh0uf9GUJ7hV7ypI1byIsNlvcE=; b=GApWw3KdvXYqcPmPt2McTUIFSIIXYmux9mTMxn4i2HGmBMhdfeltybpygVvLOOrodz1MVo HBGqUbwn8EcwCHKkvqgiWcHm+Ztw1ChcLGfhUCo0CnlG1tmaSu0Swofg5/wBK3d4AiqEV8 J3vA8cklhhOOJct83gYbyNC6R+TqFYk= X-MC-Unique: kfgYGBYBO3Kpxte4ezF8BQ-1 From: Gerd Hoffmann To: seabios@seabios.org Date: Mon, 23 Mar 2020 15:59:10 +0100 Message-Id: <20200323145911.22319-2-kraxel@redhat.com> In-Reply-To: <20200323145911.22319-1-kraxel@redhat.com> References: <20200323145911.22319-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: XXWGS6NWA7ARIHBYBBQIG6BEPIIIZIXK X-Message-ID-Hash: XXWGS6NWA7ARIHBYBBQIG6BEPIIIZIXK X-MailFrom: kraxel@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Stefan Hajnoczi , Gerd Hoffmann X-Mailman-Version: 3.3.1 Precedence: list Subject: [SeaBIOS] [PATCH v2 1/2] pci: factor out ioconfig_cmd() List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: / X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add helper function to calculate PORT_PCI_CMD value from bdf + addr. Signed-off-by: Gerd Hoffmann --- src/hw/pci.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/hw/pci.c b/src/hw/pci.c index 9855badbc7da..7aca1e6bfa97 100644 --- a/src/hw/pci.c +++ b/src/hw/pci.c @@ -14,39 +14,44 @@ #define PORT_PCI_CMD 0x0cf8 #define PORT_PCI_DATA 0x0cfc =20 +static u32 ioconfig_cmd(u16 bdf, u32 addr) +{ + return 0x80000000 | (bdf << 8) | (addr & 0xfc); +} + void pci_config_writel(u16 bdf, u32 addr, u32 val) { - outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD); + outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD); outl(val, PORT_PCI_DATA); } =20 void pci_config_writew(u16 bdf, u32 addr, u16 val) { - outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD); + outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD); outw(val, PORT_PCI_DATA + (addr & 2)); } =20 void pci_config_writeb(u16 bdf, u32 addr, u8 val) { - outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD); + outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD); outb(val, PORT_PCI_DATA + (addr & 3)); } =20 u32 pci_config_readl(u16 bdf, u32 addr) { - outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD); + outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD); return inl(PORT_PCI_DATA); } =20 u16 pci_config_readw(u16 bdf, u32 addr) { - outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD); + outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD); return inw(PORT_PCI_DATA + (addr & 2)); } =20 u8 pci_config_readb(u16 bdf, u32 addr) { - outl(0x80000000 | (bdf << 8) | (addr & 0xfc), PORT_PCI_CMD); + outl(ioconfig_cmd(bdf, addr), PORT_PCI_CMD); return inb(PORT_PCI_DATA + (addr & 3)); } =20 --=20 2.18.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org