Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/45045 )

Change subject: arch-x86: Bare metal workload.
......................................................................

arch-x86: Bare metal workload.

Change-Id: I9ff6f5a9970cc7af2ba639be18f1881748074777
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/45045
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
A src/arch/x86/bare_metal/SConscript
M src/arch/x86/X86FsWorkload.py
M src/arch/x86/SConscript
A src/arch/x86/bare_metal/workload.cc
A src/arch/x86/bare_metal/workload.hh
5 files changed, 197 insertions(+), 2 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/arch/x86/SConscript b/src/arch/x86/SConscript
index ad3d698..8c957dd 100644
--- a/src/arch/x86/SConscript
+++ b/src/arch/x86/SConscript
@@ -62,7 +62,8 @@
 Source('utility.cc', tags='x86 isa')

 SimObject('X86SeWorkload.py', sim_objects=['X86EmuLinux'], tags='x86 isa')
-SimObject('X86FsWorkload.py', sim_objects=['X86FsWorkload', 'X86FsLinux'],
+SimObject('X86FsWorkload.py',
+    sim_objects=['X86BareMetalWorkload', 'X86FsWorkload', 'X86FsLinux'],
     tags='x86 isa')
 SimObject('X86Decoder.py', sim_objects=['X86Decoder'], tags='x86 isa')
 SimObject('X86ISA.py', sim_objects=['X86ISA'], tags='x86 isa')
diff --git a/src/arch/x86/X86FsWorkload.py b/src/arch/x86/X86FsWorkload.py
index a049203..52dbadf 100644
--- a/src/arch/x86/X86FsWorkload.py
+++ b/src/arch/x86/X86FsWorkload.py
@@ -39,7 +39,12 @@
 from m5.objects.SMBios import X86SMBiosSMBiosTable
from m5.objects.IntelMP import X86IntelMPFloatingPointer, X86IntelMPConfigTable
 from m5.objects.ACPI import X86ACPIRSDP
-from m5.objects.Workload import KernelWorkload
+from m5.objects.Workload import KernelWorkload, Workload
+
+class X86BareMetalWorkload(Workload):
+    type = 'X86BareMetalWorkload'
+    cxx_header = 'arch/x86/bare_metal/workload.hh'
+    cxx_class = 'gem5::X86ISA::BareMetalWorkload'

 class X86FsWorkload(KernelWorkload):
     type = 'X86FsWorkload'
diff --git a/src/arch/x86/bare_metal/SConscript b/src/arch/x86/bare_metal/SConscript
new file mode 100644
index 0000000..04e8feb
--- /dev/null
+++ b/src/arch/x86/bare_metal/SConscript
@@ -0,0 +1,31 @@
+# Copyright 2022 Google, Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met: redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer;
+# redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution;
+# neither the name of the copyright holders nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Import('*')
+
+if env['TARGET_ISA'] != 'x86':
+    Return()
+
+Source('workload.cc')
diff --git a/src/arch/x86/bare_metal/workload.cc b/src/arch/x86/bare_metal/workload.cc
new file mode 100644
index 0000000..068c7e8
--- /dev/null
+++ b/src/arch/x86/bare_metal/workload.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2022 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "arch/x86/bare_metal/workload.hh"
+
+#include "arch/x86/faults.hh"
+#include "arch/x86/pcstate.hh"
+#include "cpu/thread_context.hh"
+#include "params/X86BareMetalWorkload.hh"
+#include "sim/system.hh"
+
+namespace gem5
+{
+
+namespace X86ISA
+{
+
+BareMetalWorkload::BareMetalWorkload(const Params &p) : Workload(p)
+{}
+
+void
+BareMetalWorkload::initState()
+{
+    Workload::initState();
+
+    for (auto *tc: system->threads) {
+        X86ISA::InitInterrupt(0).invoke(tc);
+
+        if (tc->contextId() == 0) {
+            PCState pc = tc->pcState().as<PCState>();
+            // Don't start in the microcode ROM which would halt this CPU.
+            pc.upc(0);
+            pc.nupc(1);
+            tc->pcState(pc);
+            tc->activate();
+        } else {
+ // This is an application processor (AP). It should be initialized + // to look like only the BIOS POST has run on it and put then put
+            // it into a halted state.
+            tc->suspend();
+        }
+    }
+}
+
+} // namespace X86ISA
+
+} // namespace gem5
diff --git a/src/arch/x86/bare_metal/workload.hh b/src/arch/x86/bare_metal/workload.hh
new file mode 100644
index 0000000..5e4838e
--- /dev/null
+++ b/src/arch/x86/bare_metal/workload.hh
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2022 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __ARCH_X86_BARE_METAL_WORKLOAD_HH__
+#define __ARCH_X86_BARE_METAL_WORKLOAD_HH__
+
+#include "base/loader/object_file.hh"
+#include "base/loader/symtab.hh"
+#include "base/types.hh"
+#include "cpu/thread_context.hh"
+#include "params/X86BareMetalWorkload.hh"
+#include "sim/workload.hh"
+
+namespace gem5
+{
+
+namespace X86ISA
+{
+
+class BareMetalWorkload : public Workload
+{
+  public:
+    using Params = X86BareMetalWorkloadParams;
+    BareMetalWorkload(const Params &p);
+
+  public:
+    void initState() override;
+
+    Addr getEntry() const override { return 0; }
+    ByteOrder byteOrder() const override { return ByteOrder::little; }
+    loader::Arch getArch() const override { return loader::UnknownArch; }
+    const loader::SymbolTable &
+    symtab(ThreadContext *tc) override
+    {
+        static loader::SymbolTable sym_tab;
+        return sym_tab;
+    }
+
+    bool
+    insertSymbol(const loader::Symbol &symbol) override
+    {
+        return false;
+    }
+};
+
+} // namespace X86ISA
+
+} // namespace gem5
+
+#endif // __ARCH_X86_BARE_METAL_WORKLOAD_HH__

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/45045
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9ff6f5a9970cc7af2ba639be18f1881748074777
Gerrit-Change-Number: 45045
Gerrit-PatchSet: 6
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Matt Sinclair <[email protected]>
Gerrit-Reviewer: Matthew Poremba <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to