#include <asm/bitops.h>
#include <asm/percpu.h>
+#include <jailhouse/cell.h>
#include <jailhouse/cell-config.h>
#define SHUTDOWN_NONE 0
unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set,
int exception);
+/**
+ * Get the first CPU in a given set.
+ * @param set CPU set.
+ *
+ * @return First CPU in set, or max_cpu_id + 1 if the set is empty.
+ */
+#define first_cpu(set) next_cpu(-1, (set), -1)
+
/**
* Loop-generating macro for iterating over all CPUs in a set.
* @param cpu Iteration variable holding the current CPU ID
* @param set CPU set to iterate over (struct cpu_set).
* @param exception CPU to skip if it is part of the set.
*
-* @see for_each_cpu
+ * @see for_each_cpu
*/
#define for_each_cpu_except(cpu, set, exception) \
for ((cpu) = -1; \
(cpu) <= (set)->max_cpu_id; \
)
+/**
+ * Loop-generating macro for iterating over all registered cells.
+ * @param cell Iteration variable holding the reference to the current
+ * cell (struct cell *).
+ *
+ * @see for_each_non_root_cell
+ */
+#define for_each_cell(cell) \
+ for ((cell) = &root_cell; (cell); (cell) = (cell)->next)
+
+/**
+ * Loop-generating macro for iterating over all registered cells, expect the
+ * root cell.
+ * @param cell Iteration variable holding the reference to the current
+ * cell (struct cell *).
+ *
+ * @see for_each_cell
+ */
+#define for_each_non_root_cell(cell) \
+ for ((cell) = root_cell.next; (cell); (cell) = (cell)->next)
+
+/**
+ * Loop-generating macro for iterating over all memory regions of a
+ * configuration.
+ * @param mem Iteration variable holding the reference to the current
+ * memory region (const struct jailhouse_memory *).
+ * @param config Cell or system configuration containing the regions.
+ * @param counter Helper variable (unsigned int).
+ */
+#define for_each_mem_region(mem, config, counter) \
+ for ((mem) = jailhouse_cell_mem_regions(config), (counter) = 0; \
+ (counter) < (config)->num_memory_regions; \
+ (mem)++, (counter)++)
+
/**
* Check if the CPU is assigned to the specified cell.
* @param cell Cell the CPU may belong to.
bool cpu_id_valid(unsigned long cpu_id);
-int check_mem_regions(const struct jailhouse_cell_desc *config);
int cell_init(struct cell *cell);
+void config_commit(struct cell *cell_added_removed);
+
long hypercall(unsigned long code, unsigned long arg1, unsigned long arg2);
void __attribute__((noreturn)) panic_stop(void);
int arch_unmap_memory_region(struct cell *cell,
const struct jailhouse_memory *mem);
+/**
+ * Performs the architecture-specific steps for invalidating memory caches
+ * after memory regions have been unmapped from a cell.
+ * This function should be called after memory got unmapped or memory access
+ * got restricted, and the cell should keep running.
+ * @param cell Cell for which the caches should get flushed
+ *
+ * @see per_cpu::flush_vcpu_caches
+ */
+void arch_flush_cell_vcpu_caches(struct cell *cell);
+
/**
* Performs the architecture-specific steps for creating a new cell.
* @param cell Data structure of the new cell.
* @param cell_added_removed Cell that was added or removed to/from the
* system or NULL.
*
+ * @see config_commit
* @see pci_config_commit
*/
void arch_config_commit(struct cell *cell_added_removed);