[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Minios-devel] [UNIKRAFT PATCH v2 5/5] plat/solo5: Add platform interface implementation
This patch looks good. Can you replace `// ...` comments
with `/* ... */` ones?
On 19.03.19 11:31, Haibo Xu wrote:
Add initial implementation for the interfaces defined
in include/uk/plat.
Signed-off-by: Haibo Xu <haibo.xu@xxxxxxx>
---
plat/solo5/console.c | 45 ++++++++++++++++++++++++
plat/solo5/io.c | 41 ++++++++++++++++++++++
plat/solo5/irq.c | 28 +++++++++++++++
plat/solo5/lcpu.c | 75 +++++++++++++++++++++++++++++++++++++++
plat/solo5/memory.c | 81 +++++++++++++++++++++++++++++++++++++++++++
plat/solo5/setup.c | 42 ++++++++++++++++++++++
plat/solo5/shutdown.c | 37 ++++++++++++++++++++
plat/solo5/time.c | 56 ++++++++++++++++++++++++++++++
8 files changed, 405 insertions(+)
create mode 100644 plat/solo5/console.c
create mode 100644 plat/solo5/io.c
create mode 100644 plat/solo5/irq.c
create mode 100644 plat/solo5/lcpu.c
create mode 100644 plat/solo5/memory.c
create mode 100644 plat/solo5/setup.c
create mode 100644 plat/solo5/shutdown.c
create mode 100644 plat/solo5/time.c
diff --git a/plat/solo5/console.c b/plat/solo5/console.c
new file mode 100644
index 0000000..44cb8d5
--- /dev/null
+++ b/plat/solo5/console.c
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Authors: Haibo Xu <haibo.xu@xxxxxxx>
+ *
+ * Copyright (c) 2018, Arm Ltd. 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 <uk/plat/console.h>
+#include <uk/essentials.h>
+#include <solo5/solo5.h>
+
+int ukplat_coutd(const char *buf __maybe_unused, unsigned int len)
+{
+ solo5_console_write(buf, len);
+
+ return len;
+}
+
+
+int ukplat_coutk(const char *buf __maybe_unused, unsigned int len)
+{
+ solo5_console_write(buf, len);
+
+ return len;
+}
+
+// solo5 platform doesn't support console read
+int ukplat_cink(char *buf __maybe_unused, unsigned int maxlen __maybe_unused)
+{
+ return -1;
+}
diff --git a/plat/solo5/io.c b/plat/solo5/io.c
new file mode 100644
index 0000000..dcecddb
--- /dev/null
+++ b/plat/solo5/io.c
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Haibo Xu <haibo.xu@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 <uk/plat/io.h>
+
+// For solo5 platform, the application virtual address = application physical
address.
+__phys_addr ukplat_virt_to_phys(const volatile void *address)
+{
+ return (__phys_addr)address;
+}
diff --git a/plat/solo5/irq.c b/plat/solo5/irq.c
new file mode 100644
index 0000000..d2c1392
--- /dev/null
+++ b/plat/solo5/irq.c
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Haibo Xu <haibo.xu@xxxxxxx>
+ *
+ * Copyright (c) 2018, Arm Ltd. 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 <uk/essentials.h>
+#include <uk/plat/irq.h>
+
+int ukplat_irq_init(struct uk_alloc *a __unused)
+{
+ return 0;
+}
diff --git a/plat/solo5/lcpu.c b/plat/solo5/lcpu.c
new file mode 100644
index 0000000..8aa1cb5
--- /dev/null
+++ b/plat/solo5/lcpu.c
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Haibo Xu <haibo.xu@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 <uk/essentials.h>
+
+void ukplat_lcpu_enable_irq(void)
+{
+}
+
+void ukplat_lcpu_disable_irq(void)
+{
+}
+
+unsigned long ukplat_lcpu_save_irqf(void)
+{
+ return 0;
+}
+
+void ukplat_lcpu_restore_irqf(unsigned long flags __unused)
+{
+}
+
+int ukplat_lcpu_irqs_disabled(void)
+{
+ return 0;
+}
+
+void ukplat_lcpu_irqs_handle_pending(void)
+{
+}
+
+void ukplat_lcpu_halt(void)
+{
+}
+
+void ukplat_lcpu_halt_to(__snsec until __unused)
+{
+}
+
+void ukplat_lcpu_halt_irq(void)
+{
+}
diff --git a/plat/solo5/memory.c b/plat/solo5/memory.c
new file mode 100644
index 0000000..53da30e
--- /dev/null
+++ b/plat/solo5/memory.c
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Haibo Xu <haibo.xu@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 <solo5/setup.h>
+#include <uk/plat/memory.h>
+#include <uk/assert.h>
+
+int ukplat_memregion_count(void)
+{
+ return _libsolo5plat_opts.heap.base ? 1 : 0;
Do you know if Solo5 supports also something like an initrd? If yes,
could you add the support for this, too?
+}
+
+// Can only get the heap info from solo5 tender
+int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m)
+{
+ int ret;
+
+ UK_ASSERT(m);
+
+ if (i == 0 && _libsolo5plat_opts.heap.base) {
+ m->base = _libsolo5plat_opts.heap.base;
+ m->len = _libsolo5plat_opts.heap.len;
+ m->flags = UKPLAT_MEMRF_ALLOCATABLE;
+#if CONFIG_UKPLAT_MEMRNAME
+ m->name = "heap";
+#endif
+ ret = 0;
+ } else {
+ /* invalid memory region index or no heap allocated */
+ m->base = __NULL;
+ m->len = 0;
+ m->flags = 0x0;
+#if CONFIG_UKPLAT_MEMRNAME
+ m->name = __NULL;
+#endif
+ ret = -1;
+ }
+
+ return ret;
+}
+
+int ukplat_memallocator_set(struct uk_alloc *a __unused)
+{
+ return 0;
+}
+
+struct uk_alloc *ukplat_memallocator_get(void)
+{
+ return __NULL;
+}
diff --git a/plat/solo5/setup.c b/plat/solo5/setup.c
new file mode 100644
index 0000000..6a02d30
--- /dev/null
+++ b/plat/solo5/setup.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Authors: Haibo Xu <haibo.xu@xxxxxxx>
+ *
+ * Copyright (c) 2018, Arm Ltd. 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 <uk/assert.h>
+#include <uk/plat/bootstrap.h>
+#include <solo5/setup.h>
+#include <solo5/solo5.h>
+
+#define MAX_CMDLINE_SIZE 8192
+
+struct libsolo5plat_opts _libsolo5plat_opts = { 0 };
+
+int solo5_app_main(const struct solo5_start_info *si) {
+ UK_ASSERT(si != __NULL);
+
+ uk_pr_info("Entering from SOLO5...\n");
+
+ _libsolo5plat_opts.heap.len = si->heap_size;
+ _libsolo5plat_opts.heap.base = (void*)(si->heap_start);
+
+ ukplat_entry_argp(__NULL, si->cmdline, MAX_CMDLINE_SIZE);
+
+ return SOLO5_EXIT_SUCCESS;
+}
diff --git a/plat/solo5/shutdown.c b/plat/solo5/shutdown.c
new file mode 100644
index 0000000..b213c74
--- /dev/null
+++ b/plat/solo5/shutdown.c
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Authors: Haibo Xu <haibo.xu@xxxxxxx>
+ *
+ * Copyright (c) 2018, Arm Ltd. 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/print.h>
+#include <solo5/solo5.h>
+#include <uk/plat/bootstrap.h>
+
+void ukplat_terminate(enum ukplat_gstate request __unused)
+{
+ uk_pr_info("Unikraft halted\n");
+
+ solo5_exit(0);
+}
+
+int ukplat_suspend(void)
+{
+ return -EBUSY;
+}
diff --git a/plat/solo5/time.c b/plat/solo5/time.c
new file mode 100644
index 0000000..6f5de4f
--- /dev/null
+++ b/plat/solo5/time.c
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Haibo Xu <haibo.xu@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 <uk/plat/time.h>
+#include <solo5/solo5.h>
+
+/* return ns since time_init() */
+__nsec ukplat_monotonic_clock(void)
+{
+ return (__nsec)solo5_clock_monotonic();
+}
+
+/* return wall time in nsecs */
+__nsec ukplat_clock_wall(void)
+{
+ return (__nsec)solo5_clock_wall();
+}
+
+void ukplat_time_init(void)
+{
+}
+
+void ukplat_time_fini(void)
+{
+}
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|