diff --git a/arch/x86/include/asm/uhyve.h b/arch/x86/include/asm/uhyve.h new file mode 100644 index 000000000..745ef3c32 --- /dev/null +++ b/arch/x86/include/asm/uhyve.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, Stefan Lankes, RWTH Aachen University + * All rights reserved. + * + * 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 University 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 REGENTS 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. + */ + +/** + * @author Stefan Lankes + * @file arch/x86/include/asm/uhyve.h + * @brief interface to our machine monitor + */ + +#ifndef __ARCH_UHYVE_H__ +#define __ARCH_UHYVE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +inline static void uhyve_send(unsigned short _port, unsigned int _data) +{ + outportl(_port, _data); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index dd77fe610..fa8de1117 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -1,4 +1,4 @@ -C_source := irq.c idt.c isrs.c gdt.c processor.c timer.c tasks.c apic.c pci.c uart.c syscall.c +C_source := irq.c idt.c isrs.c gdt.c processor.c timer.c tasks.c apic.c pci.c uart.c syscall.c signal.c ASM_source := entry.asm string.asm MODULE := arch_x86_kernel diff --git a/kernel/signal.c b/arch/x86/kernel/signal.c similarity index 100% rename from kernel/signal.c rename to arch/x86/kernel/signal.c diff --git a/kernel/Makefile b/kernel/Makefile index 524b2e44c..1082e2f15 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,4 @@ -C_source := main.c tasks.c syscall.c timer.c signal.c +C_source := main.c tasks.c syscall.c timer.c MODULE := kernel include $(TOPDIR)/Makefile.inc diff --git a/kernel/syscall.c b/kernel/syscall.c index 99b3d3dd3..a41269add 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -91,7 +91,7 @@ typedef struct { void NORETURN sys_exit(int arg) { if (is_uhyve()) { - outportl(UHYVE_PORT_EXIT, (unsigned) (size_t) &arg); + uhyve_send(UHYVE_PORT_EXIT, (unsigned) (size_t) &arg); } else { sys_exit_t sysargs = {__NR_exit, arg}; @@ -135,7 +135,7 @@ ssize_t sys_read(int fd, char* buf, size_t len) if (is_uhyve()) { uhyve_read_t uhyve_args = {fd, (char*) virt_to_phys((size_t) buf), len, -1}; - outportl(UHYVE_PORT_READ, (unsigned)virt_to_phys((size_t)&uhyve_args)); + uhyve_send(UHYVE_PORT_READ, (unsigned)virt_to_phys((size_t)&uhyve_args)); return uhyve_args.ret; } @@ -209,7 +209,7 @@ ssize_t sys_write(int fd, const char* buf, size_t len) if (is_uhyve()) { uhyve_write_t uhyve_args = {fd, (const char*) virt_to_phys((size_t) buf), len}; - outportl(UHYVE_PORT_WRITE, (unsigned)virt_to_phys((size_t)&uhyve_args)); + uhyve_send(UHYVE_PORT_WRITE, (unsigned)virt_to_phys((size_t)&uhyve_args)); return uhyve_args.len; } @@ -319,7 +319,7 @@ int sys_open(const char* name, int flags, int mode) if (is_uhyve()) { uhyve_open_t uhyve_open = {(const char*)virt_to_phys((size_t)name), flags, mode, -1}; - outportl(UHYVE_PORT_OPEN, (unsigned)virt_to_phys((size_t) &uhyve_open)); + uhyve_send(UHYVE_PORT_OPEN, (unsigned)virt_to_phys((size_t) &uhyve_open)); return uhyve_open.ret; } @@ -390,7 +390,7 @@ int sys_close(int fd) if (is_uhyve()) { uhyve_close_t uhyve_close = {fd, -1}; - outportl(UHYVE_PORT_CLOSE, (unsigned)virt_to_phys((size_t) &uhyve_close)); + uhyve_sendl(UHYVE_PORT_CLOSE, (unsigned)virt_to_phys((size_t) &uhyve_close)); return uhyve_close.ret; }