[Request for review] loader changes

From: Andrey V. Elsukov <ae_at_FreeBSD.org>
Date: Mon, 30 Jul 2012 11:02:53 +0400
Hi, All.

It's been a long ago, when i published my patches first time.
And it seems, there is no one who is against or wants suggest something.
So I'm asking for review, and I want start merge changes at the end of week.
Patches are here: http://people.freebsd.org/~ae/bootcode/

full.diff:
The full diff, except tools.

tools.diff:
A small test program bootparttest. It uses sys/boot/common/part.c to
taste GEOM provider or disk image in the similar way, how loader does.

common.diff:
Changes to the common code. This code is used with many architectures and libraries.

* common/Makefile.inc
  added LOADER_NO_DISK_SUPPORT knob to disable build common code related to disks and
  partitions. By default GPT and MBR support are enabled, LOADER_NO_GPT_SUPPORT and
  LOADER_NO_MBR_SUPPORT can disable they.

* common/part.c
  common/part.h
  these files are new. They contains partition tables related code. Several words about API:
  Partition table described with opaque type "struct ptable", partition entries with
  struct ptable_entry {
	uint64_t		start;
	uint64_t		end;
	int			index;
	enum partition_type	type;
  };

  The partition tables detection occurs when ptable_open() is called. This function takes
  as arguments the number of disk sectors, sector size and pointer to the callback
  function, that is know how to read from the disk.
  The ptable_close() function releases allocated resources.
  The ptable_gettype() functions returns the type of partition table.
  The ptable_getpart() functions returns information about specified partition.
  The ptable_iterate() functions calls a callback function for each partition in the table.
  The parttype2str() converts partition type to the string.

  The following partition tables are supported: BSD label, GPT, MBR, EBR and VTOC8.

* common/disk.c
  common/disk.h
  These files have been changed and they use new API to work with partitions. Also now
  they provide new disk API to the devsw disk drivers: disk_open(), disk_close(),
  disk_print(), disk_fmtdev() and disk_parsedev().

i386.diff:
Changes related to the i386 architecture:

* i386/libi386/devicename.c
  Use disk_fmtdev() and disk_parsedev() functions from the common code.

* i386/libi386/biosdisk.c
  The disk driver was rewritten to use new disk API. To the devsw ioctl handler was added.
  It handles DIOCGSECTORSIZE and DIOCGMEDIASIZE ioctls.

* i386/libi386/libi386.h
  The offset field was added to the i386_devdesc.d_kind.biosdisk structure.

* i386/libi386/Makefile
  removed unneeded flag.

* i386/pmbr/pmbr.s
  Added secondary GPT support.

* i386/loader/main.c
  ZFS probing simplified.

* i386/loader/Makefile
  removed unneeded flag.

userboot.diff:
The disk driver and sample program updated according to the changes in the disk.c.
Also new diskioctl callback added.

uboot.diff:
The disk driver was rewritten to use new disk API.

arm.diff:
powerpc.diff:
Added LOADER_NO_DISK_SUPPORT handling to be able build uboot with or without disk support.

zfs.diff:
Use new partitions API to probe all ZFS partitions in the GPT and BSD partition tables.

So, if there will not any opinions against these APIs and patches I will start
commit. The first step will be common and userboot code, then - i386 and zfs parts.

-- 
WBR, Andrey V. Elsukov



Received on Mon Jul 30 2012 - 05:10:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC