| 1 | /* Implements `movealloc`. |
| 2 | * |
| 3 | * this feature allows us to take a given virtual pointer, and copy |
| 4 | * its pages over to pages in the correct domain, and change the |
| 5 | * page tables to point to these correct pages. this is a form |
| 6 | * of "mini page migration" that we use to move over initial |
| 7 | * allocations to the right node. this lives entirely separate |
| 8 | * from our real page migration */ |
| 9 | #pragma once |
| 10 | #include <compiler/core.h> |
| 11 | #include <container_of.h> |
| 12 | #include <linker/symbols.h> |
| 13 | #include <mem/vmm.h> |
| 14 | #include <structures/list.h> |
| 15 | |
| 16 | /* this will always panic upon alloc failure - only to be used in init code! */ |
| 17 | void movealloc_full(domain_id_t domain, void *ptr, struct vmm_request rq); |
| 18 | |
| 19 | #define movealloc(d, p, ...) \ |
| 20 | movealloc_full((d), (p), vmm_request_with_defaults(__VA_ARGS__)) |
| 21 | |
| 22 | typedef void (*movealloc_callback)(void *a, void *b); |
| 23 | |
| 24 | struct movealloc_callback_node { |
| 25 | movealloc_callback callback; |
| 26 | void *a, *b; |
| 27 | struct list_node list; |
| 28 | }; |
| 29 | |
| 30 | struct movealloc_callback_chain { |
| 31 | struct list_head list; |
| 32 | }; |
| 33 | |
| 34 | #define movealloc_callback_node_from_list_node(ln) \ |
| 35 | (container_of(ln, struct movealloc_callback_node, list)) |
| 36 | |
| 37 | #define MOVEALLOC_REGISTER_CALL(name, callback, param1, param2) \ |
| 38 | static LINKER_SECTION_OBJECT(struct movealloc_callback_node, \ |
| 39 | movealloc_callbacks) \ |
| 40 | movealloc_##name = {callback, param1, param2, .list = {0}}; |
| 41 | |
| 42 | void movealloc_exec_all(void); |
| 43 | |