page.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2005 - 2006 Jakub Jermar
00003  * Copyright (C) 2006 Jakub Vana
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * - Redistributions of source code must retain the above copyright
00011  *   notice, this list of conditions and the following disclaimer.
00012  * - Redistributions in binary form must reproduce the above copyright
00013  *   notice, this list of conditions and the following disclaimer in the
00014  *   documentation and/or other materials provided with the distribution.
00015  * - The name of the author may not be used to endorse or promote products
00016  *   derived from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00019  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00020  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00021  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00022  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00023  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00024  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00025  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00027  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00036 #ifndef __ia64_PAGE_H__
00037 #define __ia64_PAGE_H__
00038 
00039 #include <arch/mm/frame.h>
00040 
00041 #define PAGE_SIZE       FRAME_SIZE
00042 #define PAGE_WIDTH      FRAME_WIDTH
00043 
00044 
00045 #ifdef KERNEL
00046 
00048 #define KERNEL_PAGE_WIDTH       28      /* 256M */
00049 
00050 #define PPN_SHIFT                       12
00051 
00052 #define VRN_SHIFT                       61
00053 #define VRN_MASK                        (7LL << VRN_SHIFT)
00054 #define VA2VRN(va)                      ((va)>>VRN_SHIFT)
00055 
00056 #ifdef __ASM__
00057 #define VRN_KERNEL                      7
00058 #else
00059 #define VRN_KERNEL                      7LL
00060 #endif
00061 
00062 #define REGION_REGISTERS                8
00063 
00064 #define KA2PA(x)        ((__address) (x-(VRN_KERNEL<<VRN_SHIFT)))
00065 #define PA2KA(x)        ((__address) (x+(VRN_KERNEL<<VRN_SHIFT)))
00066 
00067 #define VHPT_WIDTH                      20              /* 1M */
00068 #define VHPT_SIZE                       (1 << VHPT_WIDTH)
00069 
00070 #define PTA_BASE_SHIFT                  15
00071 
00073 #define MA_WRITEBACK    0x0
00074 #define MA_UNCACHEABLE  0x4
00075 
00077 #define PL_KERNEL       0x0
00078 #define PL_USER         0x3
00079 
00080 /* Access Rigths. Only certain combinations are used by the kernel. */
00081 #define AR_READ         0x0
00082 #define AR_EXECUTE      0x1
00083 #define AR_WRITE        0x2
00084 
00085 #ifndef __ASM__
00086 
00087 #include <arch/mm/frame.h>
00088 #include <arch/barrier.h>
00089 #include <genarch/mm/page_ht.h>
00090 #include <arch/mm/asid.h>
00091 #include <arch/types.h>
00092 #include <typedefs.h>
00093 #include <debug.h>
00094 
00095 struct vhpt_tag_info {
00096         unsigned long long tag : 63;
00097         unsigned ti : 1;
00098 } __attribute__ ((packed));
00099 
00100 union vhpt_tag {
00101         struct vhpt_tag_info tag_info;
00102         unsigned tag_word;
00103 };
00104 
00105 struct vhpt_entry_present {
00106         /* Word 0 */
00107         unsigned p : 1;
00108         unsigned : 1;
00109         unsigned ma : 3;
00110         unsigned a : 1;
00111         unsigned d : 1;
00112         unsigned pl : 2;
00113         unsigned ar : 3;
00114         unsigned long long ppn : 38;
00115         unsigned : 2;
00116         unsigned ed : 1;
00117         unsigned ig1 : 11;
00118         
00119         /* Word 1 */
00120         unsigned : 2;
00121         unsigned ps : 6;
00122         unsigned key : 24;
00123         unsigned : 32;
00124         
00125         /* Word 2 */
00126         union vhpt_tag tag;
00127         
00128         /* Word 3 */                                                                                                    
00129         __u64 ig3 : 64;
00130 } __attribute__ ((packed));
00131 
00132 struct vhpt_entry_not_present {
00133         /* Word 0 */
00134         unsigned p : 1;
00135         unsigned long long ig0 : 52;
00136         unsigned ig1 : 11;
00137         
00138         /* Word 1 */
00139         unsigned : 2;
00140         unsigned ps : 6;
00141         unsigned long long ig2 : 56;
00142 
00143         /* Word 2 */
00144         union vhpt_tag tag;
00145         
00146         /* Word 3 */                                                                                                    
00147         __u64 ig3 : 64;
00148 } __attribute__ ((packed));
00149 
00150 typedef union vhpt_entry {
00151         struct vhpt_entry_present present;
00152         struct vhpt_entry_not_present not_present;
00153         __u64 word[4];
00154 } vhpt_entry_t;
00155 
00156 struct region_register_map {
00157         unsigned ve : 1;
00158         unsigned : 1;
00159         unsigned ps : 6;
00160         unsigned rid : 24;
00161         unsigned : 32;
00162 } __attribute__ ((packed));
00163 
00164 typedef union region_register {
00165         struct region_register_map map;
00166         unsigned long long word;
00167 } region_register;
00168 
00169 struct pta_register_map {
00170         unsigned ve : 1;
00171         unsigned : 1;
00172         unsigned size : 6;
00173         unsigned vf : 1;
00174         unsigned : 6;
00175         unsigned long long base : 49;
00176 } __attribute__ ((packed));
00177 
00178 typedef union pta_register {
00179         struct pta_register_map map;
00180         __u64 word;
00181 } pta_register;
00182 
00192 static inline __u64 thash(__u64 va)
00193 {
00194         __u64 ret;
00195 
00196         __asm__ volatile ("thash %0 = %1\n" : "=r" (ret) : "r" (va));
00197 
00198         return ret;
00199 }
00200 
00210 static inline __u64 ttag(__u64 va)
00211 {
00212         __u64 ret;
00213 
00214         __asm__ volatile ("ttag %0 = %1\n" : "=r" (ret) : "r" (va));
00215 
00216         return ret;
00217 }
00218 
00225 static inline __u64 rr_read(index_t i)
00226 {
00227         __u64 ret;
00228         ASSERT(i < REGION_REGISTERS);
00229         __asm__ volatile ("mov %0 = rr[%1]\n" : "=r" (ret) : "r" (i << VRN_SHIFT));
00230         return ret;
00231 }
00232 
00238 static inline void rr_write(index_t i, __u64 v)
00239 {
00240         ASSERT(i < REGION_REGISTERS);
00241         __asm__ volatile (
00242                 "mov rr[%0] = %1\n" 
00243                 : 
00244                 : "r" (i << VRN_SHIFT), "r" (v)
00245         );
00246 }
00247  
00252 static inline __u64 pta_read(void)
00253 {
00254         __u64 ret;
00255         
00256         __asm__ volatile ("mov %0 = cr.pta\n" : "=r" (ret));
00257         
00258         return ret;
00259 }
00260 
00265 static inline void pta_write(__u64 v)
00266 {
00267         __asm__ volatile ("mov cr.pta = %0\n" : : "r" (v));
00268 }
00269 
00270 extern void page_arch_init(void);
00271 
00272 extern vhpt_entry_t *vhpt_hash(__address page, asid_t asid);
00273 extern bool vhpt_compare(__address page, asid_t asid, vhpt_entry_t *v);
00274 extern void vhpt_set_record(vhpt_entry_t *v, __address page, asid_t asid, __address frame, int flags);
00275 
00276 #endif /* __ASM__ */
00277 
00278 #endif /* KERNEL */
00279 
00280 #endif
00281 

Generated on Sun Jun 18 16:51:21 2006 for HelenOS Kernel (ia64) by  doxygen 1.4.6