summaryrefslogtreecommitdiff
path: root/gxp-mailbox-manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'gxp-mailbox-manager.c')
-rw-r--r--gxp-mailbox-manager.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gxp-mailbox-manager.c b/gxp-mailbox-manager.c
new file mode 100644
index 0000000..1085a51
--- /dev/null
+++ b/gxp-mailbox-manager.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Mailbox manager abstracts the mailbox interfaces of user commands.
+ *
+ * Copyright (C) 2022 Google LLC
+ */
+
+#include "gxp-mailbox-driver.h"
+#include "gxp-mailbox-manager.h"
+#include "gxp-mailbox.h"
+
+struct gxp_mailbox_manager *gxp_mailbox_create_manager(struct gxp_dev *gxp,
+ uint num_cores)
+{
+ struct gxp_mailbox_manager *mgr;
+
+ mgr = devm_kzalloc(gxp->dev, sizeof(*mgr), GFP_KERNEL);
+ if (!mgr)
+ return ERR_PTR(-ENOMEM);
+
+ mgr->gxp = gxp;
+ mgr->num_cores = num_cores;
+ mgr->get_mailbox_csr_base = gxp_mailbox_get_csr_base;
+ mgr->get_mailbox_data_base = gxp_mailbox_get_data_base;
+
+ mgr->mailboxes = devm_kcalloc(gxp->dev, mgr->num_cores,
+ sizeof(*mgr->mailboxes), GFP_KERNEL);
+ if (!mgr->mailboxes)
+ return ERR_PTR(-ENOMEM);
+
+ return mgr;
+}