You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/10/11 16:25:59 UTC

[40/45] incubator-mynewt-core git commit: mcu: MK64F12: add system start HAL

mcu: MK64F12: add system start HAL

- tested with mynewt boot app

Signed-off-by: Michael Scott <mi...@linaro.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/05b9861f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/05b9861f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/05b9861f

Branch: refs/heads/develop
Commit: 05b9861f1d3426c879cf34236f5279a360ca0794
Parents: 877d710
Author: Michael Scott <mi...@linaro.org>
Authored: Fri Oct 7 16:36:17 2016 -0700
Committer: Michael Scott <mi...@linaro.org>
Committed: Mon Oct 10 23:59:41 2016 -0700

----------------------------------------------------------------------
 hw/mcu/nxp/MK64F12/src/hal_system_start.c | 55 ++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/05b9861f/hw/mcu/nxp/MK64F12/src/hal_system_start.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nxp/MK64F12/src/hal_system_start.c b/hw/mcu/nxp/MK64F12/src/hal_system_start.c
new file mode 100644
index 0000000..d139fff
--- /dev/null
+++ b/hw/mcu/nxp/MK64F12/src/hal_system_start.c
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stddef.h>
+#include <inttypes.h>
+#include <mcu/cortex_m4.h>
+
+/**
+ * Boots the image described by the supplied image header.
+ *
+ * @param hdr                   The header for the image to boot.
+ */
+void
+system_start(void *img_start)
+{
+    /* Turn off interrupts. */
+    __disable_irq();
+
+    /* Set the VTOR to default. */
+    SCB->VTOR = 0;
+
+    // Memory barriers for good measure.
+    __ISB();
+    __DSB();
+
+    /* First word contains initial MSP value. */
+    __set_MSP(*(uint32_t *)img_start);
+    __set_PSP(*(uint32_t *)img_start);
+
+    /* Second word contains address of entry point (Reset_Handler). */
+    void (*entry)(void) = (void (*)(void))*(uint32_t *)(img_start + 4);
+
+    /* Jump to image. */
+    entry();
+
+    /* Should never reach this point */
+    while (1)
+        ;
+}