usermode/library/mcore/src/log/phlog_base.c

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 
00041 /* System header files */
00042 #include <stdio.h>
00043 #include <stdint.h>
00044 #include <stdlib.h>
00045 /* Mnemosyne common header files */
00046 #include <result.h>
00047 #include "phlog_base.h"
00048 #include "hal/pcm_i.h"
00049 
00050 
00055 m_result_t
00056 m_phlog_base_check_consistency(m_phlog_base_nvmd_t *nvmd, 
00057                                   pcm_word_t *nvphlog,
00058                                   uint64_t *stable_tail)
00059 {
00060         *stable_tail = nvmd->tail;
00061 
00062         return M_R_SUCCESS;
00063 }
00064 
00065 
00069 m_result_t
00070 m_phlog_base_format (pcm_storeset_t *set, 
00071                      m_phlog_base_nvmd_t *nvmd, 
00072                      pcm_word_t *nvphlog, 
00073                      int type)
00074 {
00075         PCM_NT_STORE(set, (volatile pcm_word_t *) &nvmd->head, 0);
00076         PCM_NT_STORE(set, (volatile pcm_word_t *) &nvmd->tail, 0);
00077         PCM_NT_FLUSH(set);
00078         
00079         return M_R_SUCCESS;
00080 }
00081 
00082 
00086 m_result_t
00087 m_phlog_base_alloc (m_phlog_base_t **phlog_basep)
00088 {
00089         m_phlog_base_t      *phlog_base;
00090         
00091         if (posix_memalign((void **) &phlog_base, sizeof(uint64_t), sizeof(m_phlog_base_t)) != 0) 
00092         {
00093                 return M_R_FAILURE;
00094         }
00095         *phlog_basep = phlog_base;
00096 
00097         return M_R_SUCCESS;
00098 }
00099 
00100 
00105 m_result_t
00106 m_phlog_base_init(m_phlog_base_t *phlog, 
00107                   m_phlog_base_nvmd_t *nvmd,
00108                   pcm_word_t *nvphlog)                                    
00109 {
00110         phlog->nvmd = nvmd;
00111         phlog->nvphlog = nvphlog;
00112         phlog->buffer_count = 0;
00113         phlog->head = phlog->nvmd->head;
00114         phlog->tail = phlog->nvmd->tail;
00115         phlog->read_index = phlog->nvmd->head;
00116 
00117         /* initialize statistics */
00118         phlog->stat_wait_for_trunc = 0;
00119         phlog->stat_wait_time_for_trunc = 0;
00120 
00121         return M_R_SUCCESS;
00122 }
00123 
00124 
00128 m_result_t
00129 m_phlog_base_truncate_async(pcm_storeset_t *set, m_phlog_base_t *phlog) 
00130 {
00131         phlog->head = phlog->read_index;
00132 
00133         PCM_NT_FLUSH(set);
00134         PCM_NT_STORE(set, (volatile pcm_word_t *) &phlog->nvmd->head, (pcm_word_t) phlog->head);
00135         PCM_NT_FLUSH(set);
00136         
00137         return M_R_SUCCESS;
00138 }

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