| 1 | /* @title: Global Variables */ |
| 2 | #pragma once |
| 3 | #include <bootstage.h> |
| 4 | #include <mem/buddy.h> |
| 5 | #include <mem/movealloc.h> |
| 6 | #include <smp/topology.h> |
| 7 | #include <stdatomic.h> |
| 8 | #include <structures/list.h> |
| 9 | #include <structures/locked_list.h> |
| 10 | |
| 11 | /* TODO: almost everything here is RO after init. |
| 12 | * |
| 13 | * I can clone these per-NUMA node and make backpointers |
| 14 | * via the per-core 'struct core' in the G segment register |
| 15 | * |
| 16 | * AKA, split into global and rw_global |
| 17 | */ |
| 18 | struct globals { |
| 19 | atomic_bool panicked; |
| 20 | volatile enum bootstage current_bootstage; |
| 21 | |
| 22 | char *root_partition; |
| 23 | |
| 24 | /* TODO: no more list */ |
| 25 | struct vfs_mount *mount_list_head; |
| 26 | struct vfs_node *root_node; |
| 27 | struct block_device *root_node_disk; |
| 28 | |
| 29 | struct topology topology; |
| 30 | |
| 31 | size_t numa_node_count; |
| 32 | struct numa_node *numa_nodes; |
| 33 | |
| 34 | atomic_size_t idle_core_count; |
| 35 | size_t core_count; |
| 36 | struct core **cores; |
| 37 | struct tlb_shootdown_cpu *shootdown_data; |
| 38 | struct scheduler **schedulers; |
| 39 | struct dpc_cpu *dpc_data; |
| 40 | |
| 41 | atomic_size_t thread_count; |
| 42 | |
| 43 | /* TODO: We can consider migrating these to per-subsystem locations */ |
| 44 | size_t domain_count; |
| 45 | struct domain **domains; |
| 46 | struct domain_buddy *domain_buddies; |
| 47 | struct page *page_array; |
| 48 | struct buddy_free_area buddy_free_area[BUDDY_MAX_ORDER]; |
| 49 | |
| 50 | bool scheduler_domains_ready; |
| 51 | struct scheduler_domain *scheduler_domains[TOPOLOGY_LEVEL_MAX]; |
| 52 | |
| 53 | vaddr_t hhdm_offset; |
| 54 | _Atomic uint64_t pt_epoch; |
| 55 | uint64_t total_pages; |
| 56 | paddr_t last_pfn; |
| 57 | |
| 58 | struct movealloc_callback_chain movealloc_chain; |
| 59 | |
| 60 | /* TODO: no more of this */ |
| 61 | _Atomic uint64_t next_tlb_gen; |
| 62 | _Atomic uint64_t rcu_gen; |
| 63 | |
| 64 | /* Per core workqueues */ |
| 65 | struct workqueue **workqueues; |
| 66 | |
| 67 | struct turnstile_hash_table *turnstiles; |
| 68 | struct locked_list thread_list; |
| 69 | |
| 70 | /* Conditional compilation globals go down here */ |
| 71 | #ifdef PROFILING_ENABLED |
| 72 | struct list_head profiling_list_head; |
| 73 | #endif |
| 74 | |
| 75 | #ifdef TEST_NIGHTMARE_ENABLED |
| 76 | atomic_bool nightmare_stop; |
| 77 | #endif |
| 78 | }; |
| 79 | |
| 80 | extern struct globals global; |
| 81 | |