usermode/library/mcore/src/segment.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2011 Computer Sciences Department, 
00003     University of Wisconsin -- Madison
00004 
00005     ----------------------------------------------------------------------
00006 
00007     This file is part of Mnemosyne: Lightweight Persistent Memory, 
00008     originally developed at the University of Wisconsin -- Madison.
00009 
00010     Mnemosyne was originally developed primarily by Haris Volos
00011     with contributions from Andres Jaan Tack.
00012 
00013     ----------------------------------------------------------------------
00014 
00015     Mnemosyne is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU General Public License
00017     as published by the Free Software Foundation, version 2
00018     of the License.
00019  
00020     Mnemosyne is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00028     Boston, MA  02110-1301, USA.
00029 
00030 ### END HEADER ###
00031 */
00032 
00040 #ifndef _MNEMOSYNE_SEGMENT_H
00041 #define _MNEMOSYNE_SEGMENT_H
00042 
00043 /* System header files */
00044 #include <pthread.h>
00045 #include <stdio.h>
00046 #include <stdint.h>
00047 /* Mnemosyne common header files */
00048 #include <list.h>
00049 #include <result.h>
00050 
00051 
00052 #ifndef MAP_SCM
00053 #define MAP_SCM 0x80000
00054 #endif
00055 
00056 
00057 #ifdef MCORE_KERNEL_PMAP
00058 # define MAP_PERSISTENT MAP_SCM
00059 #else
00060 # define MAP_PERSISTENT 0
00061 #endif
00062 
00064 #define SGTB_TYPE_PMAP                0x1    /* a segment allocated via pmap family of functions */
00065 #define SGTB_TYPE_SECTION             0x2    /* a segment of a .persistent section */
00066 #define SGTB_VALID_ENTRY              0x4
00067 #define SGTB_VALID_DATA               0x8
00068 
00069 typedef struct m_segtbl_entry_s m_segtbl_entry_t;
00070 typedef struct m_segidx_entry_s m_segidx_entry_t;
00071 typedef struct m_segidx_s       m_segidx_t;
00072 typedef struct m_segtbl_s       m_segtbl_t;
00073 
00075 struct m_segidx_entry_s {
00076         m_segtbl_entry_t *segtbl_entry; 
00077         uint32_t         index;         
00078         uint64_t         module_id;     
00079         struct list_head list;
00080 };
00081 
00082 
00083 /* Persistent segment table index. */
00084 struct m_segidx_s {
00085         pthread_mutex_t  mutex;          
00086         m_segidx_entry_t *all_entries;   
00087         m_segidx_entry_t mapped_entries; 
00088         m_segidx_entry_t free_entries;   
00089 };
00090 
00091 
00093 struct m_segtbl_entry_s {
00094         uint32_t  flags;
00095         uintptr_t start;
00096         uint32_t  size;
00097 };
00098 
00099 
00101 struct m_segtbl_s {
00102         m_segtbl_entry_t *entries;  
00103         m_segidx_t       *idx;      
00104 };
00105 
00106 
00107 extern m_segtbl_t m_segtbl;
00108 
00109 
00110 m_result_t m_segmentmgr_init();
00111 m_result_t m_segmentmgr_fini();
00112 
00113 void *m_pmap2(void *start, size_t length, int prot, int flags);
00114 m_result_t m_segment_find_using_addr(void *addr, m_segidx_entry_t **entryp);
00115 
00116 #endif /* _MNEMOSYNE_SEGMENT_H */

Generated on Sat Apr 23 11:43:36 2011 for Mnemosyne by  doxygen 1.4.7