diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
commit | f215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch) | |
tree | 6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Runtime/os2 | |
parent | Initial commit. (diff) | |
download | virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip |
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Runtime/os2')
-rw-r--r-- | src/VBox/Runtime/os2/Makefile.kup | 0 | ||||
-rw-r--r-- | src/VBox/Runtime/os2/RTErrConvertFromOS2.cpp | 187 | ||||
-rw-r--r-- | src/VBox/Runtime/os2/rtSemWaitOs2ConvertTimeout.cpp | 104 | ||||
-rw-r--r-- | src/VBox/Runtime/os2/sys0.asm | 65 |
4 files changed, 356 insertions, 0 deletions
diff --git a/src/VBox/Runtime/os2/Makefile.kup b/src/VBox/Runtime/os2/Makefile.kup new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/VBox/Runtime/os2/Makefile.kup diff --git a/src/VBox/Runtime/os2/RTErrConvertFromOS2.cpp b/src/VBox/Runtime/os2/RTErrConvertFromOS2.cpp new file mode 100644 index 00000000..b0f7d5ed --- /dev/null +++ b/src/VBox/Runtime/os2/RTErrConvertFromOS2.cpp @@ -0,0 +1,187 @@ +/* $Id: RTErrConvertFromOS2.cpp $ */ +/** @file + * IPRT - Convert OS/2 error codes to iprt status codes. + */ + +/* + * Copyright (C) 2006-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * The contents of this file may alternatively be used under the terms + * of the Common Development and Distribution License Version 1.0 + * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included + * in the VirtualBox distribution, in which case the provisions of the + * CDDL are applicable instead of those of the GPL. + * + * You may elect to license modified versions of this file under the + * terms and conditions of either the GPL or the CDDL or both. + * + * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0 + */ + + +/********************************************************************************************************************************* +* Header Files * +*********************************************************************************************************************************/ +#define INCL_ERRORS +#define INCL_DOSERRORS +#include <os2.h> +#undef RT_MAX + +#include <iprt/err.h> +#include <iprt/log.h> +#include <iprt/assert.h> + + +RTDECL(int) RTErrConvertFromOS2(unsigned uNativeCode) +{ + /* very fast check for no error. */ + if (uNativeCode == NO_ERROR) + return VINF_SUCCESS; + + switch (uNativeCode) + { + case ERROR_INVALID_FUNCTION: return VERR_INVALID_FUNCTION; + case ERROR_FILE_NOT_FOUND: return VERR_FILE_NOT_FOUND; + case ERROR_PATH_NOT_FOUND: return VERR_PATH_NOT_FOUND; + case ERROR_TOO_MANY_OPEN_FILES: return VERR_TOO_MANY_OPEN_FILES; + case ERROR_ACCESS_DENIED: return VERR_ACCESS_DENIED; + + case ERROR_INVALID_HANDLE: + case ERROR_DIRECT_ACCESS_HANDLE: return VERR_INVALID_HANDLE; + + case ERROR_NOT_ENOUGH_MEMORY: return VERR_NO_MEMORY; + + case ERROR_INVALID_DRIVE: return VERR_INVALID_DRIVE; + case ERROR_CURRENT_DIRECTORY: return VERR_CANT_DELETE_DIRECTORY; + case ERROR_NOT_SAME_DEVICE: return VERR_NOT_SAME_DEVICE; + case ERROR_NO_MORE_FILES: return VERR_NO_MORE_FILES; + case ERROR_WRITE_PROTECT: return VERR_WRITE_PROTECT; + case ERROR_BAD_UNIT: return VERR_IO_BAD_UNIT; + case ERROR_NOT_READY: return VERR_IO_NOT_READY; + case ERROR_BAD_COMMAND: return VERR_IO_BAD_COMMAND; + case ERROR_CRC: return VERR_IO_CRC; + case ERROR_BAD_LENGTH: return VERR_IO_BAD_LENGTH; + case ERROR_SEEK: return VERR_SEEK; + case ERROR_NOT_DOS_DISK: return VERR_DISK_INVALID_FORMAT; + case ERROR_SECTOR_NOT_FOUND: return VERR_IO_SECTOR_NOT_FOUND; + case ERROR_WRITE_FAULT: return VERR_WRITE_ERROR; + case ERROR_READ_FAULT: return VERR_READ_ERROR; + case ERROR_GEN_FAILURE: return VERR_IO_GEN_FAILURE; + case ERROR_SHARING_VIOLATION: return VERR_SHARING_VIOLATION; + case ERROR_LOCK_VIOLATION: return VERR_FILE_LOCK_FAILED; + case ERROR_HANDLE_EOF: return VERR_EOF; + + case ERROR_HANDLE_DISK_FULL: + case ERROR_DISK_FULL: return VERR_DISK_FULL; + + case ERROR_NOT_SUPPORTED: return VERR_NOT_SUPPORTED; + + case ERROR_INVALID_PARAMETER: + case ERROR_BAD_ARGUMENTS: + case ERROR_PMM_INVALID_FLAGS: return VERR_INVALID_PARAMETER; + + case ERROR_REM_NOT_LIST: return VERR_NET_IO_ERROR; + + case ERROR_BAD_NETPATH: + case ERROR_NETNAME_DELETED: return VERR_NET_HOST_NOT_FOUND; + + case ERROR_BAD_NET_NAME: + case ERROR_DEV_NOT_EXIST: return VERR_NET_PATH_NOT_FOUND; + + case ERROR_NETWORK_BUSY: + case ERROR_TOO_MANY_CMDS: + case ERROR_TOO_MANY_NAMES: + case ERROR_TOO_MANY_SESS: + case ERROR_OUT_OF_STRUCTURES: return VERR_NET_OUT_OF_RESOURCES; + + case ERROR_PRINTQ_FULL: + case ERROR_NO_SPOOL_SPACE: + case ERROR_PRINT_CANCELLED: return VERR_NET_PRINT_ERROR; + + case ERROR_DUP_NAME: + case ERROR_ADAP_HDW_ERR: + case ERROR_BAD_NET_RESP: + case ERROR_UNEXP_NET_ERR: + case ERROR_BAD_REM_ADAP: + case ERROR_NETWORK_ACCESS_DENIED: + case ERROR_BAD_DEV_TYPE: + case ERROR_SHARING_PAUSED: + case ERROR_REQ_NOT_ACCEP: + case ERROR_REDIR_PAUSED: + case ERROR_ALREADY_ASSIGNED: + case ERROR_INVALID_PASSWORD: + case ERROR_NET_WRITE_FAULT: return VERR_NET_IO_ERROR; + + case ERROR_FILE_EXISTS: + case ERROR_ALREADY_EXISTS: return VERR_ALREADY_EXISTS; + + case ERROR_CANNOT_MAKE: return VERR_CANT_CREATE; + case ERROR_NO_PROC_SLOTS: return VERR_MAX_PROCS_REACHED; + case ERROR_TOO_MANY_SEMAPHORES: return VERR_TOO_MANY_SEMAPHORES; + case ERROR_EXCL_SEM_ALREADY_OWNED: return VERR_EXCL_SEM_ALREADY_OWNED; + case ERROR_SEM_IS_SET: return VERR_SEM_IS_SET; + case ERROR_TOO_MANY_SEM_REQUESTS: return VERR_TOO_MANY_SEM_REQUESTS; + case ERROR_SEM_OWNER_DIED: return VERR_SEM_OWNER_DIED; + case ERROR_DRIVE_LOCKED: return VERR_DRIVE_LOCKED; + case ERROR_BROKEN_PIPE: return VERR_BROKEN_PIPE; + case ERROR_OPEN_FAILED: return VERR_OPEN_FAILED; + + case ERROR_BUFFER_OVERFLOW: + case ERROR_INSUFFICIENT_BUFFER: return VERR_BUFFER_OVERFLOW; + + case ERROR_NO_MORE_SEARCH_HANDLES: return VERR_NO_MORE_SEARCH_HANDLES; + + case ERROR_SEM_TIMEOUT: + case ERROR_TIMEOUT: return VERR_TIMEOUT; + + case ERROR_INVALID_NAME: + case ERROR_BAD_PATHNAME: return VERR_INVALID_NAME; + + case ERROR_NEGATIVE_SEEK: return VERR_NEGATIVE_SEEK; + case ERROR_SEEK_ON_DEVICE: return VERR_SEEK_ON_DEVICE; + + case ERROR_SIGNAL_REFUSED: + case ERROR_NO_SIGNAL_SENT: return VERR_SIGNAL_REFUSED; + + case ERROR_SIGNAL_PENDING: return VERR_SIGNAL_PENDING; + case ERROR_MAX_THRDS_REACHED: return VERR_MAX_THRDS_REACHED; + case ERROR_LOCK_FAILED: return VERR_FILE_LOCK_FAILED; + case ERROR_SEM_NOT_FOUND: return VERR_SEM_NOT_FOUND; + case ERROR_FILENAME_EXCED_RANGE: return VERR_FILENAME_TOO_LONG; + case ERROR_INVALID_SIGNAL_NUMBER: return VERR_SIGNAL_INVALID; + + case ERROR_BAD_PIPE: return VERR_BAD_PIPE; + case ERROR_PIPE_BUSY: return VERR_PIPE_BUSY; + case ERROR_NO_DATA: return VERR_NO_DATA; + case ERROR_PIPE_NOT_CONNECTED: return VERR_PIPE_NOT_CONNECTED; + case ERROR_MORE_DATA: return VERR_MORE_DATA; + case ERROR_NOT_OWNER: return VERR_NOT_OWNER; + case ERROR_TOO_MANY_POSTS: return VERR_TOO_MANY_POSTS; + + case ERROR_INTERRUPT: return VERR_INTERRUPTED; + + case ERROR_BUSY: return VERR_MEMORY_BUSY; + //case ERROR_NO_UNICODE_TRANSLATION: return VERR_NO_TRANSLATION; + } + + /* unknown error. */ + AssertLogRelMsgFailed(("Unhandled error %u\n", uNativeCode)); + return VERR_UNRESOLVED_ERROR; +} + diff --git a/src/VBox/Runtime/os2/rtSemWaitOs2ConvertTimeout.cpp b/src/VBox/Runtime/os2/rtSemWaitOs2ConvertTimeout.cpp new file mode 100644 index 00000000..fd99fb84 --- /dev/null +++ b/src/VBox/Runtime/os2/rtSemWaitOs2ConvertTimeout.cpp @@ -0,0 +1,104 @@ +/* $Id: rtSemWaitOs2ConvertTimeout.cpp $ */ +/** @file + * IPRT - RTSemEventMultiWait, implementation based on RTSemEventMultiWaitEx. + */ + +/* + * Copyright (C) 2010-2023 Oracle and/or its affiliates. + * + * This file is part of VirtualBox base platform packages, as + * available from https://www.virtualbox.org. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, in version 3 of the + * License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses>. + * + * The contents of this file may alternatively be used under the terms + * of the Common Development and Distribution License Version 1.0 + * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included + * in the VirtualBox distribution, in which case the provisions of the + * CDDL are applicable instead of those of the GPL. + * + * You may elect to license modified versions of this file under the + * terms and conditions of either the GPL or the CDDL or both. + * + * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0 + */ + + +/********************************************************************************************************************************* +* Header Files * +*********************************************************************************************************************************/ +#include "internal/iprt.h" +#include <iprt/semaphore.h> +#include <iprt/time.h> + + +/********************************************************************************************************************************* +* Defined Constants And Macros * +*********************************************************************************************************************************/ +/** Too lazy to include the right OS/2 header, duplicating the define we + * need here. */ +#define MY_SEM_INDEFINITE_WAIT UINT32_MAX + + +/** + * Converts the timeout to a millisecond value that can be fed to KernBlock. + * + * @returns Relative timeout in milliseconds. + * @param fFlags The semaphore wait flags. + * @param uTimeout The timeout value. + */ +uint32_t rtR0SemWaitOs2ConvertTimeout(uint32_t fFlags, uint64_t uTimeout) +{ + /* + * Simple & common cases. + */ + if (fFlags & RTSEMWAIT_FLAGS_INDEFINITE) + return MY_SEM_INDEFINITE_WAIT; + + if ( (fFlags & (RTSEMWAIT_FLAGS_MILLISECS | RTSEMWAIT_FLAGS_ABSOLUTE)) + == RTSEMWAIT_FLAGS_MILLISECS) + { + if (uTimeout < UINT32_MAX) + return (uint32_t)uTimeout; + return MY_SEM_INDEFINITE_WAIT; + } + + if (!uTimeout) + return 0; + + if (uTimeout == UINT64_MAX) + return MY_SEM_INDEFINITE_WAIT; + + /* + * For the more complicated cases (nano or/and abs), convert thru nano (lazy bird). + */ + if (fFlags & RTSEMWAIT_FLAGS_MILLISECS) + { + if (uTimeout >= UINT64_MAX / RT_NS_1MS * RT_NS_1MS) + return MY_SEM_INDEFINITE_WAIT; + uTimeout = uTimeout * RT_NS_1MS; + } + if (fFlags & RTSEMWAIT_FLAGS_ABSOLUTE) + { + uint64_t u64Now = RTTimeSystemNanoTS(); + if (u64Now >= uTimeout) + return 0; + uTimeout = uTimeout - u64Now; + } + uTimeout /= RT_NS_1MS; + if (uTimeout >= UINT32_MAX) + return MY_SEM_INDEFINITE_WAIT; + return (uint32_t)uTimeout; +} + diff --git a/src/VBox/Runtime/os2/sys0.asm b/src/VBox/Runtime/os2/sys0.asm new file mode 100644 index 00000000..f8938494 --- /dev/null +++ b/src/VBox/Runtime/os2/sys0.asm @@ -0,0 +1,65 @@ +;; @file +; IPRT - crt0/dll0 replacement stub for OS/2 R0/GC modules. +; + +; +; Copyright (C) 2006-2023 Oracle and/or its affiliates. +; +; This file is part of VirtualBox base platform packages, as +; available from https://www.virtualbox.org. +; +; This program is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation, in version 3 of the +; License. +; +; This program is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, see <https://www.gnu.org/licenses>. +; +; The contents of this file may alternatively be used under the terms +; of the Common Development and Distribution License Version 1.0 +; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included +; in the VirtualBox distribution, in which case the provisions of the +; CDDL are applicable instead of those of the GPL. +; +; You may elect to license modified versions of this file under the +; terms and conditions of either the GPL or the CDDL or both. +; +; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0 +; + + +;******************************************************************************* +;* Header Files * +;******************************************************************************* +%include "iprt/asmdefs.mac" + + +BEGINCODE + +global __text +__text: +global ___ehInit +___ehInit: + db 0cch + +..start: + int3 + xor eax,eax + ret + +BEGINDATA +global __data +__data: +global __data_start +__data_start: + +BEGINBSS +global __bss_start +__bss_start: + |