From patchwork Fri May 31 13:43:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 165533 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp786786ili; Fri, 31 May 2019 06:56:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNFOBhby6Sno/cp3klk9KaTtOetUvHdGfo2cStG5M8XvHjBFO/XGQBDeQO6NZn+ROtPRd7 X-Received: by 2002:a37:9ac9:: with SMTP id c192mr8619178qke.30.1559311013032; Fri, 31 May 2019 06:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559311013; cv=none; d=google.com; s=arc-20160816; b=y4bHViiOfJ2GrZl+AhktZX1QZLpkavkJGbi3aOoNfMeWXTtcTVv246CSgvhBbeLzNH jKEUTNmqQVqgfHol6qAmdiOmBHMUgL+JDxelaXgAIIwxok8QWpCMhttaX8DzObwfgZIo KuOCcOEjhdY6eFG11UO8eXvnmQimIohkh5Tffr/1zgQfZ8sTJENXnkI3QRRazMw5aXIx Sn/FD9ZyKlvQT1HPS0BAHWy+W+B8ILZnkn6A1WdD/G7oGBiYkiO6UdF88PGRw6bw+KGY J83kAuaJODVIElrqAtOuL3zccJkyJIWhWHjqHrq2mI1dhfsQ5RKjY6Raj3eaRMHfmj8k IppQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=1XbDcSxPxIwShmL7ibaMkqeCI/KNLPvufrTgWj8SAo0=; b=T4Fe9LP34FDgrVeWVcPAdEhEM3pkipOXh9Vjk1VUyfpT43oZ/NaxH7XS70/czDhf5M v159Gumx6rNARg6B5Ugif4zzg8hY1HE4gAp6jWILUH281NXdGJgz5HsjalP5CI0dF8Ui hnmMLPc13RCNDKB3HrW8wo8S3ExXNz+P3TzvAfKwiMrM469p09sHzYdLdId9YF2/y3Vd TOjr92vc6BYIYxEOTWYym7sOE0h6yUwaeQgby+dlUMGiOp55GQIwaD5epRnwRjj3uTZR hAyyI3T/7cTTMXH02eHGoOkE2r5tSDoZyAn7vn07O6if7CtwC5j6Ko6YCSlAAEDWihI4 5nNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DjtHXRHx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n21si1056614qtl.9.2019.05.31.06.56.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 31 May 2019 06:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DjtHXRHx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:43974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWi1a-0000nQ-0I for patch@linaro.org; Fri, 31 May 2019 09:56:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWhon-0007Tn-F3 for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWhom-0000L2-7y for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:37 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:37234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWhom-0000JW-1z for qemu-devel@nongnu.org; Fri, 31 May 2019 09:43:36 -0400 Received: by mail-ot1-x343.google.com with SMTP id r10so9216927otd.4 for ; Fri, 31 May 2019 06:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1XbDcSxPxIwShmL7ibaMkqeCI/KNLPvufrTgWj8SAo0=; b=DjtHXRHxrYfFzwevW4bKlMnGwULoonBQA7Vt6JPJzAc07Xy8fZ8YG0lT3EqL9cpDHn ZWQ5xV5RBPLTyuuN0buX9LQhI2QwVFkFxXFy59neaUwaqIn+f9QJxfdQwtnlUf2WPcfh /JrgqHhg4tgBhIpcGb5YsPDw0aUZ/3+CbgVNbgYDGu4OVVSBjZARvzD7Ss8V0a0hFObC Ljh2HBA0HbPZDe9TvSHZw/QJaBXBZmuB2V0U4Ir7dGzJ3BLiqaqg8HDDPNM3AynCr1kF FZkie+4SqFROIUFSn8qNZ8+NyAmTrLdH+R6YMtAUpa8IJCnTp8WODNVXvZgEs6Tqy3T7 LsUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1XbDcSxPxIwShmL7ibaMkqeCI/KNLPvufrTgWj8SAo0=; b=aPO3SCStj+GC2yCqSmMNJh3L/3cDowst7wZeYFKqhh4A1oBGYl+hPMhhKNTWzBoLGM W7LWWz8ZZnj8Hsm/wzqArrwRHqgigmhjy+xGHHMIJUHomTj9bBfk2xjV2XOpyLFhA6da 62sKVAjyWoKfmtWpRg+82Rq42X/7DjybxpBHdu+mlM8UB3Zy0FEttGxgVuwXlwN5HFq+ gWbz+GU9QNtl+ujDjhusyRce7J5rvgeR3kxa+dEmYMoxZBPHP3VEpnderRQkSBIpqBsQ 4amsTjK7Cfyeq801cf+pi8FtQepXVPB9HP1PwywtIQH3opsvJweWasZAX5gUm4lqSt/o SMcQ== X-Gm-Message-State: APjAAAXa20v3znTr3fq5gIBCyBH+KdW4CUDktbB0yg5Fd6Rxxvrd74wP Z/Eo1m90+F7BaYYSoqLXv3GgaaVYqZAn+w== X-Received: by 2002:a9d:6e0f:: with SMTP id e15mr2024004otr.0.1559310215125; Fri, 31 May 2019 06:43:35 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id r23sm2391176otg.49.2019.05.31.06.43.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 06:43:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 31 May 2019 08:43:02 -0500 Message-Id: <20190531134315.4109-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190531134315.4109-1-richard.henderson@linaro.org> References: <20190531134315.4109-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::343 Subject: [Qemu-devel] [PATCH v16 10/23] hw/registerfields.h: Add 8bit and 16bit register macros 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: philmd@redhat.com, ysato@users.sourceforge.jp Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Yoshinori Sato Some RX peripheral using 8bit and 16bit registers. Added 8bit and 16bit APIs. Signed-off-by: Yoshinori Sato Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190516055244.95559-11-ysato@users.sourceforge.jp> Signed-off-by: Richard Henderson --- include/hw/registerfields.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h index 2659a58737..a0bb0654d6 100644 --- a/include/hw/registerfields.h +++ b/include/hw/registerfields.h @@ -22,6 +22,14 @@ enum { A_ ## reg = (addr) }; \ enum { R_ ## reg = (addr) / 4 }; +#define REG8(reg, addr) \ + enum { A_ ## reg = (addr) }; \ + enum { R_ ## reg = (addr) }; + +#define REG16(reg, addr) \ + enum { A_ ## reg = (addr) }; \ + enum { R_ ## reg = (addr) / 2 }; + /* Define SHIFT, LENGTH and MASK constants for a field within a register */ /* This macro will define R_FOO_BAR_MASK, R_FOO_BAR_SHIFT and R_FOO_BAR_LENGTH @@ -34,6 +42,12 @@ MAKE_64BIT_MASK(shift, length)}; /* Extract a field from a register */ +#define FIELD_EX8(storage, reg, field) \ + extract8((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) +#define FIELD_EX16(storage, reg, field) \ + extract16((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH) #define FIELD_EX32(storage, reg, field) \ extract32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH) @@ -49,6 +63,22 @@ * Assigning values larger then the target field will result in * compilation warnings. */ +#define FIELD_DP8(storage, reg, field, val) ({ \ + struct { \ + unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } v = { .v = val }; \ + uint8_t d; \ + d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; }) +#define FIELD_DP16(storage, reg, field, val) ({ \ + struct { \ + unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ + } v = { .v = val }; \ + uint16_t d; \ + d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ + R_ ## reg ## _ ## field ## _LENGTH, v.v); \ + d; }) #define FIELD_DP32(storage, reg, field, val) ({ \ struct { \ unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ @@ -57,7 +87,7 @@ d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT, \ R_ ## reg ## _ ## field ## _LENGTH, v.v); \ d; }) -#define FIELD_DP64(storage, reg, field, val) ({ \ +#define FIELD_DP64(storage, reg, field, val) ({ \ struct { \ unsigned int v:R_ ## reg ## _ ## field ## _LENGTH; \ } v = { .v = val }; \