SELFOUR-632: implement cores non-architecture dependent structres

This commit is contained in:
amrzar 2016-10-07 14:30:53 +11:00
parent bebfcf6d27
commit 3f9eb7c873
41 changed files with 366 additions and 327 deletions

View file

@ -365,6 +365,7 @@ menu "seL4 System Parameters"
config MAX_NUM_NODES
int "Max number of CPU nodes"
depends on NUM_DOMAINS = 1
range 1 256
default 1
help

View file

@ -28,7 +28,7 @@ static inline word_t PURE
getSyscallArg(word_t i, word_t* ipc_buffer)
{
if (i < n_msgRegisters) {
return getRegister(ksCurThread, msgRegisters[i]);
return getRegister(NODE_STATE(ksCurThread), msgRegisters[i]);
}
assert(ipc_buffer != NULL);

View file

@ -125,7 +125,7 @@ prioPropsFromWord(word_t w)
* thread name is only available if the kernel is built in debug mode.
*/
#ifdef CONFIG_DEBUG_BUILD
#define THREAD_NAME ksCurThread->tcbName
#define THREAD_NAME NODE_STATE(ksCurThread)->tcbName
#else
#define THREAD_NAME ""
#endif
@ -138,9 +138,9 @@ prioPropsFromWord(word_t w)
do { \
printf(ANSI_DARK "<<" ANSI_GREEN "seL4" ANSI_DARK \
" [%s/%d T%p \"%s\" @%lx]: ", \
__func__, __LINE__, ksCurThread, \
__func__, __LINE__, NODE_STATE(ksCurThread), \
THREAD_NAME, \
(word_t)getRestartPC(ksCurThread)); \
(word_t)getRestartPC(NODE_STATE(ksCurThread))); \
printf(__VA_ARGS__); \
printf(">>" ANSI_RESET "\n"); \
} while (0)

View file

@ -11,10 +11,6 @@
#ifndef __ARCH_MACHINE_32_H
#define __ARCH_MACHINE_32_H
#define wordRadix 5
#define wordBits (1 << wordRadix)
#ifndef __ASSEMBLER__
#include <config.h>
#include <stdint.h>
#include <arch/types.h>
@ -22,6 +18,7 @@
#include <arch/machine/hardware.h>
#include <plat/machine/hardware.h>
#include <armv/machine.h>
#include <arch/model/smp.h>
#include <machine/io.h>
#include <mode/machine_pl2.h>
@ -357,6 +354,4 @@ static inline void setACTLR(word_t actlr)
asm volatile ("mcr p15, 0, %0, c1, c0, 1" :: "r"(actlr));
}
#endif /* __ASSEMBLER__ */
#endif /* __ARCH_MACHINE_32_H */

View file

@ -0,0 +1,16 @@
/*
* Copyright 2016, Data61
* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
* ABN 41 687 119 230.
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(D61_GPL)
*/
#pragma once
#define wordRadix 5
#define wordBits (1 << wordRadix)

View file

@ -16,7 +16,6 @@
#include <arch/types.h>
#include <model/statedata.h>
#define NODE_STATE(_state) _state
#define ARCH_NODE_STATE(_state) _state
#define MODE_NODE_STATE(_state) _state
#define NODE_STATE(_state) _state

View file

@ -12,6 +12,7 @@
#include <arch/object/structures.h>
#include <arch/api/types.h>
#include <mode/model/statedata.h>
/** MODIFIES: [*] */
static inline void setHardwareASID(hw_asid_t hw_asid)

View file

@ -13,6 +13,7 @@
#include <config.h>
#include <arch/object/structures.h>
#include <arch/api/types.h>
#include <mode/model/statedata.h>
/** MODIFIES: [*] */
static inline void setHardwareASID(hw_asid_t hw_asid)

View file

