1 /*
2  * Copyright (C) 2015 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 #pragma once
18 
19 #include <lk/list.h>
20 #include <stdbool.h>
21 
22 #include "block_cache.h"
23 
24 struct transaction;
25 
26 data_block_t block_allocate_etc(struct transaction* tr, bool is_tmp);
27 void block_free_etc(struct transaction* tr, data_block_t block, bool is_tmp);
28 bool block_allocator_allocation_queued(struct transaction* tr,
29                                        data_block_t block,
30                                        bool is_tmp);
31 void block_allocator_suspend_set_updates(struct transaction* tr);
32 void block_allocator_process_queue(struct transaction* tr);
33 
block_allocate(struct transaction * tr)34 static inline data_block_t block_allocate(struct transaction* tr) {
35     return block_allocate_etc(tr, false);
36 }
37 
block_free(struct transaction * tr,data_block_t block)38 static inline void block_free(struct transaction* tr, data_block_t block) {
39     block_free_etc(tr, block, false);
40 }
41 
block_allocate_tmp(struct transaction * tr)42 static inline data_block_t block_allocate_tmp(struct transaction* tr) {
43     return block_allocate_etc(tr, true);
44 }
45 
block_free_tmp(struct transaction * tr,data_block_t block)46 static inline void block_free_tmp(struct transaction* tr, data_block_t block) {
47     block_free_etc(tr, block, true);
48 }
49