Annotation of prex-old/sys/arch/arm/include/arch.h, Revision 1.1.1.1
1.1 nbrk 1: /*
2: * Copyright (c) 2005, Kohsuke Ohtani
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. Neither the name of the author nor the names of any co-contributors
14: * may be used to endorse or promote products derived from this software
15: * without specific prior written permission.
16: *
17: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27: * SUCH DAMAGE.
28: */
29:
30: #ifndef _ARCH_H
31: #define _ARCH_H
32:
33: /**
34: * ARM register reference:
35: *
36: * Name Number ARM Procedure Calling Standard Role
37: *
38: * a1 r0 argument 1 / integer result / scratch register / argc
39: * a2 r1 argument 2 / scratch register / argv
40: * a3 r2 argument 3 / scratch register / envp
41: * a4 r3 argument 4 / scratch register
42: * v1 r4 register variable
43: * v2 r5 register variable
44: * v3 r6 register variable
45: * v4 r7 register variable
46: * v5 r8 register variable
47: * sb/v6 r9 static base / register variable
48: * sl/v7 r10 stack limit / stack chunk handle / reg. variable
49: * fp r11 frame pointer
50: * ip r12 scratch register / new-sb in inter-link-unit calls
51: * sp r13 lower end of current stack frame
52: * lr r14 link address / scratch register
53: * pc r15 program counter
54: */
55:
56: /*
57: * Common register frame for trap/interrupt.
58: * These cpu state are saved into top of the kernel stack in
59: * trap/interrupt entries. Since the arguments of system calls are
60: * passed via registers, the system call library is completely
61: * dependent on this register format.
62: */
63: struct cpu_regs {
64: u_long r0; /* +0 (00) */
65: u_long r1; /* +4 (04) */
66: u_long r2; /* +8 (08) */
67: u_long r3; /* +12 (0C) */
68: u_long r4; /* +16 (10) */
69: u_long r5; /* +20 (14) */
70: u_long r6; /* +24 (18) */
71: u_long r7; /* +28 (1C) */
72: u_long r8; /* +32 (20) */
73: u_long r9; /* +36 (24) */
74: u_long r10; /* +40 (28) */
75: u_long r11; /* +44 (2C) */
76: u_long r12; /* +48 (30) */
77: u_long sp; /* +52 (34) */
78: u_long lr; /* +56 (38) */
79: u_long svc_sp; /* +60 (3C) */
80: u_long svc_lr; /* +64 (40) */
81: u_long pc; /* +68 (44) */
82: u_long cpsr; /* +72 (48) */
83: };
84:
85: /*
86: * Kernel mode context for context switching.
87: */
88: struct kern_regs {
89: u_long r4;
90: u_long r5;
91: u_long r6;
92: u_long r7;
93: u_long r8;
94: u_long r9;
95: u_long r10;
96: u_long r11;
97: u_long sp;
98: u_long lr;
99: };
100:
101: /*
102: * Processor context
103: */
104: struct context {
105: struct kern_regs kregs; /* Kernel mode registers */
106: struct cpu_regs *uregs; /* User mode registers */
107: };
108:
109: typedef struct context *context_t; /* context id */
110:
111: /* Types for context_set */
112: #define CTX_UENTRY 0 /* Set user mode entry addres */
113: #define CTX_USTACK 1 /* Set user mode stack address */
114: #define CTX_KENTRY 2 /* Set kernel mode entry address */
115: #define CTX_KARG 3 /* Set kernel mode argument */
116:
117: extern void context_init(context_t, u_long);
118: extern void context_set(context_t, int type, u_long);
119: extern void context_switch(context_t, context_t);
120: extern void context_save(context_t, int);
121: extern void context_restore(context_t, void *);
122:
123: /*
124: * Memory Management Unit
125: */
126:
127: typedef long *pgd_t; /* Page directory */
128:
129: /* Memory page type */
130: #define PG_UNMAP 0 /* no page */
131: #define PG_READ 1 /* read only */
132: #define PG_WRITE 2 /* read/write */
133:
134: #ifdef CONFIG_MMU
135: extern void mmu_init(void);
136: extern int mmu_map(pgd_t, void *, void *, size_t, int);
137: extern pgd_t mmu_newmap(void);
138: extern void mmu_delmap(pgd_t);
139: extern void mmu_switch(pgd_t);
140: extern void *mmu_extract(pgd_t, void *, size_t);
141: #else /* CONFIG_MMU */
142: #define mmu_init() do {} while (0)
143: #endif /* !CONFIG_MMU */
144:
145: /*
146: * User Memory access
147: */
148: extern int umem_copyin(void *, void *, size_t);
149: extern int umem_copyout(void *, void *, size_t);
150: extern int umem_strnlen(const char *, size_t, size_t *);
151:
152: /* #define breakpoint() __asm__ __volatile__("bkpt"::) */
153: #define breakpoint() do {} while (0);
154:
155: #endif /* !_ARCH_H */
CVSweb