root / prex-0.9.0 / bsp / hal / ppc / include / context.h @ 03e9c04a
History | View | Annotate | Download (3.43 KB)
1 |
/*-
|
---|---|
2 |
* Copyright (c) 2009, 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 _PPC_CONTEXT_H
|
31 |
#define _PPC_CONTEXT_H
|
32 |
|
33 |
#ifndef __ASSEMBLY__
|
34 |
|
35 |
#include <sys/types.h> |
36 |
|
37 |
/*
|
38 |
* Common register frame for trap/interrupt.
|
39 |
* These cpu state are saved into top of the kernel stack in
|
40 |
* trap/interrupt entries. Since the arguments of system calls are
|
41 |
* passed via registers, the system call library is completely
|
42 |
* dependent on this register format.
|
43 |
*/
|
44 |
struct cpu_regs {
|
45 |
uint32_t gr[32]; /* R0-R31 */ |
46 |
uint32_t lr; |
47 |
uint32_t cr; |
48 |
uint32_t xer; |
49 |
uint32_t ctr; |
50 |
uint32_t srr0; |
51 |
uint32_t srr1; |
52 |
uint32_t trap_no; /* trap number */
|
53 |
}; |
54 |
|
55 |
/*
|
56 |
* Kernel mode context for context switching.
|
57 |
*/
|
58 |
struct kern_regs {
|
59 |
uint32_t gr[19]; /* R13-R31 */ |
60 |
uint32_t r2; |
61 |
uint32_t sp; |
62 |
uint32_t lr; |
63 |
uint32_t cr; |
64 |
uint32_t kstack; /* kernel stack */
|
65 |
}; |
66 |
|
67 |
/*
|
68 |
* Processor context
|
69 |
*/
|
70 |
struct context {
|
71 |
struct kern_regs kregs; /* kernel mode registers */ |
72 |
struct cpu_regs *uregs; /* user mode registers */ |
73 |
struct cpu_regs *saved_regs; /* saved user mode registers */ |
74 |
}; |
75 |
|
76 |
typedef struct context *context_t; /* context id */ |
77 |
|
78 |
#endif /* !__ASSEMBLY__ */ |
79 |
|
80 |
#define REG_R0 0x00 |
81 |
#define REG_R1 0x04 |
82 |
#define REG_R2 0x08 |
83 |
#define REG_R3 0x0c |
84 |
#define REG_R4 0x10 |
85 |
#define REG_R5 0x14 |
86 |
#define REG_R6 0x18 |
87 |
#define REG_R7 0x1c |
88 |
#define REG_R8 0x20 |
89 |
#define REG_R9 0x24 |
90 |
#define REG_R10 0x28 |
91 |
#define REG_R11 0x2c |
92 |
#define REG_R12 0x30 |
93 |
#define REG_R13 0x34 |
94 |
#define REG_R14 0x38 |
95 |
#define REG_R15 0x3c |
96 |
#define REG_R16 0x40 |
97 |
#define REG_R17 0x44 |
98 |
#define REG_R18 0x48 |
99 |
#define REG_R19 0x4c |
100 |
#define REG_R20 0x50 |
101 |
#define REG_R21 0x54 |
102 |
#define REG_R22 0x58 |
103 |
#define REG_R23 0x5c |
104 |
#define REG_R24 0x60 |
105 |
#define REG_R25 0x64 |
106 |
#define REG_R26 0x68 |
107 |
#define REG_R27 0x6c |
108 |
#define REG_R28 0x70 |
109 |
#define REG_R29 0x74 |
110 |
#define REG_R30 0x78 |
111 |
#define REG_R31 0x7c |
112 |
#define REG_LR 0x80 |
113 |
#define REG_CR 0x84 |
114 |
#define REG_XER 0x88 |
115 |
#define REG_CTR 0x8c |
116 |
#define REG_SRR0 0x90 |
117 |
#define REG_SRR1 0x94 |
118 |
#define CTX_TRAPNO 0x98 |
119 |
|
120 |
#define CTXREGS (4*39) |
121 |
|
122 |
#endif /* !_PPC_CONTEXT_H */ |