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