[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bsp/lk/include/arch/mmu.h b/src/bsp/lk/include/arch/mmu.h
new file mode 100644
index 0000000..dc6386b
--- /dev/null
+++ b/src/bsp/lk/include/arch/mmu.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2014 Travis Geiselbrecht
+ *
+ * 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.
+ */
+#pragma once
+
+#include <arch.h>
+#include <sys/types.h>
+#include <compiler.h>
+
+__BEGIN_CDECLS
+
+#define ARCH_MMU_FLAG_CACHED (0<<0)
+#define ARCH_MMU_FLAG_UNCACHED (1<<0)
+#define ARCH_MMU_FLAG_UNCACHED_DEVICE (2<<0) /* only exists on some arches, otherwise UNCACHED */
+#define ARCH_MMU_FLAG_CACHE_MASK (3<<0)
+
+#define ARCH_MMU_FLAG_PERM_USER (1<<2)
+#define ARCH_MMU_FLAG_PERM_RO (1<<3)
+#define ARCH_MMU_FLAG_PERM_NO_EXECUTE (1<<4)
+#define ARCH_MMU_FLAG_NS (1<<5) /* NON-SECURE */
+#define ARCH_MMU_FLAG_INVALID (1<<7) /* indicates that flags are not specified */
+
+int arch_mmu_map(vaddr_t vaddr, paddr_t paddr, uint count, uint flags);
+int arch_mmu_unmap(vaddr_t vaddr, uint count);
+status_t arch_mmu_query(vaddr_t vaddr, paddr_t *paddr, uint *flags);
+vaddr_t arch_mmu_pick_spot(vaddr_t base, uint prev_region_arch_mmu_flags,
+ vaddr_t end, uint next_region_arch_mmu_flags,
+ vaddr_t align, size_t size, uint arch_mmu_flags);
+
+void arch_disable_mmu(void);
+
+__END_CDECLS
+
diff --git a/src/bsp/lk/include/arch/mp.h b/src/bsp/lk/include/arch/mp.h
new file mode 100644
index 0000000..2c3b2c5
--- /dev/null
+++ b/src/bsp/lk/include/arch/mp.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2014 Travis Geiselbrecht
+ *
+ * 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.
+ */
+#pragma once
+
+#include <sys/types.h>
+#include <kernel/mp.h>
+
+/* send inter processor interrupt, if supported */
+status_t arch_mp_send_ipi(mp_cpu_mask_t target, mp_ipi_t ipi);
+
+void arch_mp_init_percpu(void);
diff --git a/src/bsp/lk/include/arch/ops.h b/src/bsp/lk/include/arch/ops.h
new file mode 100644
index 0000000..f097751
--- /dev/null
+++ b/src/bsp/lk/include/arch/ops.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2008-2014 Travis Geiselbrecht
+ *
+ * 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 __ARCH_OPS_H
+#define __ARCH_OPS_H
+
+#ifndef ASSEMBLY
+
+#include <sys/types.h>
+#include <stddef.h>
+#include <stdbool.h>
+#include <compiler.h>
+
+__BEGIN_CDECLS
+
+/* fast routines that most arches will implement inline */
+static void arch_enable_ints(void);
+static void arch_disable_ints(void);
+static bool arch_ints_disabled(void);
+static bool arch_in_int_handler(void);
+
+static int atomic_swap(volatile int *ptr, int val);
+static int atomic_add(volatile int *ptr, int val);
+static int atomic_and(volatile int *ptr, int val);
+static int atomic_or(volatile int *ptr, int val);
+
+static uint32_t arch_cycle_count(void);
+
+static uint arch_curr_cpu_num(void);
+
+/* Use to align structures on cache lines to avoid cpu aliasing. */
+#define __CPU_ALIGN __ALIGNED(CACHE_LINE)
+
+#endif // !ASSEMBLY
+#define ICACHE 1
+#define DCACHE 2
+#define UCACHE (ICACHE|DCACHE)
+#ifndef ASSEMBLY
+
+void arch_disable_cache(uint flags);
+void arch_enable_cache(uint flags);
+
+void arch_clean_cache_range(addr_t start, size_t len);
+void arch_clean_invalidate_cache_range(addr_t start, size_t len);
+void arch_invalidate_cache_range(addr_t start, size_t len);
+void arch_sync_cache_range(addr_t start, size_t len);
+
+void arch_idle(void);
+
+__END_CDECLS
+
+#endif // !ASSEMBLY
+
+#include <arch/arch_ops.h>
+
+#endif
diff --git a/src/bsp/lk/include/arch/thread.h b/src/bsp/lk/include/arch/thread.h
new file mode 100644
index 0000000..06de51d
--- /dev/null
+++ b/src/bsp/lk/include/arch/thread.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2008 Travis Geiselbrecht
+ *
+ * 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 __ARCH_THREAD_H
+#define __ARCH_THREAD_H
+
+// give the arch code a chance to declare the arch_thread struct
+#include <arch/arch_thread.h>
+
+struct thread;
+
+void arch_thread_initialize(struct thread *);
+void arch_context_switch(struct thread *oldthread, struct thread *newthread);
+
+#endif