|
|
@@ -0,0 +1,929 @@
|
|
|
+/*
|
|
|
+ * XJKJ-STL Deterministic re2c Line Lexer & Coordinate Extractor (v0.8.1.18)
|
|
|
+ *
|
|
|
+ * Compiled via: re2c -W --no-generation-date -o parser_re2c.c parser_re2c.re
|
|
|
+ * Pure C11 / x86-64 SSE2 baseline; zero heap allocations; replaces per-line
|
|
|
+ * repeated .contains() scans with a deterministic finite automaton (DFA).
|
|
|
+ *
|
|
|
+ * Verified 1:1 against both real server firmwares:
|
|
|
+ * - .166: 107_VD012 / [Hovsee] / [HS_*] / [0][AMT #] GNR-4.3.3 (24 algos)
|
|
|
+ * - .165: [CxmtDdrTest] / [HD_*] / [0][AMEMDIAG #] GNR-4.3.0 (19 algos)
|
|
|
+ * - 118.efi / PassMark MemTest86 Site / UEFI Shell / PXE
|
|
|
+ */
|
|
|
+
|
|
|
+#include "stl_accel.h"
|
|
|
+#include <string.h>
|
|
|
+
|
|
|
+static inline uint8_t ascii_lower(uint8_t c) {
|
|
|
+ return (c >= 'A' && c <= 'Z') ? (uint8_t)(c + 32) : c;
|
|
|
+}
|
|
|
+
|
|
|
+static int parse_i32_at(const uint8_t *p, const uint8_t *end, int32_t *out, const uint8_t **after) {
|
|
|
+ while (p < end && (*p == ' ' || *p == '\t' || *p == ':' || *p == '=' || *p == '#')) {
|
|
|
+ p++;
|
|
|
+ }
|
|
|
+ if (p >= end) return 0;
|
|
|
+ int neg = 0;
|
|
|
+ if (*p == '-') { neg = 1; p++; }
|
|
|
+ else if (*p == '+') { p++; }
|
|
|
+ if (p >= end || *p < '0' || *p > '9') return 0;
|
|
|
+ int64_t v = 0;
|
|
|
+ while (p < end && *p >= '0' && *p <= '9') {
|
|
|
+ v = v * 10 + (*p - '0');
|
|
|
+ if (v > 0x7fffffffLL) v = 0x7fffffffLL;
|
|
|
+ p++;
|
|
|
+ }
|
|
|
+ *out = neg ? (int32_t)(-v) : (int32_t)v;
|
|
|
+ if (after) *after = p;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+static int parse_hex64_at(const uint8_t *p, const uint8_t *end, uint64_t *out) {
|
|
|
+ while (p < end && (*p == ' ' || *p == '\t' || *p == ':' || *p == '=')) p++;
|
|
|
+ if (p + 2 <= end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) p += 2;
|
|
|
+ if (p >= end) return 0;
|
|
|
+ uint64_t v = 0;
|
|
|
+ int digits = 0;
|
|
|
+ while (p < end) {
|
|
|
+ uint8_t c = *p;
|
|
|
+ uint8_t d;
|
|
|
+ if (c >= '0' && c <= '9') d = (uint8_t)(c - '0');
|
|
|
+ else if (c >= 'a' && c <= 'f') d = (uint8_t)(c - 'a' + 10);
|
|
|
+ else if (c >= 'A' && c <= 'F') d = (uint8_t)(c - 'A' + 10);
|
|
|
+ else break;
|
|
|
+ v = (v << 4) | d;
|
|
|
+ digits++;
|
|
|
+ p++;
|
|
|
+ }
|
|
|
+ if (digits == 0) return 0;
|
|
|
+ *out = v;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+/* Extract leading [<cpu>] prefix common on Hovsee/CxmtDdrTest/AMT lines */
|
|
|
+static void extract_leading_bracket_cpu(const uint8_t *s, const uint8_t *end, StlRe2cEvent *ev) {
|
|
|
+ const uint8_t *p = s;
|
|
|
+ while (p < end && (*p == '.' || *p == ' ' || *p == '\t')) p++;
|
|
|
+ if (p + 3 <= end && p[0] == '[' && (p[1] == '0' || p[1] == '1') && p[2] == ']') {
|
|
|
+ ev->cpu = (int8_t)(p[1] - '0');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/* Extract N<cpu>.C<ch>[.D<dimm>][.SC<sub>][.R<rank>] topology token & RMT margins */
|
|
|
+static int extract_ncd_token(const uint8_t *s, const uint8_t *end, StlRe2cEvent *ev) {
|
|
|
+ for (const uint8_t *p = s; p + 5 <= end; p++) {
|
|
|
+ if ((p[0] == 'N' || p[0] == 'n') &&
|
|
|
+ (p[1] >= '0' && p[1] <= '3') && p[2] == '.' &&
|
|
|
+ (p[3] == 'C' || p[3] == 'c') && (p[4] >= '0' && p[4] <= '9')) {
|
|
|
+ int cpu = p[1] - '0';
|
|
|
+ const uint8_t *q = p + 4;
|
|
|
+ int ch = 0;
|
|
|
+ while (q < end && *q >= '0' && *q <= '9') {
|
|
|
+ ch = ch * 10 + (*q - '0');
|
|
|
+ q++;
|
|
|
+ }
|
|
|
+ if (cpu >= 0 && cpu <= 1 && ch >= 0 && ch <= 11) {
|
|
|
+ ev->cpu = (int8_t)cpu;
|
|
|
+ ev->channel = (int8_t)ch;
|
|
|
+ while (q + 2 <= end && *q == '.') {
|
|
|
+ if (q + 3 <= end && (q[1] == 'D' || q[1] == 'd') && q[2] >= '0' && q[2] <= '1') {
|
|
|
+ ev->dimm = (int8_t)(q[2] - '0');
|
|
|
+ q += 3;
|
|
|
+ } else if (q + 4 <= end && (q[1] == 'S' || q[1] == 's') &&
|
|
|
+ (q[2] == 'C' || q[2] == 'c') && q[3] >= '0' && q[3] <= '1') {
|
|
|
+ q += 4;
|
|
|
+ } else if (q + 3 <= end && (q[1] == 'R' || q[1] == 'r') && q[2] >= '0' && q[2] <= '9') {
|
|
|
+ ev->rank = (int8_t)((q[2] - '0') & 3);
|
|
|
+ q += 3;
|
|
|
+ while (q < end && *q >= '0' && *q <= '9') q++;
|
|
|
+ } else if (q + 3 <= end && (q[1] == 'L' || q[1] == 'l') && q[2] >= '0' && q[2] <= '9') {
|
|
|
+ q += 3;
|
|
|
+ while (q < end && *q >= '0' && *q <= '9') q++;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (q < end && *q == ':') {
|
|
|
+ q++;
|
|
|
+ int32_t vals[4] = {0, 0, 0, 0};
|
|
|
+ int got = 0;
|
|
|
+ const uint8_t *nx = q;
|
|
|
+ while (nx < end && got < 4) {
|
|
|
+ while (nx < end && (*nx == ' ' || *nx == '\t')) nx++;
|
|
|
+ if (nx < end && *nx == '*') {
|
|
|
+ vals[got++] = 0;
|
|
|
+ nx++;
|
|
|
+ } else {
|
|
|
+ int32_t mv = 0;
|
|
|
+ if (parse_i32_at(nx, end, &mv, &nx)) {
|
|
|
+ vals[got++] = mv;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (got >= 4) {
|
|
|
+ ev->val0 = vals[0];
|
|
|
+ ev->val1 = vals[1];
|
|
|
+ ev->val2 = vals[2];
|
|
|
+ ev->val3 = vals[3];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int match_ci_kw(const uint8_t *p, const uint8_t *end, const char *kw, const uint8_t **after) {
|
|
|
+ size_t klen = strlen(kw);
|
|
|
+ if ((size_t)(end - p) < klen) return 0;
|
|
|
+ for (size_t i = 0; i < klen; i++) {
|
|
|
+ if (ascii_lower(p[i]) != (uint8_t)kw[i]) return 0;
|
|
|
+ }
|
|
|
+ const uint8_t *q = p + klen;
|
|
|
+ if (q < end && ((*q >= 'a' && *q <= 'z') || (*q >= 'A' && *q <= 'Z') || *q == '_')) return 0;
|
|
|
+ *after = q;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * Extract physical topology coordinates from BIOS/Training/AMT/MemTest86 lines.
|
|
|
+ * Strictly enforces 0 <= bank < 32 (never trusts broken historical >= 32 bank analyses).
|
|
|
+ */
|
|
|
+static void extract_coords_and_addr(const uint8_t *s, const uint8_t *end, StlRe2cEvent *ev) {
|
|
|
+ extract_leading_bracket_cpu(s, end, ev);
|
|
|
+ extract_ncd_token(s, end, ev);
|
|
|
+
|
|
|
+ /* Check MemTest86 "(P0,C3,S0,R0)" or "Channel/Slot: N0-3-0" or "(Chan,Slot,Rank,Bank,Row,Col): (3,0,0,12,...)" */
|
|
|
+ for (const uint8_t *p = s; p + 6 <= end; p++) {
|
|
|
+ if ((p[0] == 'N' || p[0] == 'n') && (p[1] == '0' || p[1] == '1') &&
|
|
|
+ p[2] == '-' && p[3] >= '0' && p[3] <= '9') {
|
|
|
+ int32_t ch = -1, sl = -1;
|
|
|
+ const uint8_t *nx = p + 3;
|
|
|
+ if (parse_i32_at(nx, end, &ch, &nx) && ch >= 0 && ch <= 11) {
|
|
|
+ ev->cpu = (int8_t)(p[1] - '0');
|
|
|
+ ev->channel = (int8_t)ch;
|
|
|
+ if (nx < end && *nx == '-') {
|
|
|
+ if (parse_i32_at(nx + 1, end, &sl, &nx) && sl >= 0 && sl <= 1) {
|
|
|
+ ev->dimm = (int8_t)sl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (p + 8 > end) continue;
|
|
|
+ if (p[0] == '(' && (p[1] == 'P' || p[1] == 'p') && (p[2] == '0' || p[2] == '1') &&
|
|
|
+ p[3] == ',' && (p[4] == 'C' || p[4] == 'c')) {
|
|
|
+ int32_t ch = -1, sl = -1;
|
|
|
+ const uint8_t *nx = p + 5;
|
|
|
+ if (parse_i32_at(nx, end, &ch, &nx) && ch >= 0 && ch <= 11) {
|
|
|
+ ev->cpu = (int8_t)(p[2] - '0');
|
|
|
+ ev->channel = (int8_t)ch;
|
|
|
+ if (nx + 2 < end && nx[0] == ',' && (nx[1] == 'S' || nx[1] == 's')) {
|
|
|
+ if (parse_i32_at(nx + 2, end, &sl, &nx) && sl >= 0 && sl <= 1) {
|
|
|
+ ev->dimm = (int8_t)sl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (p + 25 <= end && memcmp(p, "(Chan,Slot,Rank,Bank,Row,", 25) == 0) {
|
|
|
+ const uint8_t *lp = memchr(p + 25, '(', (size_t)(end - (p + 25)));
|
|
|
+ if (lp) {
|
|
|
+ int32_t c_ch = -1, c_sl = -1, c_rk = -1, c_bk = -1;
|
|
|
+ const uint8_t *nx = lp + 1;
|
|
|
+ if (parse_i32_at(nx, end, &c_ch, &nx) && nx < end && *nx == ',' &&
|
|
|
+ parse_i32_at(nx + 1, end, &c_sl, &nx) && nx < end && *nx == ',' &&
|
|
|
+ parse_i32_at(nx + 1, end, &c_rk, &nx) && nx < end && *nx == ',' &&
|
|
|
+ parse_i32_at(nx + 1, end, &c_bk, &nx)) {
|
|
|
+ if (c_ch >= 0 && c_ch <= 11) ev->channel = (int8_t)c_ch;
|
|
|
+ if (c_sl >= 0 && c_sl <= 1) ev->dimm = (int8_t)c_sl;
|
|
|
+ if (c_rk >= 0 && c_rk <= 3) ev->rank = (int8_t)c_rk;
|
|
|
+ if (c_bk >= 0 && c_bk < 32) ev->bank = (int8_t)c_bk;
|
|
|
+ ev->subkind = 5; /* 2nd-line MT ECC coordinate continuation */
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int bg = -1;
|
|
|
+ int ba = -1;
|
|
|
+ int direct_bank = -1;
|
|
|
+
|
|
|
+ for (const uint8_t *p = s; p < end; p++) {
|
|
|
+ if (p > s) {
|
|
|
+ uint8_t prev = p[-1];
|
|
|
+ if ((prev >= 'a' && prev <= 'z') || (prev >= 'A' && prev <= 'Z') ||
|
|
|
+ (prev >= '0' && prev <= '9') || prev == '_') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const uint8_t *after = NULL;
|
|
|
+ int32_t v = 0;
|
|
|
+ if (match_ci_kw(p, end, "socket", &after) || match_ci_kw(p, end, "scktid", &after) ||
|
|
|
+ match_ci_kw(p, end, "node", &after) || match_ci_kw(p, end, "cpu", &after)) {
|
|
|
+ if (parse_i32_at(after, end, &v, NULL) && v >= 0 && v <= 1 && ev->cpu < 0) {
|
|
|
+ ev->cpu = (int8_t)v;
|
|
|
+ }
|
|
|
+ } else if (match_ci_kw(p, end, "channel", &after) || match_ci_kw(p, end, "ch", &after) ||
|
|
|
+ match_ci_kw(p, end, "chan", &after)) {
|
|
|
+ if (parse_i32_at(after, end, &v, NULL) && v >= 0 && v <= 23) {
|
|
|
+ if (v >= 12 && ev->cpu < 0) {
|
|
|
+ ev->cpu = 1;
|
|
|
+ ev->channel = (int8_t)(v - 12);
|
|
|
+ } else if (v <= 11) {
|
|
|
+ ev->channel = (int8_t)v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (match_ci_kw(p, end, "dimm", &after) || match_ci_kw(p, end, "slot", &after)) {
|
|
|
+ if (parse_i32_at(after, end, &v, NULL) && v >= 0 && v <= 23) {
|
|
|
+ if (v <= 1) {
|
|
|
+ ev->dimm = (int8_t)v;
|
|
|
+ } else if (ev->channel < 0) {
|
|
|
+ ev->cpu = (int8_t)(v / 12);
|
|
|
+ ev->channel = (int8_t)(v % 12);
|
|
|
+ ev->dimm = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (match_ci_kw(p, end, "rank", &after)) {
|
|
|
+ if (parse_i32_at(after, end, &v, NULL) && v >= 0 && v <= 3) {
|
|
|
+ ev->rank = (int8_t)v;
|
|
|
+ }
|
|
|
+ } else if (match_ci_kw(p, end, "bankgroup", &after) || match_ci_kw(p, end, "bg", &after)) {
|
|
|
+ if (parse_i32_at(after, end, &v, NULL) && v >= 0 && v <= 7) {
|
|
|
+ bg = (int)v;
|
|
|
+ }
|
|
|
+ } else if (match_ci_kw(p, end, "bank", &after) || match_ci_kw(p, end, "ba", &after)) {
|
|
|
+ if (parse_i32_at(after, end, &v, NULL)) {
|
|
|
+ if (ascii_lower(p[1]) == 'a' && v >= 0 && v <= 3) {
|
|
|
+ ba = (int)v;
|
|
|
+ } else if (v >= 0 && v < 32) {
|
|
|
+ direct_bank = (int)v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (match_ci_kw(p, end, "addr", &after) || match_ci_kw(p, end, "address", &after) ||
|
|
|
+ match_ci_kw(p, end, "checkpoint", &after)) {
|
|
|
+ uint64_t a = 0;
|
|
|
+ if (parse_hex64_at(after, end, &a)) {
|
|
|
+ ev->addr = a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (bg >= 0 && ba >= 0) {
|
|
|
+ int combined = bg * 4 + ba;
|
|
|
+ if (combined >= 0 && combined < 32) ev->bank = (int8_t)combined;
|
|
|
+ } else if (direct_bank >= 0 && direct_bank < 32 && ev->bank < 0) {
|
|
|
+ ev->bank = (int8_t)direct_bank;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void trim_ws(const uint8_t **ps, const uint8_t **pe) {
|
|
|
+ const uint8_t *s = *ps;
|
|
|
+ const uint8_t *e = *pe;
|
|
|
+ while (s < e && (*s == ' ' || *s == '\t')) s++;
|
|
|
+ while (e > s && (e[-1] == ' ' || e[-1] == '\t' || e[-1] == '\r' || e[-1] == '\n')) e--;
|
|
|
+ *ps = s;
|
|
|
+ *pe = e;
|
|
|
+}
|
|
|
+
|
|
|
+/*!re2c
|
|
|
+ re2c:define:YYCTYPE = uint8_t;
|
|
|
+ re2c:yyfill:enable = 0;
|
|
|
+ re2c:flags:tags = 0;
|
|
|
+ re2c:flags:case-insensitive = 0;
|
|
|
+
|
|
|
+ WS = [ \t]*;
|
|
|
+ ANY = [\x00-\xff];
|
|
|
+ DIG = [0-9]+;
|
|
|
+*/
|
|
|
+
|
|
|
+static uint32_t re2c_scan_token(const uint8_t *s, const uint8_t *end, StlRe2cEvent *ev) {
|
|
|
+ uint8_t buf[520];
|
|
|
+ size_t n = (size_t)(end - s);
|
|
|
+ if (n > 512) n = 512;
|
|
|
+ memcpy(buf, s, n);
|
|
|
+ buf[n] = 0;
|
|
|
+
|
|
|
+ extract_leading_bracket_cpu(buf, buf + n, ev);
|
|
|
+
|
|
|
+ const uint8_t *YYCURSOR = buf;
|
|
|
+ const uint8_t *YYMARKER = buf;
|
|
|
+ const uint8_t *lim = buf + n;
|
|
|
+
|
|
|
+ /* Step 1: Anchored prompt & full-line patterns */
|
|
|
+ /*!re2c
|
|
|
+ WS "UIP>" WS "\x00" {
|
|
|
+ return STL_LK_ICT_PROMPT;
|
|
|
+ }
|
|
|
+ WS "[" [01] "][" ("Hovsee" | "CxmtDdrTest") "]Please input your command" ":"? WS "\x00" {
|
|
|
+ ev->cpu = (int8_t)(buf[1] == '1' ? 1 : 0);
|
|
|
+ for (size_t i = 0; i + 6 <= n; i++) {
|
|
|
+ if (memcmp(buf + i, "Hovsee", 6) == 0) { ev->fw_family = 1; break; }
|
|
|
+ if (i + 11 <= n && memcmp(buf + i, "CxmtDdrTest", 11) == 0) { ev->fw_family = 2; break; }
|
|
|
+ }
|
|
|
+ return STL_LK_ICT_PROMPT;
|
|
|
+ }
|
|
|
+ WS (("[" [01] "]" WS) | ("CPU" [01] WS ":"? WS))? "[" ("CPU" [01] WS)? ("AMT" | "AMEMDIAG") WS "#" WS "]" WS "\x00" {
|
|
|
+ for (size_t i = 0; i + 3 <= n; i++) {
|
|
|
+ if (buf[i] == '[' && (buf[i+1] == '0' || buf[i+1] == '1') && buf[i+2] == ']') {
|
|
|
+ ev->cpu = (int8_t)(buf[i+1] - '0');
|
|
|
+ }
|
|
|
+ if (i + 4 <= n && buf[i] == 'C' && buf[i+1] == 'P' && buf[i+2] == 'U' && (buf[i+3] == '0' || buf[i+3] == '1')) {
|
|
|
+ ev->cpu = (int8_t)(buf[i+3] - '0');
|
|
|
+ }
|
|
|
+ if (i + 8 <= n && memcmp(buf + i, "AMEMDIAG", 8) == 0) ev->fw_family = 2;
|
|
|
+ else if (memcmp(buf + i, "AMT", 3) == 0 && ev->fw_family == 0) ev->fw_family = 1;
|
|
|
+ }
|
|
|
+ return STL_LK_AMT_PROMPT;
|
|
|
+ }
|
|
|
+ WS "FS" [0-9] ":\\" ("EFI" | "efi") ("\\" [^\x00\r\n<>]*)? ">" WS "\x00" |
|
|
|
+ WS "FS" [0-9] ":\\" ("EFI" | "efi") ">" WS "\x00" {
|
|
|
+ for (size_t i = 0; i + 2 < n; i++) {
|
|
|
+ if (buf[i] == 'F' && buf[i+1] == 'S' && buf[i+2] >= '0' && buf[i+2] <= '9') {
|
|
|
+ ev->fs_index = (uint8_t)(buf[i+2] - '0');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_UEFI_PROMPT_EFI;
|
|
|
+ }
|
|
|
+ WS "FS" [0-9] ":" "\\"? ">" WS "\x00" {
|
|
|
+ for (size_t i = 0; i + 2 < n; i++) {
|
|
|
+ if (buf[i] == 'F' && buf[i+1] == 'S' && buf[i+2] >= '0' && buf[i+2] <= '9') {
|
|
|
+ ev->fs_index = (uint8_t)(buf[i+2] - '0');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_UEFI_PROMPT_ROOT;
|
|
|
+ }
|
|
|
+ WS "Shell>" WS "\x00" {
|
|
|
+ ev->fs_index = 255;
|
|
|
+ return STL_LK_UEFI_PROMPT_ROOT;
|
|
|
+ }
|
|
|
+ * { goto scan_anywhere; }
|
|
|
+ */
|
|
|
+
|
|
|
+scan_anywhere:
|
|
|
+ YYCURSOR = buf;
|
|
|
+ while (YYCURSOR < lim) {
|
|
|
+ const uint8_t *tok = YYCURSOR;
|
|
|
+ /*!re2c
|
|
|
+ "[SYS_BIOS]Version:" {
|
|
|
+ return STL_LK_BIOS_BOOT;
|
|
|
+ }
|
|
|
+ "Welcome to Hovsee" | "Hovsee inc. IMC Config Tool" {
|
|
|
+ ev->fw_family = 1;
|
|
|
+ return STL_LK_ICT_BANNER_HOVSEE;
|
|
|
+ }
|
|
|
+ "Welcome to CxmtDdrTest" | "CxmtDdrTest IMC Config Tool" {
|
|
|
+ ev->fw_family = 2;
|
|
|
+ return STL_LK_ICT_BANNER_CXMT;
|
|
|
+ }
|
|
|
+ "[" ("Hovsee" | "CxmtDdrTest") "]Current stage is" WS "1" {
|
|
|
+ ev->fw_family = (tok[1] == 'H') ? 1 : 2;
|
|
|
+ return STL_LK_ICT_START_STAGE1;
|
|
|
+ }
|
|
|
+ "[" ("Hovsee" | "CxmtDdrTest") "]Current stage is" WS "2" {
|
|
|
+ ev->fw_family = (tok[1] == 'H') ? 1 : 2;
|
|
|
+ return STL_LK_ICT_START_STAGE2;
|
|
|
+ }
|
|
|
+ "[Hovsee]Stage2 UIP" {
|
|
|
+ ev->fw_family = 1;
|
|
|
+ return STL_LK_ICT_START_STAGE2;
|
|
|
+ }
|
|
|
+ "[CxmtDdrTest]Stage2 UIP" {
|
|
|
+ ev->fw_family = 2;
|
|
|
+ return STL_LK_ICT_START_STAGE2;
|
|
|
+ }
|
|
|
+ "[Hovsee]Start UIP" {
|
|
|
+ ev->fw_family = 1;
|
|
|
+ return STL_LK_ICT_START_STAGE1;
|
|
|
+ }
|
|
|
+ "[CxmtDdrTest]Start UIP" {
|
|
|
+ ev->fw_family = 2;
|
|
|
+ return STL_LK_ICT_START_STAGE1;
|
|
|
+ }
|
|
|
+ "Please press ENTER to start UIP" {
|
|
|
+ return STL_LK_ICT_ENTER_HINT;
|
|
|
+ }
|
|
|
+ "[" ("Hovsee" | "CxmtDdrTest") "]Please input your command" {
|
|
|
+ ev->fw_family = (tok[1] == 'H') ? 1 : 2;
|
|
|
+ /* Only prompt if no trailing user command echo on same line */
|
|
|
+ const uint8_t *colon = memchr(YYCURSOR, ':', (size_t)(lim - YYCURSOR));
|
|
|
+ if (!colon || colon + 1 >= lim) return STL_LK_ICT_PROMPT;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ "[Hovsee]Exit UIP" | "[CxmtDdrTest]Exit UIP" |
|
|
|
+ "[Hovsee]Exit Hovsee UIP" | "[CxmtDdrTest]Exit CxmtDdrTest UIP" |
|
|
|
+ "[Hovsee]Exit ICT ddr test" | "[CxmtDdrTest]Exit ICT ddr test" |
|
|
|
+ "No command input or timeout, so go on training" |
|
|
|
+ "User input command is exit" {
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H') ev->fw_family = 1;
|
|
|
+ if (tok[0] == '[' && tok[1] == 'C') ev->fw_family = 2;
|
|
|
+ return STL_LK_ICT_EXIT;
|
|
|
+ }
|
|
|
+ "is not recognized as an internal or external command" {
|
|
|
+ ev->subkind = 3; /* UEFI shell missing binary error */
|
|
|
+ return STL_LK_MT_FAIL_COMPLETE;
|
|
|
+ }
|
|
|
+ "AdvancedMemTestWorker" | "GNR AP Gpio" | "SetVMGpioMemTest" | "DdrMemTest()" {
|
|
|
+ for (const uint8_t *p = buf; p + 6 <= lim; p++) {
|
|
|
+ if (memcmp(p, "Hovsee", 6) == 0) { ev->fw_family = 1; break; }
|
|
|
+ if (p + 11 <= lim && memcmp(p, "CxmtDdrTest", 11) == 0) { ev->fw_family = 2; break; }
|
|
|
+ }
|
|
|
+ return STL_LK_NONE;
|
|
|
+ }
|
|
|
+ "[HS_MRC]" | "[HD_MRC]" |
|
|
|
+ "[HS_StartMemTrain]" | "[HD_StartMemTrain]" |
|
|
|
+ "[Hovsee]Socket " [01] " RcdQcaTraining" {
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'S') ev->fw_family = 1;
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'D') ev->fw_family = 2;
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'o') ev->fw_family = 1;
|
|
|
+ return STL_LK_MRC_START;
|
|
|
+ }
|
|
|
+ "STOP_MRC_RUN" | "MRC Done" | "Memory Training Complete" |
|
|
|
+ "[HS_EndMemTrain]" | "[HD_EndMemTrain]" {
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'S') ev->fw_family = 1;
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'D') ev->fw_family = 2;
|
|
|
+ return STL_LK_MRC_DONE;
|
|
|
+ }
|
|
|
+ "0x4F : DXE IPL Start" | "0x60 : DXE Core Started" |
|
|
|
+ "0x90 : BDS Started" | "0x91 : Connecting Drivers" {
|
|
|
+ ev->subkind = 4; /* POST / DXE milestone */
|
|
|
+ return STL_LK_MRC_DONE;
|
|
|
+ }
|
|
|
+ ("AMT" | "AMEMDIAG") WS "Test Start" {
|
|
|
+ ev->fw_family = (tok[0] == 'A' && tok[1] == 'M' && tok[2] == 'E') ? 2 : 1;
|
|
|
+ ev->subkind = 3; /* AMT start */
|
|
|
+ return STL_LK_AMT_PROGRESS;
|
|
|
+ }
|
|
|
+ "[BIOS][Training][ScktId:" WS [01] "]" {
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ /* Check if Rank Margin Tool or MemTest or FAILED */
|
|
|
+ for (const uint8_t *p = YYCURSOR; p + 6 <= lim; p++) {
|
|
|
+ if (p + 16 <= lim && memcmp(p, "Rank Margin Tool", 16) == 0) {
|
|
|
+ return STL_LK_RMT_STOP;
|
|
|
+ }
|
|
|
+ if (memcmp(p, "FAILED", 6) == 0) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ return STL_LK_TRAINING_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_MRC_START;
|
|
|
+ }
|
|
|
+ "START_RMT_N" [01] {
|
|
|
+ ev->cpu = (int8_t)(tok[11] - '0');
|
|
|
+ return STL_LK_RMT_START;
|
|
|
+ }
|
|
|
+ "START_RMT" | "Starting RMT test v" | "Rank Margin Tool -- Started" |
|
|
|
+ "[HS_StartRmt]" | "[HD_StartRmt]" {
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'S') ev->fw_family = 1;
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'D') ev->fw_family = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_RMT_START;
|
|
|
+ }
|
|
|
+ "STOP_RMT_N" [01] {
|
|
|
+ ev->cpu = (int8_t)(tok[10] - '0');
|
|
|
+ return STL_LK_RMT_STOP;
|
|
|
+ }
|
|
|
+ "STOP_RMT" | "[HS_StopRmt]" | "[HD_StopRmt]" | "RMT test v" {
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'S') {
|
|
|
+ ev->fw_family = 1;
|
|
|
+ return STL_LK_RMT_STOP;
|
|
|
+ }
|
|
|
+ if (tok[0] == '[' && tok[1] == 'H' && tok[2] == 'D') {
|
|
|
+ ev->fw_family = 2;
|
|
|
+ return STL_LK_RMT_STOP;
|
|
|
+ }
|
|
|
+ for (const uint8_t *p = tok; p + 8 <= lim; p++) {
|
|
|
+ if (memcmp(p, "complete", 8) == 0) {
|
|
|
+ return STL_LK_RMT_STOP;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tok[0] == 'S') return STL_LK_RMT_STOP;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ "[" ("HS" | "HD") "_" ("RMTSensor" | "Sensor") "]" {
|
|
|
+ ev->fw_family = (tok[2] == 'S') ? 1 : 2;
|
|
|
+ extract_ncd_token(s, end, ev);
|
|
|
+ const uint8_t *cl = memchr(YYCURSOR, ':', (size_t)(lim - YYCURSOR));
|
|
|
+ if (cl) {
|
|
|
+ int32_t deg = 0;
|
|
|
+ const uint8_t *nx = NULL;
|
|
|
+ if (parse_i32_at(cl + 1, lim, °, &nx)) {
|
|
|
+ int32_t tenths = 0;
|
|
|
+ if (nx && nx + 1 < lim && *nx == '.' && nx[1] >= '0' && nx[1] <= '9') {
|
|
|
+ tenths = nx[1] - '0';
|
|
|
+ }
|
|
|
+ ev->val3 = deg * 10 + (deg >= 0 ? tenths : -tenths);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_INLINE_TEMP;
|
|
|
+ }
|
|
|
+ "[" ("HS" | "HD") "_DRAM]" {
|
|
|
+ ev->fw_family = (tok[2] == 'S') ? 1 : 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ /* Check Size:0 -> absent, else present */
|
|
|
+ ev->subkind = 4;
|
|
|
+ for (const uint8_t *p = YYCURSOR; p + 5 <= lim; p++) {
|
|
|
+ if (memcmp(p, "Size:", 5) == 0) {
|
|
|
+ int32_t sz = 0;
|
|
|
+ if (parse_i32_at(p + 5, lim, &sz, NULL)) {
|
|
|
+ ev->subkind = (sz > 0) ? 4 : 0;
|
|
|
+ ev->val0 = sz;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_DIMM_INVENTORY;
|
|
|
+ }
|
|
|
+ "[" ("HS" | "HD") "_DisableDimm]" | "DisableDIMM()" | "MapOutDimm()" | "Mapping out DDR" {
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ ev->subkind = 3; /* disabled */
|
|
|
+ return STL_LK_DIMM_INVENTORY;
|
|
|
+ }
|
|
|
+ "AMT Version " | "Welcome to Advanced Memory Test" | "GNR-4.3.3" {
|
|
|
+ ev->fw_family = 1;
|
|
|
+ return STL_LK_AMT_BANNER;
|
|
|
+ }
|
|
|
+ "AMEMDIAG Version " | "Welcome to Advanced Memory Diagnostic" | "GNR-4.3.0" {
|
|
|
+ ev->fw_family = 2;
|
|
|
+ return STL_LK_AMT_BANNER;
|
|
|
+ }
|
|
|
+ ("AMT" | "AMEMDIAG") WS "Test Algo Count:" {
|
|
|
+ int32_t cnt = 0;
|
|
|
+ if (parse_i32_at(YYCURSOR, lim, &cnt, NULL)) {
|
|
|
+ ev->val1 = cnt; /* algorithm count */
|
|
|
+ }
|
|
|
+ ev->subkind = 0;
|
|
|
+ return STL_LK_AMT_SUMMARY;
|
|
|
+ }
|
|
|
+ ("AMT" | "AMEMDIAG") WS "Test Result Summary:" |
|
|
|
+ ("AMT" | "AMEMDIAG") WS "Test Result:" |
|
|
|
+ "AMT Test PASS" | "AMEMDIAG Test PASS" | "All Test PASS" |
|
|
|
+ "AMT Test FAIL" | "AMEMDIAG Test FAIL" | "All Test FAIL" {
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ /* Determine scope: summary vs per-socket */
|
|
|
+ for (const uint8_t *p = tok; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "summary", &af)) {
|
|
|
+ ev->val2 = 1; /* scope = summary */
|
|
|
+ }
|
|
|
+ if (match_ci_kw(p, lim, "fail", &af) || match_ci_kw(p, lim, "block", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ } else if (match_ci_kw(p, lim, "pass", &af) && ev->subkind != 2) {
|
|
|
+ ev->subkind = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_AMT_SUMMARY;
|
|
|
+ }
|
|
|
+ "Total Error Count" {
|
|
|
+ int32_t cnt = 0;
|
|
|
+ if (parse_i32_at(YYCURSOR, lim, &cnt, NULL)) {
|
|
|
+ ev->val0 = cnt;
|
|
|
+ ev->subkind = (cnt > 0) ? 2 : 1;
|
|
|
+ }
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_AMT_SUMMARY;
|
|
|
+ }
|
|
|
+ "[" ("AMT" | "AMEMDIAG") WS DIG "/" DIG WS DIG "/" DIG WS DIG "/" DIG "]" {
|
|
|
+ /* e.g. [0][AMT 1/1 1/1 3/24] Algo ... */
|
|
|
+ ev->fw_family = (tok[1] == 'A' && tok[2] == 'M' && tok[3] == 'E') ? 2 : 1;
|
|
|
+ const uint8_t *p = tok + 4;
|
|
|
+ while (p < YYCURSOR && (*p < '0' || *p > '9')) p++;
|
|
|
+ int32_t r1=0, r2=0, p1=0, p2=0, a1=0, a2=0;
|
|
|
+ if (parse_i32_at(p, YYCURSOR, &r1, &p) && p < YYCURSOR && *p == '/' &&
|
|
|
+ parse_i32_at(p+1, YYCURSOR, &r2, &p) &&
|
|
|
+ parse_i32_at(p, YYCURSOR, &p1, &p) && p < YYCURSOR && *p == '/' &&
|
|
|
+ parse_i32_at(p+1, YYCURSOR, &p2, &p) &&
|
|
|
+ parse_i32_at(p, YYCURSOR, &a1, &p) && p < YYCURSOR && *p == '/' &&
|
|
|
+ parse_i32_at(p+1, YYCURSOR, &a2, &p)) {
|
|
|
+ ev->val0 = a1; /* algorithm_index */
|
|
|
+ ev->val1 = a2; /* algorithm_count */
|
|
|
+ if (a2 > 0) ev->val2 = (a1 * 100) / a2;
|
|
|
+ }
|
|
|
+ return STL_LK_AMT_PROGRESS;
|
|
|
+ }
|
|
|
+ "Failure detected - Advanced Memtest" | "Error Address" | "Fail Address" |
|
|
|
+ "Data Compare Error" | "[AMT_ERR]" | "[AMEMDIAG_ERR]" |
|
|
|
+ "[" ("HS" | "HD") "_MemoryError]" {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_AMT_ERROR;
|
|
|
+ }
|
|
|
+ "Logical Rank" WS "=" | "Error on rising strobe:" | "Error on falling strobe:" {
|
|
|
+ ev->subkind = 5; /* 3-line AMT diagnostic continuation */
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_AMT_ERROR;
|
|
|
+ }
|
|
|
+ "Failing DIMM" | "[BIOS][FailMode]" |
|
|
|
+ "Training Fail" | "BIST Error" | "BIST FAIL" | "Uncorrectable" |
|
|
|
+ "Correctable error threshold exceeded" {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_TRAINING_ERROR;
|
|
|
+ }
|
|
|
+ "UEFI Interactive Shell" {
|
|
|
+ return STL_LK_UEFI_BANNER;
|
|
|
+ }
|
|
|
+ "Start PXE over IPv4" | "Downloading NBP file" | "NBP filename is" {
|
|
|
+ return STL_LK_PXE_BOOT;
|
|
|
+ }
|
|
|
+ "PassMark MemTest86" | "MemTest86 V" | "MemTest86 v" |
|
|
|
+ "Found configuration file:" | "*** TEST SESSION -" | "Launching 118.efi" |
|
|
|
+ "STL_SIM TEST_START MT" {
|
|
|
+ return STL_LK_MT_BANNER;
|
|
|
+ }
|
|
|
+ "STL_SIM TEST_RESULT " ("PASS" | "FAIL") {
|
|
|
+ for (const uint8_t *p = tok; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "fail", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ return STL_LK_MT_FAIL_COMPLETE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ev->subkind = 1;
|
|
|
+ return STL_LK_MT_PASS_COMPLETE;
|
|
|
+ }
|
|
|
+ "[MEM ERROR" | "[ECC Errors]" | "[Data Error]" | "ECC Error:" {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_MT_ERROR;
|
|
|
+ }
|
|
|
+ "Channel/Slot:" | "(Chan,Slot,Rank,Bank,Row," {
|
|
|
+ ev->subkind = 5; /* 2nd-line MT ECC/Data Error coordinate continuation */
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_MT_ERROR;
|
|
|
+ }
|
|
|
+ "Finished pass #" DIG WS "(of" WS DIG ")" {
|
|
|
+ int32_t pno = 0, ptot = 0;
|
|
|
+ const uint8_t *nx = NULL;
|
|
|
+ if (parse_i32_at(tok + 15, lim, &pno, &nx)) {
|
|
|
+ const uint8_t *ofp = memchr(tok + 15, 'f', (size_t)(lim - (tok + 15)));
|
|
|
+ if (ofp) parse_i32_at(ofp + 1, lim, &ptot, NULL);
|
|
|
+ }
|
|
|
+ int32_t errs = 0;
|
|
|
+ for (const uint8_t *p = YYCURSOR; p + 6 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "count", &af) || match_ci_kw(p, lim, "errors", &af)) {
|
|
|
+ int32_t v = 0;
|
|
|
+ if (parse_i32_at(af, lim, &v, NULL)) errs += v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ev->val0 = errs;
|
|
|
+ if (ptot > 0 && pno >= ptot) {
|
|
|
+ ev->subkind = (errs > 0) ? 2 : 1;
|
|
|
+ return (errs > 0) ? STL_LK_MT_FAIL_COMPLETE : STL_LK_MT_PASS_COMPLETE;
|
|
|
+ }
|
|
|
+ ev->val2 = (ptot > 0) ? ((pno * 100) / ptot) : 50;
|
|
|
+ return STL_LK_MT_PROGRESS;
|
|
|
+ }
|
|
|
+ ("Test Result" | "Result") WS ":" WS ("PASS" | "FAIL" | "FAILED") {
|
|
|
+ for (const uint8_t *p = tok; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "fail", &af) || match_ci_kw(p, lim, "failed", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ return STL_LK_MT_FAIL_COMPLETE;
|
|
|
+ }
|
|
|
+ if (match_ci_kw(p, lim, "pass", &af)) {
|
|
|
+ ev->subkind = 1;
|
|
|
+ return STL_LK_MT_PASS_COMPLETE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ "Pass complete, no errors" {
|
|
|
+ ev->subkind = 1;
|
|
|
+ ev->val0 = 0;
|
|
|
+ return STL_LK_MT_PASS_COMPLETE;
|
|
|
+ }
|
|
|
+ "Test Complete" {
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ if (ev->val0 > 0) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ return STL_LK_MT_FAIL_COMPLETE;
|
|
|
+ }
|
|
|
+ for (const uint8_t *p = YYCURSOR; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "fail", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ return STL_LK_MT_FAIL_COMPLETE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ev->subkind = 1;
|
|
|
+ return STL_LK_MT_PASS_COMPLETE;
|
|
|
+ }
|
|
|
+ "Running test #" DIG {
|
|
|
+ int32_t tid = 0;
|
|
|
+ if (parse_i32_at(tok + 14, lim, &tid, NULL)) {
|
|
|
+ ev->val0 = tid;
|
|
|
+ ev->val1 = 13;
|
|
|
+ ev->val2 = (tid >= 0 && tid <= 13) ? ((tid * 100) / 14) : 50;
|
|
|
+ }
|
|
|
+ return STL_LK_MT_PROGRESS;
|
|
|
+ }
|
|
|
+ "N" [01] ".C" DIG (".D" [01])? (".SC" [01])? ".R" DIG (".L" DIG)? WS ":" {
|
|
|
+ extract_ncd_token(s, end, ev);
|
|
|
+ for (const uint8_t *q = YYCURSOR; q + 4 <= lim; q++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(q, lim, "advanced memtest", &af) ||
|
|
|
+ match_ci_kw(q, lim, "failure detected", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_AMT_ERROR;
|
|
|
+ }
|
|
|
+ if (match_ci_kw(q, lim, "error", &af) || match_ci_kw(q, lim, "failed", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_TRAINING_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_RMT_ROW;
|
|
|
+ }
|
|
|
+ "N" [01] ".C" DIG ".D" [01] {
|
|
|
+ extract_ncd_token(s, end, ev);
|
|
|
+ for (const uint8_t *q = tok; q + 11 <= lim; q++) {
|
|
|
+ const uint8_t *af_por = NULL;
|
|
|
+ if (match_ci_kw(q, lim, "minimum por", &af_por)) {
|
|
|
+ ev->subkind = 4;
|
|
|
+ return STL_LK_DIMM_INVENTORY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const uint8_t *p = tok; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "disabled", &af)) {
|
|
|
+ ev->subkind = 3;
|
|
|
+ return STL_LK_DIMM_INVENTORY;
|
|
|
+ }
|
|
|
+ if (match_ci_kw(p, lim, "not", &af) || match_ci_kw(p, lim, "empty", &af) ||
|
|
|
+ match_ci_kw(p, lim, "absent", &af)) {
|
|
|
+ ev->subkind = 0;
|
|
|
+ return STL_LK_DIMM_INVENTORY;
|
|
|
+ }
|
|
|
+ if (match_ci_kw(p, lim, "present", &af) || match_ci_kw(p, lim, "ddr5", &af) ||
|
|
|
+ match_ci_kw(p, lim, "enabled", &af) || match_ci_kw(p, lim, "test", &af)) {
|
|
|
+ ev->subkind = 4;
|
|
|
+ return STL_LK_DIMM_INVENTORY;
|
|
|
+ }
|
|
|
+ if (match_ci_kw(p, lim, "fail", &af) || match_ci_kw(p, lim, "error", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_TRAINING_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ "Test:" WS DIG {
|
|
|
+ for (const uint8_t *p = YYCURSOR; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "expected", &af) || match_ci_kw(p, lim, "actual", &af)) {
|
|
|
+ ev->subkind = 2;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ return STL_LK_MT_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int32_t tnum = 0;
|
|
|
+ const uint8_t *nx = NULL;
|
|
|
+ if (parse_i32_at(tok + 5, lim, &tnum, &nx)) {
|
|
|
+ ev->val0 = tnum;
|
|
|
+ if (nx && nx < lim && *nx == '/') {
|
|
|
+ int32_t ttot = 0;
|
|
|
+ if (parse_i32_at(nx + 1, lim, &ttot, &nx)) ev->val1 = ttot;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (const uint8_t *p = YYCURSOR; p < lim; p++) {
|
|
|
+ if (*p == '%' && p > buf && p[-1] >= '0' && p[-1] <= '9') {
|
|
|
+ const uint8_t *dg = p - 1;
|
|
|
+ while (dg > buf && dg[-1] >= '0' && dg[-1] <= '9') dg--;
|
|
|
+ int32_t pct = 0;
|
|
|
+ if (parse_i32_at(dg, p, &pct, NULL)) ev->val2 = pct;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return STL_LK_MT_PROGRESS;
|
|
|
+ }
|
|
|
+ ("Test Pattern" | "Algo" WS "#" | "AlgoId") {
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ int32_t aid = -1;
|
|
|
+ if (parse_i32_at(YYCURSOR, lim, &aid, NULL) && aid >= 0) ev->val0 = aid;
|
|
|
+ for (const uint8_t *p = buf; p + 4 <= lim; p++) {
|
|
|
+ const uint8_t *af = NULL;
|
|
|
+ if (match_ci_kw(p, lim, "fail", &af)) { ev->subkind = 2; break; }
|
|
|
+ if (match_ci_kw(p, lim, "pass", &af)) { ev->subkind = 1; }
|
|
|
+ }
|
|
|
+ return STL_LK_AMT_PROGRESS;
|
|
|
+ }
|
|
|
+ ("BankGroup" | "SubRank") {
|
|
|
+ ev->subkind = 5;
|
|
|
+ extract_coords_and_addr(s, end, ev);
|
|
|
+ if (ev->cpu >= 0 || ev->channel >= 0 || ev->bank >= 0) {
|
|
|
+ return STL_LK_AMT_ERROR;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ "\x00" { break; }
|
|
|
+ ANY { continue; }
|
|
|
+ */
|
|
|
+ }
|
|
|
+
|
|
|
+ return STL_LK_NONE;
|
|
|
+}
|
|
|
+
|
|
|
+void stl_re2c_parse_line(const uint8_t *line, size_t len, uint32_t tag_mask, StlRe2cEvent *ev) {
|
|
|
+ memset(ev, 0, sizeof(*ev));
|
|
|
+ ev->cpu = -1;
|
|
|
+ ev->channel = -1;
|
|
|
+ ev->dimm = -1;
|
|
|
+ ev->rank = -1;
|
|
|
+ ev->bank = -1;
|
|
|
+ if (!line || len == 0) return;
|
|
|
+
|
|
|
+ const uint8_t *s = line;
|
|
|
+ const uint8_t *e = line + len;
|
|
|
+ trim_ws(&s, &e);
|
|
|
+ if (s >= e) return;
|
|
|
+
|
|
|
+ if (tag_mask == 0 && s[0] == '.') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ev->kind = re2c_scan_token(s, e, ev);
|
|
|
+}
|
|
|
+
|
|
|
+int stl_re2c_detect_halfline_prompt(const uint8_t *buf, size_t len, StlRe2cEvent *ev) {
|
|
|
+ memset(ev, 0, sizeof(*ev));
|
|
|
+ ev->cpu = -1;
|
|
|
+ ev->channel = -1;
|
|
|
+ ev->dimm = -1;
|
|
|
+ ev->rank = -1;
|
|
|
+ ev->bank = -1;
|
|
|
+ if (!buf || len == 0) return 0;
|
|
|
+
|
|
|
+ const uint8_t *s = buf;
|
|
|
+ const uint8_t *e = buf + len;
|
|
|
+ trim_ws(&s, &e);
|
|
|
+ if (s >= e) return 0;
|
|
|
+
|
|
|
+ uint32_t k = re2c_scan_token(s, e, ev);
|
|
|
+ if (k == STL_LK_ICT_PROMPT || k == STL_LK_ICT_ENTER_HINT ||
|
|
|
+ k == STL_LK_AMT_PROMPT || k == STL_LK_UEFI_PROMPT_EFI ||
|
|
|
+ k == STL_LK_UEFI_PROMPT_ROOT) {
|
|
|
+ ev->kind = k;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ size_t tlen = (size_t)(e - s);
|
|
|
+ if (tlen >= 4 && memcmp(e - 4, "UIP>", 4) == 0) {
|
|
|
+ ev->kind = STL_LK_ICT_PROMPT;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (tlen >= 26 && memcmp(e - 26, "Please input your command:", 26) == 0) {
|
|
|
+ ev->kind = STL_LK_ICT_PROMPT;
|
|
|
+ extract_leading_bracket_cpu(s, e, ev);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (tlen >= 25 && memcmp(e - 25, "Please input your command", 25) == 0) {
|
|
|
+ ev->kind = STL_LK_ICT_PROMPT;
|
|
|
+ extract_leading_bracket_cpu(s, e, ev);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (tlen >= 7 && memcmp(e - 7, "[AMT #]", 7) == 0) {
|
|
|
+ ev->kind = STL_LK_AMT_PROMPT;
|
|
|
+ ev->fw_family = 1;
|
|
|
+ if (tlen >= 10 && e[-10] == '[' && (e[-9] == '0' || e[-9] == '1') && e[-8] == ']') {
|
|
|
+ ev->cpu = (int8_t)(e[-9] - '0');
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (tlen >= 12 && memcmp(e - 12, "[AMEMDIAG #]", 12) == 0) {
|
|
|
+ ev->kind = STL_LK_AMT_PROMPT;
|
|
|
+ ev->fw_family = 2;
|
|
|
+ if (tlen >= 15 && e[-15] == '[' && (e[-14] == '0' || e[-14] == '1') && e[-13] == ']') {
|
|
|
+ ev->cpu = (int8_t)(e[-14] - '0');
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (tlen >= 6 && memcmp(e - 6, "Shell>", 6) == 0) {
|
|
|
+ ev->kind = STL_LK_UEFI_PROMPT_ROOT;
|
|
|
+ ev->fs_index = 255;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ /* Check trailing FSx:\EFI\> or FSx:\> */
|
|
|
+ if (tlen >= 6 && e[-1] == '>') {
|
|
|
+ for (size_t i = (tlen > 24 ? tlen - 24 : 0); i + 4 < tlen; i++) {
|
|
|
+ if (s[i] == 'F' && s[i+1] == 'S' && s[i+2] >= '0' && s[i+2] <= '9' && s[i+3] == ':') {
|
|
|
+ ev->fs_index = (uint8_t)(s[i+2] - '0');
|
|
|
+ for (size_t j = i + 4; j + 3 <= tlen; j++) {
|
|
|
+ if ((s[j] == 'E' || s[j] == 'e') && (s[j+1] == 'F' || s[j+1] == 'f') &&
|
|
|
+ (s[j+2] == 'I' || s[j+2] == 'i')) {
|
|
|
+ ev->kind = STL_LK_UEFI_PROMPT_EFI;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ev->kind = STL_LK_UEFI_PROMPT_ROOT;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|