mem: improve device memory mapping

MMIO ports will no longer directly map to HHDM addresses and will need
to be searched for in the memory mapping tree
This commit is contained in:
Michael Shaw 2023-10-24 22:16:33 -04:00
commit 4dc4f07dc6
10 changed files with 111 additions and 16 deletions

View file

@ -140,6 +140,7 @@ struct rbnode *rbt_insert(struct rbtree *tree, uint64_t key)
parent->right = new;
rbt_insert_fixup(tree, new);
tree->num_nodes++;
spinlock_release(&tree->lock);
return new;
@ -290,6 +291,8 @@ void rbt_delete(struct rbtree *tree, struct rbnode *del)
if (orig_color == RB_BLACK)
rbt_delete_fixup(tree, x);
}
tree->num_nodes--;
spinlock_release(&tree->lock);
}
@ -321,6 +324,21 @@ struct rbnode *rbt_search(struct rbtree *tree, uint64_t key)
return NULL;
}
struct rbnode *rbt_successor(struct rbnode *node)
{
if (node->right != NULL) {
return rbt_minimum(node->right);
}
struct rbnode *parent = node->parent;
while (parent != NULL && node == parent->right) {
node = parent;
parent = parent->parent;
}
return parent;
}
void rbtree_print_diagram_fancy(struct rbtree *tree, struct rbnode *node, int indent)
{
if (node == NULL) {

View file

@ -27,6 +27,7 @@ int vsnprintf(char *str, const char *restrict fmt, size_t size, va_list args)
char *s;
int i;
long l;
unsigned int u;
int n;
@ -77,16 +78,16 @@ int vsnprintf(char *str, const char *restrict fmt, size_t size, va_list args)
str[ret] = i & 0xFF;
break;
case 'x':
i = va_arg(args, int);
u = va_arg(args, int);
n = 0;
memset(buf, 0, sizeof(buf));
do {
buf[n] = convert[i & 0xF];
buf[n] = convert[u & 0xF];
n++;
} while ((i >>= 4));
} while ((u >>= 4));
goto printf_reverse;
break;