[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bsp/lk/lib/version/buildid.sh b/src/bsp/lk/lib/version/buildid.sh
new file mode 100755
index 0000000..d36c46d
--- /dev/null
+++ b/src/bsp/lk/lib/version/buildid.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+eval `date -u +'BYR=%Y BMON=%-m BDOM=%-d BHR=%-H BMIN=%-M'`
+chr () {
+    printf \\$(($1/64*100+$1%64/8*10+$1%8))
+}
+b36 () {
+    if [ $1 -le 9 ]; then echo $1; else chr $((0x41 + $1 - 10)); fi
+}
+printf '%c%c%c%c%c\n' `chr $((0x41 + $BYR - 2011))` `b36 $BMON` `b36 $BDOM` `b36 $BHR` `b36 $(($BMIN/2))`
diff --git a/src/bsp/lk/lib/version/include/lib/version.h b/src/bsp/lk/lib/version/include/lib/version.h
new file mode 100644
index 0000000..1c1ec05
--- /dev/null
+++ b/src/bsp/lk/lib/version/include/lib/version.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Google, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef __LIB_VERSION_H
+#define __LIB_VERSION_H
+
+#include <compiler.h>
+
+__BEGIN_CDECLS
+
+#define VERSION_STRUCT_VERSION 0x1
+
+typedef struct {
+    unsigned int struct_version;
+    const char *arch;
+    const char *platform;
+    const char *target;
+    const char *project;
+    const char *buildid;
+} lk_version_t;
+
+extern const lk_version_t version;
+
+void print_version(void);
+
+__END_CDECLS
+
+#endif
+
diff --git a/src/bsp/lk/lib/version/rules.mk b/src/bsp/lk/lib/version/rules.mk
new file mode 100644
index 0000000..8f9afa7
--- /dev/null
+++ b/src/bsp/lk/lib/version/rules.mk
@@ -0,0 +1,32 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+MODULE := $(LOCAL_DIR)
+
+MODULE_SRCS += \
+	$(LOCAL_DIR)/version.c
+
+# if no one else has defined it by now, build us a default buildid
+# based on the current time.
+# suffix it with _LOCAL if OFFICIAL_BUILD is unset
+ifeq ($(strip $(BUILDID)),)
+ifneq ($(OFFICIAL_BUILD),)
+BUILDID := "$(shell $(LOCAL_DIR)/buildid.sh)"
+else
+BUILDID := "$(shell $(LOCAL_DIR)/buildid.sh)_LOCAL"
+endif
+endif
+
+# Generate a buildid.h file, lazy evaulated BUILDID_DEFINE at the end
+# of the first make pass. This lets modules that haven't been
+# included yet set BUILDID.
+BUILDID_DEFINE="BUILDID=\"$(BUILDID)\""
+BUILDID_H := $(BUILDDIR)/buildid.h
+$(BUILDID_H): .PHONY
+	@$(call MAKECONFIGHEADER,$@,BUILDID_DEFINE)
+
+GENERATED += $(BUILDID_H)
+
+# make sure the module properly depends on and can find buildid.h
+MODULE_SRCDEPS := $(BUILDID_H)
+
+include make/module.mk
diff --git a/src/bsp/lk/lib/version/version.c b/src/bsp/lk/lib/version/version.c
new file mode 100644
index 0000000..c56434c
--- /dev/null
+++ b/src/bsp/lk/lib/version/version.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013 Google, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include <lib/version.h>
+
+#include <debug.h>
+#include <stdio.h>
+#include <lk/init.h>
+
+/* generated for us */
+#include <buildid.h>
+
+/* ARCH, PLATFORM, TARGET, PROJECT should be defined by the build system */
+
+/* BUILDID is optional, and may be defined anywhere */
+#ifndef BUILDID
+#define BUILDID ""
+#endif
+
+const lk_version_t version = {
+    .struct_version = VERSION_STRUCT_VERSION,
+    .arch = ARCH,
+    .platform = PLATFORM,
+    .target = TARGET,
+    .project = PROJECT,
+    .buildid = BUILDID
+};
+
+void print_version(void)
+{
+    printf("version:\n");
+    printf("\tarch:     %s\n", version.arch);
+    printf("\tplatform: %s\n", version.platform);
+    printf("\ttarget:   %s\n", version.target);
+    printf("\tproject:  %s\n", version.project);
+    printf("\tbuildid:  %s\n", version.buildid);
+}
+
+#if WITH_LIB_CONSOLE
+
+#include <debug.h>
+#include <lib/console.h>
+
+static int cmd_version(int argc, const cmd_args *argv)
+{
+    print_version();
+    return 0;
+}
+
+STATIC_COMMAND_START
+STATIC_COMMAND("version", "print version", &cmd_version)
+STATIC_COMMAND_END(version);
+
+#endif // WITH_LIB_CONSOLE
+
+#if LK_DEBUGLEVEL > 0
+// print the version string if any level of debug is set
+LK_INIT_HOOK(version, (void *)&print_version, LK_INIT_LEVEL_HEAP - 1);
+#endif
+