mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
move hardware dependent functions to the subdirectory arch
This commit is contained in:
parent
1269a71439
commit
3a926240ca
5 changed files with 61 additions and 8 deletions
53
arch/x86/include/asm/uhyve.h
Normal file
53
arch/x86/include/asm/uhyve.h
Normal file
|
@ -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 <hermit/stddef.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
inline static void uhyve_send(unsigned short _port, unsigned int _data)
|
||||
{
|
||||
outportl(_port, _data);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <hermit/memory.h>
|
||||
#include <hermit/signal.h>
|
||||
#include <hermit/logging.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/uhyve.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
#include <lwip/sockets.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue