All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Day via B4 Relay <devnull+me.samcday.com@kernel.org>
To: u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	 Alper Nebi Yasak <alpernebiyasak@gmail.com>,
	 Quentin Schulz <quentin.schulz@cherry.de>,
	Bryan Brattlof <bb@ti.com>,  Yannic Moog <y.moog@phytec.de>,
	Wojciech Dubowik <Wojciech.Dubowik@mt.com>,
	 Yegor Yefremov <yegorslists@googlemail.com>,
	 Patrice Chotard <patrice.chotard@foss.st.com>,
	 Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Marek Vasut <marek.vasut+renesas@mailbox.org>,
	 Rasmus Villemoes <ravi@prevas.dk>, Javier Tia <floss@jetm.me>,
	 Minkyu Kang <mk7.kang@samsung.com>,
	 Kaustabh Chakraborty <kauschluss@disroot.org>,
	 Henrik Grimler <henrik@grimler.se>,
	yan wang <yan.wang@softathome.com>,
	 Marek Vasut <marex@nabladev.com>,
	Denis Mukhin <dmukhin@ford.com>,  Sam Day <me@samcday.com>
Subject: [PATCH v3 03/10] binman: section: add AlignUp+PadToAlignment helpers
Date: Wed, 10 Jun 2026 11:27:41 +1000	[thread overview]
Message-ID: <20260610-android-binman-v3-3-710298a38fcc@samcday.com> (raw)
In-Reply-To: <20260610-android-binman-v3-0-710298a38fcc@samcday.com>

From: Sam Day <me@samcday.com>

In the following commits we will be introducing new etypes derived from
Entry_section which need to align values and pad data. To avoid
duplication we introduce the shared helpers here.
---
 tools/binman/etype/section.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 8530b7ee17f..a8eca3eaf5f 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -1040,3 +1040,12 @@ class Entry_section(Entry):
             for entry in entries.values():
                 return entry.read_elf_segments()
         return None
+
+    def AlignUp(self, value, align):
+        """Return value aligned to given power of 2"""
+        return (value + align - 1) & ~(align - 1)
+
+
+    def PadToAlignment(self, data, align):
+        """Null-pads given data to given power of 2"""
+        return data + b'\0' * (self.AlignUp(len(data), align) - len(data))

-- 
2.54.0



WARNING: multiple messages have this Message-ID (diff)
From: Sam Day <me@samcday.com>
To: u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	 Alper Nebi Yasak <alpernebiyasak@gmail.com>,
	 Quentin Schulz <quentin.schulz@cherry.de>,
	Bryan Brattlof <bb@ti.com>,  Yannic Moog <y.moog@phytec.de>,
	Wojciech Dubowik <Wojciech.Dubowik@mt.com>,
	 Yegor Yefremov <yegorslists@googlemail.com>,
	 Patrice Chotard <patrice.chotard@foss.st.com>,
	 Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Marek Vasut <marek.vasut+renesas@mailbox.org>,
	 Rasmus Villemoes <ravi@prevas.dk>, Javier Tia <floss@jetm.me>,
	 Minkyu Kang <mk7.kang@samsung.com>,
	 Kaustabh Chakraborty <kauschluss@disroot.org>,
	 Henrik Grimler <henrik@grimler.se>,
	yan wang <yan.wang@softathome.com>,
	 Marek Vasut <marex@nabladev.com>,
	Denis Mukhin <dmukhin@ford.com>,  Sam Day <me@samcday.com>
Subject: [PATCH v3 03/10] binman: section: add AlignUp+PadToAlignment helpers
Date: Wed, 10 Jun 2026 11:27:41 +1000	[thread overview]
Message-ID: <20260610-android-binman-v3-3-710298a38fcc@samcday.com> (raw)
In-Reply-To: <20260610-android-binman-v3-0-710298a38fcc@samcday.com>

In the following commits we will be introducing new etypes derived from
Entry_section which need to align values and pad data. To avoid
duplication we introduce the shared helpers here.
---
 tools/binman/etype/section.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 8530b7ee17f..a8eca3eaf5f 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -1040,3 +1040,12 @@ class Entry_section(Entry):
             for entry in entries.values():
                 return entry.read_elf_segments()
         return None
+
+    def AlignUp(self, value, align):
+        """Return value aligned to given power of 2"""
+        return (value + align - 1) & ~(align - 1)
+
+
+    def PadToAlignment(self, data, align):
+        """Null-pads given data to given power of 2"""
+        return data + b'\0' * (self.AlignUp(len(data), align) - len(data))

-- 
2.54.0


  parent reply	other threads:[~2026-06-10  1:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10  1:27 [PATCH v3 00/10] Generate Android boot images with binman Sam Day via B4 Relay
2026-06-10  1:27 ` Sam Day
2026-06-10  1:27 ` [PATCH v3 01/10] binman: support running multiple tests Sam Day via B4 Relay
2026-06-10  1:27   ` Sam Day
2026-06-10  1:27 ` [PATCH v3 02/10] binman: test name globbing support Sam Day via B4 Relay
2026-06-10  1:27   ` Sam Day
2026-06-10  1:27 ` Sam Day via B4 Relay [this message]
2026-06-10  1:27   ` [PATCH v3 03/10] binman: section: add AlignUp+PadToAlignment helpers Sam Day
2026-06-10  1:27 ` [PATCH v3 04/10] binman: Android boot image support Sam Day via B4 Relay
2026-06-10  1:27   ` Sam Day
2026-06-10  1:27 ` [PATCH v3 05/10] .gitignore: ignore binman-generated blobs Sam Day via B4 Relay
2026-06-10  1:27   ` Sam Day
2026-06-10  1:27 ` [PATCH v3 06/10] binman: android_boot: vendor-dt support Sam Day
2026-06-10  1:27   ` Sam Day via B4 Relay
2026-06-10  1:27 ` [PATCH v3 07/10] binman: Add QCDT support Sam Day
2026-06-10  1:27   ` Sam Day via B4 Relay
2026-06-10  1:27 ` [PATCH v3 08/10] binman: Add DTBH support Sam Day
2026-06-10  1:27   ` Sam Day via B4 Relay
2026-06-10  1:27 ` [PATCH v3 09/10] arch: arm: exynos: add j7xelte binman config Sam Day via B4 Relay
2026-06-10  1:27   ` Sam Day
2026-06-13 11:45   ` Kaustabh Chakraborty
2026-06-13 12:03   ` Kaustabh Chakraborty
2026-06-10  1:27 ` [PATCH v3 10/10] configs: exynos-mobile: pull in binman Sam Day
2026-06-10  1:27   ` Sam Day via B4 Relay
2026-06-13 11:59   ` Kaustabh Chakraborty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260610-android-binman-v3-3-710298a38fcc@samcday.com \
    --to=devnull+me.samcday.com@kernel.org \
    --cc=Wojciech.Dubowik@mt.com \
    --cc=alpernebiyasak@gmail.com \
    --cc=bb@ti.com \
    --cc=dmukhin@ford.com \
    --cc=floss@jetm.me \
    --cc=henrik@grimler.se \
    --cc=kauschluss@disroot.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=marex@nabladev.com \
    --cc=me@samcday.com \
    --cc=mk7.kang@samsung.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=quentin.schulz@cherry.de \
    --cc=ravi@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=y.moog@phytec.de \
    --cc=yan.wang@softathome.com \
    --cc=yegorslists@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.