ia64/xen-unstable

view extras/mini-os/arch/ia64/sched.c @ 18106:f4135a620f59

mini-os: add stack walking debug

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 18 14:09:14 2008 +0100 (2008-07-18)
parents 8f6640070a86
children
line source
1 /*
2 * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com
3 *
4 * Description: ia64 specific part of the scheduler for mini-os
5 *
6 ****************************************************************************
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to
10 * deal in the Software without restriction, including without limitation the
11 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 * sell copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
28 #include "types.h"
29 #include "sched.h"
30 #include "lib.h"
31 #include "xmalloc.h"
32 #include "mm.h"
34 /* The function is implemented in fw.S */
35 extern void thread_starter(void);
37 void stack_walk(void)
38 {
39 /* TODO */
40 }
42 struct thread*
43 arch_create_thread(char *name, void (*function)(void *), void *data)
44 {
45 struct thread* _thread;
47 _thread = (struct thread*)_xmalloc(sizeof(struct thread), 16);
48 /* Allocate pages for stack, stack will be aligned */
49 _thread->stack = (char *)alloc_pages(STACK_SIZE_PAGE_ORDER);
50 _thread->name = name;
51 memset((void*)&(_thread->regs), 0, sizeof(_thread->regs));
52 _thread->regs.sp = ((uint64_t)_thread->stack) + STACK_SIZE - 16;
53 _thread->regs.bsp = ((uint64_t)_thread->stack) + 0x10;
54 _thread->regs.rp = FDESC_FUNC(thread_starter);
55 _thread->regs.pfs = 0x82;
56 _thread->regs.r4 = FDESC_FUNC(function);
57 _thread->regs.r6 = (uint64_t)data;
58 return _thread;
59 }
61 extern void restore_context(struct thread*);
62 extern int switch_context(struct thread*, struct thread*);
64 void
65 arch_switch_threads(struct thread* prev, struct thread* next)
66 {
67 ia64_set_r13((uint64_t)next);
68 switch_context(prev, next);
69 }
71 /* Everything initialised, start idle thread */
72 void
73 run_idle_thread(void)
74 {
75 //do_busy_loop();
76 ia64_set_r13((uint64_t)idle_thread);
77 restore_context(idle_thread);
78 printk("%s: restore_context() returned - bad!\n", __func__);
79 }