Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 May 2021 23:27:48 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        John Nielsen <lists@jnielsen.net>, "freebsd-acpi@freebsd.org" <freebsd-acpi@FreeBSD.org>
Subject:   Re: How to properly locate/parse ACPI table from kernel module?
Message-ID:  <cd4fcd79-ddca-89c8-2160-5c938ad4b9ae@FreeBSD.org>
In-Reply-To: <BCFCDCE9-F169-4C1C-AD0C-FDE511C0BC11@jnielsen.net>
References:  <BCFCDCE9-F169-4C1C-AD0C-FDE511C0BC11@jnielsen.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 17/05/2021 23:00, John Nielsen wrote:
> Hi all-
> 
> I’m not much of a kernel programmer but I’m trying to maintain/improve the
> isboot module, which allows booting directly from iSCSI by reading the iSCSI
> Boot Firmware Table (iBFT), bringing up the interface with the details
> specified therein and connecting to the specified iSCSI target before trying
> to mount root.
> 
> I’m not the original author but as the port maintainer I am hosting the code
> here: https://github.com/jnielsendotnet/isboot
> 
> I have a test system where the module loads but fails to find the iBFT. I
> reviewed the iBFT code and realized it has a bunch of magic numbers mixed in
> with some random memory diving. If I’m reading it right (see
> https://github.com/jnielsendotnet/isboot/blob/master/src/ibft.h#L37 and
> https://github.com/jnielsendotnet/isboot/blob/master/src/ibft.c#L521), it
> looks like it scans all of the (kernel?) memory between 512K and 1M in
> 16-byte increments looking for one beginning with the string “iBFT”, which if
> it finds will be used as the offset for reading the table. I don’t know where
> the 512K and 1M values came from or if they are correct, but I do have a
> system where that method does not work.

They seem to come from iBFT specification.
   Locating the iBFT
   The iBFT can be located by the Low RAM Method. Scan for the table header
   signature in system memory between 512K and 1024K. The scan MUST be done
   starting at the lower address scanning forward to the higher address. When
   using the Low RAM Method, the table header must be aligned on a 16-byte
   boundary.

> IIUC, the iBFT is an ACPI table, and it seems like using ACPI to find it
> would be safer and more reliable. So my question is: how does one do that?
> Are there other places in the kernel code that do this sort of thing that I
> could use as a model?

Yes.
Search for occurrences of AcpiGetTable() in the code, that's the function you 
want to use.

But it could be that the table gets overwritten during boot for some reason...


-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?cd4fcd79-ddca-89c8-2160-5c938ad4b9ae>