1 /*
2  *  linux/include/asm-arm/proc-armv/processor.h
3  *
4  *  Copyright (C) 1996-1999 Russell King.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  *  Changelog:
11  *   20-09-1996	RMK	Created
12  *   26-09-1996	RMK	Added 'EXTRA_THREAD_STRUCT*'
13  *   28-09-1996	RMK	Moved start_thread into the processor dependencies
14  *   09-09-1998	PJB	Delete redundant `wp_works_ok'
15  *   30-05-1999	PJB	Save sl across context switches
16  *   31-07-1999	RMK	Added 'domain' stuff
17  */
18 #ifndef __ASM_PROC_PROCESSOR_H
19 #define __ASM_PROC_PROCESSOR_H
20 
21 #include <asm/proc/domain.h>
22 
23 #define KERNEL_STACK_SIZE	PAGE_SIZE
24 
25 struct context_save_struct {
26 	unsigned long cpsr;
27 	unsigned long r4;
28 	unsigned long r5;
29 	unsigned long r6;
30 	unsigned long r7;
31 	unsigned long r8;
32 	unsigned long r9;
33 	unsigned long sl;
34 	unsigned long fp;
35 	unsigned long pc;
36 };
37 
38 #define INIT_CSS (struct context_save_struct){ SVC_MODE, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
39 
40 #define EXTRA_THREAD_STRUCT						\
41 	unsigned int	domain;
42 
43 #define EXTRA_THREAD_STRUCT_INIT					\
44 	domain:	  domain_val(DOMAIN_USER, DOMAIN_CLIENT) |		\
45 		  domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) |		\
46 		  domain_val(DOMAIN_IO, DOMAIN_CLIENT)
47 
48 #define start_thread(regs,pc,sp)					\
49 ({									\
50 	unsigned long *stack = (unsigned long *)sp;			\
51 	set_fs(USER_DS);						\
52 	memzero(regs->uregs, sizeof(regs->uregs));			\
53 	if (current->personality & ADDR_LIMIT_32BIT)			\
54 		regs->ARM_cpsr = USR_MODE;				\
55 	else								\
56 		regs->ARM_cpsr = USR26_MODE;				\
57 	regs->ARM_pc = pc;		/* pc */			\
58 	regs->ARM_sp = sp;		/* sp */			\
59 	regs->ARM_r2 = stack[2];	/* r2 (envp) */			\
60 	regs->ARM_r1 = stack[1];	/* r1 (argv) */			\
61 	regs->ARM_r0 = stack[0];	/* r0 (argc) */			\
62 })
63 
64 #define KSTK_EIP(tsk)	(((unsigned long *)(4096+(unsigned long)(tsk)))[1019])
65 #define KSTK_ESP(tsk)	(((unsigned long *)(4096+(unsigned long)(tsk)))[1017])
66 
67 /* Allocation and freeing of basic task resources. */
68 /*
69  * NOTE! The task struct and the stack go together
70  */
71 #define ll_alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1))
72 #define ll_free_task_struct(p) free_pages((unsigned long)(p),1)
73 
74 #endif
75