From: Michal Simek <michal.simek@amd.com>
To: "Jae Hyun Yoo" <quic_jaehyoo@quicinc.com>,
"Ovidiu Panait" <ovidiu.panait@windriver.com>,
"Simon Glass" <sjg@chromium.org>,
"Masahisa Kojima" <masahisa.kojima@linaro.org>,
"Pali Rohár" <pali@kernel.org>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Ashok Reddy Soma" <ashok.reddy.soma@xilinx.com>,
"Thomas Huth" <thuth@redhat.com>,
"Huang Jianan" <jnhuang95@gmail.com>,
"Chris Morgan" <macromorgan@hotmail.com>,
"Roland Gaudig" <roland.gaudig@weidmueller.com>,
"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
"Alexandru Gagniuc" <mr.nuke.me@gmail.com>
Cc: "Jamie Iles" <quic_jiles@quicinc.com>,
"Graeme Gregory" <quic_ggregory@quicinc.com>,
"Cédric Le Goater" <clg@kaod.org>,
u-boot@lists.denx.de
Subject: Re: [RFC PATCH 2/2] cmd/fru: add product info area parsing support
Date: Fri, 29 Jul 2022 13:11:52 +0200 [thread overview]
Message-ID: <684ff6aa-401b-e736-5bfb-2dd9be4992b2@amd.com> (raw)
In-Reply-To: <20220726235005.135686-3-quic_jaehyoo@quicinc.com>
On 7/27/22 01:50, Jae Hyun Yoo wrote:
> Add product info area parsing support.
>
> Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
> ---
> common/fru_ops.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++-
> include/fru.h | 22 ++++++++
> 2 files changed, 155 insertions(+), 1 deletion(-)
>
> diff --git a/common/fru_ops.c b/common/fru_ops.c
> index 0c5e264226ed..93d4970620f4 100644
> --- a/common/fru_ops.c
> +++ b/common/fru_ops.c
> @@ -218,6 +218,57 @@ static int fru_parse_board(unsigned long addr)
> return 0;
> }
>
> +static int fru_parse_product(unsigned long addr)
> +{
> + u8 i, type;
> + int len;
> + u8 *data, *term, *limit;
> +
> + memcpy(&fru_data.prd.ver, (void *)addr, 6);
> + addr += 3;
> + data = (u8 *)&fru_data.prd.manufacturer_type_len;
> +
> + /* Record max structure limit not to write data over allocated space */
> + limit = (u8 *)&fru_data.prd + sizeof(struct fru_product_data);
> +
> + for (i = 0; ; i++, data += FRU_BOARD_MAX_LEN) {
> + len = fru_check_type_len(*(u8 *)addr, fru_data.prd.lang_code,
> + &type);
> + /*
> + * Stop cature if it end of fields
> + */
> + if (len == -EINVAL)
> + break;
> +
> + /* Stop when amount of chars is more then fields to record */
> + if (data + len > limit)
> + break;
> + /* This record type/len field */
> + *data++ = *(u8 *)addr;
> +
> + /* Add offset to match data */
> + addr += 1;
> +
> + /* If len is 0 it means empty field that's why skip writing */
> + if (!len)
> + continue;
> +
> + /* Record data field */
> + memcpy(data, (u8 *)addr, len);
> + term = data + (u8)len;
> + *term = 0;
> + addr += len;
> + }
> +
> + if (i < FRU_PRODUCT_AREA_TOTAL_FIELDS) {
> + printf("Product area require minimum %d fields\n",
> + FRU_PRODUCT_AREA_TOTAL_FIELDS);
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> __weak int fru_parse_multirec(unsigned long addr)
> {
> u8 hdr_len = sizeof(struct fru_multirec_hdr);
> @@ -265,6 +316,9 @@ int fru_capture(unsigned long addr)
> if (hdr->off_board)
> fru_parse_board(addr + fru_cal_area_len(hdr->off_board));
>
> + if (hdr->off_product)
> + fru_parse_product(addr + fru_cal_area_len(hdr->off_product));
> +
> if (hdr->off_multirec)
> fru_parse_multirec(addr + fru_cal_area_len(hdr->off_multirec));
>
> @@ -352,6 +406,78 @@ static int fru_display_board(struct fru_board_data *brd, int verbose)
> return 0;
> }
>
> +static int fru_display_product(struct fru_product_data *prd, int verbose)
> +{
> + u8 type;
> + int len;
> + u8 *data;
> + static const char * const typecode[] = {
> + "Binary/Unspecified",
> + "BCD plus",
> + "6-bit ASCII",
> + "8-bit ASCII",
> + "2-byte UNICODE"
> + };
This should be generic for all records and should be shared.
Thanks,
Michal
next prev parent reply other threads:[~2022-07-29 11:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 23:50 [RFC PATCH 0/2] cmd/fru: move FRU handling support to common region Jae Hyun Yoo
2022-07-26 23:50 ` [RFC PATCH 1/2] cmd/fru: " Jae Hyun Yoo
2022-07-29 11:13 ` Michal Simek
2022-07-29 14:38 ` Jae Hyun Yoo
2022-07-29 15:00 ` Jae Hyun Yoo
2022-08-01 7:58 ` Michal Simek
2022-08-01 7:57 ` Michal Simek
2022-07-26 23:50 ` [RFC PATCH 2/2] cmd/fru: add product info area parsing support Jae Hyun Yoo
2022-07-29 11:11 ` Michal Simek [this message]
2022-07-29 14:15 ` Jae Hyun Yoo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=684ff6aa-401b-e736-5bfb-2dd9be4992b2@amd.com \
--to=michal.simek@amd.com \
--cc=ashok.reddy.soma@xilinx.com \
--cc=clg@kaod.org \
--cc=jnhuang95@gmail.com \
--cc=macromorgan@hotmail.com \
--cc=masahisa.kojima@linaro.org \
--cc=mr.nuke.me@gmail.com \
--cc=ovidiu.panait@windriver.com \
--cc=pali@kernel.org \
--cc=patrick.delaunay@foss.st.com \
--cc=quic_ggregory@quicinc.com \
--cc=quic_jaehyoo@quicinc.com \
--cc=quic_jiles@quicinc.com \
--cc=roland.gaudig@weidmueller.com \
--cc=sjg@chromium.org \
--cc=thuth@redhat.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.