1 | /* $Id: the-haiku-kernel.h 43403 2012-09-22 11:48:24Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT - Include all necessary headers for the Haiku kernel.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012 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 |
|
---|
28 | #ifndef ___the_haiku_kernel_h
|
---|
29 | #define ___the_haiku_kernel_h
|
---|
30 |
|
---|
31 | #include <sys/types.h>
|
---|
32 | #include <sys/mman.h>
|
---|
33 | #include <sys/time.h>
|
---|
34 |
|
---|
35 | #include <stdlib.h>
|
---|
36 |
|
---|
37 | #include <OS.h>
|
---|
38 | #include <KernelExport.h>
|
---|
39 |
|
---|
40 | #include <iprt/cdefs.h>
|
---|
41 | #include <iprt/err.h>
|
---|
42 | #include <iprt/types.h>
|
---|
43 |
|
---|
44 | RT_C_DECLS_BEGIN
|
---|
45 |
|
---|
46 | /* headers/private/kernel/smp.h */
|
---|
47 |
|
---|
48 | extern int32 smp_get_num_cpus(void);
|
---|
49 | extern int32 smp_get_current_cpu(void);
|
---|
50 |
|
---|
51 | /* headers/private/kernel/vm/vm.h */
|
---|
52 | extern status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
|
---|
53 | extern status_t vm_reserve_address_range(team_id team, void **_address, uint32 addressSpec, addr_t size, uint32 flags);
|
---|
54 | extern area_id vm_clone_area(team_id team, const char *name, void **address, uint32 addressSpec, uint32 protection,
|
---|
55 | uint32 mapping, area_id sourceArea, bool kernel);
|
---|
56 |
|
---|
57 | /* headers/private/kernel/thread_type.h */
|
---|
58 |
|
---|
59 | extern spinlock gThreadSpinlock;
|
---|
60 | #define GRAB_THREAD_LOCK() acquire_spinlock(&gThreadSpinlock)
|
---|
61 | #define RELEASE_THREAD_LOCK() release_spinlock(&gThreadSpinlock)
|
---|
62 | typedef struct
|
---|
63 | {
|
---|
64 | int32 flags; /* summary of events relevant in interrupt handlers (signals pending, user debugging
|
---|
65 | enabled, etc.) */
|
---|
66 | #if 0
|
---|
67 | Thread *all_next;
|
---|
68 | Thread *team_next;
|
---|
69 | Thread *queue_next; /* i.e. run queue, release queue, etc. */
|
---|
70 | timer alarm;
|
---|
71 | thread_id id;
|
---|
72 | char name[B_OS_NAME_LENGTH];
|
---|
73 | int32 priority;
|
---|
74 | int32 next_priority;
|
---|
75 | int32 io_priority;
|
---|
76 | int32 state;
|
---|
77 | int32 next_state;
|
---|
78 | #endif
|
---|
79 | // and a lot more...
|
---|
80 | } Thread;
|
---|
81 |
|
---|
82 | /* headers/private/kernel/thread.h */
|
---|
83 |
|
---|
84 | extern Thread* thread_get_thread_struct(thread_id id);
|
---|
85 | extern Thread* thread_get_thread_struct_locked(thread_id id);
|
---|
86 |
|
---|
87 | extern void thread_yield(bool force);
|
---|
88 |
|
---|
89 | RT_C_DECLS_END
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Convert from Haiku kernel return code to IPRT status code.
|
---|
93 | * @todo put this where it belongs! (i.e. in a separate file and prototype in iprt/err.h)
|
---|
94 | * Or as generic call since it's not r0 specific.
|
---|
95 | */
|
---|
96 | DECLINLINE(int) RTErrConvertFromHaikuKernReturn(status_t rc)
|
---|
97 | {
|
---|
98 | switch (rc)
|
---|
99 | {
|
---|
100 | case B_OK: return VINF_SUCCESS;
|
---|
101 | case B_BAD_SEM_ID: return VERR_SEM_ERROR;
|
---|
102 | case B_NO_MORE_SEMS: return VERR_TOO_MANY_SEMAPHORES;
|
---|
103 | case B_BAD_THREAD_ID: return VERR_INVALID_PARAMETER;
|
---|
104 | case B_NO_MORE_THREADS: return VERR_MAX_THRDS_REACHED;
|
---|
105 | case B_BAD_TEAM_ID: return VERR_INVALID_PARAMETER;
|
---|
106 | case B_NO_MORE_TEAMS: return VERR_MAX_PROCS_REACHED;
|
---|
107 | //default: return VERR_GENERAL_FAILURE;
|
---|
108 | /** POSIX Errors are defined as a subset of system errors. */
|
---|
109 | default: return RTErrConvertFromErrno(rc);
|
---|
110 | }
|
---|
111 | }
|
---|
112 |
|
---|
113 | #endif /* ___the_haiku_kernel_h */
|
---|
114 |
|
---|