Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / arch / x86_64 / kernel / task.c
1 #include <lwk/kernel.h>
2 #include <lwk/aspace.h>
3 #include <lwk/task.h>
4 #include <arch/ptrace.h>
5
6 int
7 arch_task_create(struct task_struct *task,
8                  const start_state_t *start_state)
9 {
10         struct pt_regs *regs;
11         kaddr_t kstack_top;
12         kaddr_t initial_ksp;
13
14         regs        = ((struct pt_regs *)((kaddr_t)task + TASK_SIZE)) - 1;
15         kstack_top  = (kaddr_t)(regs + 1);
16         initial_ksp = (kaddr_t)regs;
17
18         task->arch.thread.rsp0    = kstack_top;
19         task->arch.thread.rsp     = initial_ksp;
20         task->arch.thread.userrsp = start_state->stack_ptr;
21
22         /* Mark this as a new-task... arch_context_switch() checks this flag */
23         task->arch.flags = TF_NEW_TASK;
24
25         /* Task's address space is from [0, task->addr_limit) */
26         task->arch.addr_limit = PAGE_OFFSET;
27
28         /* Initialize FPU state */
29         task->arch.thread.i387.fxsave.cwd = 0x37f;
30         task->arch.thread.i387.fxsave.mxcsr = 0x1f80;
31
32         /* CPU control unit uses these fields to start the user task running */
33         if (start_state->aspace_id == KERNEL_ASPACE_ID) {
34                 regs->ss     = __KERNEL_DS;
35                 regs->rsp    = (vaddr_t)task + TASK_SIZE;
36                 regs->eflags = (1 << 9);  /* enable interrupts */
37                 regs->cs     = __KERNEL_CS;
38         } else {
39                 regs->ss     = __USER_DS;
40                 regs->rsp    = start_state->stack_ptr;
41                 regs->eflags = (1 << 9);  /* enable interrupts */
42                 regs->cs     = __USER_CS;
43         }
44         regs->rip = start_state->entry_point;
45
46         return 0;
47 }