From 9937fc682aaebb1075930b26e9c4c0be6c7e87a9 Mon Sep 17 00:00:00 2001
From: victor <taehoon@falinux.com>
Date: Wed, 6 Mar 2019 15:59:18 +0900
Subject: [PATCH] =?UTF-8?q?=EB=B6=80=ED=8A=B8=EB=A1=9C=EB=8D=94=20?=
 =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 go/src/fullcycle/analog-kernel/parser/parse.go | 199 +++++++++++++++++++++++++
 1 file changed, 199 insertions(+)

diff --git a/go/src/fullcycle/analog-kernel/parser/parse.go b/go/src/fullcycle/analog-kernel/parser/parse.go
index d3b780a..5edb704 100644
--- a/go/src/fullcycle/analog-kernel/parser/parse.go
+++ b/go/src/fullcycle/analog-kernel/parser/parse.go
@@ -21,6 +21,15 @@ var parseFuncList = []func(chan string, chan jsonObject){
 	parseSlub,
 	parsePidMax,
 	parseWorkingset,
+	parseBootloaderDram,
+	parseBootloaderMmc,
+	parseBootloaderConsole,
+	parseBootloaderGadgetDriver,
+	parseBootloaderSetupSize,
+	parseBootloaderCpu,
+	parseBootloaderBoard,
+	parseBootloaderRstStat,
+	parseBootloaderNet,
 }
 
 var reTimestamp = regexp.MustCompile(`^\[[[:blank:]]*[[:digit:]]+\.[[:digit:]]+[[:blank:]]*\]`)
@@ -532,6 +541,196 @@ func parseWorkingset(lines chan string, chanOutput chan jsonObject) {
 	chanOutput <- m
 }
 
+func parseBootloaderDram(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_dram"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^DRAM:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderMmc(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_mmc"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^MMC:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderConsole(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_console"
+	m["in"] = ""
+	m["out"] = ""
+	m["err"] = ""
+
+	const (
+		FIND_IN = iota
+		FIND_OUT
+		FIND_ERR
+		FIN
+	)
+
+	state := FIND_IN
+
+	rIn := regexp.MustCompile(`^In:\s+([[:print:]]+)`)
+	rOut := regexp.MustCompile(`^Out:\s+([[:print:]]+)`)
+	rErr := regexp.MustCompile(`^Err:\s+([[:print:]]+)`)
+	for line := range lines {
+		switch state {
+		case FIND_IN:
+			if sub := rIn.FindStringSubmatch(line); len(sub) > 1 {
+				m["in"] = sub[1]
+				state = FIND_OUT
+			}
+		case FIND_OUT:
+			if sub := rOut.FindStringSubmatch(line); len(sub) > 1 {
+				m["out"] = sub[1]
+				state = FIND_ERR
+			}
+		case FIND_ERR:
+			if sub := rErr.FindStringSubmatch(line); len(sub) > 1 {
+				m["err"] = sub[1]
+				state = FIN
+			}
+		}
+
+		if state == FIN {
+			break
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderGadgetDriver(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_gadget_driver"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^GADGET DRIVER:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderSetupSize(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_setup_size"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^Setup Size =\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderCpu(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_cpu"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^CPU:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderBoard(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_board"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^Board:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderRstStat(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_rst_stat"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^rst_stat\s+:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
+func parseBootloaderNet(lines chan string, chanOutput chan jsonObject) {
+	m := make(jsonObject)
+	m["type"] = "bootloader_net"
+	m["value"] = ""
+
+	rLine := regexp.MustCompile(`^Net:\s+([[:print:]]+)`)
+	for line := range lines {
+		if rLine.MatchString(line) {
+			if sub := rLine.FindStringSubmatch(line); len(sub) > 1 {
+				m["value"] = sub[1]
+				break
+			}
+		}
+	}
+
+	chanOutput <- m
+}
+
 func removeBrackets(s string) string {
 	for strings.HasPrefix(s, "(") && strings.HasSuffix(s, ")") {
 		openCount := strings.Count(s, "(")
-- 
2.1.4