From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YbW7X-0001L9-Sj for mharc-grub-devel@gnu.org; Fri, 27 Mar 2015 11:24:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbW7V-0001KB-Mh for grub-devel@gnu.org; Fri, 27 Mar 2015 11:24:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbW7Q-0001QS-NQ for grub-devel@gnu.org; Fri, 27 Mar 2015 11:24:25 -0400 Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:36838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbW7Q-0001QA-B7 for grub-devel@gnu.org; Fri, 27 Mar 2015 11:24:20 -0400 Received: by lbbug6 with SMTP id ug6so66071561lbb.3 for ; Fri, 27 Mar 2015 08:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=1TQbyiwxL8NtutYSrdc/7BaNogEnS2nCnLZBBBOo4TA=; b=zxP1DfbYbvkPPvdDzTXv1w0XbzWT86qaGjzFSUIHSoy4D4q5RD/XJOjKVWwWn3Jp6J 39hii9yn8SSg+rfFRdDQPHSBiK76xeFqpBuADOjolB4OfMdEKg2HBkO4JJ//J+HD/fjE +GnDZF67GEIec4WOhw3Le6MooMeZ1LsQv4NMKSL6JYDK/YlPLPS8mHfEV9gmjbiSjzHy 8LBe0Z+O27RRW/+HG+HEHkxrQNHBLtC9/El7W+d2r1vFF+7+QfFrNKpgBEtD3bwua0xk WtNvvE+ahbbjcIRRQVgWhQlZ1Pzb6OzjAHmbQvLx70xkQ7Z1ZnXGl95Ft4iuDa/KtjPp wkIg== X-Received: by 10.152.170.199 with SMTP id ao7mr17898405lac.27.1427469859623; Fri, 27 Mar 2015 08:24:19 -0700 (PDT) Received: from opensuse.site (ppp91-76-14-38.pppoe.mtu-net.ru. [91.76.14.38]) by mx.google.com with ESMTPSA id m4sm393570lae.47.2015.03.27.08.24.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 08:24:18 -0700 (PDT) Date: Fri, 27 Mar 2015 18:24:16 +0300 From: Andrei Borzenkov To: David Michael Subject: Re: [PATCH v3] Add a module for retrieving SMBIOS information Message-ID: <20150327182416.1aa0b625@opensuse.site> In-Reply-To: <87384w4gky.fsf@gmail.com> References: <87384w4gky.fsf@gmail.com> X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.25; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22b Cc: Prarit Bhargava , grub-devel@gnu.org, Raghuraman Thirumalairajan , Rajat Jain , Leif Lindholm , Sanjay Jain , Stu Grossman X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2015 15:24:26 -0000 =D0=92 Sun, 22 Mar 2015 22:01:49 -0400 David Michael =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > +struct __attribute__ ((packed)) grub_smbios_eps > + { > + grub_uint8_t anchor[4]; /* "_SM_" */ any plans to implement SMBIOS 3.0 (64 bit address) support? > + grub_uint8_t checksum; > + grub_uint8_t length; > + grub_uint8_t version_major; > + grub_uint8_t version_minor; > + grub_uint16_t maximum_structure_size; > + grub_uint8_t revision; > + grub_uint8_t formatted[5]; > + struct grub_smbios_ieps intermediate; > + }; > + > +#define eps_table_begin(eps) ((grub_addr_t)((eps)->intermediate.table_ad= dress)) > +#define eps_table_end(eps) \ > + ((grub_addr_t)((eps)->intermediate.table_address + \ > + (eps)->intermediate.table_length)) > + To make adding 64 bit SMBIOS easier, may be extract entry point and size (and other relevant fields) instead of referring to them directly. Then we'd just need to add additional search for 3.0 entry point and all other code won't need to be changed - tables themselves remain the same as far as I can tell. ... > + > +static grub_err_t > +grub_cmd_smbios (grub_extcmd_context_t ctxt, > + int argc __attribute__ ((unused)), > + char **argv __attribute__ ((unused))) > +{ > + struct grub_arg_list *state =3D ctxt->state; > + > + grub_int16_t type =3D -1; > + grub_int32_t handle =3D -1; > + grub_uint16_t match =3D 0; > + grub_uint8_t offset =3D 0; > + > + grub_int32_t option; > + const grub_uint8_t *structure; > + grub_uint8_t accessors; > + grub_uint8_t i; > + char buffer[24]; /* 64-bit number -> maximum 20 decimal digits */ > + const char *value =3D buffer; > + Could we avoid this aliasing? It is extremely confusing to see buffer used everywhere and then suddenly value in the last line. What is the reason? > + > + /* Store or print the requested value. */ > + if (state[8].set) > + { > + grub_env_set (state[8].arg, value); > + grub_env_export (state[8].arg); Why export variable here? It is up to user what to do with it later. > +static const struct grub_arg_option options[] =3D > + { > + {"type", 't', 0, N_("Match entries with the given type."), > + N_("type"), ARG_TYPE_INT}, > + {"handle", 'h', 0, N_("Match entries with the given handle."), > + N_("handle"), ARG_TYPE_INT}, > + {"match", 'm', 0, N_("Select a structure when several match."), > + N_("match"), ARG_TYPE_INT}, > + {"get-byte", 'b', 0, N_("Get the byte's value at the given offset.= "), > + N_("offset"), ARG_TYPE_INT}, > + {"get-word", 'w', 0, N_("Get two bytes' value at the given offset.= "), > + N_("offset"), ARG_TYPE_INT}, > + {"get-dword", 'd', 0, N_("Get four bytes' value at the given offset= ."), > + N_("offset"), ARG_TYPE_INT}, > + {"get-qword", 'q', 0, N_("Get eight bytes' value at the given offse= t."), > + N_("offset"), ARG_TYPE_INT}, > + {"get-string", 's', 0, N_("Get the string specified at the given off= set."), > + N_("offset"), ARG_TYPE_INT}, > + {"set", '\0', 0, N_("Store the value in the given variable nam= e."), > + N_("variable"), ARG_TYPE_STRING}, > + {0, 0, 0, 0, 0, 0} > + }; One non-trivial structure field that is rather awkward to get otherwise is UUID.=20