From a1beea41f81f7a6abc0b6758c1ad88c3db6e5d28 Mon Sep 17 00:00:00 2001
From: "iliya.saroukha" <iliya.saroukhanian@etu.hesge.ch>
Date: Fri, 31 Jan 2025 14:56:28 +0100
Subject: [PATCH] wip: vcpu structure and initialization

---
 proto/vcpu/vcpu.c | 20 ++++++++++++++++++++
 proto/vcpu/vcpu.h | 12 ++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 proto/vcpu/vcpu.c
 create mode 100644 proto/vcpu/vcpu.h

diff --git a/proto/vcpu/vcpu.c b/proto/vcpu/vcpu.c
new file mode 100644
index 0000000..140f355
--- /dev/null
+++ b/proto/vcpu/vcpu.c
@@ -0,0 +1,20 @@
+#include "vcpu.h"
+#include "../debug/debug.h"
+#include "../region/vxmon.h"
+#include <linux/errno.h>
+
+int init_vcpu(struct vcpu_t *vcpu, struct vmxon_t *vmxon) {
+    if (!vcpu) {
+        DEBUG_FMT("vcpu isn't allocated\n");
+        return -EFAULT;
+    }
+
+    if (!vmxon) {
+        DEBUG_FMT("vmxon region isn't allocated\n");
+        return -EFAULT;
+    }
+
+    vcpu->vmxon = vmxon;
+
+    return 0;
+}
diff --git a/proto/vcpu/vcpu.h b/proto/vcpu/vcpu.h
new file mode 100644
index 0000000..0c17cc0
--- /dev/null
+++ b/proto/vcpu/vcpu.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "../region/vxmon.h"
+
+struct vcpu_t {
+    struct vmxon_t *vmxon;
+    /*NOTE: prolly should store the PAs of pointers to avoid unnecessary
+     * address translations, although they should reside in the TLB by that
+     * point*/
+};
+
+int init_vcpu(struct vcpu_t *vcpu);
-- 
GitLab