Lines Matching refs:rbnode
45 struct regcache_rbtree_node *rbnode, in regcache_rbtree_get_base_top_reg() argument
48 *base = rbnode->base_reg; in regcache_rbtree_get_base_top_reg()
49 *top = rbnode->base_reg + ((rbnode->blklen - 1) * map->reg_stride); in regcache_rbtree_get_base_top_reg()
53 struct regcache_rbtree_node *rbnode, unsigned int idx) in regcache_rbtree_get_register() argument
55 return regcache_get_val(map, rbnode->block, idx); in regcache_rbtree_get_register()
59 struct regcache_rbtree_node *rbnode, in regcache_rbtree_set_register() argument
62 set_bit(idx, rbnode->cache_present); in regcache_rbtree_set_register()
63 regcache_set_val(map, rbnode->block, idx, val); in regcache_rbtree_set_register()
71 struct regcache_rbtree_node *rbnode; in regcache_rbtree_lookup() local
74 rbnode = rbtree_ctx->cached_rbnode; in regcache_rbtree_lookup()
75 if (rbnode) { in regcache_rbtree_lookup()
76 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_lookup()
79 return rbnode; in regcache_rbtree_lookup()
84 rbnode = rb_entry(node, struct regcache_rbtree_node, node); in regcache_rbtree_lookup()
85 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_lookup()
88 rbtree_ctx->cached_rbnode = rbnode; in regcache_rbtree_lookup()
89 return rbnode; in regcache_rbtree_lookup()
101 struct regcache_rbtree_node *rbnode) in regcache_rbtree_insert() argument
116 base_reg = rbnode->base_reg; in regcache_rbtree_insert()
129 rb_link_node(&rbnode->node, parent, new); in regcache_rbtree_insert()
130 rb_insert_color(&rbnode->node, root); in regcache_rbtree_insert()
259 struct regcache_rbtree_node *rbnode; in regcache_rbtree_read() local
262 rbnode = regcache_rbtree_lookup(map, reg); in regcache_rbtree_read()
263 if (rbnode) { in regcache_rbtree_read()
264 reg_tmp = (reg - rbnode->base_reg) / map->reg_stride; in regcache_rbtree_read()
265 if (!test_bit(reg_tmp, rbnode->cache_present)) in regcache_rbtree_read()
267 *value = regcache_rbtree_get_register(map, rbnode, reg_tmp); in regcache_rbtree_read()
277 struct regcache_rbtree_node *rbnode, in regcache_rbtree_insert_to_block() argument
290 offset = (rbnode->base_reg - base_reg) / map->reg_stride; in regcache_rbtree_insert_to_block()
292 blk = krealloc(rbnode->block, in regcache_rbtree_insert_to_block()
298 if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) { in regcache_rbtree_insert_to_block()
299 present = krealloc(rbnode->cache_present, in regcache_rbtree_insert_to_block()
307 memset(present + BITS_TO_LONGS(rbnode->blklen), 0, in regcache_rbtree_insert_to_block()
308 (BITS_TO_LONGS(blklen) - BITS_TO_LONGS(rbnode->blklen)) in regcache_rbtree_insert_to_block()
311 present = rbnode->cache_present; in regcache_rbtree_insert_to_block()
317 blk, rbnode->blklen * map->cache_word_size); in regcache_rbtree_insert_to_block()
322 rbnode->block = blk; in regcache_rbtree_insert_to_block()
323 rbnode->blklen = blklen; in regcache_rbtree_insert_to_block()
324 rbnode->base_reg = base_reg; in regcache_rbtree_insert_to_block()
325 rbnode->cache_present = present; in regcache_rbtree_insert_to_block()
327 regcache_rbtree_set_register(map, rbnode, pos, value); in regcache_rbtree_insert_to_block()
334 struct regcache_rbtree_node *rbnode; in regcache_rbtree_node_alloc() local
338 rbnode = kzalloc(sizeof(*rbnode), GFP_KERNEL); in regcache_rbtree_node_alloc()
339 if (!rbnode) in regcache_rbtree_node_alloc()
352 rbnode->blklen = (range->range_max - range->range_min) / in regcache_rbtree_node_alloc()
354 rbnode->base_reg = range->range_min; in regcache_rbtree_node_alloc()
358 if (!rbnode->blklen) { in regcache_rbtree_node_alloc()
359 rbnode->blklen = 1; in regcache_rbtree_node_alloc()
360 rbnode->base_reg = reg; in regcache_rbtree_node_alloc()
363 rbnode->block = kmalloc_array(rbnode->blklen, map->cache_word_size, in regcache_rbtree_node_alloc()
365 if (!rbnode->block) in regcache_rbtree_node_alloc()
368 rbnode->cache_present = kcalloc(BITS_TO_LONGS(rbnode->blklen), in regcache_rbtree_node_alloc()
369 sizeof(*rbnode->cache_present), in regcache_rbtree_node_alloc()
371 if (!rbnode->cache_present) in regcache_rbtree_node_alloc()
374 return rbnode; in regcache_rbtree_node_alloc()
377 kfree(rbnode->block); in regcache_rbtree_node_alloc()
379 kfree(rbnode); in regcache_rbtree_node_alloc()
387 struct regcache_rbtree_node *rbnode, *rbnode_tmp; in regcache_rbtree_write() local
397 rbnode = regcache_rbtree_lookup(map, reg); in regcache_rbtree_write()
398 if (rbnode) { in regcache_rbtree_write()
399 reg_tmp = (reg - rbnode->base_reg) / map->reg_stride; in regcache_rbtree_write()
400 regcache_rbtree_set_register(map, rbnode, reg_tmp, value); in regcache_rbtree_write()
433 rbnode = rbnode_tmp; in regcache_rbtree_write()
453 if (rbnode) { in regcache_rbtree_write()
454 ret = regcache_rbtree_insert_to_block(map, rbnode, in regcache_rbtree_write()
460 rbtree_ctx->cached_rbnode = rbnode; in regcache_rbtree_write()
467 rbnode = regcache_rbtree_node_alloc(map, reg); in regcache_rbtree_write()
468 if (!rbnode) in regcache_rbtree_write()
470 regcache_rbtree_set_register(map, rbnode, in regcache_rbtree_write()
471 reg - rbnode->base_reg, value); in regcache_rbtree_write()
472 regcache_rbtree_insert(map, &rbtree_ctx->root, rbnode); in regcache_rbtree_write()
473 rbtree_ctx->cached_rbnode = rbnode; in regcache_rbtree_write()
484 struct regcache_rbtree_node *rbnode; in regcache_rbtree_sync() local
491 rbnode = rb_entry(node, struct regcache_rbtree_node, node); in regcache_rbtree_sync()
493 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_sync()
508 end = rbnode->blklen; in regcache_rbtree_sync()
510 ret = regcache_sync_block(map, rbnode->block, in regcache_rbtree_sync()
511 rbnode->cache_present, in regcache_rbtree_sync()
512 rbnode->base_reg, start, end); in regcache_rbtree_sync()
524 struct regcache_rbtree_node *rbnode; in regcache_rbtree_drop() local
531 rbnode = rb_entry(node, struct regcache_rbtree_node, node); in regcache_rbtree_drop()
533 regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg, in regcache_rbtree_drop()
548 end = rbnode->blklen; in regcache_rbtree_drop()
550 bitmap_clear(rbnode->cache_present, start, end - start); in regcache_rbtree_drop()