blob: 31665050509b8e073adebd1299624a157be7a1d7 [file] [log] [blame]
Colin Cross28fa5bc2012-05-20 13:28:05 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _BACKED_BLOCK_H_
18#define _BACKED_BLOCK_H_
19
Colin Crossb55dcee2012-04-24 23:07:49 -070020#include <stdint.h>
21
Colin Cross411619e2012-04-24 18:51:42 -070022struct backed_block_list;
Colin Crossb55dcee2012-04-24 23:07:49 -070023struct backed_block;
Colin Cross28fa5bc2012-05-20 13:28:05 -070024
Colin Crossb55dcee2012-04-24 23:07:49 -070025enum backed_block_type {
26 BACKED_BLOCK_DATA,
27 BACKED_BLOCK_FILE,
28 BACKED_BLOCK_FILL,
29};
Colin Cross28fa5bc2012-05-20 13:28:05 -070030
Colin Crossb55dcee2012-04-24 23:07:49 -070031int backed_block_add_data(struct backed_block_list *bbl, void *data,
Colin Cross411619e2012-04-24 18:51:42 -070032 unsigned int len, unsigned int block);
Colin Crossb55dcee2012-04-24 23:07:49 -070033int backed_block_add_fill(struct backed_block_list *bbl, unsigned int fill_val,
34 unsigned int len, unsigned int block);
35int backed_block_add_file(struct backed_block_list *bbl, const char *filename,
Colin Cross411619e2012-04-24 18:51:42 -070036 int64_t offset, unsigned int len, unsigned int block);
Colin Cross28fa5bc2012-05-20 13:28:05 -070037
Colin Crossb55dcee2012-04-24 23:07:49 -070038struct backed_block *backed_block_iter_new(struct backed_block_list *bbl);
39struct backed_block *backed_block_iter_next(struct backed_block *bb);
40unsigned int backed_block_len(struct backed_block *bb);
41unsigned int backed_block_block(struct backed_block *bb);
42void *backed_block_data(struct backed_block *bb);
43const char *backed_block_filename(struct backed_block *bb);
44int64_t backed_block_file_offset(struct backed_block *bb);
45uint32_t backed_block_fill_val(struct backed_block *bb);
46enum backed_block_type backed_block_type(struct backed_block *bb);
47
48struct backed_block *backed_block_iter_new(struct backed_block_list *bbl);
49struct backed_block *backed_block_iter_next(struct backed_block *bb);
50
Colin Cross411619e2012-04-24 18:51:42 -070051struct backed_block_list *backed_block_list_new(void);
Colin Crossb55dcee2012-04-24 23:07:49 -070052void backed_block_list_destroy(struct backed_block_list *bbl);
Colin Cross28fa5bc2012-05-20 13:28:05 -070053
54#endif