summaryrefslogtreecommitdiffstats
path: root/src/include/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/kernel')
-rw-r--r--src/include/kernel/cpu.H18
-rw-r--r--src/include/kernel/cpumgr.H8
-rw-r--r--src/include/kernel/scheduler.H3
-rw-r--r--src/include/kernel/syscalls.H50
-rw-r--r--src/include/kernel/types.h4
5 files changed, 52 insertions, 31 deletions
diff --git a/src/include/kernel/cpu.H b/src/include/kernel/cpu.H
index 420ec8827..ee24bdd64 100644
--- a/src/include/kernel/cpu.H
+++ b/src/include/kernel/cpu.H
@@ -22,7 +22,7 @@
// IBM_PROLOG_END
/** @file cpu.H
* @brief Defines kernel information and functions about CPUs.
- *
+ *
* In this kernel the term CPU refers to a hardware thread (SMT), not core.
*/
#ifndef __KERNEL_CPU_H
@@ -40,6 +40,12 @@ class Scheduler;
/** @struct cpu_t
* @brief Stores per-CPU kernel information.
+ *
+ * @note kernel_stack and master need to be at fixed locations in this
+ * structure due to usages in start.S.
+ *
+ * - kernel_stack is a double-word at cpu_t[0 bytes].
+ * - master is a byte at cpu_t[12 bytes].
*/
struct cpu_t
{
@@ -49,8 +55,14 @@ struct cpu_t
/** ID of the CPU (PIR value) */
cpuid_t cpu;
- /** If the CPU is the master */
- bool master;
+ struct
+ {
+ /** If the CPU is the master */
+ bool master;
+
+ /** Ensure alignment of master attribute for asm code. */
+ uint64_t __reserved_master:24;
+ } PACKED;
/** Pointer to the scheduler for this CPU (may not be unique) */
Scheduler* scheduler;
diff --git a/src/include/kernel/cpumgr.H b/src/include/kernel/cpumgr.H
index e6fb33a77..31759564b 100644
--- a/src/include/kernel/cpumgr.H
+++ b/src/include/kernel/cpumgr.H
@@ -30,14 +30,18 @@ class CpuManager
{
public:
enum { MAXCPUS = KERNEL_MAX_SUPPORTED_CPUS };
-
- /** @fn getCurrentCPU
+
+ /** @fn getCurrentCPU
* Returns a pointer to the current CPU structure by using the
* task structure in SPRG3.
*/
static cpu_t* getCurrentCPU();
static cpu_t* getCpu(size_t i) { return cv_cpus[i]; }
+ /** @brief Return pointer to master CPU object.
+ */
+ static cpu_t* getMasterCPU();
+
static void init();
static void init_slave_smp(cpu_t*);
diff --git a/src/include/kernel/scheduler.H b/src/include/kernel/scheduler.H
index c7a991c45..16861b6e6 100644
--- a/src/include/kernel/scheduler.H
+++ b/src/include/kernel/scheduler.H
@@ -35,12 +35,13 @@ class Scheduler
friend class CpuManager;
void addTask(task_t*);
+ void addTaskMasterCPU(task_t*);
void returnRunnable();
void setNextRunnable();
protected:
- Scheduler() :
+ Scheduler() :
iv_taskList() {};
~Scheduler() {};
diff --git a/src/include/kernel/syscalls.H b/src/include/kernel/syscalls.H
index 47295ecc2..332273a07 100644
--- a/src/include/kernel/syscalls.H
+++ b/src/include/kernel/syscalls.H
@@ -36,62 +36,66 @@ namespace Systemcalls
* These are passed by userspace code via r3 when the sc instruction is
* executed. The kernel performs a case statement to switch to the
* appropriate system call handler.
+ *
+ * @note TASK_MIGRATE_TO_MASTER value must be kept in sync with start.S.
*/
enum SysCalls
{
/** task_yield() */
- TASK_YIELD = 0,
+ TASK_YIELD = 0,
/** task_create() */
- TASK_START,
+ TASK_START = 1,
/** task_end() */
- TASK_END,
+ TASK_END = 2,
+ /** task_affinity_migrate_to_master() */
+ TASK_MIGRATE_TO_MASTER = 3,
/** msgq_create() */
- MSGQ_CREATE,
+ MSGQ_CREATE,
/** msgq_destroy() */
- MSGQ_DESTROY,
+ MSGQ_DESTROY,
/** VFS internal */
- MSGQ_REGISTER_ROOT,
+ MSGQ_REGISTER_ROOT,
/** VFS internal */
- MSGQ_RESOLVE_ROOT,
+ MSGQ_RESOLVE_ROOT,
/** msg_send() */
- MSG_SEND,
+ MSG_SEND,
/** msg_sendrecv() */
- MSG_SENDRECV,
+ MSG_SENDRECV,
/** msg_respond() */
- MSG_RESPOND,
+ MSG_RESPOND,
/** msg_wait() */
- MSG_WAIT,
+ MSG_WAIT,
/** mmio_map() */
- MMIO_MAP,
+ MMIO_MAP,
/** mmio_unmap() */
- MMIO_UNMAP,
+ MMIO_UNMAP,
/** dev_map() */
- DEV_MAP,
+ DEV_MAP,
/** dev_unmap() */
- DEV_UNMAP,
+ DEV_UNMAP,
/** nanosleep() */
- TIME_NANOSLEEP,
+ TIME_NANOSLEEP,
/** futex_wait() */
- FUTEX_WAIT,
+ FUTEX_WAIT,
/** futex_wake() */
- FUTEX_WAKE,
+ FUTEX_WAKE,
/** shutdown() */
- MISC_SHUTDOWN,
+ MISC_SHUTDOWN,
/** cpu_core_type() */
- MISC_CPUCORETYPE,
+ MISC_CPUCORETYPE,
/** cpu_dd_level() */
- MISC_CPUDDLEVEL,
+ MISC_CPUDDLEVEL,
/** mm_alloc_block() */
- MM_ALLOC_BLOCK,
+ MM_ALLOC_BLOCK,
- SYSCALL_MAX
+ SYSCALL_MAX
};
/** @enum SysCalls_FastPath
diff --git a/src/include/kernel/types.h b/src/include/kernel/types.h
index a53dd79e9..7b201b0de 100644
--- a/src/include/kernel/types.h
+++ b/src/include/kernel/types.h
@@ -25,11 +25,11 @@
#include <stdint.h>
-typedef uint16_t tid_t; // This is 16-bit for the VMM mapping of
+typedef uint16_t tid_t; // This is 16-bit for the VMM mapping of
// stacks. See VmmManager.
struct task_t;
-typedef uint64_t cpuid_t;
+typedef uint32_t cpuid_t;
struct cpu_t;
#endif
OpenPOWER on IntegriCloud