summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSimon Rettberg2019-04-20 11:31:39 +0200
committerSimon Rettberg2019-04-20 11:31:39 +0200
commit85de662ae23f029371b340d7ba1e04dbcd10bcc7 (patch)
tree92337db070db7b1d435190071b59c69d7bbdd376 /tools
parent[serversetup-bwlp-ipxe] Use badge for refcount in bootentry table (diff)
downloadslx-admin-85de662ae23f029371b340d7ba1e04dbcd10bcc7.tar.gz
slx-admin-85de662ae23f029371b340d7ba1e04dbcd10bcc7.tar.xz
slx-admin-85de662ae23f029371b340d7ba1e04dbcd10bcc7.zip
[statistics] Show RAM manufacturer; add JEDEC DB & parser
Diffstat (limited to 'tools')
-rw-r--r--tools/jedec.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/jedec.php b/tools/jedec.php
new file mode 100644
index 00000000..a4df9667
--- /dev/null
+++ b/tools/jedec.php
@@ -0,0 +1,35 @@
+<?php
+
+/*
+ * Very cheap script to convert the jedec database from a text dump of the
+ * official PDF to json. The regex abomination below has been kicked until
+ * it worked on the version that was current as of April 2019. YMMV.
+ * For input, download the PDF from https://www.jedec.org/system/files/docs/JEP106AY.pdf
+ * and then copy/paste the contents into a plain text file called 'jedec'
+ * (And pray it doesn't break if you don't use exactly the same PDF viewer and
+ * text editor as I did - pdf.js and vim)
+ */
+
+$last = 0;
+$index = 1;
+$line = file_get_contents('jedec');
+preg_match_all("/^\s*([1-9][0-9]?|1[01][0-9]|12[0-6])\s+([^\r\n]{2,9}(?:[a-z][^\r\n]{0,10}){1,3}[\r\n]?[^\r\n0]{0,31})(?:\s*[\r\n]\s|\s+)((?:[10]\s+){8})([0-9a-f]{2})\s*\$/sim", $line, $oout, PREG_SET_ORDER);
+$output = [];
+foreach ($oout as $out) {
+ $id = (int)$out[1];
+ $name = preg_replace("/[\s\r\n]+/ms", ' ', $out[2]);
+ $bin = $out[3];
+ $hex = $out[4];
+ if ($id < $last) {
+ $index++;
+ echo "Now at bank $index\n";
+ } elseif ($id > $last + 1) {
+ echo "Skipped from $last to $id (THIS SHOULD NEVER HAPPEN)\n";
+ }
+ //echo "$id = $name ($bin) ($hex)\n";
+ $last = $id;
+ $output['bank' . $index]['id' . $id] = $name;
+}
+
+file_put_contents('jedec.json', json_encode($output));
+