Lines Matching +full:- +full:cache

1 // SPDX-License-Identifier: GPL-2.0
21 struct mrc_data_container *cache) in next_mrc_block() argument
24 u32 mrc_size = sizeof(*cache) + cache->data_size; in next_mrc_block()
25 u8 *region_ptr = (u8 *)cache; in next_mrc_block()
27 if (mrc_size & (MRC_DATA_ALIGN - 1UL)) { in next_mrc_block()
28 mrc_size &= ~(MRC_DATA_ALIGN - 1UL); in next_mrc_block()
37 static int is_mrc_cache(struct mrc_data_container *cache) in is_mrc_cache() argument
39 return cache && (cache->signature == MRC_DATA_SIGNATURE); in is_mrc_cache()
44 struct mrc_data_container *cache, *next; in mrccache_find_current() local
48 base_addr = entry->base + entry->offset; in mrccache_find_current()
49 end_addr = base_addr + entry->length; in mrccache_find_current()
50 cache = NULL; in mrccache_find_current()
56 cache = next; in mrccache_find_current()
62 if (id-- == 0) { in mrccache_find_current()
63 debug("%s: No valid MRC cache found.\n", __func__); in mrccache_find_current()
68 if (cache->checksum != compute_ip_checksum(cache->data, in mrccache_find_current()
69 cache->data_size)) { in mrccache_find_current()
70 printf("%s: MRC cache checksum mismatch\n", __func__); in mrccache_find_current()
74 debug("%s: picked entry %u from cache block\n", __func__, id); in mrccache_find_current()
76 return cache; in mrccache_find_current()
80 * find_next_mrc_cache() - get next cache entry
82 * @entry: MRC cache flash area
83 * @cache: Entry to start from
85 * @return next cache entry if found, NULL if we got to the end
88 struct mrc_data_container *cache) in find_next_mrc_cache() argument
92 base_addr = entry->base + entry->offset; in find_next_mrc_cache()
93 end_addr = base_addr + entry->length; in find_next_mrc_cache()
95 cache = next_mrc_block(cache); in find_next_mrc_cache()
96 if ((ulong)cache >= end_addr) { in find_next_mrc_cache()
98 cache = NULL; in find_next_mrc_cache()
101 debug("%s: picked next entry from cache block at %p\n", in find_next_mrc_cache()
102 __func__, cache); in find_next_mrc_cache()
105 return cache; in find_next_mrc_cache()
111 struct mrc_data_container *cache; in mrccache_update() local
117 return -EINVAL; in mrccache_update()
120 base_addr = entry->base + entry->offset; in mrccache_update()
121 debug("Updating MRC cache data\n"); in mrccache_update()
122 cache = mrccache_find_current(entry); in mrccache_update()
123 if (cache && (cache->data_size == cur->data_size) && in mrccache_update()
124 (!memcmp(cache, cur, cache->data_size + sizeof(*cur)))) { in mrccache_update()
126 return -EEXIST; in mrccache_update()
130 if (cache) in mrccache_update()
131 cache = find_next_mrc_cache(entry, cache); in mrccache_update()
134 * If we have got to the end, erase the entire mrc-cache area and start in mrccache_update()
137 if (!cache) { in mrccache_update()
138 debug("Erasing the MRC cache region of %x bytes at %x\n", in mrccache_update()
139 entry->length, entry->offset); in mrccache_update()
141 ret = spi_flash_erase_dm(sf, entry->offset, entry->length); in mrccache_update()
146 cache = (struct mrc_data_container *)base_addr; in mrccache_update()
150 offset = (ulong)cache - base_addr + entry->offset; in mrccache_update()
151 debug("Write MRC cache update to flash at %lx\n", offset); in mrccache_update()
152 ret = spi_flash_write_dm(sf, offset, cur->data_size + sizeof(*cur), in mrccache_update()
164 struct mrc_data_container *cache; in mrccache_reserve() local
167 if (!gd->arch.mrc_output_len) in mrccache_reserve()
170 /* adjust stack pointer to store pure cache data plus the header */ in mrccache_reserve()
171 gd->start_addr_sp -= (gd->arch.mrc_output_len + MRC_DATA_HEADER_SIZE); in mrccache_reserve()
172 cache = (struct mrc_data_container *)gd->start_addr_sp; in mrccache_reserve()
174 cache->signature = MRC_DATA_SIGNATURE; in mrccache_reserve()
175 cache->data_size = gd->arch.mrc_output_len; in mrccache_reserve()
176 checksum = compute_ip_checksum(gd->arch.mrc_output, cache->data_size); in mrccache_reserve()
178 cache->data_size, checksum); in mrccache_reserve()
179 cache->checksum = checksum; in mrccache_reserve()
180 cache->reserved = 0; in mrccache_reserve()
181 memcpy(cache->data, gd->arch.mrc_output, cache->data_size); in mrccache_reserve()
183 /* gd->arch.mrc_output now points to the container */ in mrccache_reserve()
184 gd->arch.mrc_output = (char *)cache; in mrccache_reserve()
186 gd->start_addr_sp &= ~0xf; in mrccache_reserve()
193 const void *blob = gd->fdt_blob; in mrccache_get_region()
202 return -ENOENT; in mrccache_get_region()
205 if (fdtdec_get_int_array(blob, node, "memory-map", reg, 2)) in mrccache_get_region()
206 return -EINVAL; in mrccache_get_region()
207 entry->base = reg[0]; in mrccache_get_region()
209 /* Find the place where we put the MRC cache */ in mrccache_get_region()
210 mrc_node = fdt_subnode_offset(blob, node, "rw-mrc-cache"); in mrccache_get_region()
212 return -EPERM; in mrccache_get_region()
215 return -EINVAL; in mrccache_get_region()
216 entry->offset = reg[0]; in mrccache_get_region()
217 entry->length = reg[1]; in mrccache_get_region()
237 if (!gd->arch.mrc_output_len) in mrccache_save()
240 gd->arch.mrc_output_len); in mrccache_save()
245 data = (struct mrc_data_container *)gd->arch.mrc_output; in mrccache_save()
248 debug("Saved MRC data with checksum %04x\n", data->checksum); in mrccache_save()
249 } else if (ret == -EEXIST) { in mrccache_save()