@ -17,6 +17,7 @@
#include <api/types.h>
#include <api/syscall.h>
#include <benchmark_track.h>
#include <arch/stack.h>
static inline void
switchToThread_fp(tcb_t *thread, pde_t *pd, pde_t stored_hw_asid)
@ -39,10 +40,10 @@ switchToThread_fp(tcb_t *thread, pde_t *pd, pde_t stored_hw_asid)
x86_write_gs_base(base);
#ifdef CONFIG_BENCHMARK_TRACK_UTILISATION
benchmark_utilisation_switch(ksCurThread, thread);
benchmark_utilisation_switch(NODE_STATE(ksCurThread), thread);
#endif
ksCurThread = thread;
NODE_STATE(ksCurThread) = thread;
}
static inline void
@ -114,10 +115,10 @@ fastpath_restore(word_t badge, word_t msgInfo, tcb_t *cur_thread)
}
#ifdef CONFIG_HARDWARE_DEBUG_API
restore_user_debug_context(ksCurThread);
restore_user_debug_context(NODE_STATE(ksCurThread));
#endif
setKernelEntryStackPointer(ksCurThread);
setKernelEntryStackPointer(NODE_STATE(ksCurThread));
if (likely(hasDefaultSelectors(cur_thread))) {
asm volatile(

View file

@ -15,9 +15,6 @@
#include <arch/machine/cpu_registers.h>
#include <arch/model/smp.h>
#define wordRadix 5
#define wordBits (1 << wordRadix)
/* Get current stack pointer */
static inline void* get_current_esp(void)
{

View file

@ -0,0 +1,16 @@
/*
* Copyright 2016, Data61
* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
* ABN 41 687 119 230.
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(D61_GPL)
*/
#pragma once
#define wordRadix 5
#define wordBits (1 << wordRadix)

View file

@ -11,7 +11,6 @@
#ifndef __ARCH_MACHINE_H
#define __ARCH_MACHINE_H
#include <mode/machine.h>
#include <arch/types.h>
#include <arch/object/structures.h>
#include <arch/machine/hardware.h>
@ -101,39 +100,6 @@ static inline void x86_wrmsr(const uint32_t reg, const uint64_t val)
asm volatile("wrmsr" :: "a"(low), "d"(high), "c"(reg));
}
/** Hardware stack switching on exception/IRQ entry.
*
* We need to tell the CPU where the TCB register context structure is so it
* can push to it on entry.
* @param target_thread The thread we're about to switch to.
*/
tcb_t *ksCurThread;
static inline void
setKernelEntryStackPointer(tcb_t *target_thread)
{
word_t register_context_top;
SMP_COND_STATEMENT(word_t kernel_stack_top);
/* Update both the TSS and the IA32_SYSENTER_ESP MSR, because both are used.
*
* The stack pointer is loaded from the TSS on IRQ and exception entry.
* The IA32_SYSENTER_ESP MSR is used on syscall entry when SYSENTER is used.
*
* For an SMP build, we also have to set the location of the kernel stack for the
* current CPU, because we use per-CPU stacks.
*/
/* save kernel stack pointer for next exception */
SMP_COND_STATEMENT(kernel_stack_top = ((word_t)kernel_stack_alloc[getCurrentCPUIndex()]) + 0xffc);
SMP_COND_STATEMENT(ksCurThread->tcbArch.tcbContext.kernelSP = kernel_stack_top);
register_context_top = (word_t)&target_thread->tcbArch.tcbContext.registers[n_contextRegisters];
tss_ptr_set_esp0(&ARCH_NODE_STATE(x86KStss).tss, register_context_top);
#ifdef CONFIG_HARDWARE_DEBUG_API
x86_wrmsr(IA32_SYSENTER_ESP_MSR, register_context_top);
#endif
}
/* Read different parts of CPUID */
static inline uint32_t x86_cpuid_edx(uint32_t eax, uint32_t ecx)
{

View file

@ -14,8 +14,8 @@
#include <config.h>
#include <arch/types.h>
#include <arch/model/statedata.h>
#include <model/statedata.h>
#include <arch/machine.h>
#if CONFIG_MAX_NUM_NODES > 1
@ -23,27 +23,26 @@
#define PAD_TO_NEXT_CACHE_LN(used) char padding[CONFIG_CACHE_LN_SZ - ((used) % CONFIG_CACHE_LN_SZ)]
typedef struct smpStatedata {
nodeState_t CPU;
PAD_TO_NEXT_CACHE_LN(sizeof(nodeState_t));
archNodeState_t cpu;
nodeState_t system;
PAD_TO_NEXT_CACHE_LN(sizeof(archNodeState_t) + sizeof(nodeState_t));
} smpStatedata_t;
typedef struct cpu_id_mapping {
/* translate actual cpu index to APIC id */
cpu_id_t index_to_cpu_id[CONFIG_MAX_NUM_NODES];
} cpu_id_mapping_t;
extern smpStatedata_t ksSMP[CONFIG_MAX_NUM_NODES] VISIBLE;
extern cpu_id_mapping_t cpu_mapping;
#define NODE_STATE(_state) ksSMP[getCurrentCPUIndex()].CPU._state
#define ARCH_NODE_STATE(_state) ksSMP[getCurrentCPUIndex()].CPU.arch._state
#define MODE_NODE_STATE(_state) ksSMP[getCurrentCPUIndex()].CPU.arch.mode._state
#define ARCH_NODE_STATE(_state) ksSMP[getCurrentCPUIndex()].cpu._state
#define MODE_NODE_STATE(_state) ksSMP[getCurrentCPUIndex()].cpu.mode._state
#define NODE_STATE(_state) ksSMP[getCurrentCPUIndex()].system._state
#else
#define NODE_STATE(_state) _state
#define ARCH_NODE_STATE(_state) _state
#define MODE_NODE_STATE(_state) _state
#define NODE_STATE(_state) _state
#endif /* CONFIG_MAX_NUM_NODES */

View file

@ -0,0 +1,47 @@
/*
* Copyright 2016, Data61
* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
* ABN 41 687 119 230.
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(D61_GPL)
*/
#pragma once
#include <mode/machine.h>
/** Hardware stack switching on exception/IRQ entry.
*
* We need to tell the CPU where the TCB register context structure is so it
* can push to it on entry.
* @param target_thread The thread we're about to switch to.
*/
static inline void
setKernelEntryStackPointer(tcb_t *target_thread)
{
word_t register_context_top;
SMP_COND_STATEMENT(word_t kernel_stack_top);
/* Update both the TSS and the IA32_SYSENTER_ESP MSR, because both are used.
*
* The stack pointer is loaded from the TSS on IRQ and exception entry.
* The IA32_SYSENTER_ESP MSR is used on syscall entry when SYSENTER is used.
*
* For an SMP build, we also have to set the location of the kernel stack for the
* current CPU, because we use per-CPU stacks.
*/
/* save kernel stack pointer for next exception */
SMP_COND_STATEMENT(kernel_stack_top = ((word_t)kernel_stack_alloc[getCurrentCPUIndex()]) + 0xffc);
SMP_COND_STATEMENT(NODE_STATE(ksCurThread)->tcbArch.tcbContext.kernelSP = kernel_stack_top);
register_context_top = (word_t)&target_thread->tcbArch.tcbContext.registers[n_contextRegisters];
tss_ptr_set_esp0(&ARCH_NODE_STATE(x86KStss).tss, register_context_top);
#ifdef CONFIG_HARDWARE_DEBUG_API
x86_wrmsr(IA32_SYSENTER_ESP_MSR, register_context_top);
#endif
}

View file

@ -19,6 +19,7 @@
#include <kernel/cspace.h>
#include <model/statedata.h>
#include <api/debug.h>
#include <mode/machine.h>
#if defined(DEBUG) || defined(CONFIG_BENCHMARK_TRACK_KERNEL_ENTRIES)
#define TRACK_KERNEL_ENTRIES 1
@ -57,7 +58,7 @@ static inline void
benchmark_debug_syscall_start(word_t cptr, word_t msgInfo, word_t syscall)
{
seL4_MessageInfo_t info = messageInfoFromWord_raw(msgInfo);
lookupCapAndSlot_ret_t lu_ret = lookupCapAndSlot(ksCurThread, cptr);
lookupCapAndSlot_ret_t lu_ret = lookupCapAndSlot(NODE_STATE(ksCurThread), cptr);
ksKernelEntry.path = Entry_Syscall;
ksKernelEntry.syscall_no = syscall;
ksKernelEntry.cap_type = cap_get_capType(lu_ret.cap);

View file

@ -66,8 +66,8 @@ static inline void benchmark_utilisation_kentry_stamp(void)
*/
static inline void benchmark_utilisation_finalise(void)
{
/* Add the time between when ksCurThread, and benchmark finalise */
benchmark_utilisation_switch(ksCurThread, ksIdleThread);
/* Add the time between when NODE_STATE(ksCurThread), and benchmark finalise */
benchmark_utilisation_switch(NODE_STATE(ksCurThread), NODE_STATE(ksIdleThread));
benchmark_end_time = ksEnter;
benchmark_log_utilisation_enabled = false;

View file

@ -71,9 +71,9 @@ getBreakpoint_t getBreakpoint(arch_tcb_t *uds, uint16_t bp_num);
void unsetBreakpoint(arch_tcb_t *uds, uint16_t bp_num);
bool_t configureSingleStepping(arch_tcb_t *uc,
uint16_t bp_num,
word_t n_instr,
bool_t is_reply);
uint16_t bp_num,
word_t n_instr,
bool_t is_reply);
static inline bool_t
singleStepFaultCounterReady(arch_tcb_t *uc)

View file

@ -1,36 +1,38 @@
/*
* Copyright 2014, General Dynamics C4 Systems
* Copyright 2016, Data61
* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
* ABN 41 687 119 230.
*
* This software may be distributed and modified according to the terms of
* the GNU General Public License version 2. Note that NO WARRANTY is provided.
* See "LICENSE_GPLv2.txt" for details.
*
* @TAG(GD_GPL)
* @TAG(D61_GPL)
*/
#ifndef __MODEL_STATEDATA_H
#define __MODEL_STATEDATA_H
#pragma once
#include <config.h>
#include <types.h>
#include <object/structures.h>
#include <object/tcb.h>
#include <arch/model/statedata.h>
#include <mode/types.h>
#include <model/smp.h>
#include <arch/machine.h>
#define NUM_READY_QUEUES (CONFIG_NUM_DOMAINS * CONFIG_NUM_PRIORITIES)
NODE_STATE_BEGIN(nodeState)
NODE_STATE_TYPE_DECLARE(archNodeState, arch);
NODE_STATE_DECLARE(tcb_queue_t, ksReadyQueues[NUM_READY_QUEUES]);
NODE_STATE_DECLARE(word_t, ksReadyQueuesL1Bitmap[CONFIG_NUM_DOMAINS]);
NODE_STATE_DECLARE(word_t, ksReadyQueuesL2Bitmap[CONFIG_NUM_DOMAINS][(CONFIG_NUM_PRIORITIES / wordBits) + 1]);
NODE_STATE_DECLARE(tcb_t, *ksCurThread);
NODE_STATE_DECLARE(tcb_t, *ksIdleThread);
NODE_STATE_DECLARE(tcb_t, *ksSchedulerAction);
NODE_STATE_END(nodeState);
#include <arch/machine.h>
#include <arch/model/smp.h>
#include <mode/machine.h>
extern word_t ksNumCPUs VISIBLE;
extern tcb_queue_t ksReadyQueues[] VISIBLE;
extern word_t ksReadyQueuesL1Bitmap[CONFIG_NUM_DOMAINS] VISIBLE;
extern word_t ksReadyQueuesL2Bitmap[CONFIG_NUM_DOMAINS][(CONFIG_NUM_PRIORITIES / wordBits) + 1] VISIBLE;
extern tcb_t *ksCurThread VISIBLE;
extern tcb_t *ksIdleThread VISIBLE;
extern tcb_t *ksSchedulerAction VISIBLE;
extern word_t ksWorkUnitsCompleted;
extern irq_state_t intStateIRQTable[] VISIBLE;
extern cte_t *intStateIRQNode VISIBLE;
@ -47,7 +49,3 @@ extern paddr_t ksUserLogBuffer;
#define SchedulerAction_ResumeCurrentThread ((tcb_t*)0)
#define SchedulerAction_ChooseNewThread ((tcb_t*)~0)
#define NUM_READY_QUEUES (CONFIG_NUM_DOMAINS * CONFIG_NUM_PRIORITIES)
#endif

View file

@ -61,23 +61,23 @@ handleUnknownSyscall(word_t w)
{
#ifdef CONFIG_DEBUG_BUILD
if (w == SysDebugPutChar) {
kernel_putchar(getRegister(ksCurThread, capRegister));
kernel_putchar(getRegister(NODE_STATE(ksCurThread), capRegister));
return EXCEPTION_NONE;
}
if (w == SysDebugHalt) {
printf("Debug halt syscall from user thread %p\n", ksCurThread);
printf("Debug halt syscall from user thread %p\n", NODE_STATE(ksCurThread));
halt();
}
if (w == SysDebugSnapshot) {
printf("Debug snapshot syscall from user thread %p\n", ksCurThread);
printf("Debug snapshot syscall from user thread %p\n", NODE_STATE(ksCurThread));
capDL();
return EXCEPTION_NONE;
}
if (w == SysDebugCapIdentify) {
word_t cptr = getRegister(ksCurThread, capRegister);
lookupCapAndSlot_ret_t lu_ret = lookupCapAndSlot(ksCurThread, cptr);
word_t cptr = getRegister(NODE_STATE(ksCurThread), capRegister);
lookupCapAndSlot_ret_t lu_ret = lookupCapAndSlot(NODE_STATE(ksCurThread), cptr);
word_t cap_type = cap_get_capType(lu_ret.cap);
setRegister(ksCurThread, capRegister, cap_type);
setRegister(NODE_STATE(ksCurThread), capRegister, cap_type);
return EXCEPTION_NONE;
}
@ -86,8 +86,8 @@ handleUnknownSyscall(word_t w)
* then assume the system is completely misconfigured and halt */
const char *name;
word_t len;
word_t cptr = getRegister(ksCurThread, capRegister);
lookupCapAndSlot_ret_t lu_ret = lookupCapAndSlot(ksCurThread, cptr);
word_t cptr = getRegister(NODE_STATE(ksCurThread), capRegister);
lookupCapAndSlot_ret_t lu_ret = lookupCapAndSlot(NODE_STATE(ksCurThread), cptr);
/* ensure we got a TCB cap */
word_t cap_type = cap_get_capType(lu_ret.cap);
if (cap_type != cap_thread_cap) {
@ -95,7 +95,7 @@ handleUnknownSyscall(word_t w)
halt();
}
/* Add 1 to the IPC buffer to skip the message info word */
name = (const char*)(lookupIPCBuffer(true, ksCurThread) + 1);
name = (const char*)(lookupIPCBuffer(true, NODE_STATE(ksCurThread)) + 1);
if (!name) {
userError("SysDebugNameThread: Failed to lookup IPC buffer, halting");
halt();
@ -113,7 +113,7 @@ handleUnknownSyscall(word_t w)
#ifdef DANGEROUS_CODE_INJECTION
if (w == SysDebugRun) {
((void (*) (void *))getRegister(ksCurThread, capRegister))((void*)getRegister(ksCurThread, msgInfoRegister));
((void (*) (void *))getRegister(NODE_STATE(ksCurThread), capRegister))((void*)getRegister(NODE_STATE(ksCurThread), msgInfoRegister));
return EXCEPTION_NONE;
}
#endif
@ -124,7 +124,7 @@ handleUnknownSyscall(word_t w)
if (ksUserLogBuffer == 0) {
userError("A user-level buffer has to be set before resetting benchmark.\
Use seL4_BenchmarkSetLogBuffer\n");
setRegister(ksCurThread, capRegister, seL4_IllegalOperation);
setRegister(NODE_STATE(ksCurThread), capRegister, seL4_IllegalOperation);
return EXCEPTION_SYSCALL_ERROR;
}
@ -132,12 +132,12 @@ handleUnknownSyscall(word_t w)
#endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */
#ifdef CONFIG_BENCHMARK_TRACK_UTILISATION
benchmark_log_utilisation_enabled = true;
ksIdleThread->benchmark.utilisation = 0;
ksCurThread->benchmark.schedule_start_time = ksEnter;
NODE_STATE(ksIdleThread)->benchmark.utilisation = 0;
NODE_STATE(ksCurThread)->benchmark.schedule_start_time = ksEnter;
benchmark_start_time = ksEnter;
benchmark_arch_utilisation_reset();
#endif /* CONFIG_BENCHMARK_TRACK_UTILISATION */
setRegister(ksCurThread, capRegister, seL4_NoError);
setRegister(NODE_STATE(ksCurThread), capRegister, seL4_NoError);
return EXCEPTION_NONE;
} else if (w == SysBenchmarkFinalizeLog) {
#ifdef CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER
@ -149,14 +149,14 @@ handleUnknownSyscall(word_t w)
return EXCEPTION_NONE;
} else if (w == SysBenchmarkSetLogBuffer) {
#ifdef CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER
word_t cptr_userFrame = getRegister(ksCurThread, capRegister);
word_t cptr_userFrame = getRegister(NODE_STATE(ksCurThread), capRegister);
if (benchmark_arch_map_logBuffer(cptr_userFrame) != EXCEPTION_NONE) {
setRegister(ksCurThread, capRegister, seL4_IllegalOperation);
setRegister(NODE_STATE(ksCurThread), capRegister, seL4_IllegalOperation);
return EXCEPTION_SYSCALL_ERROR;
}
setRegister(ksCurThread, capRegister, seL4_NoError);
setRegister(NODE_STATE(ksCurThread), capRegister, seL4_NoError);
return EXCEPTION_NONE;
#endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */
}
@ -177,7 +177,7 @@ handleUnknownSyscall(word_t w)
#endif /* CONFIG_ENABLE_BENCHMARKS */
current_fault = fault_unknown_syscall_new(w);
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
schedule();
activateThread();
@ -189,7 +189,7 @@ exception_t
handleUserLevelFault(word_t w_a, word_t w_b)
{
current_fault = fault_user_exception_new(w_a, w_b);
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
schedule();
activateThread();
@ -202,9 +202,9 @@ handleVMFaultEvent(vm_fault_type_t vm_faultType)
{
exception_t status;
status = handleVMFault(ksCurThread, vm_faultType);
status = handleVMFault(NODE_STATE(ksCurThread), vm_faultType);
if (status != EXCEPTION_NONE) {
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
}
schedule();
@ -225,7 +225,7 @@ handleInvocation(bool_t isCall, bool_t isBlocking)
word_t length;
tcb_t *thread;
thread = ksCurThread;
thread = NODE_STATE(ksCurThread);
info = messageInfoFromWord(getRegister(thread, msgInfoRegister));
cptr = getRegister(thread, capRegister);
@ -294,7 +294,7 @@ handleReply(void)
cte_t *callerSlot;
cap_t callerCap;
callerSlot = TCB_PTR_CTE_PTR(ksCurThread, tcbCaller);
callerSlot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbCaller);
callerCap = callerSlot->cap;
switch (cap_get_capType(callerCap)) {
@ -307,8 +307,8 @@ handleReply(void)
caller = TCB_PTR(cap_reply_cap_get_capTCBPtr(callerCap));
/* Haskell error:
* "handleReply: caller must not be the current thread" */
assert(caller != ksCurThread);
doReplyTransfer(ksCurThread, caller, callerSlot);
assert(caller != NODE_STATE(ksCurThread));
doReplyTransfer(NODE_STATE(ksCurThread), caller, callerSlot);
return;
}
@ -329,14 +329,14 @@ handleRecv(bool_t isBlocking)
word_t epCPtr;
lookupCap_ret_t lu_ret;
epCPtr = getRegister(ksCurThread, capRegister);
epCPtr = getRegister(NODE_STATE(ksCurThread), capRegister);
lu_ret = lookupCap(ksCurThread, epCPtr);
lu_ret = lookupCap(NODE_STATE(ksCurThread), epCPtr);
if (unlikely(lu_ret.status != EXCEPTION_NONE)) {
/* current_lookup_fault has been set by lookupCap */
current_fault = fault_cap_fault_new(epCPtr, true);
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
return;
}
@ -345,12 +345,12 @@ handleRecv(bool_t isBlocking)
if (unlikely(!cap_endpoint_cap_get_capCanReceive(lu_ret.cap))) {
current_lookup_fault = lookup_fault_missing_capability_new(0);
current_fault = fault_cap_fault_new(epCPtr, true);
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
break;
}
deleteCallerCap(ksCurThread);
receiveIPC(ksCurThread, lu_ret.cap, isBlocking);
deleteCallerCap(NODE_STATE(ksCurThread));
receiveIPC(NODE_STATE(ksCurThread), lu_ret.cap, isBlocking);
break;
case cap_notification_cap: {
@ -359,20 +359,20 @@ handleRecv(bool_t isBlocking)
ntfnPtr = NTFN_PTR(cap_notification_cap_get_capNtfnPtr(lu_ret.cap));
boundTCB = (tcb_t*)notification_ptr_get_ntfnBoundTCB(ntfnPtr);
if (unlikely(!cap_notification_cap_get_capNtfnCanReceive(lu_ret.cap)
|| (boundTCB && boundTCB != ksCurThread))) {
|| (boundTCB && boundTCB != NODE_STATE(ksCurThread)))) {
current_lookup_fault = lookup_fault_missing_capability_new(0);
current_fault = fault_cap_fault_new(epCPtr, true);
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
break;
}
receiveSignal(ksCurThread, lu_ret.cap, isBlocking);
receiveSignal(NODE_STATE(ksCurThread), lu_ret.cap, isBlocking);
break;
}
default:
current_lookup_fault = lookup_fault_missing_capability_new(0);
current_fault = fault_cap_fault_new(epCPtr, true);
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
break;
}
}
@ -380,8 +380,8 @@ handleRecv(bool_t isBlocking)
static void
handleYield(void)
{
tcbSchedDequeue(ksCurThread);
tcbSchedAppend(ksCurThread);
tcbSchedDequeue(NODE_STATE(ksCurThread));
tcbSchedAppend(NODE_STATE(ksCurThread));
rescheduleRequired();
}

View file

@ -14,6 +14,7 @@
#include <arch/fastpath/fastpath.h>
#include <arch/machine/debug.h>
#include <benchmark_track.h>
#include <arch/stack.h>
#include <api/syscall.h>
#include <util.h>
@ -23,8 +24,8 @@ void NORETURN VISIBLE restore_user_context(void)
{
c_exit_hook();
setKernelEntryStackPointer(ksCurThread);
if (unlikely(ksCurThread == ARCH_NODE_STATE(x86KSfpuOwner))) {
setKernelEntryStackPointer(NODE_STATE(ksCurThread));
if (unlikely(NODE_STATE(ksCurThread) == ARCH_NODE_STATE(x86KSfpuOwner))) {
/* We are using the FPU, make sure it is enabled */
enableFpu();
} else if (unlikely(ARCH_NODE_STATE(x86KSfpuOwner))) {
@ -35,11 +36,11 @@ void NORETURN VISIBLE restore_user_context(void)
* is currently disabled */
}
#ifdef CONFIG_HARDWARE_DEBUG_API
restore_user_debug_context(ksCurThread);
restore_user_debug_context(NODE_STATE(ksCurThread));
#endif
/* see if we entered via syscall */
if (likely(ksCurThread->tcbArch.tcbContext.registers[Error] == -1)) {
if (likely(NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers[Error] == -1)) {
asm volatile(
// Set our stack pointer to the top of the tcb so we can efficiently pop
"movl %0, %%esp\n"
@ -89,7 +90,7 @@ void NORETURN VISIBLE restore_user_context(void)
"popfl\n"
"sysexit\n"
:
: "r"(ksCurThread->tcbArch.tcbContext.registers)
: "r"(NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers)
// Clobber memory so the compiler is forced to complete all stores
// before running this assembler
: "memory"
@ -120,7 +121,7 @@ void NORETURN VISIBLE restore_user_context(void)
#endif
"iret\n"
:
: "r"(ksCurThread->tcbArch.tcbContext.registers)
: "r"(NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers)
// Clobber memory so the compiler is forced to complete all stores
// before running this assembler
: "memory"

View file

@ -765,7 +765,7 @@ exception_t benchmark_arch_map_logBuffer(word_t frame_cptr)
pptr_t frame_pptr;
/* faulting section */
lu_ret = lookupCapAndSlot(ksCurThread, frame_cptr);
lu_ret = lookupCapAndSlot(NODE_STATE(ksCurThread), frame_cptr);
if (unlikely(lu_ret.status != EXCEPTION_NONE)) {
userError("Invalid cap #%lu.", frame_cptr);

View file

@ -227,15 +227,15 @@ performIA32PageDirectoryGetStatusBits(lookupPTSlot_ret_t ptSlot, lookupPDSlot_re
((pde_ptr_get_page_size(pdSlot.pdSlot) == pde_pde_large) &&
pde_pde_large_ptr_get_present(pdSlot.pdSlot))) {
setRegister(ksCurThread, msgRegisters[0], pde_pde_large_ptr_get_accessed(pdSlot.pdSlot));
setRegister(ksCurThread, msgRegisters[1], pde_pde_large_ptr_get_dirty(pdSlot.pdSlot));
setRegister(NODE_STATE(ksCurThread), msgRegisters[0], pde_pde_large_ptr_get_accessed(pdSlot.pdSlot));
setRegister(NODE_STATE(ksCurThread), msgRegisters[1], pde_pde_large_ptr_get_dirty(pdSlot.pdSlot));
return EXCEPTION_NONE;
}
assert(ptSlot.status == EXCEPTION_NONE && pte_ptr_get_present(ptSlot.ptSlot));
setRegister(ksCurThread, msgRegisters[0], pte_ptr_get_accessed(ptSlot.ptSlot));
setRegister(ksCurThread, msgRegisters[1], pte_ptr_get_dirty(ptSlot.ptSlot));
setRegister(NODE_STATE(ksCurThread), msgRegisters[0], pte_ptr_get_accessed(ptSlot.ptSlot));
setRegister(NODE_STATE(ksCurThread), msgRegisters[1], pte_ptr_get_dirty(ptSlot.ptSlot));
return EXCEPTION_NONE;
}
@ -295,7 +295,7 @@ decodeIA32PageDirectoryInvocation(
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performIA32PageDirectoryGetStatusBits(ptSlot, pdSlot);
}

View file

@ -309,7 +309,7 @@ void unmapPageDirectory(asid_t asid, vptr_t vaddr, pde_t *pd)
0 /* present */
);
/* check if page directory belongs to current address space */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
threadRoot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbVTable)->cap;
if (isValidNativeRoot(threadRoot) && (vspace_root_t*)pptr_of_cap(threadRoot) == find_ret.vspace_root) {
/* according to the intel manual if we modify a pdpt we must
* reload cr3 */
@ -381,7 +381,7 @@ decodeIA32PageDirectoryInvocation(
userError("X86PageDirectory: Cannot unmap if more than one cap exists.");
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performIA32PageDirectoryInvocationUnmap(cap, cte);
}
@ -462,9 +462,9 @@ decodeIA32PageDirectoryInvocation(
cap = cap_page_directory_cap_set_capPDMappedASID(cap, asid);
cap = cap_page_directory_cap_set_capPDMappedAddress(cap, vaddr);
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
threadRoot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbVTable)->cap;
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performIA32PageDirectoryInvocationMap(cap, cte, pdpte, pdptSlot, threadRoot, vspaceCap);
}

View file

@ -33,7 +33,7 @@ c_handle_interrupt(int irq, int syscall)
#endif
} else if (irq == int_page_fault) {
/* Error code is in Error. Pull out bit 5, which is whether it was instruction or data */
vm_fault_type_t type = (ksCurThread->tcbArch.tcbContext.registers[Error] >> 4u) & 1u;
vm_fault_type_t type = (NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers[Error] >> 4u) & 1u;
#ifdef TRACK_KERNEL_ENTRIES
ksKernelEntry.path = Entry_VMFault;
ksKernelEntry.word = type;
@ -44,7 +44,7 @@ c_handle_interrupt(int irq, int syscall)
/* Debug exception */
#ifdef TRACK_KERNEL_ENTRIES
ksKernelEntry.path = Entry_DebugFault;
ksKernelEntry.word = ksCurThread->tcbArch.tcbContext.registers[FaultIP];
ksKernelEntry.word = NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers[FaultIP];
#endif
handleUserLevelDebugException(irq);
#endif /* CONFIG_HARDWARE_DEBUG_API */
@ -53,7 +53,7 @@ c_handle_interrupt(int irq, int syscall)
ksKernelEntry.path = Entry_UserLevelFault;
ksKernelEntry.word = irq;
#endif
handleUserLevelFault(irq, ksCurThread->tcbArch.tcbContext.registers[Error]);
handleUserLevelFault(irq, NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers[Error]);
} else if (likely(irq < int_trap_min)) {
ARCH_NODE_STATE(x86KScurInterrupt) = irq;
#ifdef TRACK_KERNEL_ENTRIES
@ -68,7 +68,7 @@ c_handle_interrupt(int irq, int syscall)
/* Adjust FaultIP to point to trapping INT
* instruction by subtracting 2 */
int sys_num;
ksCurThread->tcbArch.tcbContext.registers[FaultIP] -= 2;
NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers[FaultIP] -= 2;
/* trap number is MSBs of the syscall number and the LSBS of EAX */
sys_num = (irq << 24) | (syscall & 0x00ffffff);
#ifdef TRACK_KERNEL_ENTIRES
@ -87,10 +87,10 @@ slowpath(syscall_t syscall)
ARCH_NODE_STATE(x86KScurInterrupt) = -1;
if (config_set(CONFIG_SYSENTER)) {
/* increment NextIP to skip sysenter */
ksCurThread->tcbArch.tcbContext.registers[NextIP] += 2;
NODE_STATE(ksCurThread)->tcbArch.tcbContext.registers[NextIP] += 2;
} else {
/* set FaultIP */
setRegister(ksCurThread, FaultIP, getRegister(ksCurThread, NextIP) - 2);
setRegister(NODE_STATE(ksCurThread), FaultIP, getRegister(NODE_STATE(ksCurThread), NextIP) - 2);
}
/* check for undefined syscall */
if (unlikely(syscall < SYSCALL_MIN || syscall > SYSCALL_MAX)) {

View file

@ -33,8 +33,8 @@ performPageGetAddress(void *vbase_ptr)
capFBasePtr = pptr_to_paddr(vbase_ptr);
/* return it in the first message register */
setRegister(ksCurThread, msgRegisters[0], capFBasePtr);
setRegister(ksCurThread, msgInfoRegister,
setRegister(NODE_STATE(ksCurThread), msgRegisters[0], capFBasePtr);
setRegister(NODE_STATE(ksCurThread), msgInfoRegister,
wordFromMessageInfo(seL4_MessageInfo_new(0, 0, 0, 1)));
return EXCEPTION_NONE;
@ -48,7 +48,7 @@ void deleteASIDPool(asid_t asid_base, asid_pool_t* pool)
if (x86KSASIDTable[asid_base >> asidLowBits] == pool) {
x86KSASIDTable[asid_base >> asidLowBits] = NULL;
setVMRoot(ksCurThread);
setVMRoot(NODE_STATE(ksCurThread));
}
}
@ -81,7 +81,7 @@ void deleteASID(asid_t asid, vspace_root_t *vspace)
hwASIDInvalidate(asid);
if (poolPtr != NULL && poolPtr->array[asid & MASK(asidLowBits)] == vspace) {
poolPtr->array[asid & MASK(asidLowBits)] = NULL;
setVMRoot(ksCurThread);
setVMRoot(NODE_STATE(ksCurThread));
}
}
@ -679,7 +679,7 @@ void flushTable(vspace_root_t *vspace, word_t vptr, pte_t* pt, asid_t asid)
assert(IS_ALIGNED(vptr, PT_INDEX_BITS + PAGE_BITS));
/* check if page table belongs to current address space */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
threadRoot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbVTable)->cap;
/* find valid mappings */
for (i = 0; i < BIT(PT_INDEX_BITS); i++) {
if (pte_get_present(pt[i])) {
@ -739,7 +739,7 @@ void unmapPage(vm_page_size_t page_size, asid_t asid, vptr_t vptr, void *pptr)
}
/* check if page belongs to current address space */
threadRoot = TCB_PTR_CTE_PTR(ksCurThread, tcbVTable)->cap;
threadRoot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbVTable)->cap;
if (config_set(CONFIG_SUPPORT_PCID) || (isValidNativeRoot(threadRoot) && (vspace_root_t*)pptr_of_cap(threadRoot) == find_ret.vspace_root)) {
invalidateTranslationSingleASID(vptr, asid);
}
@ -945,7 +945,7 @@ exception_t decodeX86FrameInvocation(
}
pte = makeUserPTE(paddr, vmAttr, vmRights);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageInvocationMapPTE(cap, cte, lu_ret.ptSlot, pte, vspace);
}
@ -981,7 +981,7 @@ exception_t decodeX86FrameInvocation(
}
pde = makeUserPDELargePage(paddr, vmAttr, vmRights);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageInvocationMapPDE(cap, cte, lu_ret.pdSlot, pde, vspace);
}
@ -1083,7 +1083,7 @@ exception_t decodeX86FrameInvocation(
pte = makeUserPTE(paddr, vmAttr, vmRights);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageInvocationRemapPTE(lu_ret.ptSlot, pte, asid, vspace);
}
@ -1112,7 +1112,7 @@ exception_t decodeX86FrameInvocation(
pde = makeUserPDELargePage(paddr, vmAttr, vmRights);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageInvocationRemapPDE(pdeSlot, pde, asid, vspace);
}
@ -1128,10 +1128,10 @@ exception_t decodeX86FrameInvocation(
if (cap_frame_cap_get_capFMappedASID(cap) != asidInvalid) {
switch (cap_frame_cap_get_capFMapType(cap)) {
case X86_MappingVSpace:
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageInvocationUnmap(cap, cte);
case X86_MappingIOSpace:
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86IOUnMapInvocation(cap, cte);
case X86_MappingNone:
fail("Mapped frame cap was not mapped");
@ -1150,7 +1150,7 @@ exception_t decodeX86FrameInvocation(
/* Return it in the first message register. */
assert(n_msgRegisters >= 1);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performPageGetAddress((void*)cap_frame_cap_get_capFBasePtr(cap));
}
@ -1212,7 +1212,7 @@ decodeX86PageTableInvocation(
userError("X86PageTable: Cannot unmap if more than one cap exists.");
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageTableInvocationUnmap(cap, cte);
}
@ -1300,7 +1300,7 @@ decodeX86PageTableInvocation(
cap = cap_page_table_cap_set_capPTMappedASID(cap, asid);
cap = cap_page_table_cap_set_capPTMappedAddress(cap, vaddr);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86PageTableInvocationMap(cap, cte, pde, pdSlot.pdSlot, vspace);
}
@ -1393,7 +1393,7 @@ exception_t decodeX86MMUInvocation(
return status;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performASIDControlInvocation(frame, destSlot, parentSlot, asid_base);
}
@ -1453,7 +1453,7 @@ exception_t decodeX86MMUInvocation(
asid += i;
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performASIDPoolInvocation(asid, pool, vspaceCapSlot);
}

View file

@ -619,11 +619,11 @@ handleUserLevelDebugException(int int_vector)
benchmark_track_start();
#endif
context = &ksCurThread->tcbArch;
context = &NODE_STATE(ksCurThread)->tcbArch;
/* Software break request (INT3) is detected by the vector number */
if (int_vector == int_software_break_request) {
current_fault = fault_debug_exception_new(getRestartPC(ksCurThread),
current_fault = fault_debug_exception_new(getRestartPC(NODE_STATE(ksCurThread)),
0, seL4_SoftwareBreakRequest);
} else {
/* Hardware breakpoint trigger is detected using DR6 */
@ -651,7 +651,7 @@ handleUserLevelDebugException(int int_vector)
}
}
handleFault(ksCurThread);
handleFault(NODE_STATE(ksCurThread));
schedule();
activateThread();

View file

@ -211,11 +211,11 @@ static void sendIOSpace(uint32_t pci_request_id)
static void sendRunqueues(void)
{
word_t i;
sendWord((unsigned long)ksCurThread);
sendWord((unsigned long)NODE_STATE(ksCurThread));
for (i = 0; i < NUM_READY_QUEUES; i++) {
tcb_t *current = ksReadyQueues[i].head;
tcb_t *current = NODE_STATE(ksReadyQueues[i]).head;
if (current != 0) {
while (current != ksReadyQueues[i].end) {
while (current != NODE_STATE(ksReadyQueues[i]).end) {
sendWord((unsigned long)current);
current = current -> tcbSchedNext;
}

View file

@ -63,10 +63,10 @@ handleUnimplementedDevice(void)
* This should only be able to occur on CPUs without an FPU at all, which
* we presumably are happy to assume will not be running seL4.
*/
assert(ksCurThread != ARCH_NODE_STATE(x86KSfpuOwner));
assert(NODE_STATE(ksCurThread) != ARCH_NODE_STATE(x86KSfpuOwner));
/* Otherwise, lazily switch over the FPU. */
switchFpuOwner(ksCurThread);
switchFpuOwner(NODE_STATE(ksCurThread));
return EXCEPTION_NONE;
}

View file

@ -136,7 +136,7 @@ Arch_decodeIRQControlInvocation(word_t invLabel, word_t length, cte_t *srcSlot,
return status;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeIssueIRQHandlerIOAPIC(irq, ioapic, pin, level, polarity, vector, destSlot, srcSlot);
}
break;
@ -177,7 +177,7 @@ Arch_decodeIRQControlInvocation(word_t invLabel, word_t length, cte_t *srcSlot,
irqState = x86_irq_state_irq_msi_new(pci_bus, pci_dev, pci_func, handle);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return Arch_invokeIRQControl(irq, destSlot, srcSlot, irqState);
}
break;

View file

@ -170,10 +170,10 @@ decodeX86PortInvocation(
if (len > 0) {
/* return the value read from the port */
setRegister(ksCurThread, badgeRegister, 0);
setRegister(NODE_STATE(ksCurThread), badgeRegister, 0);
if (n_msgRegisters < 1) {
word_t* ipcBuffer;
ipcBuffer = lookupIPCBuffer(true, ksCurThread);
ipcBuffer = lookupIPCBuffer(true, NODE_STATE(ksCurThread));
if (ipcBuffer != NULL) {
ipcBuffer[1] = res;
len = 1;
@ -181,13 +181,13 @@ decodeX86PortInvocation(
len = 0;
}
} else {
setRegister(ksCurThread, msgRegisters[0], res);
setRegister(NODE_STATE(ksCurThread), msgRegisters[0], res);
len = 1;
}
}
setRegister(ksCurThread, msgInfoRegister,
setRegister(NODE_STATE(ksCurThread), msgInfoRegister,
wordFromMessageInfo(seL4_MessageInfo_new(0, 0, 0, len)));
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return EXCEPTION_NONE;
}

View file

@ -141,7 +141,7 @@ unmapVTDContextEntry(cap_t cap)
flushCacheRange(cte, VTD_CTE_SIZE_BITS);
invalidate_iotlb();
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return;
}
@ -195,7 +195,7 @@ decodeX86IOPTInvocation(
if (invLabel == X86IOPageTableUnmap) {
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86IOPTInvocationUnmap(cap, slot);
}
@ -256,7 +256,7 @@ decodeX86IOPTInvocation(
cap = cap_io_page_table_cap_set_capIOPTLevel(cap, 0);
cap = cap_io_page_table_cap_set_capIOPTIOASID(cap, pci_request_id);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86IOPTInvocationMapContextRoot(cap, slot, vtd_cte, vtd_context_slot);
} else {
lookupIOPTSlot_ret_t lu_ret;
@ -289,7 +289,7 @@ decodeX86IOPTInvocation(
cap = cap_io_page_table_cap_set_capIOPTIOASID(cap, pci_request_id);
cap = cap_io_page_table_cap_set_capIOPTMappedAddress(cap, io_address);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86IOPTInvocationMapPT(cap, slot, iopte, lu_ret.ioptSlot);
}
}
@ -404,7 +404,7 @@ decodeX86IOMapInvocation(
cap = cap_frame_cap_set_capFMappedASID(cap, pci_request_id);
cap = cap_frame_cap_set_capFMappedAddress(cap, io_address);
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performX86IOInvocationMap(cap, slot, iopte, lu_ret.ioptSlot);
}

View file

@ -20,13 +20,13 @@ timestamp_t benchmark_end_time;
void benchmark_track_utilisation_dump(void)
{
uint64_t *buffer = ((uint64_t *) & (((seL4_IPCBuffer *)lookupIPCBuffer(true, ksCurThread))->msg[0]));
uint64_t *buffer = ((uint64_t *) & (((seL4_IPCBuffer *)lookupIPCBuffer(true, NODE_STATE(ksCurThread)))->msg[0]));
tcb_t *tcb = NULL;
word_t tcb_cptr = getRegister(ksCurThread, capRegister);
word_t tcb_cptr = getRegister(NODE_STATE(ksCurThread), capRegister);
lookupCap_ret_t lu_ret;
word_t cap_type;
lu_ret = lookupCap(ksCurThread, tcb_cptr);
lu_ret = lookupCap(NODE_STATE(ksCurThread), tcb_cptr);
/* ensure we got a TCB cap */
cap_type = cap_get_capType(lu_ret.cap);
if (cap_type != cap_thread_cap) {
@ -36,7 +36,7 @@ void benchmark_track_utilisation_dump(void)
tcb = TCB_PTR(cap_thread_cap_get_capTCBPtr(lu_ret.cap));
buffer[BENCHMARK_TCB_UTILISATION] = tcb->benchmark.utilisation; /* Requested thread utilisation */
buffer[BENCHMARK_IDLE_UTILISATION] = ksIdleThread->benchmark.utilisation; /* Idle thread utilisation */
buffer[BENCHMARK_IDLE_UTILISATION] = NODE_STATE(ksIdleThread)->benchmark.utilisation; /* Idle thread utilisation */
#ifdef CONFIG_ARM_ENABLE_PMU_OVERFLOW_INTERRUPT
buffer[BENCHMARK_TOTAL_UTILISATION] =
@ -50,11 +50,11 @@ void benchmark_track_utilisation_dump(void)
void benchmark_track_reset_utilisation(void)
{
tcb_t *tcb = NULL;
word_t tcb_cptr = getRegister(ksCurThread, capRegister);
word_t tcb_cptr = getRegister(NODE_STATE(ksCurThread), capRegister);
lookupCap_ret_t lu_ret;
word_t cap_type;
lu_ret = lookupCap(ksCurThread, tcb_cptr);
lu_ret = lookupCap(NODE_STATE(ksCurThread), tcb_cptr);
/* ensure we got a TCB cap */
cap_type = cap_get_capType(lu_ret.cap);
if (cap_type != cap_thread_cap) {

View file

@ -36,7 +36,7 @@ fastpath_call(word_t cptr, word_t msgInfo)
/* Get message info, length, and fault type. */
info = messageInfoFromWord_raw(msgInfo);
length = seL4_MessageInfo_get_length(info);
fault_type = fault_get_faultType(ksCurThread->tcbFault);
fault_type = fault_get_faultType(NODE_STATE(ksCurThread)->tcbFault);
/* Check there's no extra caps, the length is ok and there's no
* saved fault. */
@ -46,7 +46,7 @@ fastpath_call(word_t cptr, word_t msgInfo)
}
/* Lookup the cap */
ep_cap = lookup_fp(TCB_PTR_CTE_PTR(ksCurThread, tcbCTable)->cap, cptr);
ep_cap = lookup_fp(TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbCTable)->cap, cptr);
/* Check it's an endpoint */
if (unlikely(!cap_capType_equals(ep_cap, cap_endpoint_cap) ||
@ -87,7 +87,7 @@ fastpath_call(word_t cptr, word_t msgInfo)
#endif
/* Ensure the destination has a higher/equal priority to us. */
if (unlikely(dest->tcbPriority < ksCurThread->tcbPriority)) {
if (unlikely(dest->tcbPriority < NODE_STATE(ksCurThread)->tcbPriority)) {
slowpath(SysCall);
}
@ -120,7 +120,7 @@ fastpath_call(word_t cptr, word_t msgInfo)
#ifdef ARCH_X86
/* Need to update NextIP in the calling thread */
setRegister(ksCurThread, NextIP, getRegister(ksCurThread, NextIP) + 2);
setRegister(NODE_STATE(ksCurThread), NextIP, getRegister(NODE_STATE(ksCurThread), NextIP) + 2);
#endif
/* Dequeue the destination. */
@ -134,22 +134,22 @@ fastpath_call(word_t cptr, word_t msgInfo)
badge = cap_endpoint_cap_get_capEPBadge(ep_cap);
/* Block sender */
thread_state_ptr_set_tsType_np(&ksCurThread->tcbState,
thread_state_ptr_set_tsType_np(&NODE_STATE(ksCurThread)->tcbState,
ThreadState_BlockedOnReply);
/* Get sender reply slot */
replySlot = TCB_PTR_CTE_PTR(ksCurThread, tcbReply);
replySlot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbReply);
/* Get dest caller slot */
callerSlot = TCB_PTR_CTE_PTR(dest, tcbCaller);
/* Insert reply cap */
cap_reply_cap_ptr_new_np(&callerSlot->cap, 0, TCB_REF(ksCurThread));
cap_reply_cap_ptr_new_np(&callerSlot->cap, 0, TCB_REF(NODE_STATE(ksCurThread)));
mdb_node_ptr_set_mdbPrev_np(&callerSlot->cteMDBNode, CTE_REF(replySlot));
mdb_node_ptr_mset_mdbNext_mdbRevocable_mdbFirstBadged(
&replySlot->cteMDBNode, CTE_REF(callerSlot), 1, 1);
fastpath_copy_mrs (length, ksCurThread, dest);
fastpath_copy_mrs (length, NODE_STATE(ksCurThread), dest);
/* Dest thread is set Running, but not queued. */
thread_state_ptr_set_tsType_np(&dest->tcbState,
@ -158,7 +158,7 @@ fastpath_call(word_t cptr, word_t msgInfo)
msgInfo = wordFromMessageInfo(seL4_MessageInfo_set_capsUnwrapped(info, 0));
fastpath_restore(badge, msgInfo, ksCurThread);
fastpath_restore(badge, msgInfo, NODE_STATE(ksCurThread));
}
void
@ -182,7 +182,7 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
/* Get message info and length */
info = messageInfoFromWord_raw(msgInfo);
length = seL4_MessageInfo_get_length(info);
fault_type = fault_get_faultType(ksCurThread->tcbFault);
fault_type = fault_get_faultType(NODE_STATE(ksCurThread)->tcbFault);
/* Check there's no extra caps, the length is ok and there's no
* saved fault. */
@ -192,7 +192,7 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
}
/* Lookup the cap */
ep_cap = lookup_fp(TCB_PTR_CTE_PTR(ksCurThread, tcbCTable)->cap,
ep_cap = lookup_fp(TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbCTable)->cap,
cptr);
/* Check it's an endpoint */
@ -202,8 +202,8 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
}
/* Check there is nothing waiting on the notification */
if (ksCurThread->tcbBoundNotification &&
notification_ptr_get_state(ksCurThread->tcbBoundNotification) == NtfnState_Active) {
if (NODE_STATE(ksCurThread)->tcbBoundNotification &&
notification_ptr_get_state(NODE_STATE(ksCurThread)->tcbBoundNotification) == NtfnState_Active) {
slowpath(SysReplyRecv);
}
@ -216,7 +216,7 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
}
/* Only reply if the reply cap is valid. */
callerSlot = TCB_PTR_CTE_PTR(ksCurThread, tcbCaller);
callerSlot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbCaller);
callerCap = callerSlot->cap;
if (unlikely(!fastpath_reply_cap_check(callerCap))) {
slowpath(SysReplyRecv);
@ -253,7 +253,7 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
#endif
/* Ensure the original caller can be scheduled directly. */
if (unlikely(caller->tcbPriority < ksCurThread->tcbPriority)) {
if (unlikely(caller->tcbPriority < NODE_STATE(ksCurThread)->tcbPriority)) {
slowpath(SysReplyRecv);
}
@ -281,31 +281,31 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
#ifdef ARCH_X86
/* Need to update NextIP in the calling thread */
setRegister(ksCurThread, NextIP, getRegister(ksCurThread, NextIP) + 2);
setRegister(NODE_STATE(ksCurThread), NextIP, getRegister(NODE_STATE(ksCurThread), NextIP) + 2);
#endif
/* Set thread state to BlockedOnReceive */
thread_state_ptr_mset_blockingObject_tsType(
&ksCurThread->tcbState, (word_t)ep_ptr, ThreadState_BlockedOnReceive);
&NODE_STATE(ksCurThread)->tcbState, (word_t)ep_ptr, ThreadState_BlockedOnReceive);
/* Place the thread in the endpoint queue */
endpointTail = TCB_PTR(endpoint_ptr_get_epQueue_tail(ep_ptr));
if (likely(!endpointTail)) {
ksCurThread->tcbEPPrev = NULL;
ksCurThread->tcbEPNext = NULL;
NODE_STATE(ksCurThread)->tcbEPPrev = NULL;
NODE_STATE(ksCurThread)->tcbEPNext = NULL;
/* Set head/tail of queue and endpoint state. */
endpoint_ptr_set_epQueue_head_np(ep_ptr, TCB_REF(ksCurThread));
endpoint_ptr_mset_epQueue_tail_state(ep_ptr, TCB_REF(ksCurThread),
endpoint_ptr_set_epQueue_head_np(ep_ptr, TCB_REF(NODE_STATE(ksCurThread)));
endpoint_ptr_mset_epQueue_tail_state(ep_ptr, TCB_REF(NODE_STATE(ksCurThread)),
EPState_Recv);
} else {
/* Append current thread onto the queue. */
endpointTail->tcbEPNext = ksCurThread;
ksCurThread->tcbEPPrev = endpointTail;
ksCurThread->tcbEPNext = NULL;
endpointTail->tcbEPNext = NODE_STATE(ksCurThread);
NODE_STATE(ksCurThread)->tcbEPPrev = endpointTail;
NODE_STATE(ksCurThread)->tcbEPNext = NULL;
/* Update tail of queue. */
endpoint_ptr_mset_epQueue_tail_state(ep_ptr, TCB_REF(ksCurThread),
endpoint_ptr_mset_epQueue_tail_state(ep_ptr, TCB_REF(NODE_STATE(ksCurThread)),
EPState_Recv);
}
@ -321,7 +321,7 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
/* Replies don't have a badge. */
badge = 0;
fastpath_copy_mrs (length, ksCurThread, caller);
fastpath_copy_mrs (length, NODE_STATE(ksCurThread), caller);
/* Dest thread is set Running, but not queued. */
thread_state_ptr_set_tsType_np(&caller->tcbState,
@ -330,5 +330,5 @@ fastpath_reply_recv(word_t cptr, word_t msgInfo)
msgInfo = wordFromMessageInfo(seL4_MessageInfo_set_capsUnwrapped(info, 0));
fastpath_restore(badge, msgInfo, ksCurThread);
fastpath_restore(badge, msgInfo, NODE_STATE(ksCurThread));
}

View file

@ -353,8 +353,8 @@ create_idle_thread(void)
return false;
}
memzero((void *)pptr, 1 << seL4_TCBBits);
ksIdleThread = TCB_PTR(pptr + TCB_OFFSET);
configureIdleThread(ksIdleThread);
NODE_STATE(ksIdleThread) = TCB_PTR(pptr + TCB_OFFSET);
configureIdleThread(NODE_STATE(ksIdleThread));
return true;
}
@ -416,8 +416,8 @@ create_initial_thread(
tcb->tcbMCP = seL4_MaxPrio;
setupReplyMaster(tcb);
setThreadState(tcb, ThreadState_Running);
ksSchedulerAction = tcb;
ksCurThread = ksIdleThread;
NODE_STATE(ksSchedulerAction) = tcb;
NODE_STATE(ksCurThread) = NODE_STATE(ksIdleThread);
ksCurDomain = ksDomSchedule[ksDomScheduleIdx].domain;
ksDomainTime = ksDomSchedule[ksDomScheduleIdx].length;
assert(ksCurDomain < CONFIG_NUM_DOMAINS && ksDomainTime > 0);

View file

@ -66,21 +66,21 @@ configureIdleThread(tcb_t *tcb)
void
activateThread(void)
{
switch (thread_state_get_tsType(ksCurThread->tcbState)) {
switch (thread_state_get_tsType(NODE_STATE(ksCurThread)->tcbState)) {
case ThreadState_Running:
break;
case ThreadState_Restart: {
word_t pc;
pc = getRestartPC(ksCurThread);
setNextPC(ksCurThread, pc);
setThreadState(ksCurThread, ThreadState_Running);
pc = getRestartPC(NODE_STATE(ksCurThread));
setNextPC(NODE_STATE(ksCurThread), pc);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Running);
break;
}
case ThreadState_IdleThreadState:
Arch_activateIdleThread(ksCurThread);
Arch_activateIdleThread(NODE_STATE(ksCurThread));
break;
default:
@ -280,23 +280,23 @@ schedule(void)
{
word_t action;
action = (word_t)ksSchedulerAction;
action = (word_t)NODE_STATE(ksSchedulerAction);
if (action == (word_t)SchedulerAction_ChooseNewThread) {
if (isRunnable(ksCurThread)) {
tcbSchedEnqueue(ksCurThread);
if (isRunnable(NODE_STATE(ksCurThread))) {
tcbSchedEnqueue(NODE_STATE(ksCurThread));
}
if (ksDomainTime == 0) {
nextDomain();
}
chooseThread();
ksSchedulerAction = SchedulerAction_ResumeCurrentThread;
NODE_STATE(ksSchedulerAction) = SchedulerAction_ResumeCurrentThread;
} else if (action != (word_t)SchedulerAction_ResumeCurrentThread) {
if (isRunnable(ksCurThread)) {
tcbSchedEnqueue(ksCurThread);
if (isRunnable(NODE_STATE(ksCurThread))) {
tcbSchedEnqueue(NODE_STATE(ksCurThread));
}
/* SwitchToThread */
switchToThread(ksSchedulerAction);
ksSchedulerAction = SchedulerAction_ResumeCurrentThread;
switchToThread(NODE_STATE(ksSchedulerAction));
NODE_STATE(ksSchedulerAction) = SchedulerAction_ResumeCurrentThread;
}
}
@ -313,11 +313,11 @@ chooseThread(void)
dom = 0;
}
if (likely(ksReadyQueuesL1Bitmap[dom])) {
word_t l1index = (wordBits - 1) - clzl(ksReadyQueuesL1Bitmap[dom]);
word_t l2index = (wordBits - 1) - clzl(ksReadyQueuesL2Bitmap[dom][l1index]);
if (likely(NODE_STATE(ksReadyQueuesL1Bitmap[dom]))) {
word_t l1index = (wordBits - 1) - clzl(NODE_STATE(ksReadyQueuesL1Bitmap[dom]));
word_t l2index = (wordBits - 1) - clzl(NODE_STATE(ksReadyQueuesL2Bitmap[dom][l1index]));
prio = l1index_to_prio(l1index) | l2index;
thread = ksReadyQueues[ready_queues_index(dom, prio)].head;
thread = NODE_STATE(ksReadyQueues[ready_queues_index(dom, prio)]).head;
assert(thread);
assert(isRunnable(thread));
switchToThread(thread);
@ -330,21 +330,21 @@ void
switchToThread(tcb_t *thread)
{
#ifdef CONFIG_BENCHMARK_TRACK_UTILISATION
benchmark_utilisation_switch(ksCurThread, thread);
benchmark_utilisation_switch(NODE_STATE(ksCurThread), thread);
#endif
Arch_switchToThread(thread);
tcbSchedDequeue(thread);
ksCurThread = thread;
NODE_STATE(ksCurThread) = thread;
}
void
switchToIdleThread(void)
{
#ifdef CONFIG_BENCHMARK_TRACK_UTILISATION
benchmark_utilisation_switch(ksCurThread, ksIdleThread);
benchmark_utilisation_switch(NODE_STATE(ksCurThread), NODE_STATE(ksIdleThread));
#endif
Arch_switchToIdleThread();
ksCurThread = ksIdleThread;
NODE_STATE(ksCurThread) = NODE_STATE(ksIdleThread);
}
void
@ -355,7 +355,7 @@ setDomain(tcb_t *tptr, dom_t dom)
if (isRunnable(tptr)) {
tcbSchedEnqueue(tptr);
}
if (tptr == ksCurThread) {
if (tptr == NODE_STATE(ksCurThread)) {
rescheduleRequired();
}
}
@ -374,7 +374,7 @@ setPriority(tcb_t *tptr, prio_t prio)
if (isRunnable(tptr)) {
tcbSchedEnqueue(tptr);
}
if (tptr == ksCurThread) {
if (tptr == NODE_STATE(ksCurThread)) {
rescheduleRequired();
}
}
@ -387,16 +387,16 @@ possibleSwitchTo(tcb_t* target, bool_t onSamePriority)
tcb_t *action;
curDom = ksCurDomain;
curPrio = ksCurThread->tcbPriority;
curPrio = NODE_STATE(ksCurThread)->tcbPriority;
targetDom = target->tcbDomain;
targetPrio = target->tcbPriority;
action = ksSchedulerAction;
action = NODE_STATE(ksSchedulerAction);
if (targetDom != curDom) {
tcbSchedEnqueue(target);
} else {
if ((targetPrio > curPrio || (targetPrio == curPrio && onSamePriority))
&& action == SchedulerAction_ResumeCurrentThread) {
ksSchedulerAction = target;
NODE_STATE(ksSchedulerAction) = target;
} else {
tcbSchedEnqueue(target);
}
@ -429,8 +429,8 @@ setThreadState(tcb_t *tptr, _thread_state_t ts)
void
scheduleTCB(tcb_t *tptr)
{
if (tptr == ksCurThread &&
ksSchedulerAction == SchedulerAction_ResumeCurrentThread &&
if (tptr == NODE_STATE(ksCurThread) &&
NODE_STATE(ksSchedulerAction) == SchedulerAction_ResumeCurrentThread &&
!isRunnable(tptr)) {
rescheduleRequired();
}
@ -439,13 +439,13 @@ scheduleTCB(tcb_t *tptr)
void
timerTick(void)
{
if (likely(thread_state_get_tsType(ksCurThread->tcbState) ==
if (likely(thread_state_get_tsType(NODE_STATE(ksCurThread)->tcbState) ==
ThreadState_Running)) {
if (ksCurThread->tcbTimeSlice > 1) {
ksCurThread->tcbTimeSlice--;
if (NODE_STATE(ksCurThread)->tcbTimeSlice > 1) {
NODE_STATE(ksCurThread)->tcbTimeSlice--;
} else {
ksCurThread->tcbTimeSlice = CONFIG_TIME_SLICE;
tcbSchedAppend(ksCurThread);
NODE_STATE(ksCurThread)->tcbTimeSlice = CONFIG_TIME_SLICE;
tcbSchedAppend(NODE_STATE(ksCurThread));
rescheduleRequired();
}
}
@ -461,10 +461,10 @@ timerTick(void)
void
rescheduleRequired(void)
{
if (ksSchedulerAction != SchedulerAction_ResumeCurrentThread
&& ksSchedulerAction != SchedulerAction_ChooseNewThread) {
tcbSchedEnqueue(ksSchedulerAction);
if (NODE_STATE(ksSchedulerAction) != SchedulerAction_ResumeCurrentThread
&& NODE_STATE(ksSchedulerAction) != SchedulerAction_ChooseNewThread) {
tcbSchedEnqueue(NODE_STATE(ksSchedulerAction));
}
ksSchedulerAction = SchedulerAction_ChooseNewThread;
NODE_STATE(ksSchedulerAction) = SchedulerAction_ChooseNewThread;
}

View file

@ -24,21 +24,21 @@ SMP_STATE_DEFINE(smpStatedata_t, ksSMP[CONFIG_MAX_NUM_NODES] ALIGN(CONFIG_CACHE_
word_t ksNumCPUs;
/* Pointer to the head of the scheduler queue for each priority */
tcb_queue_t ksReadyQueues[NUM_READY_QUEUES];
word_t ksReadyQueuesL1Bitmap[CONFIG_NUM_DOMAINS];
word_t ksReadyQueuesL2Bitmap[CONFIG_NUM_DOMAINS][(CONFIG_NUM_PRIORITIES / wordBits) + 1];
UP_STATE_DEFINE(tcb_queue_t, ksReadyQueues[NUM_READY_QUEUES]);
UP_STATE_DEFINE(word_t, ksReadyQueuesL1Bitmap[CONFIG_NUM_DOMAINS]);
UP_STATE_DEFINE(word_t, ksReadyQueuesL2Bitmap[CONFIG_NUM_DOMAINS][(CONFIG_NUM_PRIORITIES / wordBits) + 1]);
compile_assert(ksReadyQueuesL1BitmapBigEnough, (CONFIG_NUM_PRIORITIES / wordBits) <= wordBits)
/* Current thread TCB pointer */
tcb_t *ksCurThread;
UP_STATE_DEFINE(tcb_t *, ksCurThread);
/* Idle thread TCB pointer */
tcb_t *ksIdleThread;
UP_STATE_DEFINE(tcb_t *, ksIdleThread);
/* Values of 0 and ~0 encode ResumeCurrentThread and ChooseNewThread
* respectively; other values encode SwitchToThread and must be valid
* tcb pointers */
tcb_t *ksSchedulerAction;
UP_STATE_DEFINE(tcb_t *, ksSchedulerAction);
/* Units of work we have completed since the last time we checked for
* pending interrupts */

View file

@ -183,7 +183,7 @@ decodeCNodeInvocation(word_t invLabel, word_t length, cap_t cap,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
if (isMove) {
return invokeCNodeMove(newCap, srcSlot, destSlot);
} else {
@ -192,12 +192,12 @@ decodeCNodeInvocation(word_t invLabel, word_t length, cap_t cap,
}
if (invLabel == CNodeRevoke) {
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeCNodeRevoke(destSlot);
}
if (invLabel == CNodeDelete) {
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeCNodeDelete(destSlot);
}
@ -208,7 +208,7 @@ decodeCNodeInvocation(word_t invLabel, word_t length, cap_t cap,
return status;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeCNodeSaveCaller(destSlot);
}
@ -218,7 +218,7 @@ decodeCNodeInvocation(word_t invLabel, word_t length, cap_t cap,
current_syscall_error.type = seL4_IllegalOperation;
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeCNodeRecycle(destSlot);
}
@ -297,7 +297,7 @@ decodeCNodeInvocation(word_t invLabel, word_t length, cap_t cap,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeCNodeRotate(newSrcCap, newPivotCap,
srcSlot, pivotSlot, destSlot);
}
@ -359,7 +359,7 @@ invokeCNodeSaveCaller(cte_t *destSlot)
cap_t cap;
cte_t *srcSlot;
srcSlot = TCB_PTR_CTE_PTR(ksCurThread, tcbCaller);
srcSlot = TCB_PTR_CTE_PTR(NODE_STATE(ksCurThread), tcbCaller);
cap = srcSlot->cap;
switch (cap_get_capType(cap)) {

View file

@ -68,7 +68,7 @@ decodeIRQControlInvocation(word_t invLabel, word_t length,
return status;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeIRQControl(irq, destSlot, srcSlot);
} else {
return Arch_decodeIRQControlInvocation(invLabel, length, srcSlot, excaps, buffer);
@ -90,7 +90,7 @@ decodeIRQHandlerInvocation(word_t invLabel, irq_t irq,
{
switch (invLabel) {
case IRQAckIRQ:
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
invokeIRQHandler_AckIRQ(irq);
return EXCEPTION_NONE;
@ -117,13 +117,13 @@ decodeIRQHandlerInvocation(word_t invLabel, irq_t irq,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
invokeIRQHandler_SetIRQHandler(irq, ntfnCap, slot);
return EXCEPTION_NONE;
}
case IRQClearIRQHandler:
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
invokeIRQHandler_ClearIRQHandler(irq);
return EXCEPTION_NONE;

View file

@ -522,7 +522,7 @@ createObject(object_t t, void *regionBase, word_t userSize, bool_t deviceMemory)
#ifdef CONFIG_DEBUG_BUILD
strlcpy(tcb->tcbName, "child of: '", TCB_NAME_LENGTH);
strlcat(tcb->tcbName, ksCurThread->tcbName, TCB_NAME_LENGTH);
strlcat(tcb->tcbName, NODE_STATE(ksCurThread)->tcbName, TCB_NAME_LENGTH);
strlcat(tcb->tcbName, "'", TCB_NAME_LENGTH);
#endif /* CONFIG_DEBUG_BUILD */
@ -626,7 +626,7 @@ decodeInvocation(word_t invLabel, word_t length,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performInvocation_Endpoint(
EP_PTR(cap_endpoint_cap_get_capEPPtr(cap)),
cap_endpoint_cap_get_capEPBadge(cap),
@ -641,7 +641,7 @@ decodeInvocation(word_t invLabel, word_t length,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performInvocation_Notification(
NTFN_PTR(cap_notification_cap_get_capNtfnPtr(cap)),
cap_notification_cap_get_capNtfnBadge(cap));
@ -656,7 +656,7 @@ decodeInvocation(word_t invLabel, word_t length,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return performInvocation_Reply(
TCB_PTR(cap_reply_cap_get_capTCBPtr(cap)), slot);
@ -692,7 +692,7 @@ performInvocation_Endpoint(endpoint_t *ep, word_t badge,
bool_t canGrant, bool_t block,
bool_t call)
{
sendIPC(block, call, badge, canGrant, ksCurThread, ep);
sendIPC(block, call, badge, canGrant, NODE_STATE(ksCurThread), ep);
return EXCEPTION_NONE;
}
@ -708,6 +708,6 @@ performInvocation_Notification(notification_t *ntfn, word_t badge)
exception_t
performInvocation_Reply(tcb_t *thread, cte_t *slot)
{
doReplyTransfer(ksCurThread, thread, slot);
doReplyTransfer(NODE_STATE(ksCurThread), thread, slot);
return EXCEPTION_NONE;
}

View file

@ -33,7 +33,7 @@ checkPrio(prio_t prio)
{
prio_t mcp;
mcp = ksCurThread->tcbMCP;
mcp = NODE_STATE(ksCurThread)->tcbMCP;
/* system invariant: existing MCPs are bounded */
assert(mcp <= seL4_MaxPrio);
@ -55,8 +55,8 @@ addToBitmap(word_t dom, word_t prio)
word_t l1index;
l1index = prio_to_l1index(prio);
ksReadyQueuesL1Bitmap[dom] |= BIT(l1index);
ksReadyQueuesL2Bitmap[dom][l1index] |= BIT(prio & MASK(wordRadix));
NODE_STATE(ksReadyQueuesL1Bitmap[dom]) |= BIT(l1index);
NODE_STATE(ksReadyQueuesL2Bitmap[dom][l1index]) |= BIT(prio & MASK(wordRadix));
}
static inline void
@ -65,9 +65,9 @@ removeFromBitmap(word_t dom, word_t prio)
word_t l1index;
l1index = prio_to_l1index(prio);
ksReadyQueuesL2Bitmap[dom][l1index] &= ~BIT(prio & MASK(wordRadix));
if (unlikely(!ksReadyQueuesL2Bitmap[dom][l1index])) {
ksReadyQueuesL1Bitmap[dom] &= ~BIT(l1index);
NODE_STATE(ksReadyQueuesL2Bitmap[dom][l1index]) &= ~BIT(prio & MASK(wordRadix));
if (unlikely(!NODE_STATE(ksReadyQueuesL2Bitmap[dom][l1index]))) {
NODE_STATE(ksReadyQueuesL1Bitmap[dom]) &= ~BIT(l1index);
}
}
@ -84,7 +84,7 @@ tcbSchedEnqueue(tcb_t *tcb)
dom = tcb->tcbDomain;
prio = tcb->tcbPriority;
idx = ready_queues_index(dom, prio);
queue = ksReadyQueues[idx];
queue = NODE_STATE(ksReadyQueues[idx]);
if (!queue.end) { /* Empty list */
queue.end = tcb;
@ -96,7 +96,7 @@ tcbSchedEnqueue(tcb_t *tcb)
tcb->tcbSchedNext = queue.head;
queue.head = tcb;
ksReadyQueues[idx] = queue;
NODE_STATE(ksReadyQueues[idx]) = queue;
thread_state_ptr_set_tcbQueued(&tcb->tcbState, true);
}
@ -115,7 +115,7 @@ tcbSchedAppend(tcb_t *tcb)
dom = tcb->tcbDomain;
prio = tcb->tcbPriority;
idx = ready_queues_index(dom, prio);
queue = ksReadyQueues[idx];
queue = NODE_STATE(ksReadyQueues[idx]);
if (!queue.head) { /* Empty list */
queue.head = tcb;
@ -127,7 +127,7 @@ tcbSchedAppend(tcb_t *tcb)
tcb->tcbSchedNext = NULL;
queue.end = tcb;
ksReadyQueues[idx] = queue;
NODE_STATE(ksReadyQueues[idx]) = queue;
thread_state_ptr_set_tcbQueued(&tcb->tcbState, true);
}
@ -146,7 +146,7 @@ tcbSchedDequeue(tcb_t *tcb)
dom = tcb->tcbDomain;
prio = tcb->tcbPriority;
idx = ready_queues_index(dom, prio);
queue = ksReadyQueues[idx];
queue = NODE_STATE(ksReadyQueues[idx]);
if (tcb->tcbSchedPrev) {
tcb->tcbSchedPrev->tcbSchedNext = tcb->tcbSchedNext;
@ -163,7 +163,7 @@ tcbSchedDequeue(tcb_t *tcb)
queue.end = tcb->tcbSchedPrev;
}
ksReadyQueues[idx] = queue;
NODE_STATE(ksReadyQueues[idx]) = queue;
thread_state_ptr_set_tcbQueued(&tcb->tcbState, false);
}
@ -317,10 +317,10 @@ invokeConfigureSingleStepping(word_t *buffer, arch_tcb_t *context,
bp_was_consumed = configureSingleStepping(context, bp_num, n_instrs, false);
if (n_instrs == 0) {
unsetBreakpointUsedFlag(context, bp_num);
setMR(ksCurThread, buffer, 0, false);
setMR(NODE_STATE(ksCurThread), buffer, 0, false);
} else {
setBreakpointUsedFlag(context, bp_num);
setMR(ksCurThread, buffer, 0, bp_was_consumed);
setMR(NODE_STATE(ksCurThread), buffer, 0, bp_was_consumed);
}
return EXCEPTION_NONE;
}
@ -346,7 +346,7 @@ decodeConfigureSingleStepping(cap_t cap, word_t *buffer)
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeConfigureSingleStepping(buffer, context, bp_num, n_instrs);
}
@ -476,7 +476,7 @@ decodeSetBreakpoint(cap_t cap, word_t *buffer)
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeSetBreakpoint(context, bp_num,
vaddr, type, size, rw);
}
@ -487,11 +487,11 @@ invokeGetBreakpoint(word_t *buffer, arch_tcb_t *context, uint16_t bp_num)
getBreakpoint_t res;
res = getBreakpoint(context, bp_num);
setMR(ksCurThread, buffer, 0, res.vaddr);
setMR(ksCurThread, buffer, 1, res.type);
setMR(ksCurThread, buffer, 2, res.size);
setMR(ksCurThread, buffer, 3, res.rw);
setMR(ksCurThread, buffer, 4, res.is_enabled);
setMR(NODE_STATE(ksCurThread), buffer, 0, res.vaddr);
setMR(NODE_STATE(ksCurThread), buffer, 1, res.type);
setMR(NODE_STATE(ksCurThread), buffer, 2, res.size);
setMR(NODE_STATE(ksCurThread), buffer, 3, res.rw);
setMR(NODE_STATE(ksCurThread), buffer, 4, res.is_enabled);
return EXCEPTION_NONE;
}
@ -514,7 +514,7 @@ decodeGetBreakpoint(cap_t cap, word_t *buffer)
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeGetBreakpoint(buffer, context, bp_num);
}
@ -546,7 +546,7 @@ decodeUnsetBreakpoint(cap_t cap, word_t *buffer)
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeUnsetBreakpoint(context, bp_num);
}
#endif /* CONFIG_HARDWARE_DEBUG_API */
@ -573,12 +573,12 @@ decodeTCBInvocation(word_t invLabel, word_t length, cap_t cap,
case TCBSuspend:
/* Jump straight to the invoke */
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_Suspend(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)));
case TCBResume:
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_Resume(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)));
@ -662,7 +662,7 @@ decodeCopyRegisters(cap_t cap, word_t length,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_CopyRegisters(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), srcTCB,
flags & BIT(CopyRegisters_suspendSource),
@ -706,13 +706,13 @@ decodeReadRegisters(cap_t cap, word_t length, bool_t call,
transferArch = Arch_decodeTransfer(flags >> 8);
thread = TCB_PTR(cap_thread_cap_get_capTCBPtr(cap));
if (thread == ksCurThread) {
if (thread == NODE_STATE(ksCurThread)) {
userError("TCB ReadRegisters: Attempted to read our own registers.");
current_syscall_error.type = seL4_IllegalOperation;
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_ReadRegisters(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)),
flags & BIT(ReadRegisters_suspend),
@ -749,13 +749,13 @@ decodeWriteRegisters(cap_t cap, word_t length, word_t *buffer)
transferArch = Arch_decodeTransfer(flags >> 8);
thread = TCB_PTR(cap_thread_cap_get_capTCBPtr(cap));
if (thread == ksCurThread) {
if (thread == NODE_STATE(ksCurThread)) {
userError("TCB WriteRegisters: Attempted to write our own registers.");
current_syscall_error.type = seL4_IllegalOperation;
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_WriteRegisters(thread,
flags & BIT(WriteRegisters_resume),
w, transferArch, buffer);
@ -804,14 +804,14 @@ decodeTCBConfigure(cap_t cap, word_t length, cte_t* slot,
status = checkPrio(prio);
if (status != EXCEPTION_NONE) {
userError("TCB Configure: Requested priority %lu too high (max %lu).",
(unsigned long) prio, (unsigned long) ksCurThread->tcbMCP);
(unsigned long) prio, (unsigned long) NODE_STATE(ksCurThread)->tcbMCP);
return status;
}
status = checkPrio(mcp);
if (status != EXCEPTION_NONE) {
userError("TCB Configure: Requested maximum controlled priority %lu too high (max %lu),",
(unsigned long) mcp, (unsigned long) ksCurThread->tcbMCP);
(unsigned long) mcp, (unsigned long) NODE_STATE(ksCurThread)->tcbMCP);
return status;
}
@ -871,7 +871,7 @@ decodeTCBConfigure(cap_t cap, word_t length, cte_t* slot,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_ThreadControl(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), slot,
faultEP, mcp, prio,
@ -898,11 +898,11 @@ decodeSetPriority(cap_t cap, word_t length, word_t *buffer)
status = checkPrio(newPrio);
if (status != EXCEPTION_NONE) {
userError("TCB SetPriority: Requested priority %lu too high (max %lu).",
(unsigned long) newPrio, (unsigned long) ksCurThread->tcbMCP);
(unsigned long) newPrio, (unsigned long) NODE_STATE(ksCurThread)->tcbMCP);
return status;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_ThreadControl(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), NULL,
0, NULL_PRIO, newPrio,
@ -929,11 +929,11 @@ decodeSetMCPriority(cap_t cap, word_t length, word_t *buffer)
status = checkPrio(newMcp);
if (status != EXCEPTION_NONE) {
userError("TCB SetMCPriority: Requested maximum controlled priority %lu too high (max %lu).",
(unsigned long) newMcp, (unsigned long) ksCurThread->tcbMCP);
(unsigned long) newMcp, (unsigned long) NODE_STATE(ksCurThread)->tcbMCP);
return status;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_ThreadControl(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), NULL,
0, newMcp, NULL_PRIO,
@ -978,7 +978,7 @@ decodeSetIPCBuffer(cap_t cap, word_t length, cte_t* slot,
}
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_ThreadControl(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), slot,
0, NULL_PRIO, NULL_PRIO,
@ -1055,7 +1055,7 @@ decodeSetSpace(cap_t cap, word_t length, cte_t* slot,
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_ThreadControl(
TCB_PTR(cap_thread_cap_get_capTCBPtr(cap)), slot,
faultEP,
@ -1105,7 +1105,7 @@ decodeDomainInvocation(word_t invLabel, word_t length, extra_caps_t excaps, word
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
setDomain(TCB_PTR(cap_thread_cap_get_capTCBPtr(tcap)), domain);
return EXCEPTION_NONE;
}
@ -1155,7 +1155,7 @@ decodeBindNotification(cap_t cap, extra_caps_t excaps)
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_NotificationControl(tcb, ntfnPtr);
}
@ -1172,7 +1172,7 @@ decodeUnbindNotification(cap_t cap)
return EXCEPTION_SYSCALL_ERROR;
}
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeTCB_NotificationControl(tcb, NULL);
}
@ -1317,13 +1317,13 @@ invokeTCB_ReadRegisters(tcb_t *tcb_src, bool_t suspendSource,
exception_t e;
tcb_t *thread;
thread = ksCurThread;
thread = NODE_STATE(ksCurThread);
if (suspendSource) {
suspend(tcb_src);
}
e = Arch_performTransfer(arch, tcb_src, ksCurThread);
e = Arch_performTransfer(arch, tcb_src, NODE_STATE(ksCurThread));
if (e != EXCEPTION_NONE) {
return e;
}
@ -1378,7 +1378,7 @@ invokeTCB_WriteRegisters(tcb_t *dest, bool_t resumeTarget,
word_t pc;
exception_t e;
e = Arch_performTransfer(arch, ksCurThread, dest);
e = Arch_performTransfer(arch, NODE_STATE(ksCurThread), dest);
if (e != EXCEPTION_NONE) {
return e;
}

View file

@ -220,7 +220,7 @@ decodeUntypedInvocation(word_t invLabel, word_t length, cte_t *slot,
alignedFreeRef = alignUp(freeRef, objectSize);
/* Perform the retype. */
setThreadState(ksCurThread, ThreadState_Restart);
setThreadState(NODE_STATE(ksCurThread), ThreadState_Restart);
return invokeUntyped_Retype(
slot, WORD_PTR(cap_untyped_cap_get_capPtr(cap)),
(void*)alignedFreeRef, newType, userObjSize, slots, call,