2 * Copyright (C) 2006 Red Hat, Inc.
6 * Author: Steven Dake (sdake@mvista.com)
8 * This software licensed under BSD license, the text of which follows:
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither the name of the MontaVista Software, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef AIS_MAR_CKPT_H_DEFINED
36 #define AIS_MAR_CKPT_H_DEFINED
42 typedef mar_uint64_t mar_ckpt_checkpoint_handle_t
;
44 static inline void swab_mar_ckpt_checkpoint_handle_t (
45 mar_ckpt_checkpoint_handle_t
*to_swab
)
47 swab_mar_uint64_t (to_swab
);
50 typedef mar_uint32_t mar_ckpt_checkpoint_creation_flags_t
;
52 static inline void swab_mar_ckpt_checkpoint_creation_flags_t (
53 mar_ckpt_checkpoint_creation_flags_t
*to_swab
)
55 swab_mar_uint32_t (to_swab
);
59 * Marshalling the SaCkptCheckpointCreationAttributesT data structure
62 mar_ckpt_checkpoint_creation_flags_t creation_flags
__attribute__((aligned(8)));
63 mar_size_t checkpoint_size
__attribute__((aligned(8)));
64 mar_time_t retention_duration
__attribute__((aligned(8)));
65 mar_uint32_t max_sections
__attribute__((aligned(8)));
66 mar_size_t max_section_size
__attribute__((aligned(8)));
67 mar_size_t max_section_id_size
__attribute__((aligned(8)));
68 } mar_ckpt_checkpoint_creation_attributes_t
;
70 static inline void swab_mar_ckpt_checkpoint_creation_attributes_t (
71 mar_ckpt_checkpoint_creation_attributes_t
*to_swab
)
73 swab_mar_ckpt_checkpoint_creation_flags_t (&to_swab
->creation_flags
);
74 swab_mar_size_t (&to_swab
->checkpoint_size
);
75 swab_mar_time_t (&to_swab
->retention_duration
);
76 swab_mar_uint32_t (&to_swab
->max_sections
);
77 swab_mar_size_t (&to_swab
->max_section_size
);
78 swab_mar_size_t (&to_swab
->max_section_id_size
);
81 static inline void marshall_from_mar_ckpt_checkpoint_creation_attributes_t (
82 SaCkptCheckpointCreationAttributesT
*dest
,
83 mar_ckpt_checkpoint_creation_attributes_t
*src
)
85 dest
->creationFlags
= src
->creation_flags
;
86 dest
->checkpointSize
= src
->checkpoint_size
;
87 dest
->retentionDuration
= src
->retention_duration
;
88 dest
->maxSections
= src
->max_sections
;
89 dest
->maxSectionSize
= src
->max_section_size
;
90 dest
->maxSectionIdSize
= src
->max_section_id_size
;
93 static inline void marshall_to_mar_ckpt_checkpoint_creation_attributes_t (
94 mar_ckpt_checkpoint_creation_attributes_t
*dest
,
95 SaCkptCheckpointCreationAttributesT
*src
)
97 memset (dest
, 0, sizeof (mar_ckpt_checkpoint_creation_attributes_t
));
98 dest
->creation_flags
= src
->creationFlags
;
99 dest
->checkpoint_size
= src
->checkpointSize
;
100 dest
->retention_duration
= src
->retentionDuration
;
101 dest
->max_sections
= src
->maxSections
;
102 dest
->max_section_size
= src
->maxSectionSize
;
103 dest
->max_section_id_size
= src
->maxSectionIdSize
;
106 #define MAR_CKPT_CHECKPOINT_READ 0x1
107 #define MAR_CKPT_CHECKPOINT_WRITE 0x2
108 #define MAR_CKPT_CHECKPOINT_CREATE 0x4
110 typedef mar_uint32_t mar_ckpt_checkpoint_open_flags_t
;
112 static inline void swab_mar_ckpt_checkpoint_open_flags_t (mar_ckpt_checkpoint_open_flags_t
*to_swab
)
114 swab_mar_uint32_t (to_swab
);
117 #define MAR_CKPT_DEFAULT_SECTION_ID { 0, 0 }
118 #define MAR_CKPT_GENERATED_SECTION_ID { 0, 0 }
121 * Marshalling the SaCkptSectionIdT data structure
124 mar_uint16_t id_len
__attribute__((aligned(8)));
125 mar_uint8_t
*id
__attribute__((aligned(8)));
126 } mar_ckpt_section_id_t
;
128 static inline void swab_mar_ckpt_section_id_t (mar_ckpt_section_id_t
*to_swab
)
130 swab_mar_uint16_t (&to_swab
->id_len
);
133 static inline void marshall_from_mar_ckpt_section_id_t (
134 SaCkptSectionIdT
*dest
,
135 mar_ckpt_section_id_t
*src
)
137 dest
->idLen
= src
->id_len
;
141 static inline void marshall_to_mar_ckpt_section_id_t (
142 mar_ckpt_section_id_t
*dest
,
143 SaCkptSectionIdT
*src
)
145 memset (dest
, 0, sizeof (mar_ckpt_section_id_t
));
146 dest
->id_len
= src
->idLen
;
151 * Marshalling the SaCkptSectionCreationAttributesT data structure
154 mar_ckpt_section_id_t
*section_id
__attribute__((aligned(8)));
155 mar_time_t expiration_time
__attribute__((aligned(8)));
156 } mar_ckpt_section_creation_attributes_t
;
158 static inline void swab_mar_ckpt_section_creation_attributes_t (
159 mar_ckpt_section_creation_attributes_t
*to_swab
)
161 swab_mar_ckpt_section_id_t (to_swab
->section_id
);
162 swab_mar_time_t (&to_swab
->expiration_time
);
165 static inline void marshall_from_mar_ckpt_section_creation_attributes_t (
166 SaCkptSectionCreationAttributesT
*dest
,
167 mar_ckpt_section_creation_attributes_t
*src
)
169 marshall_from_mar_ckpt_section_id_t (dest
->sectionId
, src
->section_id
);
170 dest
->expirationTime
= src
->expiration_time
;
173 static inline void marshall_to_mar_ckpt_section_creation_attributes_t (
174 mar_ckpt_section_creation_attributes_t
*dest
,
175 SaCkptSectionCreationAttributesT
*src
)
177 memset (dest
, 0, sizeof (mar_ckpt_section_creation_attributes_t
));
178 marshall_to_mar_ckpt_section_id_t (dest
->section_id
, src
->sectionId
);
179 dest
->expiration_time
= src
->expirationTime
;
182 typedef mar_uint32_t mar_ckpt_section_state_t
;
183 #define MAR_CKPT_SECTION_VALID 1
184 #define MAR_CKPT_SECTION_CORRUPTED 2
186 static inline void swab_mar_ckpt_section_state_t (
187 mar_ckpt_section_state_t
*to_swab
)
189 swab_mar_uint32_t (to_swab
);
193 * Marshalling the SaCkptSectionDescriptorT data structure
196 mar_ckpt_section_id_t section_id
__attribute__((aligned(8)));
197 mar_time_t expiration_time
__attribute__((aligned(8)));
198 mar_size_t section_size
__attribute__((aligned(8)));
199 mar_ckpt_section_state_t section_state
__attribute__((aligned(8)));
200 mar_time_t last_update
__attribute__((aligned(8)));
201 } mar_ckpt_section_descriptor_t
;
203 static inline void swab_mar_ckpt_section_descriptor_t (
204 mar_ckpt_section_descriptor_t
*to_swab
)
206 swab_mar_ckpt_section_id_t (&to_swab
->section_id
);
207 swab_mar_time_t (&to_swab
->expiration_time
);
208 swab_mar_size_t (&to_swab
->section_size
);
209 swab_mar_ckpt_section_state_t (&to_swab
->section_state
);
210 swab_mar_time_t (&to_swab
->last_update
);
212 static inline void marshall_from_mar_ckpt_section_descriptor_t (
213 SaCkptSectionDescriptorT
*dest
,
214 mar_ckpt_section_descriptor_t
*src
)
216 marshall_from_mar_ckpt_section_id_t (&dest
->sectionId
, &src
->section_id
);
217 dest
->expirationTime
= src
->expiration_time
;
218 dest
->sectionSize
= src
->section_size
;
219 dest
->sectionState
= src
->section_state
;
220 dest
->lastUpdate
= src
->last_update
;
223 static inline void marshall_to_mar_ckpt_section_descriptor_t (
224 mar_ckpt_section_descriptor_t
*dest
,
225 SaCkptSectionDescriptorT
*src
)
227 memset (dest
, 0, sizeof (mar_ckpt_section_descriptor_t
));
228 marshall_to_mar_ckpt_section_id_t (&dest
->section_id
, &src
->sectionId
);
229 dest
->expiration_time
= src
->expirationTime
;
230 dest
->section_size
= src
->sectionSize
;
231 dest
->section_state
= src
->sectionState
;
232 dest
->last_update
= src
->lastUpdate
;
236 MAR_CKPT_SECTIONS_FOREVER
= 1,
237 MAR_CKPT_SECTIONS_LEQ_EXPIRATION_TIME
= 2,
238 MAR_CKPT_SECTIONS_GEQ_EXPIRATION_TIME
= 3,
239 MAR_CKPT_SECTIONS_CORRUPTED
= 4,
240 MAR_CKPT_SECTIONS_ANY
= 5
241 } mar_ckpt_sections_chosen_t
;
243 typedef mar_uint64_t mar_offset_t
;
245 static inline void swab_mar_offset_t (
246 mar_offset_t
*to_swab
)
248 swab_mar_uint64_t (to_swab
);
252 * Marshalling the SaCkptIOVectorElementT (not needed)
255 mar_ckpt_section_id_t section_id
__attribute__((aligned(8)));
256 void *data_buffer
__attribute__((aligned(8)));
257 mar_size_t data_size
__attribute__((aligned(8)));
258 mar_offset_t data_offset
__attribute__((aligned(8)));
259 mar_size_t read_size
__attribute__((aligned(8)));
260 } mar_ckpt_io_vector_element_t
;
263 * Marshalling the SaCkptCheckpointDescriptorT
266 mar_ckpt_checkpoint_creation_attributes_t checkpoint_creation_attributes
__attribute__((aligned(8)));
267 mar_uint32_t number_of_sections
__attribute__((aligned(8)));
268 mar_uint32_t memory_used
__attribute__((aligned(8)));
269 } mar_ckpt_checkpoint_descriptor_t
;
271 static inline void marshall_from_mar_ckpt_checkpoint_descriptor_t (
272 SaCkptCheckpointDescriptorT
*dest
,
273 mar_ckpt_checkpoint_descriptor_t
*src
)
275 marshall_from_mar_ckpt_checkpoint_creation_attributes_t (
276 &dest
->checkpointCreationAttributes
,
277 &src
->checkpoint_creation_attributes
);
278 dest
->numberOfSections
= src
->number_of_sections
;
279 dest
->memoryUsed
= src
->memory_used
;
282 static inline void marshall_to_mar_ckpt_checkpoint_descriptor_t (
283 mar_ckpt_checkpoint_descriptor_t
*dest
,
284 SaCkptCheckpointDescriptorT
*src
)
286 memset (dest
, 0, sizeof (mar_ckpt_checkpoint_descriptor_t
));
287 marshall_to_mar_ckpt_checkpoint_creation_attributes_t (
288 &dest
->checkpoint_creation_attributes
,
289 &src
->checkpointCreationAttributes
);
290 dest
->number_of_sections
= src
->numberOfSections
;
291 dest
->memory_used
= src
->memoryUsed
;
294 #endif /* AIS_MAR_CKPT_H_DEFINED */