manifest: Require 'compatible' property in 'hypervisor' node
Other hypervisors also use a 'hypervisor' node in the FDT to pass
config information to the VMs. Add requirement to specify which
hypervisors the node is compatible with. The 'compatible' property
is a list of NULL-separated strings in the format
"<manufacturer>,<model>". Following the naming convention of other
projects, we will use "hafnium,hafnium" as a match-all-versions value,
and later add "hafnium,hafnium_<version>" values to match specific
releases of Hafnium.
Bug: 117551352
Change-Id: Ie6dadcdace37318d4d122e80fefe989715ee9cc9
diff --git a/src/std.c b/src/std.c
index a467384..84806e2 100644
--- a/src/std.c
+++ b/src/std.c
@@ -16,7 +16,7 @@
#include "hf/std.h"
-#include "hf/panic.h"
+#include "hf/check.h"
/* Declare unsafe functions locally so they are not available globally. */
void *memset(void *s, int c, size_t n);
@@ -89,6 +89,30 @@
}
/**
+ * Finds the first occurrence of character `ch` in the first `count` bytes of
+ * memory pointed to by `ptr`.
+ *
+ * Returns NULL if `ch` is not found.
+ * Panics if `ptr` is NULL (undefined behaviour).
+ */
+void *memchr(const void *ptr, int ch, size_t count)
+{
+ size_t i;
+ const unsigned char *p = (const unsigned char *)ptr;
+
+ CHECK(ptr != NULL);
+
+ /* Iterate over at most `strsz` characters of `str`. */
+ for (i = 0; i < count; ++i) {
+ if (p[i] == (unsigned char)ch) {
+ return (void *)(&p[i]);
+ }
+ }
+
+ return NULL;
+}
+
+/**
* Returns the length of the null-terminated byte string `str`, examining at
* most `strsz` bytes.
*