From nobody Mon May 17 20:00:21 2021 X-Original-To: freebsd-acpi@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C5B3085A886 for ; Mon, 17 May 2021 20:00:27 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from webmail5.jnielsen.net (webmail5.jnielsen.net [69.87.218.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.freebsdsolutions.net", Issuer "freebsdsolutions.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FkVNp68PPz3QT5 for ; Mon, 17 May 2021 20:00:23 +0000 (UTC) (envelope-from lists@jnielsen.net) Received: from [192.168.2.189] (stealth.jnielsen.net [68.69.164.122]) (authenticated bits=0) by webmail5.jnielsen.net (8.15.2/8.15.2) with ESMTPSA id 14HK0K21047189 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 17 May 2021 14:00:22 -0600 (MDT) (envelope-from lists@jnielsen.net) X-Authentication-Warning: webmail5.jnielsen.net: Host stealth.jnielsen.net [68.69.164.122] claimed to be [192.168.2.189] From: John Nielsen Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: ACPI and power management development List-Archive: http://lists.freebsd.org/acpi List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-acpi@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: How to properly locate/parse ACPI table from kernel module? Message-Id: Date: Mon, 17 May 2021 14:00:21 -0600 To: "freebsd-acpi@freebsd.org" X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Rspamd-Queue-Id: 4FkVNp68PPz3QT5 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of lists@jnielsen.net designates 69.87.218.172 as permitted sender) smtp.mailfrom=lists@jnielsen.net X-Spamd-Result: default: False [-1.80 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mailers.freebsdsolutions.net:c]; MV_CASE(0.50)[]; HAS_XAW(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[69.87.218.172:from]; ASN(0.00)[asn:6364, ipnet:69.87.218.0/24, country:US]; R_DKIM_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; SUBJECT_ENDS_QUESTION(1.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-acpi@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[69.87.218.172:from:127.0.2.255]; DMARC_NA(0.00)[jnielsen.net]; TO_DN_EQ_ADDR_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-acpi] Hi all- I=E2=80=99m not much of a kernel programmer but I=E2=80=99m 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=E2=80=99m 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=E2=80=99m 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 = =E2=80=9CiBFT=E2=80=9D, which if it finds will be used as the offset for = reading the table. I don=E2=80=99t 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. 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? Any gotchas I should know about as a = (less-than) novice kernel programmer? Thanks! JN