1/* @title: Global Variables */
2#pragma once
3#include <atomic.h>
4#include <bootstage.h>
5#include <mem/buddy.h>
6#include <mem/movealloc.h>
7#include <smp/topology.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 */
18struct 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 cc_counted_by(core_count);
37 struct scheduler **schedulers cc_counted_by(core_count);
38 struct dpc_cpu *dpc_data cc_counted_by(core_count);
39
40 atomic_size_t thread_count;
41
42 /* TODO: We can consider migrating these to per-subsystem locations */
43 size_t domain_count;
44 struct domain **domains cc_counted_by(domain_count);
45 struct domain_buddy *domain_buddies;
46 struct page *page_array;
47 struct buddy_free_area buddy_free_area[BUDDY_MAX_ORDER];
48
49 bool scheduler_domains_ready;
50 struct scheduler_domain *scheduler_domains[TOPOLOGY_LEVEL_MAX];
51
52 vaddr_t hhdm_offset;
53 atomic_uint64_t pt_epoch;
54 uint64_t total_pages;
55 pfn_t last_pfn;
56
57 struct movealloc_callback_chain movealloc_chain;
58
59 /* Per core workqueues */
60 struct workqueue **workqueues cc_counted_by(core_count);
61
62 struct turnstile_hash_table *turnstiles;
63 struct locked_list thread_list;
64
65 /* Conditional compilation globals go down here */
66#ifdef PROFILING_ENABLED
67 struct list_head profiling_list_head;
68#endif
69};
70
71extern struct globals global;
72