From patchwork Wed Sep 6 10:10:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1830313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=aY2SKhoc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RgdSM6dWyz1yh5 for ; Wed, 6 Sep 2023 20:11:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=aY2SKhoc; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RgdSM5YSNz3c8L for ; Wed, 6 Sep 2023 20:11:15 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=aY2SKhoc; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1034; helo=mail-pj1-x1034.google.com; envelope-from=npiggin@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RgdRk4H5Lz303l for ; Wed, 6 Sep 2023 20:10:42 +1000 (AEST) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-271b102659fso573236a91.0 for ; Wed, 06 Sep 2023 03:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693995039; x=1694599839; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Kqsop9zDTJ7dpoS55A/lCcesoyeNZ838npR57Lp4ZIY=; b=aY2SKhocLm6nHxMfQ36/8iLgy6dIyFIZ4bZXG26XwYN/BSL6EJFLpdL5xaL9GTXISH i6GvTkEEBAqrxuhzTRANmRypMpfFzzLpeacJWlNtyM1LVya1vYX42qM0X2dm6Zkrwekl Lc8gPAkW8bSRq6lFsWYWnGtKjcVMGKKFYA0wy/ATTYmN4LICsi31DmsRu0qZP2XgCfqg I0E/e/YoN5Y5N782j7yaa0Ggx5m8M+azr5faVaKN/ym8/3X7MjqkqsQyY/SLYgPtT/6R ijX2j6XkOlAh8TufBZIGDi7pqYGbmDgf4Z2TbyBECmk3zHhpLpa0JuUlEjqOQlKWAFQP he+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693995039; x=1694599839; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kqsop9zDTJ7dpoS55A/lCcesoyeNZ838npR57Lp4ZIY=; b=DKfAvEedFTG+khUO+uo/4NLEItocrEepezcBDw1dhX573LH9jOV9fdkyUR9yr1eo/m 5AN4bsNt7QChnFP6t5GNnAdNIfecqGXcoycQlKWOE06KFWU5v/OQWBFBenSG3ZPYADXj xGUZFzGDuPyFUbrvltXgpR6PV5d0Qzse8eLV1aqi5PLSkER3NLoA5jQIddykO4UWZz7T +UF5bCFBIUYlMhY9L9uPqXjt6r5db2llbZ+0e/AHlRpv8SFgsRzcY6aCisU8wo2G1Phl H8RuuQIwVfcgT3l52vyHdCUP+Np7mVs/50Hy4KjcUC52jbjt8598QNMrP9lN9YNY4r9M xnlg== X-Gm-Message-State: AOJu0Yw3QpdxQ78Ml77sRYvvkglhuDUwsECS2g/lRgkQj2NUU19W2b7S rqVqgxWN24yR5WKn3LfFFCtApeWPjJk= X-Google-Smtp-Source: AGHT+IFrtoUtjBnbW7sB9avdH9w9ymUpRz9IrC7nyomfxSRXchmsVQgj/VCTYBKq9aikKkbu1l/Hcw== X-Received: by 2002:a17:90a:8689:b0:26d:23c3:9f30 with SMTP id p9-20020a17090a868900b0026d23c39f30mr20577757pjn.14.1693995039478; Wed, 06 Sep 2023 03:10:39 -0700 (PDT) Received: from wheely.local0.net (193-116-105-24.tpgi.com.au. [193.116.105.24]) by smtp.gmail.com with ESMTPSA id m13-20020a17090a7f8d00b002609cadc56esm10639705pjl.11.2023.09.06.03.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 03:10:39 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Wed, 6 Sep 2023 20:10:14 +1000 Message-Id: <20230906101017.130276-5-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906101017.130276-1-npiggin@gmail.com> References: <20230906101017.130276-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 4/7] hdata: split idata accessor function X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add HDIF_idata that returns the idata pointer structure, not a pointer to the data itself. Signed-off-by: Nicholas Piggin --- hdata/hdif.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/hdata/hdif.c b/hdata/hdif.c index aba7f3660..98bd98d3c 100644 --- a/hdata/hdif.c +++ b/hdata/hdif.c @@ -4,10 +4,9 @@ #include "hdif.h" #include -const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di, - unsigned int *size) +static const struct HDIF_idata_ptr * +HDIF_idata(const struct HDIF_common_hdr *hdif, unsigned int idx) { - const struct HDIF_common_hdr *hdr = hdif; const struct HDIF_idata_ptr *iptr; if (!HDIF_check(hdif, NULL)) { @@ -16,14 +15,25 @@ const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di, return NULL; } - if (di >= be16_to_cpu(hdr->idptr_count)) { + if (idx >= be16_to_cpu(hdif->idptr_count)) { prlog(PR_DEBUG, "HDIF: idata %d out of range for %.6s!\n", - di, hdr->id); + idx, hdif->id); return NULL; } - iptr = (void *)hdif + be32_to_cpu(hdr->idptr_off) - + di * sizeof(struct HDIF_idata_ptr); + iptr = (void *)hdif + be32_to_cpu(hdif->idptr_off); + + return &iptr[idx]; +} + +const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di, + unsigned int *size) +{ + const struct HDIF_idata_ptr *iptr; + + iptr = HDIF_idata(hdif, di); + if (!iptr) + return NULL; if (size) *size = be32_to_cpu(iptr->size);