1 /* SPDX-License-Identifier: Apache-2.0 */ 2 /* Copyright (C) 2018 IBM Corp. */ 3 4 #ifndef WINDOWS_H 5 #define WINDOWS_H 6 7 #define WINDOWS_NO_FLUSH false 8 #define WINDOWS_WITH_FLUSH true 9 10 struct mbox_context; 11 12 /* Window Dirty/Erase bytemap masks */ 13 #define WINDOW_CLEAN 0x00 14 #define WINDOW_DIRTY 0x01 15 #define WINDOW_ERASED 0x02 16 17 #define FLASH_OFFSET_UNINIT 0xFFFFFFFF 18 19 struct window_context { 20 void *mem; /* Portion of Reserved Memory Region */ 21 uint32_t flash_offset; /* Flash area the window maps (bytes) */ 22 uint32_t size; /* Window Size (bytes) power-of-2 */ 23 uint8_t *dirty_bmap; /* Bytemap of the dirty/erased state */ 24 uint32_t age; /* Used for LRU eviction scheme */ 25 }; 26 27 struct window_list { 28 uint32_t num; 29 uint32_t max_age; 30 uint32_t default_size; 31 struct window_context *window; 32 }; 33 34 /* Initialisation Functions */ 35 int windows_init(struct mbox_context *context); 36 void windows_free(struct mbox_context *context); 37 /* Write From Window Functions */ 38 int window_flush_v1(struct mbox_context *context, 39 uint32_t offset_bytes, uint32_t count_bytes); 40 int window_flush(struct mbox_context *context, uint32_t offset, 41 uint32_t count, uint8_t type); 42 /* Window Management Functions */ 43 void windows_alloc_dirty_bytemap(struct mbox_context *context); 44 int window_set_bytemap(struct mbox_context *context, struct window_context *cur, 45 uint32_t offset, uint32_t size, uint8_t val); 46 void windows_close_current(struct mbox_context *context, bool set_bmc_event, 47 uint8_t flags); 48 void window_reset(struct mbox_context *context, struct window_context *window); 49 void windows_reset_all(struct mbox_context *context, bool set_bmc_event); 50 struct window_context *windows_find_oldest(struct mbox_context *context); 51 struct window_context *windows_find_largest(struct mbox_context *context); 52 struct window_context *windows_search(struct mbox_context *context, 53 uint32_t offset, bool exact); 54 int windows_create_map(struct mbox_context *context, 55 struct window_context **this_window, 56 uint32_t offset, bool exact); 57 58 #endif /* WINDOWS_H */ 59