VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/haiku/the-haiku-kernel.h@ 96407

Last change on this file since 96407 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: the-haiku-kernel.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IPRT - Include all necessary headers for the Haiku kernel.
4 */
5
6/*
7 * Copyright (C) 2012-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_SRC_r0drv_haiku_the_haiku_kernel_h
38#define IPRT_INCLUDED_SRC_r0drv_haiku_the_haiku_kernel_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <sys/types.h>
44#include <sys/mman.h>
45#include <sys/time.h>
46
47#include <stdlib.h>
48
49#include <OS.h>
50#include <KernelExport.h>
51
52#include <iprt/cdefs.h>
53#include <iprt/err.h>
54#include <iprt/types.h>
55
56RT_C_DECLS_BEGIN
57
58/* headers/private/kernel/smp.h */
59
60extern int32 smp_get_num_cpus(void);
61extern int32 smp_get_current_cpu(void);
62
63/* headers/private/kernel/vm/vm.h */
64extern status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
65extern status_t vm_reserve_address_range(team_id team, void **_address, uint32 addressSpec, addr_t size, uint32 flags);
66extern area_id vm_clone_area(team_id team, const char *name, void **address, uint32 addressSpec, uint32 protection,
67 uint32 mapping, area_id sourceArea, bool kernel);
68
69/* headers/private/kernel/thread_type.h */
70
71extern spinlock gThreadSpinlock;
72#define GRAB_THREAD_LOCK() acquire_spinlock(&gThreadSpinlock)
73#define RELEASE_THREAD_LOCK() release_spinlock(&gThreadSpinlock)
74typedef struct
75{
76 int32 flags; /* summary of events relevant in interrupt handlers (signals pending, user debugging
77 enabled, etc.) */
78#if 0
79 Thread *all_next;
80 Thread *team_next;
81 Thread *queue_next; /* i.e. run queue, release queue, etc. */
82 timer alarm;
83 thread_id id;
84 char name[B_OS_NAME_LENGTH];
85 int32 priority;
86 int32 next_priority;
87 int32 io_priority;
88 int32 state;
89 int32 next_state;
90#endif
91 // and a lot more...
92} Thread;
93
94/* headers/private/kernel/thread.h */
95
96extern Thread* thread_get_thread_struct(thread_id id);
97extern Thread* thread_get_thread_struct_locked(thread_id id);
98
99extern void thread_yield(bool force);
100
101RT_C_DECLS_END
102
103/**
104 * Convert from Haiku kernel return code to IPRT status code.
105 * @todo put this where it belongs! (i.e. in a separate file and prototype in iprt/err.h)
106 * Or as generic call since it's not r0 specific.
107 */
108DECLINLINE(int) RTErrConvertFromHaikuKernReturn(status_t rc)
109{
110 switch (rc)
111 {
112 case B_OK: return VINF_SUCCESS;
113 case B_BAD_SEM_ID: return VERR_SEM_ERROR;
114 case B_NO_MORE_SEMS: return VERR_TOO_MANY_SEMAPHORES;
115 case B_BAD_THREAD_ID: return VERR_INVALID_PARAMETER;
116 case B_NO_MORE_THREADS: return VERR_MAX_THRDS_REACHED;
117 case B_BAD_TEAM_ID: return VERR_INVALID_PARAMETER;
118 case B_NO_MORE_TEAMS: return VERR_MAX_PROCS_REACHED;
119 //default: return VERR_GENERAL_FAILURE;
120 /** POSIX Errors are defined as a subset of system errors. */
121 default: return RTErrConvertFromErrno(rc);
122 }
123}
124
125#endif /* !IPRT_INCLUDED_SRC_r0drv_haiku_the_haiku_kernel_h */
126
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette