00001 /* 00002 * Copyright (C) 2005 Jakub Jermar 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * - Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * - Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * - The name of the author may not be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00019 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00020 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00022 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00024 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00026 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00035 #ifndef __ia64_CONTEXT_H__ 00036 #define __ia64_CONTEXT_H__ 00037 00038 #include <arch/types.h> 00039 #include <arch/register.h> 00040 #include <typedefs.h> 00041 #include <align.h> 00042 #include <arch/stack.h> 00043 00044 /* 00045 * context_save_arch() and context_restore_arch() are both leaf procedures. 00046 * No need to allocate scratch area. 00047 * 00048 * One item is put onto the stack to support get_stack_base(). 00049 */ 00050 #define SP_DELTA (0+ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT)) 00051 00052 #ifdef context_set 00053 #undef context_set 00054 #endif 00055 00056 /* RSE stack starts at the bottom of memory stack. */ 00057 #define context_set(c, _pc, stack, size) \ 00058 do { \ 00059 (c)->pc = (__address) _pc; \ 00060 (c)->bsp = ((__address) stack) + ALIGN_UP((size), REGISTER_STACK_ALIGNMENT); \ 00061 (c)->ar_pfs &= PFM_MASK; \ 00062 (c)->sp = ((__address) stack) + ALIGN_UP((size), STACK_ALIGNMENT) - SP_DELTA; \ 00063 } while (0); 00064 00065 /* 00066 * Only save registers that must be preserved across 00067 * function calls. 00068 */ 00069 struct context { 00070 00071 /* 00072 * Application registers 00073 */ 00074 __u64 ar_pfs; 00075 __u64 ar_unat_caller; 00076 __u64 ar_unat_callee; 00077 __u64 ar_rsc; 00078 __address bsp; /* ar_bsp */ 00079 __u64 ar_rnat; 00080 __u64 ar_lc; 00081 00082 /* 00083 * General registers 00084 */ 00085 __u64 r1; 00086 __u64 r4; 00087 __u64 r5; 00088 __u64 r6; 00089 __u64 r7; 00090 __address sp; /* r12 */ 00091 __u64 r13; 00092 00093 /* 00094 * Branch registers 00095 */ 00096 __address pc; /* b0 */ 00097 __u64 b1; 00098 __u64 b2; 00099 __u64 b3; 00100 __u64 b4; 00101 __u64 b5; 00102 00103 /* 00104 * Predicate registers 00105 */ 00106 __u64 pr; 00107 00108 __r128 f2 __attribute__ ((aligned(16))); 00109 __r128 f3; 00110 __r128 f4; 00111 __r128 f5; 00112 00113 __r128 f16; 00114 __r128 f17; 00115 __r128 f18; 00116 __r128 f19; 00117 __r128 f20; 00118 __r128 f21; 00119 __r128 f22; 00120 __r128 f23; 00121 __r128 f24; 00122 __r128 f25; 00123 __r128 f26; 00124 __r128 f27; 00125 __r128 f28; 00126 __r128 f29; 00127 __r128 f30; 00128 __r128 f31; 00129 00130 ipl_t ipl; 00131 }; 00132 00133 #endif 00134