2016-03-12 13:23:49 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* arch/arm/src/armv7-a/arm_cpustart.c
|
|
|
|
|
*
|
2021-03-24 09:12:29 +01:00
|
|
|
* 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
|
2016-03-12 13:23:49 -06:00
|
|
|
*
|
2021-03-24 09:12:29 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-03-12 13:23:49 -06:00
|
|
|
*
|
2021-03-24 09:12:29 +01:00
|
|
|
* 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.
|
2016-03-12 13:23:49 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Included Files
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2021-05-18 14:59:14 +08:00
|
|
|
#include <assert.h>
|
2021-05-14 10:45:57 +08:00
|
|
|
#include <debug.h>
|
2016-03-12 13:23:49 -06:00
|
|
|
|
|
|
|
|
#include <nuttx/arch.h>
|
|
|
|
|
#include <nuttx/sched.h>
|
2016-12-07 09:08:20 -06:00
|
|
|
#include <nuttx/sched_note.h>
|
2016-03-12 13:23:49 -06:00
|
|
|
|
2020-04-30 19:20:29 -06:00
|
|
|
#include "arm_internal.h"
|
2016-05-20 12:39:02 -06:00
|
|
|
#include "cp15_cacheops.h"
|
2016-11-27 10:21:20 -06:00
|
|
|
#include "gic.h"
|
2016-03-12 13:23:49 -06:00
|
|
|
#include "sched/sched.h"
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
|
|
2016-05-22 15:01:49 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Private Functions
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-12 13:23:49 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Public Functions
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: arm_start_handler
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* This is the handler for SGI1. This handler simply returns from the
|
|
|
|
|
* interrupt, restoring the state of the new task at the head of the ready
|
|
|
|
|
* to run list.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* Standard interrupt handling
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* Zero on success; a negated errno value on failure.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2022-04-17 13:57:58 +08:00
|
|
|
int arm_start_handler(int irq, void *context, void *arg)
|
2016-03-12 13:23:49 -06:00
|
|
|
{
|
2022-04-17 13:57:58 +08:00
|
|
|
struct tcb_s *tcb = this_task();
|
2016-11-27 10:21:20 -06:00
|
|
|
|
2016-11-27 17:14:57 -06:00
|
|
|
sinfo("CPU%d Started\n", this_cpu());
|
2016-11-27 10:21:20 -06:00
|
|
|
|
2016-12-07 09:08:20 -06:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
|
|
|
|
/* Notify that this CPU has started */
|
|
|
|
|
|
|
|
|
|
sched_note_cpu_started(tcb);
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-12 13:23:49 -06:00
|
|
|
/* Reset scheduler parameters */
|
|
|
|
|
|
2020-05-09 08:04:45 -06:00
|
|
|
nxsched_resume_scheduler(tcb);
|
2016-03-12 13:23:49 -06:00
|
|
|
|
2016-05-22 15:01:49 -06:00
|
|
|
/* Dump registers so that we can see what is going to happen on return */
|
|
|
|
|
|
2022-12-14 09:58:38 +08:00
|
|
|
#if 0
|
2022-12-21 22:26:38 +08:00
|
|
|
up_dump_register(tcb->xcp.regs);
|
2022-12-14 09:58:38 +08:00
|
|
|
#endif
|
2016-05-22 15:01:49 -06:00
|
|
|
|
2016-03-12 13:23:49 -06:00
|
|
|
/* Then switch contexts. This instantiates the exception context of the
|
|
|
|
|
* tcb at the head of the assigned task list. In this case, this should
|
|
|
|
|
* be the CPUs NULL task.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-05-02 14:49:55 -06:00
|
|
|
arm_restorestate(tcb->xcp.regs);
|
2016-03-12 13:23:49 -06:00
|
|
|
return OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: up_cpu_start
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
2021-08-10 21:00:09 +02:00
|
|
|
* In an SMP configuration, only one CPU is initially active (CPU 0).
|
|
|
|
|
* System initialization occurs on that single thread. At the completion of
|
|
|
|
|
* the initialization of the OS, just before beginning normal multitasking,
|
2016-03-12 13:23:49 -06:00
|
|
|
* the additional CPUs would be started by calling this function.
|
|
|
|
|
*
|
2021-08-10 21:00:09 +02:00
|
|
|
* Each CPU is provided the entry point to its IDLE task when started. A
|
2016-03-12 13:23:49 -06:00
|
|
|
* TCB for each CPU's IDLE task has been initialized and placed in the
|
2021-08-10 21:00:09 +02:00
|
|
|
* CPU's g_assignedtasks[cpu] list. No stack has been allocated or
|
2016-03-12 13:23:49 -06:00
|
|
|
* initialized.
|
|
|
|
|
*
|
|
|
|
|
* The OS initialization logic calls this function repeatedly until each
|
|
|
|
|
* CPU has been started, 1 through (CONFIG_SMP_NCPUS-1).
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* cpu - The index of the CPU being started. This will be a numeric
|
2021-08-10 21:00:09 +02:00
|
|
|
* value in the range of one to (CONFIG_SMP_NCPUS-1).
|
|
|
|
|
* (CPU 0 is already active)
|
2016-03-12 13:23:49 -06:00
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* Zero on success; a negated errno value on failure.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2023-12-29 21:35:38 +08:00
|
|
|
int weak_function up_cpu_start(int cpu)
|
2016-03-12 13:23:49 -06:00
|
|
|
{
|
2016-06-20 11:59:15 -06:00
|
|
|
sinfo("Starting CPU%d\n", cpu);
|
2016-05-22 15:01:49 -06:00
|
|
|
|
2016-03-12 13:23:49 -06:00
|
|
|
DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS && cpu != this_cpu());
|
|
|
|
|
|
2016-12-07 09:08:20 -06:00
|
|
|
#ifdef CONFIG_SCHED_INSTRUMENTATION
|
|
|
|
|
/* Notify of the start event */
|
|
|
|
|
|
|
|
|
|
sched_note_cpu_start(this_task(), cpu);
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-12 13:23:49 -06:00
|
|
|
/* Execute SGI1 */
|
|
|
|
|
|
2024-03-13 08:23:02 +08:00
|
|
|
arm_cpu_sgi(GIC_SMP_CPUSTART, (1 << cpu));
|
|
|
|
|
|
2022-09-18 17:42:16 +08:00
|
|
|
return OK;
|
2016-03-12 13:23:49 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* CONFIG_SMP */
|