|
POK(kernelpart)
|
Generic interface to handle architectures. More...
Go to the source code of this file.
| pok_ret_t pok_arch_event_register | ( | uint8_t | vector, |
| void(*)(void) | handler | ||
| ) |
Register an event (for example, an interruption)
Attach the handler to the given trap number (vector).
Definition at line 83 of file arch.c.
{
(void) vector;
(void) handler;
return (POK_ERRNO_OK);
}
Function that do nothing. Useful for the idle task for example.
Definition at line 74 of file arch.c.
{
while (1)
{
}
return (POK_ERRNO_OK);
}
Function that initializes architecture concerns.
Initialize all SPARC managers (traps, syscalls, space).
Definition at line 43 of file arch.c.
{
set_msr (MSR_IP);
#if POK_NEEDS_PARTITIONS
pok_arch_space_init();
#endif
return (POK_ERRNO_OK);
}
Disable interruptions
Definition at line 53 of file arch.c.
{
unsigned int msr;
msr = get_msr();
msr &= ~MSR_EE;
set_msr(msr);
return (POK_ERRNO_OK);
}
Enable interruptions
Definition at line 63 of file arch.c.
{
unsigned int msr;
msr = get_msr();
msr |= MSR_EE;
set_msr(msr);
return (POK_ERRNO_OK);
}
| uint32_t pok_context_create | ( | uint32_t | thread_id, |
| uint32_t | stack_size, | ||
| uint32_t | entry | ||
| ) |
| void pok_context_reset | ( | uint32_t | stack_size, |
| uint32_t | stack_addr | ||
| ) |
| void pok_context_switch | ( | uint32_t * | old_sp, |
| uint32_t | new_sp | ||
| ) |
| pok_ret_t pok_create_space | ( | uint8_t | partition_id, |
| uint32_t | addr, | ||
| uint32_t | size | ||
| ) |
| void pok_dispatch_space | ( | uint8_t | partition_id, |
| uint32_t | user_pc, | ||
| uint32_t | user_sp, | ||
| uint32_t | kernel_sp, | ||
| uint32_t | arg1, | ||
| uint32_t | arg2 | ||
| ) |
Definition at line 114 of file space.c.
{
interrupt_frame ctx;
uint32_t code_sel;
uint32_t data_sel;
uint32_t sp;
code_sel = GDT_BUILD_SELECTOR (GDT_PARTITION_CODE_SEGMENT (partition_id), 0, 3);
data_sel = GDT_BUILD_SELECTOR (GDT_PARTITION_DATA_SEGMENT (partition_id), 0, 3);
sp = (uint32_t) &ctx;
memset (&ctx, 0, sizeof (interrupt_frame));
pok_arch_preempt_disable ();
ctx.es = ctx.ds = ctx.ss = data_sel;
ctx.__esp = (uint32_t) (&ctx.error); /* for pusha */
ctx.eip = user_pc;
ctx.eax = arg1;
ctx.ebx = arg2;
ctx.cs = code_sel;
ctx.eflags = 1 << 9;
ctx.esp = user_sp;
tss_set_esp0 (kernel_sp);
asm ("mov %0, %%esp \n"
"pop %%es \n"
"pop %%ds \n"
"popa \n"
"addl $4, %%esp \n"
"iret \n"
:
: "m" (sp)
);
}
| uint32_t pok_space_base_vaddr | ( | uint32_t | addr | ) |
Definition at line 64 of file space.c.
{
(void) addr;
return (0);
}
| uint32_t pok_space_context_create | ( | uint8_t | id, |
| uint32_t | entry_rel, | ||
| uint32_t | stack_rel, | ||
| uint32_t | arg1, | ||
| uint32_t | arg2 | ||
| ) |
Create a new context in the given space
Initilize thread stack.
Definition at line 72 of file space.c.
{
context_t* ctx;
volatile_context_t* vctx;
char* stack_addr;
(void) partition_id;
stack_addr = pok_bsp_mem_alloc (KERNEL_STACK_SIZE);
vctx = (volatile_context_t *)
(stack_addr + KERNEL_STACK_SIZE - sizeof (volatile_context_t));
ctx = (context_t *)((char *)vctx - sizeof (context_t) + 8);
memset (ctx, 0, sizeof (*ctx));
memset (vctx, 0, sizeof (*vctx));
vctx->r3 = arg1;
vctx->r4 = arg2;
vctx->sp = stack_rel - 12;
vctx->srr0 = entry_rel;
vctx->srr1 = MSR_EE | MSR_IP | MSR_DR | MSR_IR | MSR_PR;
ctx->lr = (uint32_t) pok_arch_rfi;
ctx->sp = (uint32_t) &vctx->sp;
#ifdef POK_NEEDS_DEBUG
printf ("space_context_create %d: entry=%x stack=%x arg1=%x arg2=%x ksp=%x\n",
partition_id, entry_rel, stack_rel, arg1, arg2, &vctx->sp);
#endif
return (uint32_t)ctx;
}
| void pok_space_context_restart | ( | uint32_t | sp, |
| uint32_t | entry, | ||
| uint32_t | user_stack | ||
| ) |
| pok_ret_t pok_space_switch | ( | uint8_t | old_partition_id, |
| uint8_t | new_partition_id | ||
| ) |
Switch from one space to another
Switch adress space in MMU (context register).
Definition at line 55 of file space.c.
{
(void) old_partition_id;
/* printf ("space_switch %u -> %u\n", old_partition_id, new_partition_id); */
asm volatile ("mtsr %0,%1" : : "r"(0), "r"(PPC_SR_KP | new_partition_id));
return (POK_ERRNO_OK);
}
| uint32_t pok_thread_stack_addr | ( | const uint8_t | partition_id, |
| const uint32_t | local_thread_id | ||
| ) |
Returns the stack address for a the thread number N in a partition.
Compute the stack adress for the given thread.
Definition at line 92 of file arch.c.
{
return pok_partitions[partition_id].size - 16 - (local_thread_id * POK_USER_STACK_SIZE);
}