]> rtime.felk.cvut.cz Git - jailhouse.git/blobdiff - hypervisor/include/jailhouse/control.h
core: Introduce first_cpu
[jailhouse.git] / hypervisor / include / jailhouse / control.h
index a55ee352af7134fdad9d617ea8373eda40662905..c7da909dcfb3570b56604ecc5d9f1ef9f50bdf54 100644 (file)
@@ -33,6 +33,14 @@ extern struct jailhouse_system *system_config;
 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
@@ -84,6 +92,19 @@ unsigned int next_cpu(unsigned int cpu, struct cpu_set *cpu_set,
 #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.
@@ -99,7 +120,6 @@ static inline bool cell_owns_cpu(struct cell *cell, unsigned int cpu_id)
 
 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);