<p>Youness Alaoui would like Matt DeVillier to <strong>review</strong> this change.</p><p><a href="https://review.coreboot.org/22040">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">purism/librem13v2: Add reading of serial number from cbfs<br><br>Check CBFS for 'serial_number' field, and use value if exists;<br>otherwise use value set at compile time.<br><br>Change-Id: I4b50f6310ca32b9dd372db075a5b5729e3b06619<br>Signed-off-by: Matt DeVillier <matt.devillier@gmail.com><br>Signed-off-by: Youness Alaoui <youness.alaoui@puri.sm><br>---<br>A src/mainboard/purism/librem13v2/mainboard.c<br>1 file changed, 47 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/22040/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/mainboard/purism/librem13v2/mainboard.c b/src/mainboard/purism/librem13v2/mainboard.c<br>new file mode 100644<br>index 0000000..e941fc5<br>--- /dev/null<br>+++ b/src/mainboard/purism/librem13v2/mainboard.c<br>@@ -0,0 +1,47 @@<br>+/*<br>+ * This file is part of the coreboot project.<br>+ *<br>+ * Copyright (C) 2017 Purism SPC<br>+ *<br>+ * This program is free software; you can redistribute it and/or modify<br>+ * it under the terms of the GNU General Public License as published by<br>+ * the Free Software Foundation; version 2 of the License.<br>+ *<br>+ * This program is distributed in the hope that it will be useful,<br>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>+ * GNU General Public License for more details.<br>+ */<br>+<br>+#include <rules.h><br>+#include <smbios.h><br>+#include <string.h><br>+#include <cbfs.h><br>+<br>+#define MAX_SERIAL_LENGTH 0x100<br>+<br>+const char *smbios_mainboard_serial_number(void)<br>+{<br>+       static char serial_number[MAX_SERIAL_LENGTH + 1] = {0};<br>+      struct cbfsf file;<br>+<br>+        if (serial_number[0] != 0)<br>+           return serial_number;<br>+<br>+     if (cbfs_boot_locate(&file, "serial_number", NULL) == 0) {<br>+             struct region_device cbfs_region;<br>+            size_t serial_len;<br>+           cbfs_file_data(&cbfs_region, &file);<br>+<br>+              serial_len = region_device_sz(&cbfs_region);<br>+             if (serial_len < MAX_SERIAL_LENGTH) {<br>+                     rdev_readat(&cbfs_region, serial_number, 0, serial_len);<br>+                 serial_number[serial_len] = 0;<br>+               }<br>+    } else {<br>+             strncpy(serial_number, CONFIG_MAINBOARD_SERIAL_NUMBER,<br>+                       MAX_SERIAL_LENGTH);<br>+  }<br>+<br>+ return serial_number;<br>+}<br></pre><p>To view, visit <a href="https://review.coreboot.org/22040">change 22040</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/22040"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I4b50f6310ca32b9dd372db075a5b5729e3b06619 </div>
<div style="display:none"> Gerrit-Change-Number: 22040 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Youness Alaoui <snifikino@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matt DeVillier <matt.devillier@gmail.com> </div>