[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/PLAT_RASPI PATCH 08/13] plats/raspi: Adding Unikraft platform specific functions



Adding Unikraft platform specific functions.

Signed-off-by: Santiago Pagani <santiagopagani@xxxxxxxxx>
---
 include/raspi/setup.h |  47 +++++++++++++++
 io.c                  |  45 ++++++++++++++
 lcpu.c                |  70 ++++++++++++++++++++++
 memory.c              | 133 ++++++++++++++++++++++++++++++++++++++++++
 setup.c               |  89 ++++++++++++++++++++++++++++
 shutdown.c            |  46 +++++++++++++++
 6 files changed, 430 insertions(+)
 create mode 100644 include/raspi/setup.h
 create mode 100644 io.c
 create mode 100644 lcpu.c
 create mode 100644 memory.c
 create mode 100644 setup.c
 create mode 100644 shutdown.c

diff --git a/include/raspi/setup.h b/include/raspi/setup.h
new file mode 100644
index 0000000..a0e6cb5
--- /dev/null
+++ b/include/raspi/setup.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Santiago Pagani <santiagopagani@xxxxxxxxx>
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holder 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 HOLDER 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.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+#ifndef __RASPI_SETUP_H__
+#define __RASPI_SETUP_H__
+
+#include <stdint.h>
+
+uint64_t _libraspiplat_get_reset_time(void);
+uint64_t _libraspiplat_get_hardware_init_time(void);
+
+uint64_t get_sp ( void );
+uint64_t get_sp_start ( void );
+
+#endif /* __RASPI_SETUP_H__ */
diff --git a/io.c b/io.c
new file mode 100644
index 0000000..f83d809
--- /dev/null
+++ b/io.c
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
+ *
+ * Copyright (c) 2018, NEC Europe Ltd., NEC Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holder 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 HOLDER 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.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+#include <uk/plat/io.h>
+
+/**
+ * TODO:
+ * For our Raspberry Pi platform, the guest virtual address == guest physical 
address.
+ * We may have to reconsider this implementation when condition changes.
+ */
+__phys_addr ukplat_virt_to_phys(const volatile void *address)
+{
+       return (__phys_addr)address;
+}
diff --git a/lcpu.c b/lcpu.c
new file mode 100644
index 0000000..6f15c3f
--- /dev/null
+++ b/lcpu.c
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Wei Chen <wei.chen@xxxxxxx>
+ *
+ * Copyright (c) 2018, Arm Ltd., All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holder 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 HOLDER 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.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+#include <stdint.h>
+#include <uk/plat/lcpu.h>
+#include <arm/irq.h>
+
+void ukplat_lcpu_enable_irq(void)
+{
+       local_irq_enable();
+}
+
+void ukplat_lcpu_disable_irq(void)
+{
+       local_irq_disable();
+}
+
+unsigned long ukplat_lcpu_save_irqf(void)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+
+       return flags;
+}
+
+void ukplat_lcpu_restore_irqf(unsigned long flags)
+{
+       local_irq_restore(flags);
+}
+
+int ukplat_lcpu_irqs_disabled(void)
+{
+       return irqs_disabled();
+}
+
+void ukplat_lcpu_irqs_handle_pending(void)
+{
+       // TODO
+}
diff --git a/memory.c b/memory.c
new file mode 100644
index 0000000..44ab36f
--- /dev/null
+++ b/memory.c
@@ -0,0 +1,133 @@
+/* SPDX-License-Identifier: ISC */
+/* Copyright (c) 2015, IBM
+ *           (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ * Author(s): Dan Williams <djwillia@xxxxxxxxxx>
+ *            Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
+ *            Santiago Pagani <santiagopagani@xxxxxxxxx>
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <uk/plat/memory.h>
+#include <uk/plat/common/sections.h>
+#include <uk/essentials.h>
+#include <raspi/sysregs.h>
+
+int ukplat_memregion_count(void)
+{
+       return 7;
+}
+
+int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m)
+{
+       int ret;
+
+       UK_ASSERT(m);
+
+       switch (i) {
+       case 0: /* stack */
+               m->base  = (void *) 0;
+               m->len   = (size_t) __TEXT;
+               m->flags = (UKPLAT_MEMRF_RESERVED
+                           | UKPLAT_MEMRF_READABLE
+                           | UKPLAT_MEMRF_WRITABLE);
+               ret = 0;
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "stack";
+#endif
+               break;
+       case 1: /* text */
+               m->base  = (void *) __TEXT;
+               m->len   = (size_t) __ETEXT - (size_t) __TEXT;
+               m->flags = (UKPLAT_MEMRF_RESERVED
+                           | UKPLAT_MEMRF_READABLE);
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "text";
+#endif
+               ret = 0;
+               break;
+       case 2: /* rodata */
+               m->base  = (void *) __RODATA;
+               m->len   = (size_t) __ERODATA - (size_t) __RODATA;
+               m->flags = (UKPLAT_MEMRF_RESERVED
+                           | UKPLAT_MEMRF_READABLE);
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "rodata";
+#endif
+               ret = 0;
+               break;
+       case 3: /* ctors */
+               m->base  = (void *) __CTORS;
+               m->len   = (size_t) __ECTORS - (size_t) __CTORS;
+               m->flags = (UKPLAT_MEMRF_RESERVED
+                           | UKPLAT_MEMRF_READABLE);
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "ctors";
+#endif
+               ret = 0;
+               break;
+       case 4: /* data */
+               m->base  = (void *) __DATA;
+               m->len   = (size_t) __EDATA - (size_t) __DATA;
+               m->flags = (UKPLAT_MEMRF_RESERVED
+                           | UKPLAT_MEMRF_READABLE
+                           | UKPLAT_MEMRF_WRITABLE);
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "data";
+#endif
+               ret = 0;
+               break;
+       case 5: /* bss */
+               m->base  = (void *) __BSS_START;
+               m->len   = (size_t) __END - (size_t) __BSS_START;
+               m->flags = (UKPLAT_MEMRF_RESERVED
+                           | UKPLAT_MEMRF_READABLE
+                           | UKPLAT_MEMRF_WRITABLE);
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "bss";
+#endif
+               ret = 0;
+               break;
+       case 6: /* heap */
+               m->base  = (void *) __END;
+               m->len   = (size_t) (MMIO_BASE/2 - 1) - (size_t) __END;
+               m->flags = UKPLAT_MEMRF_ALLOCATABLE;
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = "heap";
+#endif
+               ret = 0;
+               break;
+       default:
+               m->base  = __NULL;
+               m->len   = 0;
+               m->flags = 0x0;
+#if CONFIG_UKPLAT_MEMRNAME
+               m->name  = __NULL;
+#endif
+               ret = -1;
+               break;
+       }
+
+       return ret;
+}
+
+int _ukplat_mem_mappings_init(void)
+{
+       return 0;
+}
+
+void ukplat_stack_set_current_thread(void *thread_addr __unused)
+{
+}
diff --git a/setup.c b/setup.c
new file mode 100644
index 0000000..6081cc6
--- /dev/null
+++ b/setup.c
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Santiago Pagani <santiagopagani@xxxxxxxxx>
+ *
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ *                     All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of the copyright holder 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 HOLDER 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.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+#include <uk/plat/bootstrap.h>
+#include <uk/plat/time.h>
+#include <arm/cpu.h>
+#if CONFIG_RASPI_LCD
+       #include <raspi/lfb.h>
+#endif
+#if CONFIG_RASPI_TOUCHSCREEN
+       #include <raspi/touchscreen.h>
+#endif
+#include <raspi/console.h>
+#include <raspi/time.h>
+#include <uk/print.h>
+#include <uk/arch/types.h>
+
+//smcc_psci_callfn_t smcc_psci_call;
+
+static uint64_t assembly_entry;
+static uint64_t hardware_init_done;
+
+uint64_t _libraspiplat_get_reset_time(void)
+{
+       return assembly_entry;
+}
+
+uint64_t _libraspiplat_get_hardware_init_time(void)
+{
+       return hardware_init_done;
+}
+
+void _libraspiplat_entry(uint64_t low0, uint64_t hi0, uint64_t low1, uint64_t 
hi1)
+{
+       if (hi0 == hi1) {
+               assembly_entry = ((hi0 << 32)&0xFFFFFFFF00000000) | 
(low0&0xFFFFFFFF);
+       } else {
+               assembly_entry = ((hi1 << 32)&0xFFFFFFFF00000000) | 
(low1&0xFFFFFFFF);
+       }
+
+    _libraspiplat_init_console();
+
+       #if CONFIG_RASPI_LCD
+       lfb_init();
+       #endif
+
+       #if CONFIG_RASPI_TOUCHSCREEN
+               touchscreen_init();
+       #endif
+       
+       hardware_init_done = get_system_timer();
+
+       /*
+        * Enter Unikraft
+        */
+       ukplat_entry(0, 0);
+}
diff --git a/shutdown.c b/shutdown.c
new file mode 100644
index 0000000..131a348
--- /dev/null
+++ b/shutdown.c
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Authors: Martin Lucina
+ *          Felipe Huici <felipe.huici@xxxxxxxxx>
+ *          Santiago Pagani <santiagopagani@xxxxxxxxx>
+ *
+ * Copyright (c) 2016-2017 Docker, Inc.
+ * Copyright (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
+ *                     All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <uk/plat/common/cpu.h>
+#include <uk/plat/common/irq.h>
+#include <uk/plat/bootstrap.h>
+
+static void cpu_halt(void) __noreturn;
+
+void ukplat_terminate(enum ukplat_gstate request __unused)
+{
+       cpu_halt();
+}
+
+static void cpu_halt(void)
+{
+       __CPU_HALT();
+}
+
+int ukplat_suspend(void)
+{
+       return -EBUSY;
+}
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.