mmu.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 __sparc64_MMU_H__
00036 #define __sparc64_MMU_H__
00037 
00038 #include <arch/asm.h>
00039 #include <arch/barrier.h>
00040 #include <arch/types.h>
00041 #include <typedefs.h>
00042 
00044 #define ASI_LSU_CONTROL_REG             0x45    
00047 #define ASI_IMMU                        0x50
00048 #define ASI_IMMU_TSB_8KB_PTR_REG        0x51    
00049 #define ASI_IMMU_TSB_64KB_PTR_REG       0x52
00050 #define ASI_ITLB_DATA_IN_REG            0x54
00051 #define ASI_ITLB_DATA_ACCESS_REG        0x55
00052 #define ASI_ITLB_TAG_READ_REG           0x56
00053 #define ASI_IMMU_DEMAP                  0x57
00054 
00056 #define VA_IMMU_TAG_TARGET              0x0     
00057 #define VA_IMMU_SFSR                    0x18    
00058 #define VA_IMMU_TSB_BASE                0x28    
00059 #define VA_IMMU_TAG_ACCESS              0x30    
00062 #define ASI_DMMU                        0x58
00063 #define ASI_DMMU_TSB_8KB_PTR_REG        0x59    
00064 #define ASI_DMMU_TSB_64KB_PTR_REG       0x5a
00065 #define ASI_DMMU_TSB_DIRECT_PTR_REG     0x5b
00066 #define ASI_DTLB_DATA_IN_REG            0x5c
00067 #define ASI_DTLB_DATA_ACCESS_REG        0x5d
00068 #define ASI_DTLB_TAG_READ_REG           0x5e
00069 #define ASI_DMMU_DEMAP                  0x5f
00070 
00072 #define VA_DMMU_TAG_TARGET              0x0     
00073 #define VA_PRIMARY_CONTEXT_REG          0x8     
00074 #define VA_SECONDARY_CONTEXT_REG        0x10    
00075 #define VA_DMMU_SFSR                    0x18    
00076 #define VA_DMMU_SFAR                    0x20    
00077 #define VA_DMMU_TSB_BASE                0x28    
00078 #define VA_DMMU_TAG_ACCESS              0x30    
00079 #define VA_DMMU_VA_WATCHPOINT_REG       0x38    
00080 #define VA_DMMU_PA_WATCHPOINT_REG       0x40    
00084 union lsu_cr_reg {
00085         __u64 value;
00086         struct {
00087                 unsigned : 23;
00088                 unsigned pm : 8;
00089                 unsigned vm : 8;
00090                 unsigned pr : 1;
00091                 unsigned pw : 1;
00092                 unsigned vr : 1;
00093                 unsigned vw : 1;
00094                 unsigned : 1;
00095                 unsigned fm : 16;       
00096                 unsigned dm : 1;        
00097                 unsigned im : 1;        
00098                 unsigned dc : 1;        
00099                 unsigned ic : 1;        
00101         } __attribute__ ((packed));
00102 };
00103 typedef union lsu_cr_reg lsu_cr_reg_t;
00104 
00105 
00106 #define immu_enable()   immu_set(true)
00107 #define immu_disable()  immu_set(false)
00108 #define dmmu_enable()   dmmu_set(true)
00109 #define dmmu_disable()  dmmu_set(false)
00110 
00112 static inline void immu_set(bool enable)
00113 {
00114         lsu_cr_reg_t cr;
00115         
00116         cr.value = asi_u64_read(ASI_LSU_CONTROL_REG, 0);
00117         cr.im = enable;
00118         asi_u64_write(ASI_LSU_CONTROL_REG, 0, cr.value);
00119         membar();
00120 }
00121 
00123 static inline void dmmu_set(bool enable)
00124 {
00125         lsu_cr_reg_t cr;
00126         
00127         cr.value = asi_u64_read(ASI_LSU_CONTROL_REG, 0);
00128         cr.dm = enable;
00129         asi_u64_write(ASI_LSU_CONTROL_REG, 0, cr.value);
00130         membar();
00131 }
00132 
00133 #endif
00134 

Generated on Sun Jun 18 17:37:25 2006 for HelenOS Kernel (sparc64) by  doxygen 1.4.6