00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00041
00042 #include <stdio.h>
00043 #include <stdint.h>
00044 #include <stdlib.h>
00045
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
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 }