-/* $OpenBSD: config.c,v 1.22 2017/01/17 22:10:55 krw Exp $ */
+/* $OpenBSD: config.c,v 1.23 2018/09/16 12:17:05 kettenis Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
uint64_t rombase;
uint64_t romsize;
+uint64_t uartbase;
uint64_t max_page_size;
return NULL;
}
+void
+pri_delete_devalias(struct md *md)
+{
+ struct md_node *node;
+
+ /*
+ * There may be multiple "devalias" nodes. Only remove the one
+ * that resides under the "openboot" node.
+ */
+ node = md_find_node(protomd, "openboot");
+ assert(node);
+ node = md_find_subnode(protomd, node, "devalias");
+ if (node)
+ md_delete_node(protomd, node);
+}
+
void
pri_init(struct md *md)
{
continue;
if (!md_get_prop_val(md, node2, "offset", &offset) ||
!md_get_prop_val(md, node2, "size", &size))
- continue;
+ continue;
rombase = base + offset;
romsize = size;
}
protomd = md_copy(md);
md_find_delete_node(protomd, "components");
- md_find_delete_node(protomd, "devalias");
md_find_delete_node(protomd, "domain-services");
md_find_delete_node(protomd, "channel-devices");
md_find_delete_node(protomd, "channel-endpoints");
md_find_delete_node(protomd, "firmware");
md_find_delete_node(protomd, "ldc_endpoints");
md_find_delete_node(protomd, "memory-segments");
+ pri_delete_devalias(protomd);
md_collect_garbage(protomd);
md_write(protomd, "protomd");
if (resource_id >= max_guests)
errx(1, "resource_id larger than max_guests");
- console = xmalloc(sizeof(*console));
+ console = xzalloc(sizeof(*console));
md_get_prop_val(md, node, "ino", &console->ino);
+ md_get_prop_val(md, node, "uartbase", &console->uartbase);
console->resource_id = resource_id;
consoles[resource_id] = console;
console->hv_node = node;
device = xzalloc(sizeof(*device));
md_get_prop_val(md, node, "gid", &device->gid);
md_get_prop_val(md, node, "cfghandle", &device->cfghandle);
+ md_get_prop_val(md, node, "rcid", &device->rcid);
device->resource_id = resource_id;
if (strcmp(node->name->str, "pcie_bus") == 0)
pcie_busses[resource_id] = device;
md_get_prop_val(md, node, "tod", &tod);
md_get_prop_val(md, node, "erpt-pa", &erpt_pa);
md_get_prop_val(md, node, "erpt-size", &erpt_size);
+ md_get_prop_val(md, node, "uartbase", &uartbase);
- node = md_find_node(md, "frag_space");
- md_get_prop_val(md, node, "fragsize", &fragsize);
- TAILQ_INIT(&frag_mblocks);
- TAILQ_FOREACH(prop, &node->prop_list, link) {
- if (prop->tag == MD_PROP_ARC &&
- strcmp(prop->name->str, "fwd") == 0)
- hvmd_init_frag(md, prop->d.arc.node);
- }
- pri_alloc_memory(0, fragsize);
+ node = md_find_node(md, "platform");
+ if (node)
+ md_get_prop_val(md, node, "stick-frequency", &stick_frequency);
node = md_find_node(md, "hvmd_mblock");
if (node) {
pri_alloc_memory(hvmd_mblock->membase, hvmd_mblock->memsize);
}
+ node = md_find_node(md, "frag_space");
+ md_get_prop_val(md, node, "fragsize", &fragsize);
+ if (fragsize == 0)
+ fragsize = md_maxsize;
+ TAILQ_INIT(&frag_mblocks);
+ TAILQ_FOREACH(prop, &node->prop_list, link) {
+ if (prop->tag == MD_PROP_ARC &&
+ strcmp(prop->name->str, "fwd") == 0)
+ hvmd_init_frag(md, prop->d.arc.node);
+ }
+ pri_alloc_memory(0, fragsize);
+
node = md_find_node(md, "consoles");
TAILQ_FOREACH(prop, &node->prop_list, link) {
if (prop->tag == MD_PROP_ARC &&
md_add_prop_val(md, node, "resource_id", device->resource_id);
md_add_prop_val(md, node, "cfghandle", device->cfghandle);
md_add_prop_val(md, node, "gid", device->gid);
+ md_add_prop_val(md, node, "rcid", device->rcid);
device->hv_node = node;
}
md_add_prop_val(md, node, "ino", console->ino);
console->hv_node = node;
+ if (console->uartbase) {
+ md_add_prop_val(md, node, "uartbase", console->uartbase);
+ return;
+ }
+
TAILQ_FOREACH(endpoint, &console->guest->endpoint_list, link) {
if (endpoint->rx_ino == console->ino) {
md_link_node(md, node, endpoint->hv_node);
md_add_prop_val(md, node, "mdpa", guest->mdpa);
md_add_prop_val(md, node, "rombase", rombase);
md_add_prop_val(md, node, "romsize", romsize);
+ md_add_prop_val(md, node, "uartbase", uartbase);
guest->hv_node = node;
node = md_add_node(md, "virtual_devices");
struct md_node *parent;
struct md_node *node;
- node = md_find_node(md, "devalias");
- if (node == NULL) {
- parent = md_find_node(md, "openboot");
- assert(parent);
+ parent = md_find_node(md, "openboot");
+ assert(parent);
+ node = md_find_subnode(md, parent, "devalias");
+ if (node == NULL) {
node = md_add_node(md, "devalias");
md_link_node(md, parent, node);
}
struct md_node *child;
struct cpu *cpu;
uint64_t pid;
- uint64_t id;
const char *name;
char *path;
}
}
- md_collect_garbage(md);
-
node = md_find_node(md, "memory");
- md_get_prop_val(md, node, "memory-generation-id#", &id);
- md_delete_node(md, node);
- md_collect_garbage(md);
-
- parent = md_find_node(md, "root");
- assert(parent);
+ TAILQ_FOREACH_SAFE(prop, &node->prop_list, link, prop2) {
+ if (prop->tag == MD_PROP_ARC &&
+ strcmp(prop->name->str, "fwd") == 0) {
+ node2 = prop->d.arc.node;
+ md_delete_node(md, node2);
+ }
+ }
- node = md_add_node(md, "memory");
- md_add_prop_val(md, node, "memory-generation-id#", id);
- md_link_node(md, parent, node);
+ md_collect_garbage(md);
+ parent = md_find_node(md, "memory");
TAILQ_FOREACH(mblock, &guest->mblock_list, link) {
child = md_add_node(md, "mblock");
md_add_prop_val(md, child, "base", mblock->realbase);
md_add_prop_val(md, child, "size", mblock->memsize);
- md_link_node(md, node, child);
+ md_link_node(md, parent, child);
}
xasprintf(&path, "%s.md", guest->name);