Commit 2b591388ff9e2bfebe7898c894b6fcafb353acb4
1 parent
9937fc682a
Exists in
master
라즈베리 파이 3 부트로더 정보 추가
Showing
1 changed file
with
113 additions
and
0 deletions
Show diff stats
go/src/fullcycle/analog-kernel/parser/parse.go
@@ -30,6 +30,10 @@ var parseFuncList = []func(chan string, chan jsonObject){ | @@ -30,6 +30,10 @@ var parseFuncList = []func(chan string, chan jsonObject){ | ||
30 | parseBootloaderBoard, | 30 | parseBootloaderBoard, |
31 | parseBootloaderRstStat, | 31 | parseBootloaderRstStat, |
32 | parseBootloaderNet, | 32 | parseBootloaderNet, |
33 | + parseBootloaderBootcode, | ||
34 | + parseBootloaderRead, | ||
35 | + parseBootloaderCommandLine, | ||
36 | + parseBootloaderLoad, | ||
33 | } | 37 | } |
34 | 38 | ||
35 | var reTimestamp = regexp.MustCompile(`^\[[[:blank:]]*[[:digit:]]+\.[[:digit:]]+[[:blank:]]*\]`) | 39 | var reTimestamp = regexp.MustCompile(`^\[[[:blank:]]*[[:digit:]]+\.[[:digit:]]+[[:blank:]]*\]`) |
@@ -731,6 +735,115 @@ func parseBootloaderNet(lines chan string, chanOutput chan jsonObject) { | @@ -731,6 +735,115 @@ func parseBootloaderNet(lines chan string, chanOutput chan jsonObject) { | ||
731 | chanOutput <- m | 735 | chanOutput <- m |
732 | } | 736 | } |
733 | 737 | ||
738 | +func parseBootloaderBootcode(lines chan string, chanOutput chan jsonObject) { | ||
739 | + m := make(jsonObject) | ||
740 | + m["type"] = "bootloader_bootcode" | ||
741 | + m["value"] = "" | ||
742 | + | ||
743 | + rLine := regexp.MustCompile(`^Raspberry Pi Bootcode`) | ||
744 | + for line := range lines { | ||
745 | + if rLine.MatchString(line) { | ||
746 | + m["value"] = line | ||
747 | + break | ||
748 | + } | ||
749 | + } | ||
750 | + | ||
751 | + chanOutput <- m | ||
752 | +} | ||
753 | + | ||
754 | +func parseBootloaderRead(lines chan string, chanOutput chan jsonObject) { | ||
755 | + const ( | ||
756 | + FIND_NAME = iota | ||
757 | + FIND_SIZE | ||
758 | + ) | ||
759 | + | ||
760 | + state := FIND_NAME | ||
761 | + elements := make(map[string]string) | ||
762 | + name := "" | ||
763 | + | ||
764 | + rLine := regexp.MustCompile(`brfs: File read: ([[:print:]]+)`) | ||
765 | + for line := range lines { | ||
766 | + if rLine.MatchString(line) { | ||
767 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | ||
768 | + switch state { | ||
769 | + case FIND_NAME: | ||
770 | + name = sub[1] | ||
771 | + state = FIND_SIZE | ||
772 | + case FIND_SIZE: | ||
773 | + elements[name] = sub[1] | ||
774 | + state = FIND_NAME | ||
775 | + } | ||
776 | + } | ||
777 | + } | ||
778 | + } | ||
779 | + | ||
780 | + list := make([]jsonObject, 0) | ||
781 | + for name, size := range elements { | ||
782 | + list = append(list, jsonObject{"name": name, "size": size}) | ||
783 | + } | ||
784 | + | ||
785 | + m := make(jsonObject) | ||
786 | + m["type"] = "bootloader_read" | ||
787 | + m["list"] = list | ||
788 | + | ||
789 | + chanOutput <- m | ||
790 | +} | ||
791 | + | ||
792 | +func parseBootloaderCommandLine(lines chan string, chanOutput chan jsonObject) { | ||
793 | + m := make(jsonObject) | ||
794 | + m["type"] = "bootloader_command_line" | ||
795 | + m["value"] = "" | ||
796 | + | ||
797 | + const ( | ||
798 | + FIND_HEADER = iota | ||
799 | + FIND_LINE | ||
800 | + DONE | ||
801 | + ) | ||
802 | + | ||
803 | + state := FIND_HEADER | ||
804 | + | ||
805 | + rLine := regexp.MustCompile(`Read command line from file`) | ||
806 | + rValue := regexp.MustCompile(`[[:graph:]]+ ([[:print:]]+)`) | ||
807 | + for line := range lines { | ||
808 | + switch state { | ||
809 | + case FIND_HEADER: | ||
810 | + if rLine.MatchString(line) { | ||
811 | + state = FIND_LINE | ||
812 | + } | ||
813 | + case FIND_LINE: | ||
814 | + if sub := rValue.FindStringSubmatch(line); len(sub) > 1 { | ||
815 | + m["value"] = sub[1] | ||
816 | + state = DONE | ||
817 | + } | ||
818 | + } | ||
819 | + | ||
820 | + if state == DONE { | ||
821 | + break | ||
822 | + } | ||
823 | + } | ||
824 | + | ||
825 | + chanOutput <- m | ||
826 | +} | ||
827 | + | ||
828 | +func parseBootloaderLoad(lines chan string, chanOutput chan jsonObject) { | ||
829 | + list := make([]jsonObject, 0) | ||
830 | + | ||
831 | + rLine := regexp.MustCompile(`Loading '([[:print:]]+)' to (0x[[:xdigit:]]+) size (0x[[:xdigit:]]+)`) | ||
832 | + for line := range lines { | ||
833 | + if rLine.MatchString(line) { | ||
834 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 3 { | ||
835 | + list = append(list, jsonObject{"name": sub[1], "address": sub[2], "size": sub[3]}) | ||
836 | + } | ||
837 | + } | ||
838 | + } | ||
839 | + | ||
840 | + m := make(jsonObject) | ||
841 | + m["type"] = "bootloader_load" | ||
842 | + m["list"] = list | ||
843 | + | ||
844 | + chanOutput <- m | ||
845 | +} | ||
846 | + | ||
734 | func removeBrackets(s string) string { | 847 | func removeBrackets(s string) string { |
735 | for strings.HasPrefix(s, "(") && strings.HasSuffix(s, ")") { | 848 | for strings.HasPrefix(s, "(") && strings.HasSuffix(s, ")") { |
736 | openCount := strings.Count(s, "(") | 849 | openCount := strings.Count(s, "(") |