Commit 9937fc682aaebb1075930b26e9c4c0be6c7e87a9
1 parent
1ed17e94b1
Exists in
master
부트로더 정보 추가
Showing
1 changed file
with
199 additions
and
0 deletions
Show diff stats
go/src/fullcycle/analog-kernel/parser/parse.go
... | ... | @@ -21,6 +21,15 @@ var parseFuncList = []func(chan string, chan jsonObject){ |
21 | 21 | parseSlub, |
22 | 22 | parsePidMax, |
23 | 23 | parseWorkingset, |
24 | + parseBootloaderDram, | |
25 | + parseBootloaderMmc, | |
26 | + parseBootloaderConsole, | |
27 | + parseBootloaderGadgetDriver, | |
28 | + parseBootloaderSetupSize, | |
29 | + parseBootloaderCpu, | |
30 | + parseBootloaderBoard, | |
31 | + parseBootloaderRstStat, | |
32 | + parseBootloaderNet, | |
24 | 33 | } |
25 | 34 | |
26 | 35 | var reTimestamp = regexp.MustCompile(`^\[[[:blank:]]*[[:digit:]]+\.[[:digit:]]+[[:blank:]]*\]`) |
... | ... | @@ -532,6 +541,196 @@ func parseWorkingset(lines chan string, chanOutput chan jsonObject) { |
532 | 541 | chanOutput <- m |
533 | 542 | } |
534 | 543 | |
544 | +func parseBootloaderDram(lines chan string, chanOutput chan jsonObject) { | |
545 | + m := make(jsonObject) | |
546 | + m["type"] = "bootloader_dram" | |
547 | + m["value"] = "" | |
548 | + | |
549 | + rLine := regexp.MustCompile(`^DRAM:\s+([[:print:]]+)`) | |
550 | + for line := range lines { | |
551 | + if rLine.MatchString(line) { | |
552 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
553 | + m["value"] = sub[1] | |
554 | + break | |
555 | + } | |
556 | + } | |
557 | + } | |
558 | + | |
559 | + chanOutput <- m | |
560 | +} | |
561 | + | |
562 | +func parseBootloaderMmc(lines chan string, chanOutput chan jsonObject) { | |
563 | + m := make(jsonObject) | |
564 | + m["type"] = "bootloader_mmc" | |
565 | + m["value"] = "" | |
566 | + | |
567 | + rLine := regexp.MustCompile(`^MMC:\s+([[:print:]]+)`) | |
568 | + for line := range lines { | |
569 | + if rLine.MatchString(line) { | |
570 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
571 | + m["value"] = sub[1] | |
572 | + break | |
573 | + } | |
574 | + } | |
575 | + } | |
576 | + | |
577 | + chanOutput <- m | |
578 | +} | |
579 | + | |
580 | +func parseBootloaderConsole(lines chan string, chanOutput chan jsonObject) { | |
581 | + m := make(jsonObject) | |
582 | + m["type"] = "bootloader_console" | |
583 | + m["in"] = "" | |
584 | + m["out"] = "" | |
585 | + m["err"] = "" | |
586 | + | |
587 | + const ( | |
588 | + FIND_IN = iota | |
589 | + FIND_OUT | |
590 | + FIND_ERR | |
591 | + FIN | |
592 | + ) | |
593 | + | |
594 | + state := FIND_IN | |
595 | + | |
596 | + rIn := regexp.MustCompile(`^In:\s+([[:print:]]+)`) | |
597 | + rOut := regexp.MustCompile(`^Out:\s+([[:print:]]+)`) | |
598 | + rErr := regexp.MustCompile(`^Err:\s+([[:print:]]+)`) | |
599 | + for line := range lines { | |
600 | + switch state { | |
601 | + case FIND_IN: | |
602 | + if sub := rIn.FindStringSubmatch(line); len(sub) > 1 { | |
603 | + m["in"] = sub[1] | |
604 | + state = FIND_OUT | |
605 | + } | |
606 | + case FIND_OUT: | |
607 | + if sub := rOut.FindStringSubmatch(line); len(sub) > 1 { | |
608 | + m["out"] = sub[1] | |
609 | + state = FIND_ERR | |
610 | + } | |
611 | + case FIND_ERR: | |
612 | + if sub := rErr.FindStringSubmatch(line); len(sub) > 1 { | |
613 | + m["err"] = sub[1] | |
614 | + state = FIN | |
615 | + } | |
616 | + } | |
617 | + | |
618 | + if state == FIN { | |
619 | + break | |
620 | + } | |
621 | + } | |
622 | + | |
623 | + chanOutput <- m | |
624 | +} | |
625 | + | |
626 | +func parseBootloaderGadgetDriver(lines chan string, chanOutput chan jsonObject) { | |
627 | + m := make(jsonObject) | |
628 | + m["type"] = "bootloader_gadget_driver" | |
629 | + m["value"] = "" | |
630 | + | |
631 | + rLine := regexp.MustCompile(`^GADGET DRIVER:\s+([[:print:]]+)`) | |
632 | + for line := range lines { | |
633 | + if rLine.MatchString(line) { | |
634 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
635 | + m["value"] = sub[1] | |
636 | + break | |
637 | + } | |
638 | + } | |
639 | + } | |
640 | + | |
641 | + chanOutput <- m | |
642 | +} | |
643 | + | |
644 | +func parseBootloaderSetupSize(lines chan string, chanOutput chan jsonObject) { | |
645 | + m := make(jsonObject) | |
646 | + m["type"] = "bootloader_setup_size" | |
647 | + m["value"] = "" | |
648 | + | |
649 | + rLine := regexp.MustCompile(`^Setup Size =\s+([[:print:]]+)`) | |
650 | + for line := range lines { | |
651 | + if rLine.MatchString(line) { | |
652 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
653 | + m["value"] = sub[1] | |
654 | + break | |
655 | + } | |
656 | + } | |
657 | + } | |
658 | + | |
659 | + chanOutput <- m | |
660 | +} | |
661 | + | |
662 | +func parseBootloaderCpu(lines chan string, chanOutput chan jsonObject) { | |
663 | + m := make(jsonObject) | |
664 | + m["type"] = "bootloader_cpu" | |
665 | + m["value"] = "" | |
666 | + | |
667 | + rLine := regexp.MustCompile(`^CPU:\s+([[:print:]]+)`) | |
668 | + for line := range lines { | |
669 | + if rLine.MatchString(line) { | |
670 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
671 | + m["value"] = sub[1] | |
672 | + break | |
673 | + } | |
674 | + } | |
675 | + } | |
676 | + | |
677 | + chanOutput <- m | |
678 | +} | |
679 | + | |
680 | +func parseBootloaderBoard(lines chan string, chanOutput chan jsonObject) { | |
681 | + m := make(jsonObject) | |
682 | + m["type"] = "bootloader_board" | |
683 | + m["value"] = "" | |
684 | + | |
685 | + rLine := regexp.MustCompile(`^Board:\s+([[:print:]]+)`) | |
686 | + for line := range lines { | |
687 | + if rLine.MatchString(line) { | |
688 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
689 | + m["value"] = sub[1] | |
690 | + break | |
691 | + } | |
692 | + } | |
693 | + } | |
694 | + | |
695 | + chanOutput <- m | |
696 | +} | |
697 | + | |
698 | +func parseBootloaderRstStat(lines chan string, chanOutput chan jsonObject) { | |
699 | + m := make(jsonObject) | |
700 | + m["type"] = "bootloader_rst_stat" | |
701 | + m["value"] = "" | |
702 | + | |
703 | + rLine := regexp.MustCompile(`^rst_stat\s+:\s+([[:print:]]+)`) | |
704 | + for line := range lines { | |
705 | + if rLine.MatchString(line) { | |
706 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
707 | + m["value"] = sub[1] | |
708 | + break | |
709 | + } | |
710 | + } | |
711 | + } | |
712 | + | |
713 | + chanOutput <- m | |
714 | +} | |
715 | + | |
716 | +func parseBootloaderNet(lines chan string, chanOutput chan jsonObject) { | |
717 | + m := make(jsonObject) | |
718 | + m["type"] = "bootloader_net" | |
719 | + m["value"] = "" | |
720 | + | |
721 | + rLine := regexp.MustCompile(`^Net:\s+([[:print:]]+)`) | |
722 | + for line := range lines { | |
723 | + if rLine.MatchString(line) { | |
724 | + if sub := rLine.FindStringSubmatch(line); len(sub) > 1 { | |
725 | + m["value"] = sub[1] | |
726 | + break | |
727 | + } | |
728 | + } | |
729 | + } | |
730 | + | |
731 | + chanOutput <- m | |
732 | +} | |
733 | + | |
535 | 734 | func removeBrackets(s string) string { |
536 | 735 | for strings.HasPrefix(s, "(") && strings.HasSuffix(s, ")") { |
537 | 736 | openCount := strings.Count(s, "(") | ... | ... |