arch/ia64/include/psthread.h

Go to the documentation of this file.
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 __LIBC__ia64PSTHREAD_H__
00036 #define __LIBC__ia64PSTHREAD_H__
00037 
00038 #include <types.h>
00039 #include <align.h>
00040 #include <libarch/stack.h>
00041 #include <arch/types.h>
00042 
00043 /*
00044  * context_save() and context_restore() are both leaf procedures.
00045  * No need to allocate scratch area.
00046  */
00047 #define SP_DELTA        (0+ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT))
00048 
00049 #define PFM_MASK        (~0x3fffffffff)
00050 
00051 #define PSTHREAD_INITIAL_STACK_PAGES_NO 2
00052 /* Stack is divided into two equal parts (for memory stack and register stack). */
00053 #define PSTHREAD_INITIAL_STACK_DIVISION 2  
00054 
00055 #ifdef context_set
00056 #undef context_set
00057 #endif
00058 
00059 #define context_set(c, _pc, stack, size, tls)                                                           \
00060         do {                                                                                            \
00061                 (c)->pc = (uint64_t) _pc;                                                               \
00062                 (c)->bsp = ((uint64_t) stack) + size / PSTHREAD_INITIAL_STACK_DIVISION;                                                         \
00063                 (c)->ar_pfs &= PFM_MASK;                                                                \
00064                 (c)->sp = ((uint64_t) stack) + ALIGN_UP((size / PSTHREAD_INITIAL_STACK_DIVISION), STACK_ALIGNMENT) - SP_DELTA;          \
00065                 (c)->tp = (uint64_t) tls;                                                               \
00066         } while (0);
00067         
00068 
00069 /*
00070  * Only save registers that must be preserved across
00071  * function calls.
00072  */
00073 typedef struct context {
00074 
00075         /*
00076          * Application registers
00077          */
00078         uint64_t ar_pfs;
00079         uint64_t ar_unat_caller;
00080         uint64_t ar_unat_callee;
00081         uint64_t ar_rsc;
00082         uint64_t bsp;           /* ar_bsp */
00083         uint64_t ar_rnat;
00084         uint64_t ar_lc;
00085 
00086         /*
00087          * General registers
00088          */
00089         uint64_t r1;
00090         uint64_t r4;
00091         uint64_t r5;
00092         uint64_t r6;
00093         uint64_t r7;
00094         uint64_t sp;            /* r12 */
00095         uint64_t tp;            /* r13 */
00096         
00097         /*
00098          * Branch registers
00099          */
00100         uint64_t pc;            /* b0 */
00101         uint64_t b1;
00102         uint64_t b2;
00103         uint64_t b3;
00104         uint64_t b4;
00105         uint64_t b5;
00106 
00107         /*
00108          * Predicate registers
00109          */
00110         uint64_t pr;
00111 
00112         __r128 f2 __attribute__ ((aligned(16)));
00113         __r128 f3;
00114         __r128 f4;
00115         __r128 f5;
00116 
00117         __r128 f16;
00118         __r128 f17;
00119         __r128 f18;
00120         __r128 f19;
00121         __r128 f20;
00122         __r128 f21;
00123         __r128 f22;
00124         __r128 f23;
00125         __r128 f24;
00126         __r128 f25;
00127         __r128 f26;
00128         __r128 f27;
00129         __r128 f28;
00130         __r128 f29;
00131         __r128 f30;
00132         __r128 f31;
00133 
00134 } context_t;
00135 
00136 #endif
00137 

Generated on Sun Jun 18 18:00:18 2006 for HelenOS Userspace (ia64) by  doxygen 1.4.6