diff options
| author | Patrick Williams <iawillia@us.ibm.com> | 2011-08-22 10:34:45 -0500 |
|---|---|---|
| committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2011-08-22 12:24:55 -0500 |
| commit | c6571028ca3b54ba0a4ec73d1f39fdeba6c79fb9 (patch) | |
| tree | 4275488285e93e4c2386a6c3fc2f1f7855d2a03a /src/kernel | |
| parent | d329a4202e1f4a8b3283e31e2dfb5a838c49796e (diff) | |
| download | talos-hostboot-c6571028ca3b54ba0a4ec73d1f39fdeba6c79fb9.tar.gz talos-hostboot-c6571028ca3b54ba0a4ec73d1f39fdeba6c79fb9.zip | |
Create initial stack-frame from userspace.
Change-Id: Ie1133bd079e7b9a8f2f82daa06efc426bf0fd0d6
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/268
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/kernel')
| -rw-r--r-- | src/kernel/start.S | 10 | ||||
| -rw-r--r-- | src/kernel/taskmgr.C | 18 |
2 files changed, 19 insertions, 9 deletions
diff --git a/src/kernel/start.S b/src/kernel/start.S index bdf872d9d..d67cb7790 100644 --- a/src/kernel/start.S +++ b/src/kernel/start.S @@ -393,10 +393,18 @@ system_call_fast_path: ;// Results: ;// * TOC base -> GPR2 ;// * Function Address -> CTR - ;// * GPR1, GPR3 preserved. + ;// * GPR3 preserved. + ;// * Initial stack-frame created. ;// * Branch to CTR (no link). .global userspace_task_entry userspace_task_entry: + ;// Skip stack frame if GPR1 == NULL. + cmpi cr0, r1, 0 + beq- 1f + ;// Create frame. + ;// NULL back-chain + 48 bytes + quad-word alignment. See ABI. + stdu r1, -56(r1) +1: ld r5, 0(r4) mtctr r5 ld r2, 8(r4) diff --git a/src/kernel/taskmgr.C b/src/kernel/taskmgr.C index 7d2454b6d..d23115152 100644 --- a/src/kernel/taskmgr.C +++ b/src/kernel/taskmgr.C @@ -50,20 +50,20 @@ task_t* TaskManager::_createIdleTask() return this->_createTask(&TaskManager::idleTaskLoop, NULL, false); } -task_t* TaskManager::_createTask(TaskManager::task_fn_t t, +task_t* TaskManager::_createTask(TaskManager::task_fn_t t, void* p, bool withStack) { task_t* task = new task_t; memset(task, '\0', sizeof(task_t)); task->tid = this->getNextTid(); - - // Set NIP to be userspace_task_entry stub and GPR3 to be the + + // Set NIP to be userspace_task_entry stub and GPR3 to be the // function pointer for the desired task entry point. task->context.nip = reinterpret_cast<void*>(&userspace_task_entry); task->context.gprs[4] = reinterpret_cast<uint64_t>(t); - // Set up LR to be the entry point for task_end in case a task + // Set up LR to be the entry point for task_end in case a task // 'returns' from its entry point. By the Power ABI, the entry // point address is in (func_ptr)[0]. task->context.lr = reinterpret_cast<uint64_t*>(&task_end)[0]; @@ -73,19 +73,21 @@ task_t* TaskManager::_createTask(TaskManager::task_fn_t t, // Set up argument. task->context.gprs[3] = (uint64_t) p; - + // Setup stack. if (withStack) { - task->context.stack_ptr = + task->context.stack_ptr = PageManager::allocatePage(TASK_DEFAULT_STACK_SIZE); - memset(task->context.stack_ptr, '\0', + memset(task->context.stack_ptr, '\0', TASK_DEFAULT_STACK_SIZE * PAGESIZE); - task->context.gprs[1] = ((uint64_t)task->context.stack_ptr) + 16320; + task->context.gprs[1] = ((uint64_t)task->context.stack_ptr) + + TASK_DEFAULT_STACK_SIZE * PAGESIZE - 8; } else { task->context.stack_ptr = NULL; + task->context.gprs[1] = NULL; } return task; |

