Merged changes from branch build_system_redesign at revision 14573.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2005-10-29 16:27:43 +00:00
parent 5412b02d50
commit 338b8dc301
1836 changed files with 114718 additions and 14057 deletions
+627
View File
@@ -0,0 +1,627 @@
/* Kernel specific structures and functions
*
* Copyright 2004, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _OS_H
#define _OS_H
#include <stdarg.h>
#include <SupportDefs.h>
#include <StorageDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------*/
/* System constants */
#define B_OS_NAME_LENGTH 32
#define B_PAGE_SIZE 4096
#define B_INFINITE_TIMEOUT (9223372036854775807LL)
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 */
typedef int32 area_id;
typedef int32 port_id;
typedef int32 sem_id;
typedef int32 team_id;
typedef int32 thread_id;
/*-------------------------------------------------------------*/
/* Areas */
typedef struct area_info {
area_id area;
char name[B_OS_NAME_LENGTH];
size_t size;
uint32 lock;
uint32 protection;
team_id team;
uint32 ram_size;
uint32 copy_count;
uint32 in_count;
uint32 out_count;
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)))
#define get_next_area_info(team, cookie, ainfo) \
_get_next_area_info((team), (cookie), (ainfo), sizeof(*(ainfo)))
/*-------------------------------------------------------------*/
/* Ports */
typedef struct port_info {
port_id port;
team_id team;
char name[B_OS_NAME_LENGTH];
int32 capacity; /* queue depth */
int32 queue_count; /* # msgs waiting to be read */
int32 total_count; /* total # msgs read so far */
} port_info;
extern port_id create_port(int32 capacity, const char *name);
extern port_id find_port(const char *name);
extern ssize_t read_port(port_id port, int32 *code, void *buffer, size_t bufferSize);
extern ssize_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);
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);
/* 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)))
/*-------------------------------------------------------------*/
/* Semaphores */
typedef struct sem_info {
sem_id sem;
team_id team;
char name[B_OS_NAME_LENGTH];
int32 count;
thread_id latest_holder;
} sem_info;
/* semaphore flags */
enum {
B_CAN_INTERRUPT = 0x01, // acquisition of the semaphore can be
// interrupted (system use only)
B_CHECK_PERMISSION = 0x04, // ownership will be checked (system use
// only)
B_KILL_CAN_INTERRUPT = 0x20, // acquisition of the semaphore can be
// interrupted by SIGKILL[THR], even
// if not B_CAN_INTERRUPT (system use
// only)
/* release_sem_etc() only flags */
B_DO_NOT_RESCHEDULE = 0x02, // thread is not rescheduled
B_RELEASE_ALL = 0x08, // all waiting threads will be woken up,
// count will be zeroed
B_RELEASE_IF_WAITING_ONLY = 0x10, // release count only if there are any
// threads waiting
};
extern sem_id create_sem(int32 count, const char *name);
extern status_t delete_sem(sem_id id);
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);
// ToDo: the following two calls are not part of the BeOS API, and might be
// changed or even removed for the final release of Haiku R1
extern status_t switch_sem(sem_id semToBeReleased, sem_id id);
extern status_t switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count,
uint32 flags, bigtime_t timeout);
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);
#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)))
/*-------------------------------------------------------------*/
/* Teams */
typedef struct {
team_id team;
int32 thread_count;
int32 image_count;
int32 area_count;
thread_id debugger_nub_thread;
port_id debugger_nub_port;
int32 argc;
char args[64];
uid_t uid;
gid_t gid;
} team_info;
#define B_CURRENT_TEAM 0
#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;
enum {
/* compatible to sys/resource.h RUSAGE_SELF and RUSAGE_CHILDREN */
B_TEAM_USAGE_SELF = 0,
B_TEAM_USAGE_CHILDREN = -1,
};
/* system private, use macros instead */
extern status_t _get_team_usage_info(team_id team, int32 who, team_usage_info *info, 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
#define B_SYSTEM_TIMEBASE 0
typedef int32 (*thread_func) (void *);
#define thread_entry thread_func /* thread_entry is for backward compatibility only! Use thread_func */
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);
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);
extern thread_id find_thread(const char *name);
extern status_t send_data(thread_id thread, int32 code, const void *buffer,
size_t bufferSize);
extern int32 receive_data(thread_id *sender, void *buffer, size_t bufferSize);
extern bool has_data(thread_id thread);
extern status_t snooze(bigtime_t amount);
extern status_t snooze_etc(bigtime_t amount, int timeBase, uint32 flags);
extern status_t snooze_until(bigtime_t time, int timeBase);
/* 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) \
_get_next_thread_info((team), (cookie), (info), sizeof(*(info)))
/*-------------------------------------------------------------*/
/* Time */
extern uint32 real_time_clock(void);
extern void set_real_time_clock(uint32 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);
// TODO: Remove. Temporary debug helper.
extern void debug_printf(const char *format, ...)
__attribute__ ((format (__printf__, 1, 2)));
extern void debug_vprintf(const char *format, va_list args);
/*-------------------------------------------------------------*/
/* System information */
#if __INTEL__
# define B_MAX_CPU_COUNT 8
#elif __POWERPC__
# define B_MAX_CPU_COUNT 8
#endif
#define OBOS_CPU_TYPES
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 */
/* Updated according to Intel(R) Processor Identification and
* the CPUID instruction (Table 4)
* AP-485 Intel - 24161828.pdf
*/
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,
B_CPU_INTEL_PENTIUM_M = 0x1069,
B_CPU_INTEL_PENTIUM_III_XEON = 0x106a,
B_CPU_INTEL_PENTIUM_III_MODEL_11 = 0x106b,
B_CPU_INTEL_PENTIUM_M_MODEL_13 = 0x106d, /* Dothan */
B_CPU_INTEL_PENTIUM_IV = 0x10f0,
B_CPU_INTEL_PENTIUM_IV_MODEL_1,
B_CPU_INTEL_PENTIUM_IV_MODEL_2,
B_CPU_INTEL_PENTIUM_IV_MODEL_3,
B_CPU_INTEL_PENTIUM_IV_MODEL_4,
/* AMD */
/* Checked with "AMD Processor Recognition Application Note"
* (Table 3)
* 20734.pdf
*/
B_CPU_AMD_x86 = 0x1100,
B_CPU_AMD_K5_MODEL_0 = 0x1150,
B_CPU_AMD_K5_MODEL_1,
B_CPU_AMD_K5_MODEL_2,
B_CPU_AMD_K5_MODEL_3,
B_CPU_AMD_K6_MODEL_6 = 0x1156,
B_CPU_AMD_K6_MODEL_7 = 0x1157,
B_CPU_AMD_K6_MODEL_8 = 0x1158,
B_CPU_AMD_K6_2 = 0x1158,
B_CPU_AMD_K6_MODEL_9 = 0x1159,
B_CPU_AMD_K6_III = 0x1159,
B_CPU_AMD_K6_III_MODEL_13 = 0x115d,
B_CPU_AMD_ATHLON_MODEL_1 = 0x1161,
B_CPU_AMD_ATHLON_MODEL_2 = 0x1162,
B_CPU_AMD_DURON = 0x1163,
B_CPU_AMD_ATHLON_THUNDERBIRD = 0x1164,
B_CPU_AMD_ATHLON_XP = 0x1166,
B_CPU_AMD_ATHLON_XP_MODEL_7,
B_CPU_AMD_ATHLON_XP_MODEL_8,
B_CPU_AMD_ATHLON_XP_MODEL_10 = 0x116a, /* Barton */
B_CPU_AMD_SEMPRON_MODEL_8 = B_CPU_AMD_ATHLON_XP_MODEL_8,
B_CPU_AMD_SEMPRON_MODEL_10 = B_CPU_AMD_ATHLON_XP_MODEL_10,
/* According to "Revision guide for AMD Athlon 64
* and AMD Opteron Processors" (25759.pdf)
*/
B_CPU_AMD_ATHLON_64_MODEL_4 = 0x11f4,
B_CPU_AMD_ATHLON_64_MODEL_5,
B_CPU_AMD_OPTERON = B_CPU_AMD_ATHLON_64_MODEL_5,
B_CPU_AMD_ATHLON_64_FX = B_CPU_AMD_ATHLON_64_MODEL_5,
B_CPU_AMD_ATHLON_64_MODEL_7 = 0x11f7,
B_CPU_AMD_ATHLON_64_MODEL_8,
B_CPU_AMD_ATHLON_64_MODEL_11 = 0x11fb,
B_CPU_AMD_ATHLON_64_MODEL_12,
B_CPU_AMD_ATHLON_64_MODEL_14 = 0x11fe,
B_CPU_AMD_ATHLON_64_MODEL_15,
/* VIA/Cyrix */
B_CPU_CYRIX_x86 = 0x1200,
B_CPU_VIA_CYRIX_x86 = 0x1200,
B_CPU_CYRIX_GXm = 0x1254,
B_CPU_CYRIX_6x86MX = 0x1260,
/* VIA/IDT */
B_CPU_IDT_x86 = 0x1300,
B_CPU_VIA_IDT_x86 = 0x1300,
B_CPU_IDT_WINCHIP_C6 = 0x1354,
B_CPU_IDT_WINCHIP_2 = 0x1358,
B_CPU_IDT_WINCHIP_3,
B_CPU_VIA_EDEN = 0x1367,
B_CPU_VIA_EDEN_EZRA_T = 0x1368,
/* Transmeta */
B_CPU_TRANSMETA_x86 = 0x1600,
B_CPU_TRANSMETA_CRUSOE = 0x1654,
/* Rise */
B_CPU_RISE_x86 = 0x1400,
B_CPU_RISE_mP6 = 0x1450,
/* National Semiconductor */
B_CPU_NATIONAL_x86 = 0x1500,
B_CPU_NATIONAL_GEODE_GX1 = 0x1554,
B_CPU_NATIONAL_GEODE_GX2,
/* 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 0xff00
#ifdef __INTEL__
typedef union {
struct {
uint32 max_eax;
char vendor_id[12];
} eax_0;
struct {
uint32 stepping : 4;
uint32 model : 4;
uint32 family : 4;
uint32 type : 2;
uint32 reserved_0 : 2;
uint32 extended_model : 4;
uint32 extended_family : 8;
uint32 reserved_1 : 4;
uint32 reserved_2;
uint32 features;
uint32 reserved_3;
} 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 eaxRegister, uint32 cpuNum);
#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;
char kernel_name[B_FILE_NAME_LENGTH]; /* name of kernel */
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 whatever */
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 */
+526
View File
@@ -0,0 +1,526 @@
/*
* Copyright 2005, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _DEBUGGER_H
#define _DEBUGGER_H
#include <signal.h>
#include <image.h>
#include <OS.h>
// include architecture specific definitions
#ifdef __INTEL__
#include <arch/x86/arch_debugger.h>
#elif __POWERPC__
#include <arch/ppc/arch_debugger.h>
#endif
typedef struct debug_cpu_state debug_cpu_state;
#ifdef __cplusplus
extern "C" {
#endif
extern status_t install_default_debugger(port_id debuggerPort);
extern port_id install_team_debugger(team_id team, port_id debuggerPort);
extern status_t remove_team_debugger(team_id team);
extern status_t debug_thread(thread_id thread);
extern void wait_for_debugger(void);
// team debugging flags
enum {
// event mask: If a flag is set, any of the team's threads will stop when
// the respective event occurs. All flags are enabled by default. Always
// enabled are debugger() calls and hardware exceptions, as well as the
// deletion of the debugged team.
B_TEAM_DEBUG_SIGNALS = 0x00010000,
B_TEAM_DEBUG_PRE_SYSCALL = 0x00020000,
B_TEAM_DEBUG_POST_SYSCALL = 0x00040000,
B_TEAM_DEBUG_TEAM_CREATION = 0x00080000,
B_TEAM_DEBUG_THREADS = 0x00100000,
B_TEAM_DEBUG_IMAGES = 0x00200000,
// new thread handling
B_TEAM_DEBUG_STOP_NEW_THREADS = 0x01000000,
B_TEAM_DEBUG_USER_FLAG_MASK = 0xffff0000,
};
// per-thread debugging flags
enum {
// event mask: If a flag is set, the thread will stop when the respective
// event occurs. If there is a corresponding team flag, it is sufficient,
// if either is set. Per default none of the flags is set.
B_THREAD_DEBUG_PRE_SYSCALL = 0x00010000,
B_THREAD_DEBUG_POST_SYSCALL = 0x00020000,
// child thread handling
B_THREAD_DEBUG_STOP_CHILD_THREADS = 0x00100000,
B_THREAD_DEBUG_SYSCALL_TRACE_CHILD_THREADS = 0x00200000,
B_THREAD_DEBUG_USER_FLAG_MASK = 0xffff0000,
};
// in case of a B_EXCEPTION_OCCURRED event: the type of the exception
typedef enum {
B_NON_MASKABLE_INTERRUPT = 0,
B_MACHINE_CHECK_EXCEPTION,
B_SEGMENT_VIOLATION,
B_ALIGNMENT_EXCEPTION,
B_DIVIDE_ERROR,
B_OVERFLOW_EXCEPTION,
B_BOUNDS_CHECK_EXCEPTION,
B_INVALID_OPCODE_EXCEPTION,
B_SEGMENT_NOT_PRESENT,
B_STACK_FAULT,
B_GENERAL_PROTECTION_FAULT,
B_FLOATING_POINT_EXCEPTION,
} debug_exception_type;
// Value indicating how a stopped thread shall continue.
enum {
B_THREAD_DEBUG_HANDLE_EVENT = 0, // handle the event normally
// (e.g. a signal is delivered, a
// CPU fault kills the team,...)
B_THREAD_DEBUG_IGNORE_EVENT, // ignore the event and continue as if
// it didn't occur (e.g. a signal or
// a CPU fault will be ignored)
};
// watchpoint types (ToDo: Check PPC support.)
enum {
B_DATA_READ_WATCHPOINT = 0, // !x86
B_DATA_WRITE_WATCHPOINT,
B_DATA_READ_WRITE_WATCHPOINT,
};
// how to apply signal ignore masks
typedef enum {
B_DEBUG_SIGNAL_MASK_AND = 0,
B_DEBUG_SIGNAL_MASK_OR,
B_DEBUG_SIGNAL_MASK_SET,
} debug_signal_mask_op;
#define B_DEBUG_SIGNAL_TO_MASK(signal) (1ULL << ((signal) - 1))
// maximal number of bytes to read/write via B_DEBUG_MESSAGE_{READ,WRITE]_MEMORY
enum {
B_MAX_READ_WRITE_MEMORY_SIZE = 1024,
};
// messages to the debug nub thread
typedef enum {
B_DEBUG_MESSAGE_READ_MEMORY = 0, // read from the team's memory
B_DEBUG_MESSAGE_WRITE_MEMORY, // write to the team's memory
B_DEBUG_MESSAGE_SET_TEAM_FLAGS, // set the team's debugging flags
B_DEBUG_MESSAGE_SET_THREAD_FLAGS, // set a thread's debugging flags
B_DEBUG_MESSAGE_CONTINUE_THREAD, // continue a stopped thread
B_DEBUG_MESSAGE_SET_CPU_STATE, // change a stopped thread's CPU state
B_DEBUG_MESSAGE_GET_CPU_STATE, // get the thread's current CPU state
B_DEBUG_MESSAGE_SET_BREAKPOINT, // set a breakpoint
B_DEBUG_MESSAGE_CLEAR_BREAKPOINT, // clear a breakpoint
B_DEBUG_MESSAGE_SET_WATCHPOINT, // set a watchpoint
B_DEBUG_MESSAGE_CLEAR_WATCHPOINT, // clear a watchpoint
B_DEBUG_MESSAGE_SET_SIGNAL_MASKS, // set/get a thread's masks of signals
B_DEBUG_MESSAGE_GET_SIGNAL_MASKS, // the debugger is interested in
B_DEBUG_MESSAGE_SET_SIGNAL_HANDLER, // set/get a thread's signal handler for
B_DEBUG_MESSAGE_GET_SIGNAL_HANDLER, // a signal
B_DEBUG_MESSAGE_PREPARE_HANDOVER, // prepares the debugged team for being
// handed over to another debugger;
// the new debugger can just invoke
// install_team_debugger()
} debug_nub_message;
// messages sent to the debugger
typedef enum {
B_DEBUGGER_MESSAGE_THREAD_DEBUGGED = 0, // debugger message in reaction to
// an invocation of debug_thread()
B_DEBUGGER_MESSAGE_DEBUGGER_CALL, // thread called debugger()
B_DEBUGGER_MESSAGE_BREAKPOINT_HIT, // thread hit a breakpoint
B_DEBUGGER_MESSAGE_WATCHPOINT_HIT, // thread hit a watchpoint
B_DEBUGGER_MESSAGE_SINGLE_STEP, // thread was single-stepped
B_DEBUGGER_MESSAGE_PRE_SYSCALL, // begin of a syscall
B_DEBUGGER_MESSAGE_POST_SYSCALL, // end of a syscall
B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED, // thread received a signal
B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED, // an exception occurred
B_DEBUGGER_MESSAGE_TEAM_CREATED, // the debugged team created a new
// one
B_DEBUGGER_MESSAGE_TEAM_DELETED, // the debugged team is gone
B_DEBUGGER_MESSAGE_THREAD_CREATED, // a thread has been created
B_DEBUGGER_MESSAGE_THREAD_DELETED, // a thread has been deleted
B_DEBUGGER_MESSAGE_IMAGE_CREATED, // an image has been created
B_DEBUGGER_MESSAGE_IMAGE_DELETED, // an image has been deleted
B_DEBUGGER_MESSAGE_HANDED_OVER, // the debugged team has been
// handed over to another debugger
} debug_debugger_message;
// #pragma mark -
// #pragma mark ----- messages to the debug nub thread -----
// B_DEBUG_MESSAGE_READ_MEMORY
typedef struct {
port_id reply_port; // port to send the reply to
void *address; // address from which to read
int32 size; // number of bytes to read
} debug_nub_read_memory;
typedef struct {
status_t error; // B_OK, if reading went fine
int32 size; // the number of bytes actually read
// > 0, iff error == B_OK
char data[B_MAX_READ_WRITE_MEMORY_SIZE];
// the read data
} debug_nub_read_memory_reply;
// B_DEBUG_MESSAGE_WRITE_MEMORY
typedef struct {
port_id reply_port; // port to send the reply to
void *address; // address to which to write
int32 size; // number of bytes to write
char data[B_MAX_READ_WRITE_MEMORY_SIZE];
// data to write
} debug_nub_write_memory;
typedef struct {
status_t error; // B_OK, if writing went fine
int32 size; // the number of bytes actually written
} debug_nub_write_memory_reply;
// B_DEBUG_MESSAGE_SET_TEAM_FLAGS
typedef struct {
int32 flags; // the new team debugging flags
} debug_nub_set_team_flags;
// B_DEBUG_MESSAGE_SET_THREAD_FLAGS
typedef struct {
thread_id thread; // the thread
int32 flags; // the new thread debugging flags
} debug_nub_set_thread_flags;
// B_DEBUG_MESSAGE_CONTINUE_THREAD
typedef struct {
thread_id thread; // the thread
uint32 handle_event; // how to handle the occurred event
bool single_step; // true == single step, false == run full speed
} debug_nub_continue_thread;
// B_DEBUG_MESSAGE_SET_CPU_STATE
typedef struct {
thread_id thread; // the thread
debug_cpu_state cpu_state; // the new CPU state
} debug_nub_set_cpu_state;
// B_DEBUG_MESSAGE_GET_CPU_STATE
typedef struct {
port_id reply_port; // port to send the reply to
thread_id thread; // the thread
} debug_nub_get_cpu_state;
typedef struct {
status_t error; // != B_OK, if something went wrong
// (bad thread ID, thread not stopped)
debug_debugger_message message; // the reason why the thread stopped
debug_cpu_state cpu_state; // the thread's CPU state
} debug_nub_get_cpu_state_reply;
// B_DEBUG_MESSAGE_SET_BREAKPOINT
typedef struct {
port_id reply_port; // port to send the reply to
void *address; // breakpoint address
} debug_nub_set_breakpoint;
typedef struct {
status_t error; // B_OK, if the breakpoint has been set
// successfully
} debug_nub_set_breakpoint_reply;
// B_DEBUG_MESSAGE_CLEAR_BREAKPOINT
typedef struct {
void *address; // breakpoint address
} debug_nub_clear_breakpoint;
// B_DEBUG_MESSAGE_SET_WATCHPOINT
typedef struct {
port_id reply_port; // port to send the reply to
void *address; // watchpoint address
uint32 type; // watchpoint type (see type constants above)
int32 length; // number of bytes to watch (typically 1, 2,
// 4); architecture specific alignment
// restrictions apply.
} debug_nub_set_watchpoint;
typedef struct {
status_t error; // B_OK, if the watchpoint has been set
// successfully
} debug_nub_set_watchpoint_reply;
// B_DEBUG_MESSAGE_CLEAR_WATCHPOINT
typedef struct {
void *address; // watchpoint address
} debug_nub_clear_watchpoint;
// B_DEBUG_MESSAGE_SET_SIGNAL_MASKS
typedef struct {
thread_id thread; // the thread
uint64 ignore_mask; // the mask for signals the
// debugger wishes not to be
// notified of
uint64 ignore_once_mask; // the mask for signals the
// debugger wishes not to be
// notified of when they next
// occur
debug_signal_mask_op ignore_op; // what to do with ignore_mask
debug_signal_mask_op ignore_once_op; // what to do with
// ignore_once_mask
} debug_nub_set_signal_masks;
// B_DEBUG_MESSAGE_GET_SIGNAL_MASKS
typedef struct {
port_id reply_port; // port to send the reply to
thread_id thread; // the thread
} debug_nub_get_signal_masks;
typedef struct {
status_t error; // B_OK, if the thread exists
uint64 ignore_mask; // the mask for signals the debugger wishes
// not to be notified of
uint64 ignore_once_mask; // the mask for signals the debugger wishes
// not to be notified of when they next
// occur
} debug_nub_get_signal_masks_reply;
// B_DEBUG_MESSAGE_SET_SIGNAL_HANDLER
typedef struct {
thread_id thread; // the thread
int signal; // the signal
struct sigaction handler; // the new signal handler
} debug_nub_set_signal_handler;
// B_DEBUG_MESSAGE_GET_SIGNAL_HANDLER
typedef struct {
port_id reply_port; // port to send the reply to
thread_id thread; // the thread
int signal; // the signal
} debug_nub_get_signal_handler;
typedef struct {
status_t error; // B_OK, if the thread exists
struct sigaction handler; // the signal handler
} debug_nub_get_signal_handler_reply;
// B_DEBUG_MESSAGE_PREPARE_HANDOVER
// no parameters, no reply
// union of all messages structures sent to the debug nub thread
typedef union {
debug_nub_read_memory read_memory;
debug_nub_write_memory write_memory;
debug_nub_set_team_flags set_team_flags;
debug_nub_set_thread_flags set_thread_flags;
debug_nub_continue_thread continue_thread;
debug_nub_set_cpu_state set_cpu_state;
debug_nub_get_cpu_state get_cpu_state;
debug_nub_set_breakpoint set_breakpoint;
debug_nub_clear_breakpoint clear_breakpoint;
debug_nub_set_watchpoint set_watchpoint;
debug_nub_clear_watchpoint clear_watchpoint;
debug_nub_set_signal_masks set_signal_masks;
debug_nub_get_signal_masks get_signal_masks;
debug_nub_set_signal_handler set_signal_handler;
debug_nub_get_signal_handler get_signal_handler;
} debug_nub_message_data;
// #pragma mark -
// #pragma mark ----- messages to the debugger -----
// first member of all debugger messages -- not a message by itself
typedef struct {
thread_id thread; // the thread being the event origin
team_id team; // the thread's team
port_id nub_port; // port to debug nub for this team (only set
// for synchronous messages)
} debug_origin;
// B_DEBUGGER_MESSAGE_THREAD_DEBUGGED
typedef struct {
debug_origin origin;
} debug_thread_debugged;
// B_DEBUGGER_MESSAGE_DEBUGGER_CALL
typedef struct {
debug_origin origin;
void *message; // address of the message passed to
// debugger()
} debug_debugger_call;
// B_DEBUGGER_MESSAGE_BREAKPOINT_HIT
typedef struct {
debug_origin origin;
debug_cpu_state cpu_state; // cpu state
bool software; // true, if the is a software breakpoint
// (i.e. caused by a respective trap
// instruction)
} debug_breakpoint_hit;
// B_DEBUGGER_MESSAGE_WATCHPOINT_HIT
typedef struct {
debug_origin origin;
debug_cpu_state cpu_state; // cpu state
} debug_watchpoint_hit;
// B_DEBUGGER_MESSAGE_SINGLE_STEP
typedef struct {
debug_origin origin;
debug_cpu_state cpu_state; // cpu state
} debug_single_step;
// B_DEBUGGER_MESSAGE_PRE_SYSCALL
typedef struct {
debug_origin origin;
uint32 syscall; // the syscall number
uint32 args[16]; // syscall arguments
} debug_pre_syscall;
// B_DEBUGGER_MESSAGE_POST_SYSCALL
typedef struct {
debug_origin origin;
bigtime_t start_time; // time of syscall start
bigtime_t end_time; // time of syscall completion
uint64 return_value; // the syscall's return value
uint32 syscall; // the syscall number
uint32 args[16]; // syscall arguments
} debug_post_syscall;
// B_DEBUGGER_MESSAGE_SIGNAL_RECEIVED
typedef struct {
debug_origin origin;
int signal; // the signal
struct sigaction handler; // the signal handler
bool deadly; // true, if handling the signal will kill
// the team
} debug_signal_received;
// B_DEBUGGER_MESSAGE_EXCEPTION_OCCURRED
typedef struct {
debug_origin origin;
debug_exception_type exception; // the exception
int signal; // the signal that will be sent,
// when the thread continues
// normally
} debug_exception_occurred;
// B_DEBUGGER_MESSAGE_TEAM_CREATED
typedef struct {
debug_origin origin;
team_id new_team; // the newly created team
} debug_team_created;
// B_DEBUGGER_MESSAGE_TEAM_DELETED
typedef struct {
debug_origin origin; // thread is < 0, team is the deleted team
// (asynchronous message)
} debug_team_deleted;
// B_DEBUGGER_MESSAGE_THREAD_CREATED
typedef struct {
debug_origin origin; // the thread that created the new thread
team_id new_thread; // the newly created thread
} debug_thread_created;
// B_DEBUGGER_MESSAGE_THREAD_DELETED
typedef struct {
debug_origin origin; // the deleted thread (asynchronous message)
} debug_thread_deleted;
// B_DEBUGGER_MESSAGE_IMAGE_CREATED
typedef struct {
debug_origin origin;
image_info info; // info for the image
} debug_image_created;
// B_DEBUGGER_MESSAGE_IMAGE_DELETED
typedef struct {
debug_origin origin;
image_info info; // info for the image
} debug_image_deleted;
// B_DEBUGGER_MESSAGE_HANDED_OVER
typedef struct {
debug_origin origin; // thread is < 0, team is the deleted team
// (asynchronous message)
team_id debugger; // the new debugger
port_id debugger_port; // the port the new debugger uses
} debug_handed_over;
// union of all messages structures sent to the debugger
typedef union {
debug_thread_debugged thread_debugged;
debug_debugger_call debugger_call;
debug_breakpoint_hit breakpoint_hit;
debug_watchpoint_hit watchpoint_hit;
debug_single_step single_step;
debug_pre_syscall pre_syscall;
debug_post_syscall post_syscall;
debug_signal_received signal_received;
debug_exception_occurred exception_occurred;
debug_team_created team_created;
debug_team_deleted team_deleted;
debug_thread_created thread_created;
debug_thread_deleted thread_deleted;
debug_image_created image_created;
debug_image_deleted image_deleted;
debug_handed_over handed_over;
debug_origin origin; // for convenience (no real message)
} debug_debugger_message_data;
extern void get_debug_message_string(debug_debugger_message message,
char *buffer, int32 bufferSize);
extern void get_debug_exception_string(debug_exception_type exception,
char *buffer, int32 bufferSize);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // _DEBUGGER_H
+81
View File
@@ -0,0 +1,81 @@
/* Disk device iteration and information
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _FS_DEVICE_H
#define _FS_DEVICE_H
#include <Drivers.h>
#include <OS.h>
#include <SupportDefs.h>
// session flags
enum {
B_DATA_SESSION = 0x01, /* data session */
B_VIRTUAL_SESSION = 0x02, /* e.g. hard disk */
};
typedef struct session_info {
off_t offset; /* offset from start of device (in bytes) */
off_t size; /* size (in bytes) */
int32 logical_block_size; /* logical block size (in bytes) */
int32 index; /* session index */
uint32 flags; /* session flags */
} session_info;
// partition flags
enum {
B_HIDDEN_PARTITION = 0x01, /* non-file system partition */
B_VIRTUAL_PARTITION = 0x02, /* e.g. floppy */
B_EMPTY_PARTITION = 0x04, /* empty partition, implies
B_HIDDEN_PARTITION */
};
typedef struct extended_partition_info {
partition_info info;
uint32 flags; /* partition flags */
char partition_name[B_FILE_NAME_LENGTH];
char partition_type[B_FILE_NAME_LENGTH];
char file_system_short_name[B_FILE_NAME_LENGTH]; /* "", if hidden */
char file_system_long_name[B_FILE_NAME_LENGTH]; /* or unknown FS */
char volume_name[B_FILE_NAME_LENGTH]; /* "", if hidden */
uint32 file_system_flags; /* same as fs_info::flags */
} extended_partition_info;
#ifdef __cplusplus
extern "C" {
#endif
// getting infos
status_t get_nth_session_info(int deviceFD, int32 index,
session_info *sessionInfo);
status_t get_nth_partition_info(int deviceFD, int32 sessionIndex,
int32 partitionIndex,
extended_partition_info *partitionInfo,
char *partitionMapName);
// partitioning
status_t get_partitioning_parameters(int deviceFD, int32 sessionIndex,
const char *identifier, char *buffer,
size_t bufferSize, size_t *actualSize);
status_t partition_session(int deviceFD, int32 sessionIndex,
const char *identifier, const char *parameters);
// initialization
status_t get_fs_initialization_parameters(int deviceFD, int32 sessionIndex,
int32 partitionIndex,
const char *fileSystem, char *buffer,
size_t bufferSize,
size_t *actualSize);
// TODO: Move to <unistd.h>. It fits better there.
status_t initialize_volume(const char *where, const char *fileSystem,
const char *volumeName, const char *parameters);
#ifdef __cplusplus
}
#endif
#endif /* _FS_DEVICE_H */
+44
View File
@@ -0,0 +1,44 @@
/* File System attributes
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _FS_ATTR_H
#define _FS_ATTR_H
#include <OS.h>
#include <dirent.h>
typedef struct attr_info {
uint32 type;
off_t size;
} attr_info;
#ifdef __cplusplus
extern "C" {
#endif
extern ssize_t fs_read_attr(int fd, const char *attribute, uint32 type, off_t pos, void *buffer, size_t readBytes);
extern ssize_t fs_write_attr(int fd, const char *attribute, uint32 type, off_t pos, const void *buffer, size_t readBytes);
extern int fs_remove_attr(int fd, const char *attribute);
extern int fs_stat_attr(int fd, const char *attribute, struct attr_info *attrInfo);
// ToDo: the following three functions are not part of the R5 API, and
// are only preliminary - they may change or be removed at any point
//extern int fs_open_attr(const char *path, const char *attribute, uint32 type, int openMode);
extern int fs_open_attr(int fd, const char *attribute, uint32 type, int openMode);
extern int fs_close_attr(int fd);
extern DIR *fs_open_attr_dir(const char *path);
extern DIR *fs_fopen_attr_dir(int fd);
extern int fs_close_attr_dir(DIR *dir);
extern struct dirent *fs_read_attr_dir(DIR *dir);
extern void fs_rewind_attr_dir(DIR *dir);
#ifdef __cplusplus
}
#endif
#endif /* _FS_ATTR_H */
+40
View File
@@ -0,0 +1,40 @@
/* File System indices
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _FS_INDEX_H
#define _FS_INDEX_H
#include <OS.h>
#include <dirent.h>
typedef struct index_info {
uint32 type;
off_t size;
time_t modification_time;
time_t creation_time;
uid_t uid;
gid_t gid;
} index_info;
#ifdef __cplusplus
extern "C" {
#endif
extern int fs_create_index(dev_t device, const char *name, uint32 type, uint32 flags);
extern int fs_remove_index(dev_t device, const char *name);
extern int fs_stat_index(dev_t device, const char *name, struct index_info *indexInfo);
extern DIR *fs_open_index_dir(dev_t device);
extern int fs_close_index_dir(DIR *indexDirectory);
extern struct dirent *fs_read_index_dir(DIR *indexDirectory);
extern void fs_rewind_index_dir(DIR *indexDirectory);
#ifdef __cplusplus
}
#endif
#endif /* _FS_INDEX_H */
+52
View File
@@ -0,0 +1,52 @@
/* General File System informations/capabilities
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _FS_INFO_H
#define _FS_INFO_H
#include <OS.h>
/* fs_info.flags */
#define B_FS_IS_READONLY 0x00000001
#define B_FS_IS_REMOVABLE 0x00000002
#define B_FS_IS_PERSISTENT 0x00000004
#define B_FS_IS_SHARED 0x00000008
#define B_FS_HAS_MIME 0x00010000
#define B_FS_HAS_ATTR 0x00020000
#define B_FS_HAS_QUERY 0x00040000
// those additions are preliminary and may be removed
#define B_FS_HAS_SELF_HEALING_LINKS 0x00080000
#define B_FS_HAS_ALIASES 0x00100000
#define B_FS_SUPPORTS_NODE_MONITORING 0x00200000
typedef struct fs_info {
dev_t dev; /* volume dev_t */
ino_t root; /* root ino_t */
uint32 flags; /* flags (see above) */
off_t block_size; /* fundamental block size */
off_t io_size; /* optimal i/o size */
off_t total_blocks; /* total number of blocks */
off_t free_blocks; /* number of free blocks */
off_t total_nodes; /* total number of nodes */
off_t free_nodes; /* number of free nodes */
char device_name[128]; /* device holding fs */
char volume_name[B_FILE_NAME_LENGTH]; /* volume name */
char fsh_name[B_OS_NAME_LENGTH]; /* name of fs handler */
} fs_info;
#ifdef __cplusplus
extern "C" {
#endif
extern dev_t dev_for_path(const char *path);
extern dev_t next_dev(int32 *pos);
extern int fs_stat_dev(dev_t dev, fs_info *info);
#ifdef __cplusplus
}
#endif
#endif /* _FS_INFO_H */
+41
View File
@@ -0,0 +1,41 @@
/* File System attribute queries
**
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef _FS_QUERY_H
#define _FS_QUERY_H
#include <OS.h>
#include <dirent.h>
/* Flags for fs_open_[live_]query() */
#define B_LIVE_QUERY 0x00000001
// Note, if you specify B_LIVE_QUERY, you have to use fs_open_live_query();
// it will be ignored in fs_open_query().
#define B_QUERY_NON_INDEXED 0x00000002
// Only enable this feature for non time-critical things, it might
// take a long time to proceed.
// Also, not every file system might support this feature.
#ifdef __cplusplus
extern "C" {
#endif
extern DIR *fs_open_query(dev_t device, const char *query, uint32 flags);
extern DIR *fs_open_live_query(dev_t device, const char *query,
uint32 flags, port_id port, int32 token);
extern int fs_close_query(DIR *d);
extern struct dirent *fs_read_query(DIR *d);
extern status_t get_path_for_dirent(struct dirent *dent, char *buf,
size_t len);
#ifdef __cplusplus
}
#endif
#endif /* _FS_QUERY_H */
+31
View File
@@ -0,0 +1,31 @@
/* File System volume functions
**
** Distributed under the terms of the Haiku License.
*/
#ifndef _FS_VOLUME_H
#define _FS_VOLUME_H
#include <OS.h>
/* mount flags */
#define B_MOUNT_READ_ONLY 1
#define B_MOUNT_VIRTUAL_DEVICE 2
/* unmount flags */
#define B_FORCE_UNMOUNT 1
#ifdef __cplusplus
extern "C" {
#endif
extern status_t fs_mount_volume(const char *where, const char *device,
const char *filesystem, uint32 flags, const char *parameters);
extern status_t fs_unmount_volume(const char *path, uint32 flags);
#ifdef __cplusplus
}
#endif
#endif /* _FS_VOLUME_H */
+114
View File
@@ -0,0 +1,114 @@
/******************************************************************************
/
/ File: image.h
/
/ Description: Kernel interface for managing executable images.
/
/ Copyright 1993-98, Be Incorporated
/
******************************************************************************/
#ifndef _IMAGE_H
#define _IMAGE_H
#include <BeBuild.h>
#include <OS.h>
#include <sys/param.h>
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------*/
/*----- Image types, info, and functions ------------------*/
#define B_INIT_BEFORE_FUNCTION_NAME "initialize_before"
#define B_INIT_AFTER_FUNCTION_NAME "initialize_after"
#define B_TERM_BEFORE_FUNCTION_NAME "terminate_before"
#define B_TERM_AFTER_FUNCTION_NAME "terminate_after"
typedef int32 image_id;
typedef enum {
B_APP_IMAGE = 1,
B_LIBRARY_IMAGE,
B_ADD_ON_IMAGE,
B_SYSTEM_IMAGE
} image_type;
typedef struct {
image_id id;
image_type type;
int32 sequence;
int32 init_order;
void (*init_routine)();
void (*term_routine)();
dev_t device;
ino_t node;
char name[MAXPATHLEN];
void *text;
void *data;
int32 text_size;
int32 data_size;
} image_info;
// flags for _kern_load_image()
enum {
B_WAIT_TILL_LOADED = 0x01, // Wait till the loader has loaded and relocated
// (but not yet initialized) the application
// image and all dependencies. If not supplied,
// the function returns before the loader
// started to do anything at all, i.e. it
// returns success, even if the executable
// doesn't exist.
};
extern _IMPEXP_ROOT thread_id load_image(int32 argc, const char **argv,
const char **envp);
extern _IMPEXP_ROOT image_id load_add_on(const char *path);
extern _IMPEXP_ROOT status_t unload_add_on(image_id imageID);
/* private; use the macros, below */
extern _IMPEXP_ROOT status_t _get_image_info (image_id imageID,
image_info *info, size_t size);
extern _IMPEXP_ROOT status_t _get_next_image_info (team_id team, int32 *cookie,
image_info *info, size_t size);
/* use these */
#define get_image_info(image, info) \
_get_image_info((image), (info), sizeof(*(info)))
#define get_next_image_info(team, cookie, info) \
_get_next_image_info((team), (cookie), (info), sizeof(*(info)))
/*---------------------------------------------------------*/
/*----- symbol types and functions ------------------------*/
#define B_SYMBOL_TYPE_DATA 0x1
#define B_SYMBOL_TYPE_TEXT 0x2
#define B_SYMBOL_TYPE_ANY 0x5
extern _IMPEXP_ROOT status_t get_image_symbol(image_id imid,
const char *name, int32 sclass, void **ptr);
extern _IMPEXP_ROOT status_t get_nth_image_symbol(image_id imid, int32 index,
char *buf, int32 *bufsize, int32 *sclass,
void **ptr);
/*---------------------------------------------------------*/
/*----- cache manipulation --------------------------------*/
#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
extern _IMPEXP_ROOT void clear_caches(void *addr, size_t len, uint32 flags);
/*---------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif /* _IMAGE_H */
+54
View File
@@ -0,0 +1,54 @@
/*****************************************************************************
File: scheduler.h
Description: Scheduling inquiry functions
Copyright 1998-, Be Incorporated, All Rights Reserved.
*****************************************************************************/
#if !defined(SCHEDULER_H)
#define SCHEDULER_H
#include <SupportDefs.h>
#include <OS.h>
/* To get a good thread priority, call suggest_thread_priority() with the following information: */
/* 'what' is a bit mask describing what you're doing in the thread. */
/* 'period' is how many times a second your thread needs to run (-1 if you're running continuously.) */
/* 'jitter' is an estimate (in us) of how much that period can vary, as long as it stays centered on the average. */
/* 'length' is how long (in us) you expect to run for each invocation. */
/* "invocation" means, typically, receiving a message, dispatching it, and then returning to reading a message. */
/* MANIPULATION means both filtering and compression/decompression. */
/* PLAYBACK and RECORDING means threads feeding/reading ACTUAL HARDWARE ONLY. */
/* 0 means don't care */
enum be_task_flags { /* bitmasks for "what" */
B_DEFAULT_MEDIA_PRIORITY = 0,
B_OFFLINE_PROCESSING = 0x1,
B_STATUS_RENDERING = 0x2, /* can also use this for "preview" type things */
B_USER_INPUT_HANDLING = 0x4,
B_LIVE_VIDEO_MANIPULATION = 0x8, /* non-live processing is OFFLINE_PROCESSING */
B_VIDEO_PLAYBACK = 0x10, /* feeding hardware */
B_VIDEO_RECORDING = 0x20, /* grabbing from hardware */
B_LIVE_AUDIO_MANIPULATION = 0x40, /* non-live processing is OFFLINE_PROCESSING */
B_AUDIO_PLAYBACK = 0x80, /* feeding hardware */
B_AUDIO_RECORDING = 0x100, /* grabbing from hardware */
B_LIVE_3D_RENDERING = 0x200, /* non-live rendering is OFFLINE_PROCESSING */
B_NUMBER_CRUNCHING = 0x400,
B_MIDI_PROCESSING = 0x800
};
#if defined(__cplusplus)
extern "C" {
_IMPEXP_ROOT int32 suggest_thread_priority(uint32 task_flags = B_DEFAULT_MEDIA_PRIORITY,
int32 period = 0, bigtime_t jitter = 0, bigtime_t length = 0);
_IMPEXP_ROOT bigtime_t estimate_max_scheduling_latency(thread_id th = -1); /* default is current thread */
}
#else
_IMPEXP_ROOT int32 suggest_thread_priority(uint32 what, int32 period, bigtime_t jitter, bigtime_t length);
_IMPEXP_ROOT bigtime_t estimate_max_scheduling_latency(thread_id th); /* default is current thread */
#endif
#endif /* SCHEDULER_H */