| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
barebox as EFI loader can use the information about which partitions are
bootable to guide its decision. Record this information.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240304190038.3486881-22-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Traditionally barebox starts partition numbers at 0. This was changed
in 8f48e6366c to start at 1. This was done to make the parted numbering
consistent to the Linux tool. This breaks boot scripts though which
assume 0 to be the first partition, so change it back.
Fixes: 8f48e6366c ("partitions: dos: implement partition manipulation support")
Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240229071825.1624411-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
Traditionally barebox starts partition numbers at 0. This was changed
in bdc3cb54dc to start at 1. This was done to make the parted numbering
consistent to the Linux tool. This breaks boot scripts though which
assume 0 to be the first partition, so change it back.
Fixes: bdc3cb54dc ("partitions: efi: implement partition manipulation support")
Link: https://lore.barebox.org/20240229071825.1624411-1-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We have a GUID for partitions to use for barebox environment. Add an
option for parted to create these.
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20240219145159.1962618-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This fills in the partition manipulation function hooks to add/remove
efi (GPT) partitions and to write a GPT partition table. This depends on
te msdos partition writing support for generating a protective MBR.
Link: https://lore.barebox.org/20240219083140.2713047-12-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| | |
This fills in the msdos specific function hooks to add/remove
partitions.
Link: https://lore.barebox.org/20240219083140.2713047-11-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| | |
This will be needed by upcoming partition manipulation code, so move it
to include/
Link: https://lore.barebox.org/20240219083140.2713047-9-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| | |
Keep raw data for later partition write support.
Link: https://lore.barebox.org/20240219083140.2713047-5-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Allocate struct partition in the parser rather than in the core
partition code. Doing so allows the parser to embed struct partition
in an implementation specific struct type.
Link: https://lore.barebox.org/20240219083140.2713047-4-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Allocate struct partition_desc in parser rather than in the core. Doing
so allows the efi/dos partition code to embed the struct partition_desc
is a efi/dos specific struct type.
Link: https://lore.barebox.org/20240219083140.2713047-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| | |
Save an indention level by continuing early in the loop.
Link: https://lore.barebox.org/20240219083140.2713047-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In efi_partition() gpt and ptes is allocated but never freed. It's no
longer used when leaving this function, so free the memory before
leaving it.
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20240215074757.960200-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For MBR-partitioned disks, the NT signature is used to derive the PARTUUID used
to identify the root partition. For this to work reliably, the NT signature is
expected to be unique across all attached MBR-partitioned storage.
Some partition tools may populate the NT signature with an all-zero
value by default, which will likely run afoul of the uniqueness
expectations. When this happens, barebox' bootm.appendroot feature will
report a non-descriptive error message:
ERROR: Failed to append kernel cmdline parameter 'root='
and continue to boot the kernel without a root= option.
As the kernel doesn't mind an all-zero NT signature, let's just support
computing the correct partuuid in this case. The user is still presented
with an info message:
Adding "root=PARTUUID=00000000-02" to Kernel commandline
and it's up to them to do something about it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240213100836.2853989-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
We already record DOS partition type in cdev, so let's do the same for
GPT Type UUID. This will be used in a later commit to identify
barebox-state partitions.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230607120714.3083182-19-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, the only way to differentiate between a GPT disk and a MBR
one is to check whether the cdev's device has a guid (=> GPT) or a
nt_signature (=> MBR) device parameter. We already have a flag parameter
though, so let's record this info there for easy retrieval.
We intentionally don't use the struct cdev::filetype member, because
we don't want to change behavior of file_detect_type().
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230607120714.3083182-14-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The UUID field has different meanings:
For a master cdev:
- GPT Header DiskGUID if GPT-formatted
- MBR Header NT Disk Signature if MBR-formatted
For a partition cdev:
- GPT UniquePartitionGUID
- MBR Header NT Disk Signature followed by "-${partititon_number}"
Later code will add yet another UUID (Partition Type GUID), so let's
make existing code more readable by using either diskuuid or partuuid as
appropriate.
No functional change.
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230607120714.3083182-10-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have three UUID/GUID definitions in barebox:
- efi_guid_t: for EFI GUIDs
- uuid_t: for RFC 4122/DCE 1.1 (Variant 1) UUIDs
- guid_t: Apparently UUIDs stored in little-endian
In preparation for switching efi_guid_t to be a special case of guid_t
like in Linux, let's replace non-EFI uses of efi_guid_t with guid_t.
This allows us to drop the efi.h header outside of EFI code.
This also involves two replacements of efi_char16_t with wchar_t.
This is ok, as we always build with -fshort-wchar.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230607120714.3083182-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The efi partition enumeration stops, if a partition entry is
invalid or non-existent.
Later partitions which would be valid are therefore not enumerated.
This can be the case, eg. if a device with the following
partitions is enumerated: p1, p2, p4, p5, p6.
Skipping the invalid entry instead of exiting the enumeration fixes
this problem.
Signed-off-by: Christopher Ebner <ch.ebner@commend.com>
Link: https://lore.barebox.org/20230605101105.485283-1-ch.ebner@commend.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The '_d' suffix was originally introduced in case we want to import
Linux struct device as a separate struct into barebox. Over time it
became clear that this won't happen, instead barebox struct device_d
is basically the same as Linux struct device. Rename the struct name
accordingly to make porting Linux code easier.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We already register an nt_signature parameter for MBR partitions.
Register an equivalent guid parameter for GPT partitions as well.
This is less critical because disk GUID isn't used for root=
Linux boot argument computation, as each partition has its own
PARTUUID. It's still useful to allow shell scripts to check
against it to detect e.g. a factory flash image.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220630124035.4019644-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This debug message is printed for the alternative GPT header as well,
which may not exist at that location, because the medium has a different
length than what's in the GPT header. Make it easier to differentiate,
whether the message refers to the primary or alternate GPT header by
printing the LBA the header was expected at.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Link: https://lore.barebox.org/20220319072427.1310855-1-ahmad@a3f.at
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows identifying disks by UUID. For disks with GPT the disk GUID is
used. For DOS partition tables the NT signature ist used, similar to how
the partuuid is generated.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Link: https://lore.barebox.org/20220124100458.2924679-3-m.olbrich@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20220207094953.949868-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
Partitions are not the only devices that can have UUIDs. Change the name to
something more generic to prepare for other users.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Link: https://lore.barebox.org/20220124100458.2924679-2-m.olbrich@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://lore.barebox.org/20220207094953.949868-1-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
extended partitions are currently registered with their full size which
means they overlap with the logical partitions therein. Since 7f9f45b9bf
("devfs: Do not create overlapping partitions") we no longer register
overlapping partitions, so the logical partitions are no longer
accessible. Fix this by reducing the size of the extended partition to
two blocks (1kiB) which is the same as Linux does.
Fixes: 7f9f45b9bf ("devfs: Do not create overlapping partitions")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To verify only Kconfig/Makefile is touched:
git show --numstat --format=oneline HEAD | grep -v 'Kconfig\|Makefile'
will print only arch/powerpc/Kbuild.
To verify nothing unexpected is added:
git show -U0 | grep '^-[^-]\|^+[^+]' | sort -u
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220103120539.1730644-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
| |
The header contains GUIDs and definitions that will become applicable outside
of the GPT partition parser as well, so move them out.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20211122084732.2597109-27-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The GPT partiton parser has a check which should check if the GPT has
more partitions than we support. This doesn't work because the loop
iterating over the partitions exits with a maximum i of MAX_PARTITION,
i > MAX_PARTITION will never be true. Fix the check.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210602071533.10093-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Having MAX_PARTITION defined to 8 is enough for a DOS partition table,
but not for GPT. Increase it to the maximum GPT supports. It might be
even better to allocate the partitions dynamically, but for nor take the
easy way out.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviwed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210602071533.10093-1-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The 16-bit port has experienced bitrot and failed to compile with more
recent linkers for at least a year. Fixing the linker error is insufficient
to restore a barebox that can boot to shell. This continued breakage likely
means that there are no users interested in updating. As new x86 projects
should be using MACH_EFI_GENERIC anyway, retire support for 16-bit legacy
boot (MACH_X86_GENERIC).
Acked-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
While block drivers may do DMA, they always use block caching chunks as
bounce buffer. No dma is every done directly to the block_read data
argument, so it doesn't need to be allocated with dma_alloc. The buffer
also need not be zeroed, as block_read will either overwrite it
completely or fail.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
On some boards (such as i.MX) the buffer might contain both:
A barebox image *and* a GPT partition table.
Thus, irrelevant filetypes should be ignored.
|
|
|
|
|
|
|
| |
No one is modifying 'force_gpt', so constify it to reflect that fact.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Creating logical DOS partitions with fdisk (Fedora 27, fdisk from
util-linux 2.30.2) results in extended partition of type 0x05 being
created on the device. Partitioned like this, device is succesfully
recognized by Linux, but, due to algorithm in dos_partition(), not
Barebox.
Looking closer at the actual contents of MBR shows that while marked
as "Extended partition with CHS addressing" that partition still have
all of the LBA adressed fields filled correctly.
Given the above and the fact that similar code in Linux
kernel (block/partitions/msdos.c) does not make a distinction between
types 0x0f and 0x05, port Linux's is_extended_partition() and convert
the code to treat types 0x05, 0x0f and 0x85 the same way.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch creates a consitent set of device parameter functions.
With this we have: dev_add_param_<type><access>
"type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask
The improvement here is that we now can exactly specify the width of the
int type parameters and also correctly distinguish between signed and
unsigned variables which means that a variable no longer ends up with
INT_MAX when it's assigned -1.
"access" can be empty for regular read/write parameter, "_ro" for readonly
parameters which get their value from a variable pointer in the
background or "_fixed" for parameters which are set to a fixed value
(without a pointer in the background).
Some more exotic types are not (yet) implemented, like
dev_add_param_ip_ro.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
| |
Commit bc31d85c6e23 ("cdev: Add partuuid string to struct cdev") added
partuuid strings for dos partitions but only for the (up to) four
primary partitions. Do the same for the logical partitions. Their
numbers start at 5 independently of the number of available primary
partitions.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
We have a crc.h, so move our crc function prototypes there to further
cleanup common.h.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
In commit bc31d85c6e23d724664e76bcfc3b2eda778012a3 the partition UUID
was added to the partition struct and thence to the cdev(s) for the
partition. But just for DOS partitions. Do this for GPT aka EFI
partitions too.
Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
This adds the partuuid string to struct cdev in order to have this
available for constructing a suitable Linux root=PARTUUID= option
for booting Linux.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
LBAs are numbered starting from zero so the last LBA # would be equal
to total number of blocks minus one.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
This adds support for running barebox in an EFI environment
on X86 PC hardware.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
With upcoming EFI payload support the efi.h file will diverge
from the kernel, so move it from include/linux/ to include/
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The FSF address has changed; The FSF site says that
address is
Free Software Foundation
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301
USA
(see http://www.fsf.org/about/contact/)
Instead of updating it each time the address changes,
just drop it completely treewide.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
| |
DOS MBRs might contain an extended partition that holds several logical
partitions. Add these to the partitions of the block device.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
| |
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
|
|
| |
The code used to ineffectively take the end of the last partition as guess
for the disk size. Better use the end of the partition that has its end
rearmost.
Also return an unsigned type instead of int as the result is always
non-negative.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
| |
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
|
|
|
| |
The NT disk Signature is a unique 32-bit value in the MBR allowing
to identify a MSDOS partitioned disk. The signature can be used to
specify the Linux rootfs.
This patch adds support for the NT disk Signature in the form of a
device parameter which can both be read and written.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|
|
|
|
|
|
|
| |
The disk partitions use blockdevice functions, so add the corresponding
depends on BLOCK.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
|