diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h
index d9aea8c76a..2db32221e9 100644
--- a/headers/os/kernel/OS.h
+++ b/headers/os/kernel/OS.h
@@ -1,35 +1,10 @@
-/* OS.h
- */
+/* OS.h - kernel specific structures and functions
+**
+** Distributed under the terms of the OpenBeOS License.
+*/
#ifndef _OS_H
#define _OS_H
-
-/**
- * @mainpage OpenBeOS Header Documentation
- *
- * @section Introduction
- * This is the header documentation as produced with doxygen. Anyone can
- * produce this using the doxygen tool and doing this
- *
- * cd docs
- * doxygen doxygen.conf
- *
- * The resulting files will be produced in dox/html.
- *
- * @section Updating
- * I will attempt to keep these up to date, but if they're not, just
- * give me a nudge!
- */
-
-/**
- * @file kernel/OS.h
- * @brief Definitions, prototypes needed throughout the OS
- */
-
-/**
- * @defgroup OpenBeOS_Headers OpenBeOS System Headers
- * @brief Headers that are available for applications
- */
#include
// ToDo: has to be included here, but does currently causes compiler errors
@@ -38,95 +13,40 @@
// ToDo: is automatically included by SupportDefs.h, so that one can be removed later
#include
+
#ifdef __cplusplus
extern "C" {
#endif
-/**
- * @defgroup Sys_Consts Constants
- * @ingroup OpenBeOS_Headers
- * @brief Constants defined by the system headers
- * @note these are prefixed B_ for compatability with BeOS
- * @{
- */
-/**
- * @def B_OS_NAME_LENGTH
- * the maximum length of names applied to various structures
- * for example the maximum length of a thread name supplied in
- * a spawn_thread() call is determined by this value
- */
-/**
- * @def B_PAGE_SIZE
- *size of a single page of memory.
- * @note this is also the smallest area that can be requested
- */
+/*-------------------------------------------------------------*/
+/* System constants */
-#define B_OS_NAME_LENGTH 32
-#define B_PAGE_SIZE 4096
+#define B_OS_NAME_LENGTH 32
+#define B_PAGE_SIZE 4096
+#define B_INFINITE_TIMEOUT (9223372036854775807LL)
-/** @def B_CAN_INTERRUPT
- * if set the call can be interrupted
- */
-/** @def B_DO_NOT_RESCHEDULE
- * explanation reqd
- */
-/** @def B_CHECK_PERMISSION
- * when set the ownership will be checked, and if permission
- * is not available then the call will fail.
- */
-/** @def B_TIMEOUT
- * there is a timeout given in this call
- */
-/** @def B_RELATIVE_TIMEOUT
- * the timeout given in this call is relative to the time now
- */
-/** @def B_ABSOLUTE_TIMEOUT
- * the timeout given in this call is a time that the timeout will expire
- */
-#define B_CAN_INTERRUPT 1
-#define B_DO_NOT_RESCHEDULE 2
-#define B_CHECK_PERMISSION 4
-#define B_TIMEOUT 8
-#define B_RELATIVE_TIMEOUT 8
-#define B_ABSOLUTE_TIMEOUT 16
+enum {
+ B_TIMEOUT = 8, /* relative timeout */
+ B_RELATIVE_TIMEOUT = 8, /* fails after a relative timeout with B_WOULD_BLOCK */
+ B_ABSOLUTE_TIMEOUT = 16, /* fails after an absolute timeout with B_WOULD BLOCK */
+};
-/** @} */
+/*-------------------------------------------------------------*/
+/* Types */
-/**
- * @defgroup Sys_types Types
- * @ingroup OpenBeOS_Headers
- * @brief Definitions of basic system types.
- * @note these are not in sys/types.h as they are specific to
- * this system
- * @note these are global to the system.
- * @{
- */
+typedef int32 area_id;
+typedef int32 port_id;
+typedef int32 sem_id;
+typedef int32 team_id;
+typedef int32 thread_id;
-/**
- * @typedef area_id
- * id of an area
- */
-
-typedef int32 area_id;
-
-/** @} */
-
-/**
- * @defgroup Areas Memory Areas
- * @brief memory areas
- * @ingroup OpenBeOS_Headers
- * @{
- */
+/*-------------------------------------------------------------*/
/* Areas */
-/**
- * @struct area_info
- * gives details about a particular area
- */
+
typedef struct area_info {
area_id area;
char name[B_OS_NAME_LENGTH];
- int foo;
size_t size;
uint32 lock;
uint32 protection;
@@ -138,25 +58,47 @@ typedef struct area_info {
void *address;
} area_info;
+/* area locking */
+#define B_NO_LOCK 0
+#define B_LAZY_LOCK 1
+#define B_FULL_LOCK 2
+#define B_CONTIGUOUS 3
+#define B_LOMEM 4
+
+/* address spec for create_area(), and clone_area() */
+#define B_ANY_ADDRESS 0
+#define B_EXACT_ADDRESS 1
+#define B_BASE_ADDRESS 2
+#define B_CLONE_ADDRESS 3
+#define B_ANY_KERNEL_ADDRESS 4
+
+/* area protection */
+#define B_READ_AREA 1
+#define B_WRITE_AREA 2
+
+extern area_id create_area(const char *name, void **start_addr, uint32 addr_spec,
+ size_t size, uint32 lock, uint32 protection);
+extern area_id clone_area(const char *name, void **dest_addr, uint32 addr_spec,
+ uint32 protection, area_id source);
+extern area_id find_area(const char *name);
+extern area_id area_for(void *address);
+extern status_t delete_area(area_id id);
+extern status_t resize_area(area_id id, size_t new_size);
+extern status_t set_area_protection(area_id id, uint32 new_protection);
+
+/* system private, use macros instead */
+extern status_t _get_area_info(area_id id, area_info *areaInfo, size_t size);
+extern status_t _get_next_area_info(team_id team, int32 *cookie, area_info *areaInfo, size_t size);
+
#define get_area_info(id, ainfo) \
- _get_area_info((id), (ainfo),sizeof(*(ainfo)))
+ _get_area_info((id), (ainfo),sizeof(*(ainfo)))
#define get_next_area_info(team, cookie, ainfo) \
- _get_next_area_info((team), (cookie), (ainfo), sizeof(*(ainfo)))
+ _get_next_area_info((team), (cookie), (ainfo), sizeof(*(ainfo)))
-/** @} */
-
-/**
- * @defgroup Ports Messaging Ports
- * @brief A system wide messaging system
- * @ingroup OpenBeOS_Headers
- * @{
- */
+/*-------------------------------------------------------------*/
/* Ports */
-/**
- * @struct port_info
- * details about a port, including ownership
- */
+
typedef struct port_info {
port_id port;
team_id team;
@@ -166,43 +108,36 @@ typedef struct port_info {
int32 total_count; /* total # msgs read so far */
} port_info;
-port_id create_port(int32, const char *);
-port_id find_port(const char *);
-status_t read_port(port_id, int32 *, void *, size_t);
-status_t read_port_etc(port_id, int32 *, void *, size_t, uint32, bigtime_t);
-status_t write_port(port_id, int32, const void *, size_t);
-status_t write_port_etc(port_id, int32, const void *, size_t, uint32, bigtime_t);
-status_t close_port(port_id port);
-status_t delete_port(port_id port);
+extern port_id create_port(int32 capacity, const char *name);
+extern port_id find_port(const char *name);
+extern status_t read_port(port_id port, int32 *code, void *buffer, size_t bufferSize);
+extern status_t read_port_etc(port_id port, int32 *code, void *buffer, size_t bufferSize,
+ uint32 flags, bigtime_t timeout);
+extern status_t write_port(port_id port, int32 code, const void *buffer, size_t bufferSize);
+extern status_t write_port_etc(port_id port, int32 code, const void *buffer, size_t bufferSize,
+ uint32 flags, bigtime_t timeout);
+extern status_t close_port(port_id port);
+extern status_t delete_port(port_id port);
-ssize_t port_buffer_size(port_id);
-ssize_t port_buffer_size_etc(port_id, uint32, bigtime_t);
-ssize_t port_count(port_id);
-status_t set_port_owner(port_id, team_id);
+extern ssize_t port_buffer_size(port_id port);
+extern ssize_t port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout);
+extern ssize_t port_count(port_id port);
+extern status_t set_port_owner(port_id port, team_id team);
-status_t _get_port_info(port_id, port_info *, size_t);
-status_t _get_next_port_info(team_id, int32 *, port_info *, size_t);
+/* system private, use the macros instead */
+extern status_t _get_port_info(port_id port, port_info *portInfo, size_t portInfoSize);
+extern status_t _get_next_port_info(team_id team, int32 *cookie, port_info *portInfo,
+ size_t portInfoSize);
-#define get_port_info(port, info) \
- _get_port_info((port), (info), sizeof(*(info)))
-
-#define get_next_port_info(team, cookie, info) \
- _get_next_port_info((team), (cookie), (info), sizeof(*(info)))
-
-/** @} */
-
-/**
- * @defgroup Sems Semaphores
- * @brief used to provide synchronisation between threads
- * @ingroup OpenBeOS_Headers
- * @{
- */
+#define get_port_info(port, info) \
+ _get_port_info((port), (info), sizeof(*(info)))
+#define get_next_port_info(team, cookie, info) \
+ _get_next_port_info((team), (cookie), (info), sizeof(*(info)))
-/**
- * @struct sem_info
- * information on a semaphore
- */
+/*-------------------------------------------------------------*/
+/* Semaphores */
+
typedef struct sem_info {
sem_id sem;
team_id team;
@@ -211,107 +146,38 @@ typedef struct sem_info {
thread_id latest_holder;
} sem_info;
-sem_id create_sem_etc(int32 count, const char *name, team_id owner); /* not public BeOS */
-sem_id create_sem(int32 count, const char *name);
-status_t delete_sem(sem_id id);
-status_t delete_sem_etc(sem_id id, status_t return_code); /* not public BeOS */
-status_t acquire_sem(sem_id id);
-status_t acquire_sem_etc(sem_id id, int32 count, uint32 flags, bigtime_t timeout);
-status_t release_sem(sem_id id);
-status_t release_sem_etc(sem_id id, int32 count, uint32 flags);
-status_t get_sem_count(sem_id id, int32* thread_count);
-status_t _get_sem_info(sem_id id, struct sem_info *info, size_t);
-status_t _get_next_sem_info(team_id team, int32 *cookie, struct sem_info *info, size_t);
-status_t set_sem_owner(sem_id id, team_id team);
+/* semaphore flags */
+enum {
+ B_CAN_INTERRUPT = 1, /* acquisition of the semaphore can be interrupted (system use only) */
+ B_DO_NOT_RESCHEDULE = 2, /* thread is not rescheduled after release_sem_etc() */
+ B_CHECK_PERMISSION = 4, /* ownership will be checked (system use only) */
+};
-#define get_sem_info(sem, info) \
- _get_sem_info((sem), (info), sizeof(*(info)))
-
-#define get_next_sem_info(team, cookie, info) \
- _get_next_sem_info((team), (cookie), (info), sizeof(*(info)))
+extern sem_id create_sem(int32 count, const char *name);
+extern status_t delete_sem(sem_id id);
+extern status_t delete_sem_etc(sem_id id, status_t returnCode); /* ToDo: not public BeOS */
+extern status_t acquire_sem(sem_id id);
+extern status_t acquire_sem_etc(sem_id id, int32 count, uint32 flags, bigtime_t timeout);
+extern status_t release_sem(sem_id id);
+extern status_t release_sem_etc(sem_id id, int32 count, uint32 flags);
+extern status_t get_sem_count(sem_id id, int32 *threadCount);
+extern status_t set_sem_owner(sem_id id, team_id team);
-/** @} */
+/* system private, use the macros instead */
+extern status_t _get_sem_info(sem_id id, struct sem_info *info, size_t infoSize);
+extern status_t _get_next_sem_info(team_id team, int32 *cookie, struct sem_info *info,
+ size_t infoSize);
-/**
- * @defgroup Threads Threads
- * @brief a distinct, independantly executing task belong to a team
- * @ingroup OpenBeOS_Headers
- * @{
- */
+#define get_sem_info(sem, info) \
+ _get_sem_info((sem), (info), sizeof(*(info)))
-/* Threads */
+#define get_next_sem_info(team, cookie, info) \
+ _get_next_sem_info((team), (cookie), (info), sizeof(*(info)))
-//enum {
-// THREAD_STATE_READY = 0, // ready to run
-// THREAD_STATE_RUNNING, // running right now somewhere
-// THREAD_STATE_WAITING, // blocked on something
-// THREAD_STATE_SUSPENDED, // suspended, not in queue
-// THREAD_STATE_FREE_ON_RESCHED, // free the thread structure upon reschedule
-// THREAD_STATE_BIRTH // thread is being created
-//};
-typedef enum {
- B_THREAD_RUNNING=1,
- B_THREAD_READY,
- B_THREAD_RECEIVING,
- B_THREAD_ASLEEP,
- B_THREAD_SUSPENDED,
- B_THREAD_WAITING
-} thread_state;
+/*-------------------------------------------------------------*/
+/* Teams */
-/*
-#define THREAD_IDLE_PRIORITY 0
-
-#define THREAD_NUM_PRIORITY_LEVELS 64
-#define THREAD_MIN_PRIORITY (THREAD_IDLE_PRIORITY + 1)
-#define THREAD_MAX_PRIORITY (THREAD_NUM_PRIORITY_LEVELS - THREAD_NUM_RT_PRIORITY_LEVELS - 1)
-
-#define THREAD_NUM_RT_PRIORITY_LEVELS 16
-#define THREAD_MIN_RT_PRIORITY (THREAD_MAX_PRIORITY + 1)
-#define THREAD_MAX_RT_PRIORITY (THREAD_NUM_PRIORITY_LEVELS - 1)
-
-#define THREAD_LOWEST_PRIORITY THREAD_MIN_PRIORITY
-#define THREAD_LOW_PRIORITY 12
-#define THREAD_MEDIUM_PRIORITY 24
-#define THREAD_HIGH_PRIORITY 36
-#define THREAD_HIGHEST_PRIORITY THREAD_MAX_PRIORITY
-
-#define THREAD_RT_LOW_PRIORITY THREAD_MIN_RT_PRIORITY
-#define THREAD_RT_HIGH_PRIORITY THREAD_MAX_RT_PRIORITY
-*/
-
-#define B_IDLE_PRIORITY 0
-#define B_LOWEST_ACTIVE_PRIORITY 1
-
-#define B_LOW_PRIORITY 5
-#define B_NORMAL_PRIORITY 10
-#define B_DISPLAY_PRIORITY 15
-#define B_URGENT_DISPLAY_PRIORITY 20
-#define B_REAL_TIME_DISPLAY_PRIORITY 100
-#define B_URGENT_PRIORITY 110
-#define B_REAL_TIME_PRIORITY 120
-
-#define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
-#define B_MIN_PRIORITY B_IDLE_PRIORITY
-#define B_MAX_PRIORITY B_REAL_TIME_PRIORITY
-
-/** information on a thread
- * @note the thread can be in any state
- */
-typedef struct {
- thread_id thread;
- team_id team;
- char name[B_OS_NAME_LENGTH];
- thread_state state;
- int32 priority;
- sem_id sem;
- bigtime_t user_time;
- bigtime_t kernel_time;
- void *stack_base;
- void *stack_end;
-} thread_info;
-
-/** information on a team */
typedef struct {
team_id team;
int32 thread_count;
@@ -325,65 +191,342 @@ typedef struct {
gid_t gid;
} team_info;
-/**
- * gives information on user and kernel time for a thread
- */
+#define B_SYSTEM_TEAM 2
+
+extern status_t kill_team(team_id team);
+ /* see also: send_signal() */
+
+/* system private, use macros instead */
+extern status_t _get_team_info(team_id id, team_info *info, size_t size);
+extern status_t _get_next_team_info(int32 *cookie, team_info *info, size_t size);
+
+#define get_team_info(id, info) \
+ _get_team_info((id), (info), sizeof(*(info)))
+
+#define get_next_team_info(cookie, info) \
+ _get_next_team_info((cookie), (info), sizeof(*(info)))
+
+/* team usage info */
+
typedef struct {
bigtime_t user_time;
bigtime_t kernel_time;
} team_usage_info;
-/** @typedef thread_func
- * the prototype for a function passed in a spawn_thread() call is
- * @code
- * int32 some_thread_func(void *data)
- * {
- * ...
- * }
- * @endcode
- */
+/* system private, use macros instead */
+extern status_t _get_team_usage_info(team_id team, int32 who, team_usage_info *tui, size_t size);
+
+#define get_team_usage_info(team, who, info) \
+ _get_team_usage_info((team), (who), (info), sizeof(*(info)))
+
+/*-------------------------------------------------------------*/
+/* Threads */
+
+typedef enum {
+ B_THREAD_RUNNING = 1,
+ B_THREAD_READY,
+ B_THREAD_RECEIVING,
+ B_THREAD_ASLEEP,
+ B_THREAD_SUSPENDED,
+ B_THREAD_WAITING
+} thread_state;
+
+typedef struct {
+ thread_id thread;
+ team_id team;
+ char name[B_OS_NAME_LENGTH];
+ thread_state state;
+ int32 priority;
+ sem_id sem;
+ bigtime_t user_time;
+ bigtime_t kernel_time;
+ void *stack_base;
+ void *stack_end;
+} thread_info;
+
+#define B_IDLE_PRIORITY 0
+#define B_LOWEST_ACTIVE_PRIORITY 1
+#define B_LOW_PRIORITY 5
+#define B_NORMAL_PRIORITY 10
+#define B_DISPLAY_PRIORITY 15
+#define B_URGENT_DISPLAY_PRIORITY 20
+#define B_REAL_TIME_DISPLAY_PRIORITY 100
+#define B_URGENT_PRIORITY 110
+#define B_REAL_TIME_PRIORITY 120
+
+#define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
+#define B_MIN_PRIORITY B_IDLE_PRIORITY
+#define B_MAX_PRIORITY B_REAL_TIME_PRIORITY
+
typedef int32 (*thread_func) (void *);
+// the equivalent thread_entry has been removed (deprecated)
-/** @fn thread_id spawn_thread(thread_func func, const char *name, int32 priority, void *data)
- * creates a new thread within a team
- * @note the new thread will be created in the suspended state and will not run
- * until a resume_thread() call is issued
- * @note the maximum length of name is B_OS_NAME_LENGTH characters
- */
-thread_id spawn_thread (thread_func, const char *, int32, void *);
-status_t kill_thread(thread_id thread);
-status_t resume_thread(thread_id thread);
-status_t suspend_thread(thread_id thread);
+extern thread_id spawn_thread(thread_func, const char *name, int32 priority, void *data);
+extern status_t kill_thread(thread_id thread);
+extern status_t resume_thread(thread_id thread);
+extern status_t suspend_thread(thread_id thread);
-thread_id find_thread(const char *);
+extern status_t rename_thread(thread_id thread, const char *newName);
+extern status_t set_thread_priority (thread_id thread, int32 newPriority);
+extern void exit_thread(status_t status);
+extern status_t wait_for_thread (thread_id thread, status_t *threadReturnValue);
+extern status_t on_exit_thread(void (*callback)(void *), void *data);
-status_t send_data(thread_id thread, int32 code, const void *buffer, size_t buffer_size);
-status_t receive_data(thread_id *sender, void *buffer, size_t buffer_size);
-bool has_data(thread_id thread);
+// ToDo: we also need the INTEL static inline here for compatibility (and the _kfind_thread_() function)
+extern thread_id find_thread(const char *name);
-status_t snooze(bigtime_t);
+extern status_t send_data(thread_id thread, int32 code, const void *buffer, size_t buffer_size);
+extern status_t receive_data(thread_id *sender, void *buffer, size_t buffer_size);
+extern bool has_data(thread_id thread);
-status_t _get_thread_info(thread_id id, thread_info *info, size_t size);
-status_t _get_next_thread_info(team_id team, int32 *cookie, thread_info *info, size_t size);
-status_t _get_team_info(team_id id, team_info *info, size_t size);
-status_t _get_next_team_info(int32 *cookie, team_info *info, size_t size);
+extern status_t snooze(bigtime_t amount);
+extern status_t snooze_until(bigtime_t time, int timeBase);
-#define get_thread_info(id, info) \
+/* system private, use macros instead */
+extern status_t _get_thread_info(thread_id id, thread_info *info, size_t size);
+extern status_t _get_next_thread_info(team_id team, int32 *cookie, thread_info *info, size_t size);
+
+#define get_thread_info(id, info) \
_get_thread_info((id), (info), sizeof(*(info)))
-#define get_next_thread_info(team, cookie, info) \
+#define get_next_thread_info(team, cookie, info) \
_get_next_thread_info((team), (cookie), (info), sizeof(*(info)))
-#define get_team_info(id, info) \
- _get_team_info((id), (info), sizeof(*(info)))
-#define get_next_team_info(cookie, info) \
- _get_next_team_info((cookie), (info), sizeof(*(info)))
+/*-------------------------------------------------------------*/
+/* Time */
+
+extern uint32 real_time_clock(void);
+extern void set_real_time_clock(int32 secs_since_jan1_1970);
+extern bigtime_t real_time_clock_usecs(void);
+extern status_t set_timezone(char *timezone);
+extern bigtime_t system_time(void); /* time since booting in microseconds */
+
+
+/*-------------------------------------------------------------*/
+/* Alarm */
+
+enum {
+ B_ONE_SHOT_ABSOLUTE_ALARM = 1,
+ B_ONE_SHOT_RELATIVE_ALARM,
+ B_PERIODIC_ALARM /* "when" specifies the period */
+};
+
+extern bigtime_t set_alarm(bigtime_t when, uint32 flags);
+
+
+/*-------------------------------------------------------------*/
+/* Debugger */
+
+extern void debugger(const char *message);
+
+/*
+ calling this function with a non-zero value will cause your thread
+ to receive signals for any exceptional conditions that occur (i.e.
+ you'll get SIGSEGV for data access exceptions, SIGFPE for floating
+ point errors, SIGILL for illegal instructions, etc).
+
+ to re-enable the default debugger pass a zero.
+*/
+extern const int disable_debugger(int state);
+
+
+/*-------------------------------------------------------------*/
+/* System information */
+
+#if __INTEL__
+# define B_MAX_CPU_COUNT 8
+#elif __POWERPC__
+# define B_MAX_CPU_COUNT 8
+#endif
+
+typedef enum cpu_types {
+ // ToDo: add latest models
+
+ /* Motorola/IBM */
+ B_CPU_PPC_601 = 1,
+ B_CPU_PPC_603 = 2,
+ B_CPU_PPC_603e = 3,
+ B_CPU_PPC_604 = 4,
+ B_CPU_PPC_604e = 5,
+ B_CPU_PPC_750 = 6,
+ B_CPU_PPC_686 = 13,
+
+ /* Intel */
+ B_CPU_INTEL_X86 = 0x1000,
+ B_CPU_INTEL_PENTIUM = 0x1051,
+ B_CPU_INTEL_PENTIUM75,
+ B_CPU_INTEL_PENTIUM_486_OVERDRIVE,
+ B_CPU_INTEL_PENTIUM_MMX,
+ B_CPU_INTEL_PENTIUM_MMX_MODEL_4 = B_CPU_INTEL_PENTIUM_MMX,
+ B_CPU_INTEL_PENTIUM_MMX_MODEL_8 = 0x1058,
+ B_CPU_INTEL_PENTIUM75_486_OVERDRIVE,
+ B_CPU_INTEL_PENTIUM_PRO = 0x1061,
+ B_CPU_INTEL_PENTIUM_II = 0x1063,
+ B_CPU_INTEL_PENTIUM_II_MODEL_3 = 0x1063,
+ B_CPU_INTEL_PENTIUM_II_MODEL_5 = 0x1065,
+ B_CPU_INTEL_CELERON = 0x1066,
+ B_CPU_INTEL_PENTIUM_III = 0x1067,
+ B_CPU_INTEL_PENTIUM_III_MODEL_8 = 0x1068,
+
+ /* AMD */
+ B_CPU_AMD_X86 = 0x1100,
+ B_CPU_AMD_K5_MODEL0 = 0x1150,
+ B_CPU_AMD_K5_MODEL1,
+ B_CPU_AMD_K5_MODEL2,
+ B_CPU_AMD_K5_MODEL3,
+ B_CPU_AMD_K6_MODEL6 = 0x1156,
+ B_CPU_AMD_K6_MODEL7 = 0x1157,
+ B_CPU_AMD_K6_MODEL8 = 0x1158,
+ B_CPU_AMD_K6_2 = 0x1158,
+ B_CPU_AMD_K6_MODEL9 = 0x1159,
+ B_CPU_AMD_K6_III = 0x1159,
+
+ B_CPU_AMD_ATHLON_MODEL1 = 0x1161,
+
+ /* VIA */
+ B_CPU_CYRIX_X86 = 0x1200,
+ B_CPU_CYRIX_GXm = 0x1254,
+ B_CPU_CYRIX_6x86MX = 0x1260,
+
+ /* others */
+ B_CPU_IDT_X86 = 0x1300,
+ B_CPU_IDT_WINCHIP_C6 = 0x1354,
+ B_CPU_IDT_WINCHIP_2 = 0x1358,
+
+ B_CPU_RISE_X86 = 0x1400,
+ B_CPU_RISE_mP6 = 0x1450,
+
+ /* For compatibility */
+ B_CPU_AMD_29K = 14,
+ B_CPU_X86,
+ B_CPU_MC6502,
+ B_CPU_Z80,
+ B_CPU_ALPHA,
+ B_CPU_MIPS,
+ B_CPU_HPPA,
+ B_CPU_M68K,
+ B_CPU_ARM,
+ B_CPU_SH,
+ B_CPU_SPARC,
+} cpu_type;
+
+#define B_CPU_X86_VENDOR_MASK 0x1F00
+
+#ifdef __INTEL__
+typedef union {
+ struct {
+ uint32 max_eax;
+ char vendorid[12];
+ } eax_0;
+
+ struct {
+ uint32 stepping : 4;
+ uint32 model : 4;
+ uint32 family : 4;
+ uint32 type : 2;
+ uint32 reserved_0 : 18;
+
+ uint32 reserved_1;
+ uint32 features;
+ uint32 reserved_2;
+ } eax_1;
+
+struct {
+ uint8 call_num;
+ uint8 cache_descriptors[15];
+ } eax_2;
+
+ struct {
+ uint32 reserved[2];
+ uint32 serial_number_high;
+ uint32 serial_number_low;
+ } eax_3;
+
+ char as_chars[16];
+
+ struct {
+ uint32 eax;
+ uint32 ebx;
+ uint32 edx;
+ uint32 ecx;
+ } regs;
+} cpuid_info;
+
+extern status_t get_cpuid(cpuid_info* info, uint32 eax_register, uint32 cpu_num);
+#endif
+
+
+typedef enum platform_types {
+ B_BEBOX_PLATFORM = 0,
+ B_MAC_PLATFORM,
+ B_AT_CLONE_PLATFORM,
+ B_ENIAC_PLATFORM,
+ B_APPLE_II_PLATFORM,
+ B_CRAY_PLATFORM,
+ B_LISA_PLATFORM,
+ B_TI_994A_PLATFORM,
+ B_TIMEX_SINCLAIR_PLATFORM,
+ B_ORAC_1_PLATFORM,
+ B_HAL_PLATFORM,
+ B_BESM_6_PLATFORM,
+ B_MK_61_PLATFORM,
+ B_NINTENDO_64_PLATFORM
+} platform_type;
+
+typedef struct {
+ bigtime_t active_time; /* usec of doing useful work since boot */
+} cpu_info;
+
+
+typedef int32 machine_id[2]; /* unique machine ID */
+
+typedef struct {
+ machine_id id; /* unique machine ID */
+ bigtime_t boot_time; /* time of boot (usecs since 1/1/1970) */
+
+ int32 cpu_count; /* number of cpus */
+ enum cpu_types cpu_type; /* type of cpu */
+ int32 cpu_revision; /* revision # of cpu */
+ cpu_info cpu_infos[B_MAX_CPU_COUNT]; /* info about individual cpus */
+ int64 cpu_clock_speed; /* processor clock speed (Hz) */
+ int64 bus_clock_speed; /* bus clock speed (Hz) */
+ enum platform_types platform_type; /* type of machine we're on */
+
+ int32 max_pages; /* total # physical pages */
+ int32 used_pages; /* # physical pages in use */
+ int32 page_faults; /* # of page faults */
+ int32 max_sems;
+ int32 used_sems;
+ int32 max_ports;
+ int32 used_ports;
+ int32 max_threads;
+ int32 used_threads;
+ int32 max_teams;
+ int32 used_teams;
+
+// ToDo: B_FILE_NAME_LENGTH is currently not defined at this point
+// char kernel_name[B_FILE_NAME_LENGTH]; /* name of kernel */
+ char kernel_name[256];
+ char kernel_build_date[B_OS_NAME_LENGTH]; /* date kernel built */
+ char kernel_build_time[B_OS_NAME_LENGTH]; /* time kernel built */
+ int64 kernel_version; /* version of this kernel */
+
+ bigtime_t _busy_wait_time; /* reserved for Be */
+ int32 pad[4]; /* just in case... */
+} system_info;
+
+/* system private, use macro instead */
+extern status_t _get_system_info (system_info *returned_info, size_t size);
+
+#define get_system_info(info) \
+ _get_system_info((info), sizeof(*(info)))
+
+extern int32 is_computer_on(void);
+extern double is_computer_on_fire(void);
-/** @} */
#ifdef __cplusplus
}
#endif
#endif /* _OS_H */
-
diff --git a/headers/os/kernel/image.h b/headers/os/kernel/image.h
index 127fdf618e..3ca748ba00 100644
--- a/headers/os/kernel/image.h
+++ b/headers/os/kernel/image.h
@@ -38,19 +38,19 @@ typedef enum {
} image_type;
typedef struct {
- image_id id;
- image_type type;
- int32 sequence;
- int32 init_order;
+ image_id id;
+ image_type type;
+ int32 sequence;
+ int32 init_order;
void (*init_routine)();
void (*term_routine)();
- dev_t device;
+ dev_t device;
ino_t node;
- char name[MAXPATHLEN];
- void *text;
+ char name[MAXPATHLEN];
+ void *text;
void *data;
- int32 text_size;
- int32 data_size;
+ int32 text_size;
+ int32 data_size;
} image_info;
extern _IMPEXP_ROOT thread_id load_image(int32 argc, const char **argv,
@@ -87,7 +87,7 @@ extern _IMPEXP_ROOT status_t get_nth_image_symbol(image_id imid, int32 index,
/*---------------------------------------------------------*/
/*----- cache manipulation --------------------------------*/
-#define B_FLUSH_DCACHE 0x0001 /* dcache = data cache */
+#define B_FLUSH_DCACHE 0x0001 /* dcache = data cache */
#define B_FLUSH_ICACHE 0x0004 /* icache = instruction cache */
#define B_INVALIDATE_DCACHE 0x0002
#define B_INVALIDATE_ICACHE 0x0008
@@ -100,7 +100,4 @@ extern _IMPEXP_ROOT void clear_caches(void *addr, size_t len, uint32 flags);
}
#endif
-/*-------------------------------------------------------------*/
-/*-------------------------------------------------------------*/
-
-#endif /* _IMAGE_H */
+#endif /* _IMAGE_H */