mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [3/3] incubator-mynewt-larva git commit: Add system_start() to NRF51.
Date Wed, 03 Feb 2016 20:55:28 GMT
Add system_start() to NRF51.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/99f3e5f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/99f3e5f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/99f3e5f0

Branch: refs/heads/master
Commit: 99f3e5f0a388dea7f4e097e2f3eefa4667f1af52
Parents: ed475f0
Author: Marko Kiiskila <marko@runtime.io>
Authored: Wed Feb 3 12:55:05 2016 -0800
Committer: Marko Kiiskila <marko@runtime.io>
Committed: Wed Feb 3 12:55:05 2016 -0800

----------------------------------------------------------------------
 hw/mcu/nordic/nrf51xxx/src/hal_system_start.c | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/99f3e5f0/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c b/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c
new file mode 100644
index 0000000..208438f
--- /dev/null
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_system_start.c
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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_m0.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)
+{
+    typedef void jump_fn(void);
+
+    uint32_t base0entry;
+    uint32_t jump_addr;
+    jump_fn *fn;
+
+    /* First word contains initial MSP value. */
+    __set_MSP(*(uint32_t *)img_start);
+
+    /* Second word contains address of entry point (Reset_Handler). */
+    base0entry = *(uint32_t *)(img_start + 4);
+    jump_addr = base0entry;
+    fn = (jump_fn *)jump_addr;
+
+    /* Jump to image. */
+    fn();
+}


Mime
View raw message