| /**************************************************************************** |
| * arch/arm/src/mps/mps_start.c |
| * |
| * 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. |
| * |
| ****************************************************************************/ |
| |
| /**************************************************************************** |
| * Included Files |
| ****************************************************************************/ |
| |
| #include <nuttx/config.h> |
| #include <nuttx/init.h> |
| |
| #include "arm_internal.h" |
| #include "mps_irq.h" |
| #include "mpu.h" |
| |
| /**************************************************************************** |
| * Public Functions |
| ****************************************************************************/ |
| |
| #define HEAP_BASE ((uintptr_t)_ebss + CONFIG_IDLETHREAD_STACKSIZE) |
| |
| /**************************************************************************** |
| * Public Data |
| ****************************************************************************/ |
| |
| /* g_idle_topstack: _sbss is the start of the BSS region as defined by the |
| * linker script. _ebss lies at the end of the BSS region. The idle task |
| * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE. |
| * The IDLE thread is the thread that the system boots on and, eventually, |
| * becomes the IDLE, do nothing task that runs only when there is nothing |
| * else to run. The heap continues from there until the end of memory. |
| * g_idle_topstack is a read-only variable the provides this computed |
| * address. |
| */ |
| |
| const uintptr_t g_idle_topstack = HEAP_BASE; |
| |
| /**************************************************************************** |
| * Private Functions |
| ****************************************************************************/ |
| |
| /**************************************************************************** |
| * Name: __start |
| * |
| * Description: |
| * This is the reset entry point. |
| * |
| ****************************************************************************/ |
| |
| void __start(void) |
| { |
| const uint32_t *src; |
| uint32_t *dest; |
| |
| /* If enabled reset the MPU */ |
| |
| mpu_early_reset(); |
| arm_fpuconfig(); |
| |
| /* Set bss to zero */ |
| |
| for (dest = (uint32_t *)_sbss; dest < (uint32_t *)_ebss; ) |
| { |
| *dest++ = 0; |
| } |
| |
| /* Copy the program from FLASH to RAM. */ |
| |
| for (src = (const uint32_t *)_eronly, |
| dest = (uint32_t *)_sdata; dest < (uint32_t *)_edata; |
| ) |
| { |
| *dest++ = *src++; |
| } |
| |
| #ifdef USE_EARLYSERIALINIT |
| arm_earlyserialinit(); |
| #endif |
| |
| nx_start(); |
| } |