2008-01-09 02:13:24 +01:00
|
|
|
/****************************************************************************
|
2019-02-04 23:20:35 +01:00
|
|
|
* sched/init/nx_start.c
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +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
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +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.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2008-01-09 02:13:24 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-09 02:13:24 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-01-09 02:13:24 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2017-08-15 01:19:27 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <nuttx/arch.h>
|
2019-02-18 23:25:08 +01:00
|
|
|
#include <nuttx/board.h>
|
2017-08-15 01:19:27 +02:00
|
|
|
#include <nuttx/compiler.h>
|
|
|
|
#include <nuttx/sched.h>
|
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#include <nuttx/net/net.h>
|
2020-02-17 18:08:08 +01:00
|
|
|
#include <nuttx/mm/iob.h>
|
2023-04-13 15:25:22 +02:00
|
|
|
#include <nuttx/mm/kmap.h>
|
2017-08-15 01:19:27 +02:00
|
|
|
#include <nuttx/mm/mm.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
2022-02-24 08:12:51 +01:00
|
|
|
#include <nuttx/pgalloc.h>
|
2017-08-15 01:19:27 +02:00
|
|
|
#include <nuttx/sched_note.h>
|
2018-08-23 17:09:39 +02:00
|
|
|
#include <nuttx/binfmt/binfmt.h>
|
2022-03-11 15:52:32 +01:00
|
|
|
#include <nuttx/drivers/drivers.h>
|
2017-08-15 01:19:27 +02:00
|
|
|
#include <nuttx/init.h>
|
|
|
|
|
|
|
|
#include "sched/sched.h"
|
|
|
|
#include "signal/signal.h"
|
|
|
|
#include "semaphore/semaphore.h"
|
2022-03-11 21:01:19 +01:00
|
|
|
#include "mqueue/mqueue.h"
|
2022-10-19 16:28:43 +02:00
|
|
|
#include "mqueue/msg.h"
|
2017-08-15 01:19:27 +02:00
|
|
|
#include "clock/clock.h"
|
|
|
|
#include "timer/timer.h"
|
|
|
|
#include "irq/irq.h"
|
2019-02-11 19:09:26 +01:00
|
|
|
#include "group/group.h"
|
2017-08-15 01:19:27 +02:00
|
|
|
#include "init/init.h"
|
2022-06-05 16:18:05 +02:00
|
|
|
#include "tls/tls.h"
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-20 00:33:35 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* This set of all CPUs */
|
|
|
|
|
2021-07-15 13:46:07 +02:00
|
|
|
#define SCHED_ALL_CPUS ((1 << CONFIG_SMP_NCPUS) - 1)
|
2016-02-20 00:33:35 +01:00
|
|
|
|
2008-01-09 02:13:24 +01:00
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2008-01-09 02:13:24 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-09 02:13:24 +01:00
|
|
|
/* Task Lists ***************************************************************/
|
2019-06-30 18:35:10 +02:00
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* The state of a task is indicated both by the task_state field of the TCB
|
|
|
|
* and by a series of task lists. All of these tasks lists are declared
|
|
|
|
* below. Although it is not always necessary, most of these lists are
|
|
|
|
* prioritized so that common list handling logic can be used (only the
|
2016-02-10 18:45:26 +01:00
|
|
|
* g_readytorun, the g_pendingtasks, and the g_waitingforsemaphore lists
|
|
|
|
* need to be prioritized).
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2016-02-10 18:45:26 +01:00
|
|
|
/* This is the list of all tasks that are ready to run. This is a
|
|
|
|
* prioritized list with head of the list holding the highest priority
|
2017-08-15 01:19:27 +02:00
|
|
|
* (unassigned) task. In the non-SMP case, the head of this list is the
|
2016-02-10 18:45:26 +01:00
|
|
|
* currently active task and the tail of this list, the lowest priority
|
|
|
|
* task, is always the IDLE task.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_readytorun;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-10 18:45:26 +01:00
|
|
|
/* In order to support SMP, the function of the g_readytorun list changes,
|
2017-08-15 01:19:27 +02:00
|
|
|
* The g_readytorun is still used but in the SMP case it will contain only:
|
2016-02-10 18:45:26 +01:00
|
|
|
*
|
|
|
|
* - Only tasks/threads that are eligible to run, but not currently running,
|
|
|
|
* and
|
|
|
|
* - Tasks/threads that have not been assigned to a CPU.
|
|
|
|
*
|
2018-01-13 22:38:55 +01:00
|
|
|
* Otherwise, the TCB will be retained in an assigned task list,
|
2016-02-10 18:45:26 +01:00
|
|
|
* g_assignedtasks. As its name suggests, on 'g_assignedtasks queue for CPU
|
|
|
|
* 'n' would contain only tasks/threads that are assigned to CPU 'n'. Tasks/
|
|
|
|
* threads would be assigned a particular CPU by one of two mechanisms:
|
|
|
|
*
|
|
|
|
* - (Semi-)permanently through an RTOS interfaces such as
|
|
|
|
* pthread_attr_setaffinity(), or
|
|
|
|
* - Temporarily through scheduling logic when a previously unassigned task
|
|
|
|
* is made to run.
|
|
|
|
*
|
|
|
|
* Tasks/threads that are assigned to a CPU via an interface like
|
|
|
|
* pthread_attr_setaffinity() would never go into the g_readytorun list, but
|
|
|
|
* would only go into the g_assignedtasks[n] list for the CPU 'n' to which
|
|
|
|
* the thread has been assigned. Hence, the g_readytorun list would hold
|
|
|
|
* only unassigned tasks/threads.
|
|
|
|
*
|
|
|
|
* Like the g_readytorun list in in non-SMP case, each g_assignedtask[] list
|
|
|
|
* is prioritized: The head of the list is the currently active task on this
|
|
|
|
* CPU. Tasks after the active task are ready-to-run and assigned to this
|
|
|
|
* CPU. The tail of this assigned task list, the lowest priority task, is
|
|
|
|
* always the CPU's IDLE task.
|
|
|
|
*/
|
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
#ifdef CONFIG_SMP
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_assignedtasks[CONFIG_SMP_NCPUS];
|
2021-07-10 03:01:20 +02:00
|
|
|
#endif
|
2018-11-15 14:11:51 +01:00
|
|
|
|
|
|
|
/* g_running_tasks[] holds a references to the running task for each cpu.
|
|
|
|
* It is valid only when up_interrupt_context() returns true.
|
|
|
|
*/
|
|
|
|
|
|
|
|
FAR struct tcb_s *g_running_tasks[CONFIG_SMP_NCPUS];
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* This is the list of all tasks that are ready-to-run, but cannot be placed
|
|
|
|
* in the g_readytorun list because: (1) They are higher priority than the
|
|
|
|
* currently active task at the head of the g_readytorun list, and (2) the
|
|
|
|
* currently active task has disabled pre-emption.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_pendingtasks;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* This is the list of all tasks that are blocked waiting for a signal */
|
|
|
|
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_waitingforsignal;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-08-29 21:09:00 +02:00
|
|
|
#ifdef CONFIG_PAGING
|
2010-08-14 03:56:13 +02:00
|
|
|
/* This is the list of all tasks that are blocking waiting for a page fill */
|
|
|
|
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_waitingforfill;
|
2010-08-14 03:56:13 +02:00
|
|
|
#endif
|
|
|
|
|
2018-08-30 18:27:18 +02:00
|
|
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
2020-04-09 14:46:24 +02:00
|
|
|
/* This is the list of all tasks that have been stopped
|
2020-10-29 05:53:41 +01:00
|
|
|
* via SIGSTOP or SIGTSTP
|
2020-04-09 14:46:24 +02:00
|
|
|
*/
|
2018-08-30 18:27:18 +02:00
|
|
|
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_stoppedtasks;
|
2018-08-30 18:27:18 +02:00
|
|
|
#endif
|
|
|
|
|
2023-07-03 13:24:13 +02:00
|
|
|
/* This list of all tasks that have been initialized, but not yet
|
2007-02-18 00:21:28 +01:00
|
|
|
* activated. NOTE: This is the only list that is not prioritized.
|
|
|
|
*/
|
|
|
|
|
2022-08-29 10:39:43 +02:00
|
|
|
dq_queue_t g_inactivetasks;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* This is the value of the last process ID assigned to a task */
|
|
|
|
|
2007-03-14 19:58:21 +01:00
|
|
|
volatile pid_t g_lastpid;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* The following hash table is used for two things:
|
2007-03-01 22:05:55 +01:00
|
|
|
*
|
2016-02-11 15:06:33 +01:00
|
|
|
* 1. This hash table greatly speeds the determination of a new unique
|
|
|
|
* process ID for a task, and
|
2007-02-18 00:21:28 +01:00
|
|
|
* 2. Is used to quickly map a process ID into a TCB.
|
|
|
|
*/
|
|
|
|
|
2021-10-14 05:03:07 +02:00
|
|
|
FAR struct tcb_s **g_pidhash;
|
2021-06-15 10:45:40 +02:00
|
|
|
volatile int g_npidhash;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2023-07-03 13:24:13 +02:00
|
|
|
/* This is a table of task lists. This table is indexed by the task state
|
2016-02-11 15:06:33 +01:00
|
|
|
* enumeration type (tstate_t) and provides a pointer to the associated
|
2023-07-03 13:24:13 +02:00
|
|
|
* static task list (if there is one) as well as a set of attribute flags
|
2018-01-13 15:34:58 +01:00
|
|
|
* indicating properties of the list, for example, if the list is an
|
2016-02-11 15:06:33 +01:00
|
|
|
* ordered list or not.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2014-08-08 23:30:59 +02:00
|
|
|
const struct tasklist_s g_tasklisttable[NUM_TASK_STATES] =
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2016-02-11 15:06:33 +01:00
|
|
|
{ /* TSTATE_TASK_INVALID */
|
|
|
|
NULL,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{ /* TSTATE_TASK_PENDING */
|
|
|
|
&g_pendingtasks,
|
|
|
|
TLIST_ATTR_PRIORITIZED
|
|
|
|
},
|
2016-02-12 15:15:16 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2016-02-11 15:06:33 +01:00
|
|
|
{ /* TSTATE_TASK_READYTORUN */
|
|
|
|
&g_readytorun,
|
|
|
|
TLIST_ATTR_PRIORITIZED
|
|
|
|
},
|
|
|
|
{ /* TSTATE_TASK_ASSIGNED */
|
|
|
|
g_assignedtasks,
|
2016-02-12 15:15:16 +01:00
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_INDEXED | TLIST_ATTR_RUNNABLE
|
2016-02-11 15:06:33 +01:00
|
|
|
},
|
|
|
|
{ /* TSTATE_TASK_RUNNING */
|
|
|
|
g_assignedtasks,
|
2016-02-12 15:15:16 +01:00
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_INDEXED | TLIST_ATTR_RUNNABLE
|
2016-02-11 15:06:33 +01:00
|
|
|
},
|
|
|
|
#else
|
2016-02-12 15:15:16 +01:00
|
|
|
{ /* TSTATE_TASK_READYTORUN */
|
|
|
|
&g_readytorun,
|
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE
|
|
|
|
},
|
2016-02-11 15:06:33 +01:00
|
|
|
{ /* TSTATE_TASK_RUNNING */
|
|
|
|
&g_readytorun,
|
2016-02-12 15:15:16 +01:00
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE
|
2016-02-11 15:06:33 +01:00
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{ /* TSTATE_TASK_INACTIVE */
|
|
|
|
&g_inactivetasks,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{ /* TSTATE_WAIT_SEM */
|
2022-09-19 12:17:14 +02:00
|
|
|
(FAR void *)offsetof(sem_t, waitlist),
|
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_OFFSET
|
2019-04-29 22:52:05 +02:00
|
|
|
},
|
2016-02-11 15:06:33 +01:00
|
|
|
{ /* TSTATE_WAIT_SIG */
|
|
|
|
&g_waitingforsignal,
|
|
|
|
0
|
|
|
|
}
|
2007-03-01 00:45:56 +01:00
|
|
|
#ifndef CONFIG_DISABLE_MQUEUE
|
2010-08-17 03:37:39 +02:00
|
|
|
,
|
2016-02-11 15:06:33 +01:00
|
|
|
{ /* TSTATE_WAIT_MQNOTEMPTY */
|
2022-10-17 09:49:16 +02:00
|
|
|
(FAR void *)offsetof(struct mqueue_inode_s, cmn.waitfornotempty),
|
2022-09-09 08:26:43 +02:00
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_OFFSET
|
2016-02-11 15:06:33 +01:00
|
|
|
},
|
|
|
|
{ /* TSTATE_WAIT_MQNOTFULL */
|
2022-10-17 09:49:16 +02:00
|
|
|
(FAR void *)offsetof(struct mqueue_inode_s, cmn.waitfornotfull),
|
2022-09-09 08:26:43 +02:00
|
|
|
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_OFFSET
|
2016-02-11 15:06:33 +01:00
|
|
|
}
|
2007-03-01 00:45:56 +01:00
|
|
|
#endif
|
2010-08-14 03:56:13 +02:00
|
|
|
#ifdef CONFIG_PAGING
|
2010-08-17 03:37:39 +02:00
|
|
|
,
|
2016-02-11 15:06:33 +01:00
|
|
|
{ /* TSTATE_WAIT_PAGEFILL */
|
|
|
|
&g_waitingforfill,
|
|
|
|
TLIST_ATTR_PRIORITIZED
|
|
|
|
}
|
2010-08-14 03:56:13 +02:00
|
|
|
#endif
|
2018-08-30 18:27:18 +02:00
|
|
|
#ifdef CONFIG_SIG_SIGSTOP_ACTION
|
|
|
|
,
|
|
|
|
{ /* TSTATE_TASK_STOPPED */
|
|
|
|
&g_stoppedtasks,
|
|
|
|
0 /* See tcb->prev_state */
|
|
|
|
},
|
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
|
2016-02-05 15:34:03 +01:00
|
|
|
/* This is the current initialization state. The level of initialization
|
|
|
|
* is only important early in the start-up sequence when certain OS or
|
|
|
|
* hardware resources may not yet be available to the kernel logic.
|
|
|
|
*/
|
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
uint8_t g_nx_initstate; /* See enum nx_initstate_e */
|
2016-02-05 15:34:03 +01:00
|
|
|
|
2008-01-09 02:13:24 +01:00
|
|
|
/****************************************************************************
|
2016-02-13 16:04:54 +01:00
|
|
|
* Private Data
|
2008-01-09 02:13:24 +01:00
|
|
|
****************************************************************************/
|
2019-11-09 15:15:12 +01:00
|
|
|
|
2018-01-13 15:34:58 +01:00
|
|
|
/* This is an array of task control block (TCB) for the IDLE thread of each
|
2016-02-13 16:04:54 +01:00
|
|
|
* CPU. For the non-SMP case, this is a a single TCB; For the SMP case,
|
|
|
|
* there is one TCB per CPU. NOTE: The system boots on CPU0 into the IDLE
|
|
|
|
* task. The IDLE task later starts the other CPUs and spawns the user
|
|
|
|
* initialization task. That user initialization task is responsible for
|
|
|
|
* bringing up the rest of the system.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
static struct task_tcb_s g_idletcb[CONFIG_SMP_NCPUS];
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-01 22:05:55 +01:00
|
|
|
/* This is the name of the idle task */
|
|
|
|
|
2017-08-12 19:24:11 +02:00
|
|
|
#if CONFIG_TASK_NAME_SIZE <= 0 || !defined(CONFIG_SMP)
|
2023-07-03 13:24:13 +02:00
|
|
|
# ifdef CONFIG_SMP
|
2016-02-13 16:04:54 +01:00
|
|
|
static const char g_idlename[] = "CPU Idle";
|
2023-07-03 13:24:13 +02:00
|
|
|
# else
|
2016-02-11 19:18:54 +01:00
|
|
|
static const char g_idlename[] = "Idle Task";
|
2023-07-03 13:24:13 +02:00
|
|
|
# endif
|
2017-08-12 19:24:11 +02:00
|
|
|
#endif
|
2007-03-01 22:05:55 +01:00
|
|
|
|
2023-07-03 13:24:13 +02:00
|
|
|
/* This is IDLE threads argument list. NOTE: Normally the argument
|
2016-02-13 16:04:54 +01:00
|
|
|
* list is created on the stack prior to starting the task. We have to
|
2023-07-03 13:24:13 +02:00
|
|
|
* do things little differently here for the IDLE tasks.
|
2016-02-13 16:04:54 +01:00
|
|
|
*/
|
2014-09-02 00:49:42 +02:00
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
static FAR char *g_idleargv[CONFIG_SMP_NCPUS][2];
|
2014-09-02 00:49:42 +02:00
|
|
|
|
2008-01-09 02:13:24 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Functions
|
2008-01-09 02:13:24 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-09 02:13:24 +01:00
|
|
|
/****************************************************************************
|
2019-02-04 23:20:35 +01:00
|
|
|
* Name: nx_start
|
2012-07-14 21:30:31 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function is called to initialize the operating system and to spawn
|
2014-08-08 23:30:59 +02:00
|
|
|
* the user initialization thread of execution. This is the initial entry
|
2023-07-03 13:24:13 +02:00
|
|
|
* point into NuttX.
|
2014-08-08 23:30:59 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2014-08-08 23:30:59 +02:00
|
|
|
* Does not return.
|
2012-07-14 21:30:31 +02:00
|
|
|
*
|
2008-01-09 02:13:24 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
void nx_start(void)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2016-06-20 19:59:15 +02:00
|
|
|
sinfo("Entry\n");
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-05 15:34:03 +01:00
|
|
|
/* Boot up is complete */
|
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
g_nx_initstate = OSINIT_BOOT;
|
2016-02-05 15:34:03 +01:00
|
|
|
|
2013-03-12 22:53:18 +01:00
|
|
|
/* Initialize RTOS Data ***************************************************/
|
2019-06-30 18:35:10 +02:00
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
/* Initialize the IDLE task TCB *******************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
|
2016-02-13 16:04:54 +01:00
|
|
|
{
|
|
|
|
FAR dq_queue_t *tasklist;
|
2016-02-11 15:06:33 +01:00
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
/* Initialize a TCB for this thread of execution. NOTE: The default
|
|
|
|
* value for most components of the g_idletcb are zero. The entire
|
|
|
|
* structure is set to zero. Then only the (potentially) non-zero
|
|
|
|
* elements are initialized. NOTE: The idle task is the only task in
|
|
|
|
* that has pid == 0 and sched_priority == 0.
|
|
|
|
*/
|
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
memset((void *)&g_idletcb[i], 0, sizeof(struct task_tcb_s));
|
|
|
|
g_idletcb[i].cmn.pid = i;
|
|
|
|
g_idletcb[i].cmn.task_state = TSTATE_TASK_RUNNING;
|
2016-02-13 16:04:54 +01:00
|
|
|
|
|
|
|
/* Set the entry point. This is only for debug purposes. NOTE: that
|
|
|
|
* the start_t entry point is not saved. That is acceptable, however,
|
2020-02-23 09:50:23 +01:00
|
|
|
* because it can be used only for restarting a task: The IDLE task
|
2016-02-13 16:04:54 +01:00
|
|
|
* cannot be restarted.
|
|
|
|
*/
|
2016-02-11 15:06:33 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
2021-07-10 03:01:20 +02:00
|
|
|
if (i > 0)
|
2016-02-13 16:04:54 +01:00
|
|
|
{
|
2021-07-10 03:01:20 +02:00
|
|
|
g_idletcb[i].cmn.start = nx_idle_trampoline;
|
|
|
|
g_idletcb[i].cmn.entry.main = (main_t)nx_idle_trampoline;
|
2016-02-13 16:04:54 +01:00
|
|
|
}
|
|
|
|
else
|
2016-02-16 23:43:19 +01:00
|
|
|
#endif
|
2016-02-13 16:04:54 +01:00
|
|
|
{
|
2021-07-10 03:01:20 +02:00
|
|
|
g_idletcb[i].cmn.start = nx_start;
|
|
|
|
g_idletcb[i].cmn.entry.main = (main_t)nx_start;
|
2016-02-13 16:04:54 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
/* Set the task flags to indicate that this is a kernel thread and, if
|
2016-02-20 00:33:35 +01:00
|
|
|
* configured for SMP, that this task is locked to this CPU.
|
2016-02-13 16:04:54 +01:00
|
|
|
*/
|
2013-03-22 00:37:11 +01:00
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2021-07-10 03:01:20 +02:00
|
|
|
g_idletcb[i].cmn.flags = (TCB_FLAG_TTYPE_KERNEL |
|
|
|
|
TCB_FLAG_NONCANCELABLE |
|
|
|
|
TCB_FLAG_CPU_LOCKED);
|
|
|
|
g_idletcb[i].cmn.cpu = i;
|
2013-03-22 00:37:11 +01:00
|
|
|
|
2016-02-20 00:33:35 +01:00
|
|
|
/* Set the affinity mask to allow the thread to run on all CPUs. No,
|
|
|
|
* this IDLE thread can only run on its assigned CPU. That is
|
|
|
|
* enforced by the TCB_FLAG_CPU_LOCKED which overrides the affinity
|
|
|
|
* mask. This is essential because all tasks inherit the affinity
|
|
|
|
* mask from their parent and, ultimately, the parent of all tasks is
|
|
|
|
* the IDLE task.
|
|
|
|
*/
|
|
|
|
|
2023-04-19 05:00:57 +02:00
|
|
|
g_idletcb[i].cmn.affinity =
|
|
|
|
(cpu_set_t)(CONFIG_SMP_DEFAULT_CPUSET & SCHED_ALL_CPUS);
|
2021-07-15 13:46:07 +02:00
|
|
|
#else
|
|
|
|
g_idletcb[i].cmn.flags = (TCB_FLAG_TTYPE_KERNEL |
|
|
|
|
TCB_FLAG_NONCANCELABLE);
|
2016-02-20 00:33:35 +01:00
|
|
|
#endif
|
2016-02-13 16:04:54 +01:00
|
|
|
|
|
|
|
#if CONFIG_TASK_NAME_SIZE > 0
|
2016-02-20 00:33:35 +01:00
|
|
|
/* Set the IDLE task name */
|
|
|
|
|
2016-02-13 16:04:54 +01:00
|
|
|
# ifdef CONFIG_SMP
|
2021-07-10 03:01:20 +02:00
|
|
|
snprintf(g_idletcb[i].cmn.name, CONFIG_TASK_NAME_SIZE, "CPU%d IDLE",
|
|
|
|
i);
|
2016-02-13 16:04:54 +01:00
|
|
|
# else
|
2022-03-06 12:58:44 +01:00
|
|
|
strlcpy(g_idletcb[i].cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE);
|
2016-02-13 16:04:54 +01:00
|
|
|
# endif
|
|
|
|
|
|
|
|
/* Configure the task name in the argument list. The IDLE task does
|
|
|
|
* not really have an argument list, but this name is still useful
|
|
|
|
* for things like the NSH PS command.
|
|
|
|
*
|
|
|
|
* In the kernel mode build, the arguments are saved on the task's
|
|
|
|
* stack and there is no support that yet.
|
|
|
|
*/
|
2013-03-22 00:37:11 +01:00
|
|
|
|
2022-03-12 05:07:33 +01:00
|
|
|
g_idleargv[i][0] = g_idletcb[i].cmn.name;
|
2007-02-18 00:21:28 +01:00
|
|
|
#else
|
2022-03-12 05:07:33 +01:00
|
|
|
g_idleargv[i][0] = (FAR char *)g_idlename;
|
2007-02-18 00:21:28 +01:00
|
|
|
#endif /* CONFIG_TASK_NAME_SIZE */
|
|
|
|
|
2019-08-04 22:50:28 +02:00
|
|
|
/* Then add the idle task's TCB to the head of the current ready to
|
2016-02-13 16:04:54 +01:00
|
|
|
* run list.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-10 22:43:05 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2022-09-19 12:17:14 +02:00
|
|
|
tasklist = TLIST_HEAD(&g_idletcb[i].cmn, i);
|
2016-02-10 22:43:05 +01:00
|
|
|
#else
|
2022-09-19 12:17:14 +02:00
|
|
|
tasklist = TLIST_HEAD(&g_idletcb[i].cmn);
|
2016-02-10 22:43:05 +01:00
|
|
|
#endif
|
2021-07-10 03:01:20 +02:00
|
|
|
dq_addfirst((FAR dq_entry_t *)&g_idletcb[i], tasklist);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-11-15 14:11:51 +01:00
|
|
|
/* Mark the idle task as the running task */
|
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
g_running_tasks[i] = &g_idletcb[i].cmn;
|
2016-02-13 16:04:54 +01:00
|
|
|
}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-05-18 16:21:28 +02:00
|
|
|
/* Task lists are initialized */
|
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
g_nx_initstate = OSINIT_TASKLISTS;
|
2016-05-18 16:21:28 +02:00
|
|
|
|
2013-03-12 22:53:18 +01:00
|
|
|
/* Initialize RTOS facilities *********************************************/
|
2019-02-19 00:36:11 +01:00
|
|
|
|
2014-09-29 14:50:48 +02:00
|
|
|
/* Initialize the semaphore facility. This has to be done very early
|
|
|
|
* because many subsystems depend upon fully functional semaphores.
|
2012-08-26 23:35:14 +02:00
|
|
|
*/
|
|
|
|
|
2017-10-03 20:51:15 +02:00
|
|
|
nxsem_initialize();
|
2012-08-26 23:35:14 +02:00
|
|
|
|
2020-05-07 21:06:05 +02:00
|
|
|
#if defined(MM_KERNEL_USRHEAP_INIT) || defined(CONFIG_MM_KERNEL_HEAP) || \
|
|
|
|
defined(CONFIG_MM_PGALLOC)
|
2007-02-18 00:21:28 +01:00
|
|
|
/* Initialize the memory manager */
|
|
|
|
|
2020-03-09 14:07:59 +01:00
|
|
|
{
|
|
|
|
FAR void *heap_start;
|
|
|
|
size_t heap_size;
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2014-09-02 19:22:09 +02:00
|
|
|
#ifdef MM_KERNEL_USRHEAP_INIT
|
2020-03-09 14:07:59 +01:00
|
|
|
/* Get the user-mode heap from the platform specific code and configure
|
|
|
|
* the user-mode memory allocator.
|
|
|
|
*/
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2020-03-09 14:07:59 +01:00
|
|
|
up_allocate_heap(&heap_start, &heap_size);
|
|
|
|
kumm_initialize(heap_start, heap_size);
|
2014-08-31 20:50:05 +02:00
|
|
|
#endif
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2014-08-31 20:50:05 +02:00
|
|
|
#ifdef CONFIG_MM_KERNEL_HEAP
|
2020-03-09 14:07:59 +01:00
|
|
|
/* Get the kernel-mode heap from the platform specific code and
|
|
|
|
* configure the kernel-mode memory allocator.
|
|
|
|
*/
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2020-03-09 14:07:59 +01:00
|
|
|
up_allocate_kheap(&heap_start, &heap_size);
|
|
|
|
kmm_initialize(heap_start, heap_size);
|
2007-02-18 00:21:28 +01:00
|
|
|
#endif
|
2014-08-25 19:18:32 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_MM_PGALLOC
|
2020-03-09 14:07:59 +01:00
|
|
|
/* If there is a page allocator in the configuration, then get the page
|
|
|
|
* heap information from the platform-specific code and configure the
|
|
|
|
* page allocator.
|
|
|
|
*/
|
2014-08-25 19:18:32 +02:00
|
|
|
|
2020-03-09 14:07:59 +01:00
|
|
|
up_allocate_pgheap(&heap_start, &heap_size);
|
|
|
|
mm_pginitialize(heap_start, heap_size);
|
2014-08-25 19:18:32 +02:00
|
|
|
#endif
|
2020-03-09 14:07:59 +01:00
|
|
|
}
|
2020-05-07 21:06:05 +02:00
|
|
|
#endif
|
2020-04-29 21:21:23 +02:00
|
|
|
|
2023-04-13 15:25:22 +02:00
|
|
|
#ifdef CONFIG_MM_KMAP
|
|
|
|
/* Initialize the kernel dynamic mapping module */
|
|
|
|
|
|
|
|
kmm_map_initialize();
|
|
|
|
#endif
|
|
|
|
|
2021-06-25 16:07:23 +02:00
|
|
|
#ifdef CONFIG_ARCH_HAVE_EXTRA_HEAPS
|
|
|
|
/* Initialize any extra heap. */
|
|
|
|
|
|
|
|
up_extraheaps_init();
|
2014-11-25 21:10:35 +01:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2020-02-17 18:08:08 +01:00
|
|
|
#ifdef CONFIG_MM_IOB
|
|
|
|
/* Initialize IO buffering */
|
|
|
|
|
|
|
|
iob_initialize();
|
|
|
|
#endif
|
|
|
|
|
2021-06-15 10:45:40 +02:00
|
|
|
/* Initialize the logic that determine unique process IDs. */
|
|
|
|
|
|
|
|
g_npidhash = 4;
|
|
|
|
while (g_npidhash <= CONFIG_SMP_NCPUS)
|
|
|
|
{
|
|
|
|
g_npidhash <<= 1;
|
|
|
|
}
|
|
|
|
|
2021-10-14 05:03:07 +02:00
|
|
|
g_pidhash = kmm_zalloc(sizeof(*g_pidhash) * g_npidhash);
|
2021-06-15 10:45:40 +02:00
|
|
|
DEBUGASSERT(g_pidhash);
|
|
|
|
|
2021-07-15 12:25:48 +02:00
|
|
|
/* IDLE Group Initialization **********************************************/
|
|
|
|
|
2021-06-15 10:45:40 +02:00
|
|
|
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
|
|
|
|
{
|
|
|
|
int hashndx;
|
|
|
|
|
|
|
|
/* Assign the process ID(s) of ZERO to the idle task(s) */
|
|
|
|
|
2021-10-14 05:03:07 +02:00
|
|
|
hashndx = PIDHASH(i);
|
|
|
|
g_pidhash[hashndx] = &g_idletcb[i].cmn;
|
2021-07-15 12:25:48 +02:00
|
|
|
|
|
|
|
/* Allocate the IDLE group */
|
|
|
|
|
|
|
|
DEBUGVERIFY(group_allocate(&g_idletcb[i], g_idletcb[i].cmn.flags));
|
2021-11-29 04:00:27 +01:00
|
|
|
g_idletcb[i].cmn.group->tg_info->argv = &g_idleargv[i][0];
|
2021-07-15 12:25:48 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Create a stack for all CPU IDLE threads (except CPU0 which already
|
|
|
|
* has a stack).
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
{
|
|
|
|
DEBUGVERIFY(up_cpu_idlestack(i, &g_idletcb[i].cmn,
|
|
|
|
CONFIG_IDLETHREAD_STACKSIZE));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initialize the processor-specific portion of the TCB */
|
|
|
|
|
|
|
|
up_initial_state(&g_idletcb[i].cmn);
|
|
|
|
|
2022-06-05 16:18:05 +02:00
|
|
|
/* Initialize the thread local storage */
|
2021-07-15 12:25:48 +02:00
|
|
|
|
2022-06-05 16:18:05 +02:00
|
|
|
tls_init_info(&g_idletcb[i].cmn);
|
2021-07-15 12:25:48 +02:00
|
|
|
|
|
|
|
/* Complete initialization of the IDLE group. Suppress retention
|
|
|
|
* of child status in the IDLE group.
|
|
|
|
*/
|
|
|
|
|
2022-03-01 19:24:05 +01:00
|
|
|
group_initialize(&g_idletcb[i]);
|
2022-02-23 11:23:21 +01:00
|
|
|
g_idletcb[i].cmn.group->tg_flags = GROUP_FLAG_NOCLDWAIT |
|
|
|
|
GROUP_FLAG_PRIVILEGED;
|
2021-06-15 10:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
g_lastpid = CONFIG_SMP_NCPUS - 1;
|
|
|
|
|
2016-02-05 15:34:03 +01:00
|
|
|
/* The memory manager is available */
|
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
g_nx_initstate = OSINIT_MEMORY;
|
2016-02-05 15:34:03 +01:00
|
|
|
|
2013-01-23 00:42:51 +01:00
|
|
|
/* Initialize tasking data structures */
|
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
task_initialize();
|
2013-01-23 00:42:51 +01:00
|
|
|
|
2022-08-07 15:20:07 +02:00
|
|
|
/* Disables context switching because we need take the memory manager
|
2022-02-25 11:44:07 +01:00
|
|
|
* semaphore on this CPU so that it will not be available on the other
|
|
|
|
* CPUs until we have finished initialization.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sched_lock();
|
|
|
|
|
2020-09-17 06:49:02 +02:00
|
|
|
/* Initialize the file system (needed to support device drivers) */
|
|
|
|
|
|
|
|
fs_initialize();
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* Initialize the interrupt handling subsystem (if included) */
|
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
irq_initialize();
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Initialize the POSIX timer facility (if included in the link) */
|
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
clock_initialize();
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-21 18:21:26 +01:00
|
|
|
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
2022-08-16 06:20:39 +02:00
|
|
|
timer_initialize();
|
2007-03-21 18:21:26 +01:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Initialize the signal facility (if in link) */
|
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
nxsig_initialize();
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2022-11-16 11:20:31 +01:00
|
|
|
#if !defined(CONFIG_DISABLE_MQUEUE) || !defined(CONFIG_DISABLE_MQUEUE_SYSV)
|
2007-02-18 00:21:28 +01:00
|
|
|
/* Initialize the named message queue facility (if in link) */
|
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
nxmq_initialize();
|
2007-03-01 00:45:56 +01:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2022-10-19 16:28:43 +02:00
|
|
|
#ifndef CONFIG_DISABLE_MQUEUE_SYSV
|
|
|
|
/* Initialize the System V message queue facility (if in link) */
|
|
|
|
|
|
|
|
nxmsg_initialize();
|
|
|
|
#endif
|
|
|
|
|
2015-02-14 01:32:15 +01:00
|
|
|
#ifdef CONFIG_NET
|
2018-11-09 20:54:55 +01:00
|
|
|
/* Initialize the networking system */
|
2015-02-14 01:32:15 +01:00
|
|
|
|
2018-11-09 20:54:55 +01:00
|
|
|
net_initialize();
|
2015-02-14 01:32:15 +01:00
|
|
|
#endif
|
|
|
|
|
2022-03-11 21:10:24 +01:00
|
|
|
#ifndef CONFIG_BINFMT_DISABLE
|
|
|
|
/* Initialize the binfmt system */
|
|
|
|
|
|
|
|
binfmt_initialize();
|
|
|
|
#endif
|
|
|
|
|
2019-02-19 00:36:11 +01:00
|
|
|
/* Initialize Hardware Facilities *****************************************/
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* The processor specific details of running the operating system
|
|
|
|
* will be handled here. Such things as setting up interrupt
|
|
|
|
* service routines and starting the clock are some of the things
|
|
|
|
* that are different for each processor and hardware platform.
|
|
|
|
*/
|
|
|
|
|
|
|
|
up_initialize();
|
2022-04-11 13:44:26 +02:00
|
|
|
|
|
|
|
/* Initialize common drivers */
|
|
|
|
|
|
|
|
drivers_initialize();
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2019-02-18 23:25:08 +01:00
|
|
|
#ifdef CONFIG_BOARD_EARLY_INITIALIZE
|
2019-02-18 22:32:00 +01:00
|
|
|
/* Call the board-specific up_initialize() extension to support
|
|
|
|
* early initialization of board-specific drivers and resources
|
|
|
|
* that cannot wait until board_late_initialize.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 23:25:08 +01:00
|
|
|
board_early_initialize();
|
2019-02-18 22:32:00 +01:00
|
|
|
#endif
|
|
|
|
|
2019-02-18 23:25:08 +01:00
|
|
|
/* Hardware resources are now available */
|
2016-02-05 15:34:03 +01:00
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
g_nx_initstate = OSINIT_HARDWARE;
|
2016-02-05 15:34:03 +01:00
|
|
|
|
2019-02-19 00:36:11 +01:00
|
|
|
/* Setup for Multi-Tasking ************************************************/
|
|
|
|
|
2016-03-17 16:49:43 +01:00
|
|
|
/* Announce that the CPU0 IDLE task has started */
|
|
|
|
|
|
|
|
sched_note_start(&g_idletcb[0].cmn);
|
2016-02-13 16:04:54 +01:00
|
|
|
|
2021-07-15 12:25:48 +02:00
|
|
|
/* Initialize stdio for the IDLE task of each CPU */
|
2016-03-17 16:49:43 +01:00
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
|
2016-02-13 16:04:54 +01:00
|
|
|
{
|
2021-07-10 03:01:20 +02:00
|
|
|
if (i > 0)
|
2016-02-13 16:04:54 +01:00
|
|
|
{
|
|
|
|
/* Clone stdout, stderr, stdin from the CPU0 IDLE task. */
|
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
DEBUGVERIFY(group_setuptaskfiles(&g_idletcb[i]));
|
2016-02-13 16:04:54 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Create stdout, stderr, stdin on the CPU0 IDLE task. These
|
|
|
|
* will be inherited by all of the threads created by the CPU0
|
|
|
|
* IDLE task.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2021-07-10 03:01:20 +02:00
|
|
|
DEBUGVERIFY(group_setupidlefiles(&g_idletcb[i]));
|
2016-02-13 16:04:54 +01:00
|
|
|
}
|
2016-06-21 15:52:24 +02:00
|
|
|
}
|
|
|
|
|
2016-02-10 20:49:27 +01:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Start all CPUs *********************************************************/
|
|
|
|
|
2016-02-15 18:07:42 +01:00
|
|
|
/* A few basic sanity checks */
|
|
|
|
|
2021-06-15 10:45:40 +02:00
|
|
|
DEBUGASSERT(this_cpu() == 0);
|
2016-02-15 18:07:42 +01:00
|
|
|
|
|
|
|
/* Then start the other CPUs */
|
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
DEBUGVERIFY(nx_smp_start());
|
2016-02-10 20:49:27 +01:00
|
|
|
|
|
|
|
#endif /* CONFIG_SMP */
|
|
|
|
|
2013-03-12 22:53:18 +01:00
|
|
|
/* Bring Up the System ****************************************************/
|
2019-06-30 18:35:10 +02:00
|
|
|
|
2016-02-05 15:34:03 +01:00
|
|
|
/* The OS is fully initialized and we are beginning multi-tasking */
|
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
g_nx_initstate = OSINIT_OSREADY;
|
2016-02-05 15:34:03 +01:00
|
|
|
|
2011-03-12 18:49:47 +01:00
|
|
|
/* Create initial tasks and bring-up the system */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2019-02-04 23:20:35 +01:00
|
|
|
DEBUGVERIFY(nx_bringup());
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2022-02-21 11:14:10 +01:00
|
|
|
/* Enter to idleloop */
|
|
|
|
|
|
|
|
g_nx_initstate = OSINIT_IDLELOOP;
|
|
|
|
|
2021-06-03 14:57:10 +02:00
|
|
|
/* Let other threads have access to the memory manager */
|
|
|
|
|
|
|
|
sched_unlock();
|
|
|
|
|
2013-03-12 22:53:18 +01:00
|
|
|
/* The IDLE Loop **********************************************************/
|
2019-06-30 18:35:10 +02:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* When control is return to this point, the system is idle. */
|
|
|
|
|
2016-06-12 00:42:42 +02:00
|
|
|
sinfo("CPU0: Beginning Idle Loop\n");
|
2015-10-08 03:59:14 +02:00
|
|
|
for (; ; )
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2007-03-14 19:58:21 +01:00
|
|
|
/* Perform any processor-specific idle state operations */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
up_idle();
|
|
|
|
}
|
|
|
|
}
|