diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index d9e57a13ce..39ecda4306 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -227,7 +227,7 @@ AddFilesToHaikuImage system add-ons kernel busses usb : uhci ohci ehci ; AddFilesToHaikuImage system add-ons kernel console : vga_text ; AddFilesToHaikuImage system add-ons kernel debugger - : demangle $(X86_ONLY)disasm hangman + : demangle $(X86_ONLY)disasm invalidate_on_exit usb_keyboard run_on_exit ; AddFilesToHaikuImage system add-ons kernel file_systems : $(SYSTEM_ADD_ONS_FILE_SYSTEMS) ; diff --git a/headers/private/firewire/iec13213.h b/headers/private/firewire/iec13213.h index f018518cb1..cb2b2aa9d4 100644 --- a/headers/private/firewire/iec13213.h +++ b/headers/private/firewire/iec13213.h @@ -30,11 +30,15 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * $FreeBSD: src/sys/dev/firewire/iec13213.h,v 1.14 2005/01/06 01:42:41 imp Exp $ * */ + +#include + + #define STATE_CLEAR 0x0000 #define STATE_SET 0x0004 #define NODE_IDS 0x0008 @@ -161,7 +165,7 @@ struct csrtext { struct bus_info { #define CSR_BUS_NAME_IEEE1394 0x31333934 - uint32_t bus_name; + uint32_t bus_name; #if BYTE_ORDER == BIG_ENDIAN uint32_t irmc:1, /* iso. resource manager capable */ cmc:1, /* cycle master capable */ @@ -209,6 +213,8 @@ struct crom_context { struct crom_ptr stack[CROM_MAX_DEPTH]; }; +__BEGIN_DECLS + void crom_init_context(struct crom_context *, uint32_t *); struct csrreg *crom_get(struct crom_context *); void crom_next(struct crom_context *); @@ -232,12 +238,12 @@ struct crom_src { struct crom_chunk { STAILQ_ENTRY(crom_chunk) link; - struct crom_chunk *ref_chunk; - int ref_index; + struct crom_chunk *ref_chunk; + int ref_index; int offset; struct { BIT16x2(crc_len, crc); - uint32_t buf[CROM_MAX_CHUNK_LEN]; + uint32_t buf[CROM_MAX_CHUNK_LEN]; } data; }; @@ -246,6 +252,9 @@ extern int crom_add_entry(struct crom_chunk *, int, int); extern int crom_add_chunk(struct crom_src *src, struct crom_chunk *, struct crom_chunk *, int); extern int crom_add_simple_text(struct crom_src *src, struct crom_chunk *, - struct crom_chunk *, char *); + struct crom_chunk *, const char *); extern int crom_load(struct crom_src *, uint32_t *, int); + #endif + +__END_DECLS diff --git a/headers/private/kernel/arch/arm/arch_thread.h b/headers/private/kernel/arch/arm/arch_thread.h index 6606e9a18a..c524a451c9 100644 --- a/headers/private/kernel/arch/arm/arch_thread.h +++ b/headers/private/kernel/arch/arm/arch_thread.h @@ -22,9 +22,9 @@ struct iframe *arm_get_user_iframe(void); /* as we won't support SMP on arm (yet?) we can use a global here */ /*TODO SMP-ARMS are comming..*/ -extern struct thread *gCurrentThread; +extern Thread *gCurrentThread; -extern inline struct thread * +extern inline Thread * arch_thread_get_current_thread(void) { return gCurrentThread; @@ -32,7 +32,7 @@ arch_thread_get_current_thread(void) extern inline void -arch_thread_set_current_thread(struct thread *t) +arch_thread_set_current_thread(Thread *t) { gCurrentThread = t; } diff --git a/headers/private/kernel/arch/debug.h b/headers/private/kernel/arch/debug.h index 1ef4104f9f..e73ada344e 100644 --- a/headers/private/kernel/arch/debug.h +++ b/headers/private/kernel/arch/debug.h @@ -16,7 +16,12 @@ struct kernel_args; -struct thread; + +namespace BKernel { + struct Thread; +} + +using BKernel::Thread; // arch_debug_get_stack_trace() flags @@ -34,7 +39,7 @@ void *arch_debug_get_caller(void); int32 arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, int32 skipIframes, int32 skipFrames, uint32 flags); void* arch_debug_get_interrupt_pc(bool* _isSyscall); -bool arch_debug_contains_call(struct thread *thread, const char *symbol, +bool arch_debug_contains_call(Thread *thread, const char *symbol, addr_t start, addr_t end); void arch_debug_save_registers(struct arch_debug_registers* registers); void arch_debug_unset_current_thread(void); diff --git a/headers/private/kernel/arch/m68k/arch_cpu.h b/headers/private/kernel/arch/m68k/arch_cpu.h index cffda0fca1..ee6ad016a4 100644 --- a/headers/private/kernel/arch/m68k/arch_cpu.h +++ b/headers/private/kernel/arch/m68k/arch_cpu.h @@ -22,7 +22,7 @@ #ifndef _ASSEMBLER -/* 68k has many different possible stack frames, differentiated by a 4 bit number, +/* 68k has many different possible stack frames, differentiated by a 4 bit number, * but they also depend on the cpu type. * cf. mint/sys/arch/check_exc.h */ @@ -283,7 +283,7 @@ struct iframe { struct mc680x0_fp_control_regs fpc; /* fpu state */ struct mc680x0_fpu_state fpu; - + /* data and address registers */ uint32 d[8]; uint32 a[7]; @@ -517,7 +517,7 @@ extern int arch_machine; Use of (some) special purpose registers. XXX: those regs aren't implemented/accessed the same way on different cpus... - SRP[63-32]: current struct thread* + SRP[63-32]: current Thread* SRP[31-0] : CAAR : can we use it ?? MSP : @@ -526,7 +526,7 @@ extern int arch_machine; SPRG0: per CPU physical address pointer to an ppc_cpu_exception_context structure SPRG1: scratch - SPRG2: current struct thread* + SPRG2: current Thread* SPRG3: TLS base pointer (only for userland threads) */ diff --git a/headers/private/kernel/arch/m68k/arch_thread.h b/headers/private/kernel/arch/m68k/arch_thread.h index 1c14f672bc..8bffc0da69 100644 --- a/headers/private/kernel/arch/m68k/arch_thread.h +++ b/headers/private/kernel/arch/m68k/arch_thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -20,9 +20,9 @@ void m68k_pop_iframe(struct iframe_stack *stack); struct iframe *m68k_get_user_iframe(void); /* as we won't support SMP on m68k (yet?) we can use a global here */ -extern struct thread *gCurrentThread; +extern Thread *gCurrentThread; -extern inline struct thread * +extern inline Thread * arch_thread_get_current_thread(void) { return gCurrentThread; @@ -30,7 +30,7 @@ arch_thread_get_current_thread(void) extern inline void -arch_thread_set_current_thread(struct thread *t) +arch_thread_set_current_thread(Thread *t) { gCurrentThread = t; } @@ -38,17 +38,17 @@ arch_thread_set_current_thread(struct thread *t) #if 0 /* this would only work on 030... */ -extern inline struct thread * +extern inline Thread * arch_thread_get_current_thread(void) { uint64 v = 0; asm volatile("pmove %%srp,(%0)" : : "a"(&v)); - return (struct thread *)(uint32)(v & 0xffffffff); + return (Thread *)(uint32)(v & 0xffffffff); } extern inline void -arch_thread_set_current_thread(struct thread *t) +arch_thread_set_current_thread(Thread *t) { uint64 v; asm volatile("pmove %%srp,(%0)\n" \ diff --git a/headers/private/kernel/arch/mipsel/arch_thread.h b/headers/private/kernel/arch/mipsel/arch_thread.h index ae16ff84b2..49aac8ce27 100644 --- a/headers/private/kernel/arch/mipsel/arch_thread.h +++ b/headers/private/kernel/arch/mipsel/arch_thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2009, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -22,17 +22,17 @@ void mipsel_pop_iframe(struct iframe_stack* stack); struct iframe* mipsel_get_user_iframe(void); -static inline struct thread* +static inline Thread* arch_thread_get_current_thread(void) { #warning IMPLEMENT arch_thread_get_current_thread - struct thread* t; + Thread* t; return t; } static inline void -arch_thread_set_current_thread(struct thread* t) +arch_thread_set_current_thread(Thread* t) { #warning IMPLEMENT arch_thread_set_current_thread } diff --git a/headers/private/kernel/arch/ppc/arch_cpu.h b/headers/private/kernel/arch/ppc/arch_cpu.h index 7e8332b018..e65acbec64 100644 --- a/headers/private/kernel/arch/ppc/arch_cpu.h +++ b/headers/private/kernel/arch/ppc/arch_cpu.h @@ -206,7 +206,7 @@ enum ppc_processor_version { SPRG0: per CPU physical address pointer to an ppc_cpu_exception_context structure SPRG1: scratch - SPRG2: current struct thread* + SPRG2: current Thread* SPRG3: TLS base pointer (only for userland threads) */ diff --git a/headers/private/kernel/arch/ppc/arch_thread.h b/headers/private/kernel/arch/ppc/arch_thread.h index 93fc550be6..3ff5824326 100644 --- a/headers/private/kernel/arch/ppc/arch_thread.h +++ b/headers/private/kernel/arch/ppc/arch_thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -20,17 +20,17 @@ void ppc_pop_iframe(struct iframe_stack *stack); struct iframe *ppc_get_user_iframe(void); -static inline struct thread * +static inline Thread * arch_thread_get_current_thread(void) { - struct thread *t; + Thread *t; asm volatile("mfsprg2 %0" : "=r"(t)); return t; } static inline void -arch_thread_set_current_thread(struct thread *t) +arch_thread_set_current_thread(Thread *t) { asm volatile("mtsprg2 %0" : : "r"(t)); } diff --git a/headers/private/kernel/arch/thread.h b/headers/private/kernel/arch/thread.h index 174a61c629..6efad95dec 100644 --- a/headers/private/kernel/arch/thread.h +++ b/headers/private/kernel/arch/thread.h @@ -17,18 +17,18 @@ extern "C" { #endif status_t arch_thread_init(struct kernel_args *args); -status_t arch_team_init_team_struct(struct team *t, bool kernel); -status_t arch_thread_init_thread_struct(struct thread *t); -status_t arch_thread_init_tls(struct thread *thread); -void arch_thread_context_switch(struct thread *t_from, struct thread *t_to); -status_t arch_thread_init_kthread_stack(struct thread *t, +status_t arch_team_init_team_struct(Team *t, bool kernel); +status_t arch_thread_init_thread_struct(Thread *t); +status_t arch_thread_init_tls(Thread *thread); +void arch_thread_context_switch(Thread *t_from, Thread *t_to); +status_t arch_thread_init_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)); void arch_thread_dump_info(void *info); -status_t arch_thread_enter_userspace(struct thread *t, addr_t entry, +status_t arch_thread_enter_userspace(Thread *t, addr_t entry, void *args1, void *args2); -bool arch_on_signal_stack(struct thread *thread); -status_t arch_setup_signal_frame(struct thread *t, struct sigaction *sa, +bool arch_on_signal_stack(Thread *thread); +status_t arch_setup_signal_frame(Thread *t, struct sigaction *sa, int signal, int signalMask); int64 arch_restore_signal_frame(void); diff --git a/headers/private/kernel/arch/user_debugger.h b/headers/private/kernel/arch/user_debugger.h index 7ab43e1f8a..90240f76ab 100644 --- a/headers/private/kernel/arch/user_debugger.h +++ b/headers/private/kernel/arch/user_debugger.h @@ -1,10 +1,11 @@ /* - * Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef KERNEL_ARCH_USER_DEBUGGER_H #define KERNEL_ARCH_USER_DEBUGGER_H + #include "kernel_debug_config.h" #ifndef _ASSEMBLER @@ -17,7 +18,7 @@ extern "C" { struct arch_team_debug_info; struct arch_thread_debug_info; -struct thread; + void arch_clear_team_debug_info(struct arch_team_debug_info *info); void arch_destroy_team_debug_info(struct arch_team_debug_info *info); diff --git a/headers/private/kernel/arch/x86/arch_thread.h b/headers/private/kernel/arch/x86/arch_thread.h index 17bb54de30..648006b454 100644 --- a/headers/private/kernel/arch/x86/arch_thread.h +++ b/headers/private/kernel/arch/x86/arch_thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009, The Haiku Team. All rights reserved. + * Copyright 2002-2011, The Haiku Team. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2002, Travis Geiselbrecht. All rights reserved. @@ -18,9 +18,9 @@ extern "C" { struct iframe *i386_get_user_iframe(void); struct iframe *i386_get_current_iframe(void); -struct iframe *i386_get_thread_user_iframe(struct thread *thread); +struct iframe *i386_get_thread_user_iframe(Thread *thread); -uint32 x86_next_page_directory(struct thread *from, struct thread *to); +uint32 x86_next_page_directory(Thread *from, Thread *to); void x86_restart_syscall(struct iframe* frame); @@ -33,16 +33,16 @@ void arch_syscall_64_bit_return_value(void); static -inline struct thread * +inline Thread * arch_thread_get_current_thread(void) { - struct thread *t; + Thread *t; read_dr3(t); return t; } static inline void -arch_thread_set_current_thread(struct thread *t) +arch_thread_set_current_thread(Thread *t) { write_dr3(t); } diff --git a/headers/private/kernel/arch/x86/arch_user_debugger.h b/headers/private/kernel/arch/x86/arch_user_debugger.h index d5327cade2..1b72d9b2f6 100644 --- a/headers/private/kernel/arch/x86/arch_user_debugger.h +++ b/headers/private/kernel/arch/x86/arch_user_debugger.h @@ -1,14 +1,15 @@ /* - * Copyright 2005-2009, Ingo Weinhold, bonefish@users.sf.net. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_ARCH_X86_USER_DEBUGGER_H #define _KERNEL_ARCH_X86_USER_DEBUGGER_H + #define ARCH_INIT_USER_DEBUG x86_init_user_debug // number of breakpoints the CPU supports -// Actually it supports 4, but DR3 is used to hold the struct thread*. +// Actually it supports 4, but DR3 is used to hold the Thread*. #define X86_BREAKPOINT_COUNT 3 // debug status register DR6 @@ -116,7 +117,6 @@ extern "C" { #endif struct iframe; -struct thread; extern void x86_init_user_debug_at_kernel_exit(struct iframe *frame); extern void x86_exit_user_debug_at_kernel_entry(); @@ -137,4 +137,5 @@ extern void x86_init_user_debug(); #define DEBUG_SOFTWARE_BREAKPOINT_SIZE 1 #define DEBUG_SHARED_BREAK_AND_WATCHPOINTS 1 + #endif // _KERNEL_ARCH_X86_USER_DEBUGGER_H diff --git a/headers/private/kernel/condition_variable.h b/headers/private/kernel/condition_variable.h index 705191b742..f6dd46984c 100644 --- a/headers/private/kernel/condition_variable.h +++ b/headers/private/kernel/condition_variable.h @@ -1,5 +1,5 @@ /* - * Copyright 2007-2008, Ingo Weinhold, bonefish@cs.tu-berlin.de. + * Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_CONDITION_VARIABLE_H @@ -41,7 +41,7 @@ private: private: ConditionVariable* fVariable; - struct thread* fThread; + Thread* fThread; status_t fWaitStatus; friend struct ConditionVariable; diff --git a/headers/private/kernel/cpu.h b/headers/private/kernel/cpu.h index acb293e422..89cd96012e 100644 --- a/headers/private/kernel/cpu.h +++ b/headers/private/kernel/cpu.h @@ -23,7 +23,12 @@ struct kernel_args; -struct thread; + +namespace BKernel { + struct Thread; +} + +using BKernel::Thread; /* CPU local data structure */ @@ -45,7 +50,7 @@ typedef struct cpu_ent { addr_t fault_handler_stack_pointer; jmp_buf fault_jump_buffer; - struct thread* running_thread; + Thread* running_thread; bool invoke_scheduler; bool invoke_scheduler_if_idle; bool disabled; diff --git a/headers/private/kernel/debug.h b/headers/private/kernel/debug.h index 4d63d72013..051a62dbed 100644 --- a/headers/private/kernel/debug.h +++ b/headers/private/kernel/debug.h @@ -17,6 +17,22 @@ #include "kernel_debug_config.h" +// We need the BKernel::Thread type below (opaquely) in the exported C +// functions below. Since this header is currently still included by plain C +// code, we define a dummy type BKernel_Thread in C mode and a equally named +// macro in C++ mode. +#ifdef __cplusplus + namespace BKernel { + struct Thread; + } + + using BKernel::Thread; +# define BKernel_Thread Thread +#else + typedef struct BKernel_Thread BKernel_Thread; +#endif + + /* KDEBUG The kernel debug level. Level 1 is usual asserts, > 1 should be used for very expensive runtime @@ -180,8 +196,8 @@ extern status_t debug_get_next_demangled_argument(uint32* _cookie, const char* symbol, char* name, size_t nameSize, int32* _type, size_t* _argumentLength); -extern struct thread* debug_set_debugged_thread(struct thread* thread); -extern struct thread* debug_get_debugged_thread(); +extern BKernel_Thread* debug_set_debugged_thread(BKernel_Thread* thread); +extern BKernel_Thread* debug_get_debugged_thread(); extern bool debug_is_debugged_team(team_id teamID); extern struct arch_debug_registers* debug_get_debug_registers(int32 cpu); @@ -197,7 +213,7 @@ extern void _user_debug_output(const char *userString); #ifdef __cplusplus struct DebuggedThreadSetter { - DebuggedThreadSetter(struct thread* thread) + DebuggedThreadSetter(Thread* thread) : fPreviousThread(debug_set_debugged_thread(thread)) { @@ -209,7 +225,7 @@ struct DebuggedThreadSetter { } private: - struct thread* fPreviousThread; + Thread* fPreviousThread; }; diff --git a/headers/private/kernel/elf.h b/headers/private/kernel/elf.h index 6690b5e6a8..bb8e9e7cb9 100644 --- a/headers/private/kernel/elf.h +++ b/headers/private/kernel/elf.h @@ -20,7 +20,8 @@ struct kernel_args; extern "C" { #endif -status_t elf_load_user_image(const char *path, struct team *team, int flags, addr_t *_entry); +status_t elf_load_user_image(const char *path, Team *team, int flags, + addr_t *_entry); // these two might get public one day: image_id load_kernel_add_on(const char *path); @@ -29,7 +30,7 @@ status_t unload_kernel_add_on(image_id id); status_t elf_debug_lookup_symbol_address(addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch); -status_t elf_debug_lookup_user_symbol_address(struct team* team, addr_t address, +status_t elf_debug_lookup_user_symbol_address(Team* team, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch); addr_t elf_debug_lookup_symbol(const char* searchName); diff --git a/headers/private/kernel/kimage.h b/headers/private/kernel/kimage.h index 4cead2c245..adbc70a9d5 100644 --- a/headers/private/kernel/kimage.h +++ b/headers/private/kernel/kimage.h @@ -9,7 +9,13 @@ struct image; -struct team; + +namespace BKernel { + struct Team; +} + +using BKernel::Team; + #ifdef __cplusplus @@ -35,16 +41,16 @@ struct image { extern "C" { #endif -extern image_id register_image(struct team *team, image_info *info, size_t size); -extern status_t unregister_image(struct team *team, image_id id); -extern int32 count_images(struct team *team); -extern status_t remove_images(struct team *team); +extern image_id register_image(Team *team, image_info *info, size_t size); +extern status_t unregister_image(Team *team, image_id id); +extern int32 count_images(Team *team); +extern status_t remove_images(Team *team); typedef bool (*image_iterator_callback)(struct image* image, void* cookie); struct image* image_iterate_through_images(image_iterator_callback callback, void* cookie); -extern status_t image_debug_lookup_user_symbol_address(struct team *team, +extern status_t image_debug_lookup_user_symbol_address(Team *team, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch); extern status_t image_init(void); diff --git a/headers/private/kernel/kscheduler.h b/headers/private/kernel/kscheduler.h index 86cc0c68de..9e19b28fda 100644 --- a/headers/private/kernel/kscheduler.h +++ b/headers/private/kernel/kscheduler.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2005-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -14,25 +14,24 @@ struct scheduling_analysis; -struct thread; struct SchedulerListener; struct scheduler_ops { - void (*enqueue_in_run_queue)(struct thread* thread); + void (*enqueue_in_run_queue)(Thread* thread); void (*reschedule)(void); - void (*set_thread_priority)(struct thread* thread, int32 priority); - bigtime_t (*estimate_max_scheduling_latency)(struct thread* thread); + void (*set_thread_priority)(Thread* thread, int32 priority); + bigtime_t (*estimate_max_scheduling_latency)(Thread* thread); - void (*on_thread_create)(struct thread* thread); + void (*on_thread_create)(Thread* thread); // called when the thread structure is first created - // initialization of per-thread housekeeping data structures should // be done here - void (*on_thread_init)(struct thread* thread); + void (*on_thread_init)(Thread* thread); // called when a thread structure is initialized and made ready for // use - should be used to reset the housekeeping data structures // if needed - void (*on_thread_destroy)(struct thread* thread); + void (*on_thread_destroy)(Thread* thread); // called when a thread structure is freed - freeing up any allocated // mem on the scheduler's part should be done here diff --git a/headers/private/kernel/ksignal.h b/headers/private/kernel/ksignal.h index 72e071c420..088f3bb70d 100644 --- a/headers/private/kernel/ksignal.h +++ b/headers/private/kernel/ksignal.h @@ -10,6 +10,13 @@ #include +namespace BKernel { + struct Thread; +} + +using BKernel::Thread; + + #define KILL_SIGNALS ((1L << (SIGKILL - 1)) | (1L << (SIGKILLTHR - 1))) #define SIGNAL_TO_MASK(signal) (1LL << (signal - 1)) @@ -24,7 +31,7 @@ extern "C" { #endif -extern bool handle_signals(struct thread *thread); +extern bool handle_signals(Thread *thread); extern bool is_kill_signal_pending(void); extern int has_signals_pending(void *_thread); extern bool is_signal_blocked(int signal); diff --git a/headers/private/kernel/listeners.h b/headers/private/kernel/listeners.h index b9026155b6..64bb94d3d1 100644 --- a/headers/private/kernel/listeners.h +++ b/headers/private/kernel/listeners.h @@ -1,10 +1,11 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef KERNEL_LISTENERS_H #define KERNEL_LISTENERS_H + #include #include @@ -14,7 +15,6 @@ struct ConditionVariable; struct mutex; struct rw_lock; -struct thread; // scheduler listeners @@ -24,11 +24,11 @@ struct SchedulerListener : DoublyLinkedListLinkImpl { virtual ~SchedulerListener(); virtual void ThreadEnqueuedInRunQueue( - struct thread* thread) = 0; + Thread* thread) = 0; virtual void ThreadRemovedFromRunQueue( - struct thread* thread) = 0; - virtual void ThreadScheduled(struct thread* oldThread, - struct thread* newThread) = 0; + Thread* thread) = 0; + virtual void ThreadScheduled(Thread* oldThread, + Thread* newThread) = 0; }; diff --git a/headers/private/kernel/port.h b/headers/private/kernel/port.h index 9c4d22aaa2..3237ea59aa 100644 --- a/headers/private/kernel/port.h +++ b/headers/private/kernel/port.h @@ -32,7 +32,7 @@ extern "C" { #endif status_t port_init(struct kernel_args *args); -void delete_owned_ports(struct team* team); +void delete_owned_ports(Team* team); int32 port_max_ports(void); int32 port_used_ports(void); diff --git a/headers/private/kernel/posix/xsi_semaphore.h b/headers/private/kernel/posix/xsi_semaphore.h index 1a6e66ff52..6c38d5864c 100644 --- a/headers/private/kernel/posix/xsi_semaphore.h +++ b/headers/private/kernel/posix/xsi_semaphore.h @@ -14,10 +14,17 @@ #include +namespace BKernel { + struct Team; +} + +using BKernel::Team; + + __BEGIN_DECLS extern void xsi_sem_init(); -extern void xsi_sem_undo(struct team *team); +extern void xsi_sem_undo(Team *team); /* user calls */ int _user_xsi_semget(key_t key, int numberOfSemaphores, int flags); diff --git a/headers/private/kernel/sem.h b/headers/private/kernel/sem.h index 5efd572938..1808764060 100644 --- a/headers/private/kernel/sem.h +++ b/headers/private/kernel/sem.h @@ -22,7 +22,7 @@ extern "C" { #endif extern status_t haiku_sem_init(struct kernel_args *args); -extern void sem_delete_owned_sems(struct team* team); +extern void sem_delete_owned_sems(Team* team); extern int32 sem_used_sems(void); extern int32 sem_max_sems(void); diff --git a/headers/private/kernel/syscall_restart.h b/headers/private/kernel/syscall_restart.h index fb41f6354d..708f9d3373 100644 --- a/headers/private/kernel/syscall_restart.h +++ b/headers/private/kernel/syscall_restart.h @@ -1,10 +1,11 @@ /* - * Copyright 2008, Haiku Inc. All rights reserved. + * Copyright 2008-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _KERNEL_SYSCALL_RESTART_H #define _KERNEL_SYSCALL_RESTART_H + #include #include @@ -20,7 +21,7 @@ syscall_restart_handle_timeout_pre(bigtime_t& timeout) { // If restarted, get the timeout from the restart parameters. Otherwise // convert relative timeout to an absolute one. - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) timeout = *(bigtime_t*)thread->syscall_restart.parameters; else if (timeout >= 0) { @@ -44,7 +45,7 @@ syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout) // convert relative timeout to an absolute one. Note that we preserve // relative 0 us timeouts, so that the syscall can still decide whether to // return B_WOULD_BLOCK instead of B_TIMED_OUT. - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) { timeout = *(bigtime_t*)thread->syscall_restart.parameters; if (timeout > 0 && (flags & B_RELATIVE_TIMEOUT) != 0) @@ -67,7 +68,7 @@ syscall_restart_handle_timeout_post(status_t error, bigtime_t timeout) { if (error == B_INTERRUPTED) { // interrupted -- store timeout and set flag for syscall restart - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); *(bigtime_t*)thread->syscall_restart.parameters = timeout; atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL); } @@ -81,7 +82,7 @@ syscall_restart_handle_post(status_t error) { if (error == B_INTERRUPTED) { // interrupted -- set flag for syscall restart - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL); } @@ -92,7 +93,7 @@ syscall_restart_handle_post(status_t error) static inline bool syscall_restart_is_restarted() { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); return (thread->flags & THREAD_FLAGS_SYSCALL) != 0 && (thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0; @@ -114,8 +115,8 @@ struct SyscallFlagUnsetter { } private: - struct thread* fThread; - bool fWasSyscall; + Thread* fThread; + bool fWasSyscall; }; @@ -147,8 +148,8 @@ struct SyscallRestartWrapper { operator Type() const { return fResult; } private: - Type fResult; - struct thread* fThread; + Type fResult; + Thread* fThread; }; diff --git a/headers/private/kernel/team.h b/headers/private/kernel/team.h index e33166ac72..b15e99ed27 100644 --- a/headers/private/kernel/team.h +++ b/headers/private/kernel/team.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2009, Haiku Inc. All Rights Reserved. + * Copyright 2004-2011, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. */ #ifndef _TEAM_H @@ -22,34 +22,34 @@ extern "C" { status_t team_init(struct kernel_args *args); status_t wait_for_team(team_id id, status_t *returnCode); -void team_remove_team(struct team *team); -port_id team_shutdown_team(struct team *team, cpu_status& state); -void team_delete_team(struct team *team, port_id debuggerPort); +void team_remove_team(Team *team); +port_id team_shutdown_team(Team *team, cpu_status& state); +void team_delete_team(Team *team, port_id debuggerPort); struct process_group *team_get_process_group_locked( struct process_session *session, pid_t id); void team_delete_process_group(struct process_group *group); -struct team *team_get_kernel_team(void); +Team *team_get_kernel_team(void); team_id team_get_kernel_team_id(void); team_id team_get_current_team_id(void); status_t team_get_address_space(team_id id, struct VMAddressSpace **_addressSpace); char **user_team_get_arguments(void); int user_team_get_arg_count(void); -struct job_control_entry* team_get_death_entry(struct team *team, +struct job_control_entry* team_get_death_entry(Team *team, thread_id child, bool* _deleteEntry); bool team_is_valid(team_id id); -struct team *team_get_team_struct_locked(team_id id); +Team *team_get_team_struct_locked(team_id id); int32 team_max_teams(void); int32 team_used_teams(void); -typedef bool (*team_iterator_callback)(struct team* team, void* cookie); -struct team* team_iterate_through_teams(team_iterator_callback callback, +typedef bool (*team_iterator_callback)(Team* team, void* cookie); +Team* team_iterate_through_teams(team_iterator_callback callback, void* cookie); thread_id load_image_etc(int32 argCount, const char* const* args, const char* const* env, int32 priority, team_id parentID, uint32 flags); -void team_set_job_control_state(struct team* team, job_control_state newState, +void team_set_job_control_state(Team* team, job_control_state newState, int signal, bool threadsLocked); void team_set_controlling_tty(int32 index); int32 team_get_controlling_tty(); @@ -60,8 +60,8 @@ status_t start_watching_team(team_id team, void (*hook)(team_id, void *), status_t stop_watching_team(team_id team, void (*hook)(team_id, void *), void *data); -struct user_thread* team_allocate_user_thread(struct team* team); -void team_free_user_thread(struct thread* thread); +struct user_thread* team_allocate_user_thread(Team* team); +void team_free_user_thread(Thread* thread); bool team_associate_data(AssociatedData* data); bool team_dissociate_data(AssociatedData* data); diff --git a/headers/private/kernel/thread.h b/headers/private/kernel/thread.h index 501c60c2b7..7991f43119 100644 --- a/headers/private/kernel/thread.h +++ b/headers/private/kernel/thread.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -35,10 +35,10 @@ struct thread_creation_attributes; extern "C" { #endif -void thread_enqueue(struct thread *t, struct thread_queue *q); -struct thread *thread_lookat_queue(struct thread_queue *q); -struct thread *thread_dequeue(struct thread_queue *q); -struct thread *thread_dequeue_id(struct thread_queue *q, thread_id id); +void thread_enqueue(Thread *t, struct thread_queue *q); +Thread *thread_lookat_queue(struct thread_queue *q); +Thread *thread_dequeue(struct thread_queue *q); +Thread *thread_dequeue_id(struct thread_queue *q, thread_id id); void thread_at_kernel_entry(bigtime_t now); // called when the thread enters the kernel on behalf of the thread @@ -54,32 +54,32 @@ void thread_exit(void); int32 thread_max_threads(void); int32 thread_used_threads(void); -const char* thread_state_to_text(struct thread* thread, int32 state); +const char* thread_state_to_text(Thread* thread, int32 state); int32 thread_get_io_priority(thread_id id); void thread_set_io_priority(int32 priority); #define thread_get_current_thread arch_thread_get_current_thread -struct thread *thread_get_thread_struct(thread_id id); -struct thread *thread_get_thread_struct_locked(thread_id id); +Thread *thread_get_thread_struct(thread_id id); +Thread *thread_get_thread_struct_locked(thread_id id); static thread_id thread_get_current_thread_id(void); static inline thread_id thread_get_current_thread_id(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); return thread ? thread->id : 0; } static inline bool -thread_is_idle_thread(struct thread *thread) +thread_is_idle_thread(Thread *thread) { return thread->entry == NULL; } -typedef bool (*thread_iterator_callback)(struct thread* thread, void* cookie); -struct thread* thread_iterate_through_threads(thread_iterator_callback callback, +typedef bool (*thread_iterator_callback)(Thread* thread, void* cookie); +Thread* thread_iterate_through_threads(thread_iterator_callback callback, void* cookie); thread_id allocate_thread_id(void); @@ -140,7 +140,7 @@ int _user_setrlimit(int resource, const struct rlimit * rlp); Thread lock can be, but doesn't need to be held. */ static inline bool -thread_is_interrupted(struct thread* thread, uint32 flags) +thread_is_interrupted(Thread* thread, uint32 flags) { return ((flags & B_CAN_INTERRUPT) && (thread->sig_pending & ~thread->sig_block_mask) != 0) @@ -150,7 +150,7 @@ thread_is_interrupted(struct thread* thread, uint32 flags) static inline bool -thread_is_blocked(struct thread* thread) +thread_is_blocked(Thread* thread) { return thread->wait.status == 1; } @@ -161,7 +161,7 @@ thread_is_blocked(struct thread* thread) Thread lock can be, but doesn't need to be locked. */ static inline void -thread_prepare_to_block(struct thread* thread, uint32 flags, uint32 type, +thread_prepare_to_block(Thread* thread, uint32 flags, uint32 type, const void* object) { thread->wait.flags = flags; @@ -174,7 +174,7 @@ thread_prepare_to_block(struct thread* thread, uint32 flags, uint32 type, static inline status_t -thread_block_locked(struct thread* thread) +thread_block_locked(Thread* thread) { if (thread->wait.status == 1) { // check for signals, if interruptable @@ -191,7 +191,7 @@ thread_block_locked(struct thread* thread) static inline void -thread_unblock_locked(struct thread* thread, status_t status) +thread_unblock_locked(Thread* thread, status_t status) { if (atomic_test_and_set(&thread->wait.status, status, 1) != 1) return; @@ -203,7 +203,7 @@ thread_unblock_locked(struct thread* thread, status_t status) static inline status_t -thread_interrupt(struct thread* thread, bool kill) +thread_interrupt(Thread* thread, bool kill) { if ((thread->wait.flags & B_CAN_INTERRUPT) != 0 || (kill && (thread->wait.flags & B_KILL_CAN_INTERRUPT) != 0)) { @@ -216,14 +216,14 @@ thread_interrupt(struct thread* thread, bool kill) static inline void -thread_pin_to_current_cpu(struct thread* thread) +thread_pin_to_current_cpu(Thread* thread) { thread->pinned_to_cpu++; } static inline void -thread_unpin_from_current_cpu(struct thread* thread) +thread_unpin_from_current_cpu(Thread* thread) { thread->pinned_to_cpu--; } diff --git a/headers/private/kernel/thread_types.h b/headers/private/kernel/thread_types.h index 34c2f9c852..2097c1fe22 100644 --- a/headers/private/kernel/thread_types.h +++ b/headers/private/kernel/thread_types.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2010, Haiku Inc. + * Copyright 2004-2011, Haiku, Inc. * Distributed under the terms of the MIT License. * * Thread definition and structures @@ -58,14 +58,22 @@ typedef enum job_control_state { } job_control_state; +struct cpu_ent; struct image; // defined in image.c struct io_context; struct realtime_sem_context; // defined in realtime_sem.cpp struct scheduler_thread_data; struct select_info; struct user_thread; // defined in libroot/user_thread.h +struct VMAddressSpace; struct xsi_sem_context; // defined in xsi_semaphore.cpp +namespace BKernel { + struct Team; + struct Thread; +} + + struct death_entry { struct list_link link; pid_t group_id; @@ -88,12 +96,12 @@ struct process_group { struct process_session *session; pid_t id; int32 refs; - struct team *teams; + BKernel::Team *teams; bool orphaned; }; struct team_loading_info { - struct thread *thread; // the waiting thread + Thread* thread; // the waiting thread status_t result; // the result of the loading bool done; // set when loading is done/aborted }; @@ -117,7 +125,7 @@ struct job_control_entry : DoublyLinkedListLinkImpl { bool has_group_ref; // valid while state != JOB_CONTROL_STATE_DEAD - struct team* team; + BKernel::Team* team; // valid when state == JOB_CONTROL_STATE_DEAD pid_t group_id; @@ -199,12 +207,20 @@ private: }; -struct team : AssociatedDataOwner { - struct team *next; // next in hash - struct team *siblings_next; - struct team *parent; - struct team *children; - struct team *group_next; +typedef int32 (*thread_entry_func)(thread_func, void *); + +typedef bool (*page_fault_callback)(addr_t address, addr_t faultAddress, + bool isWrite); + + +namespace BKernel { + +struct Team : AssociatedDataOwner { + Team *next; // next in hash + Team *siblings_next; + Team *parent; + Team *children; + Team *group_next; team_id id; pid_t group_id; pid_t session_id; @@ -221,16 +237,14 @@ struct team : AssociatedDataOwner { struct list dead_threads; int dead_threads_count; - // TODO: Remove the no longer necessary level of indirection for the - // following members. - team_dead_children *dead_children; - team_job_control_children *stopped_children; - team_job_control_children *continued_children; + team_dead_children dead_children; + team_job_control_children stopped_children; + team_job_control_children continued_children; struct job_control_entry* job_control_entry; - struct VMAddressSpace *address_space; - struct thread *main_thread; - struct thread *thread_list; + VMAddressSpace *address_space; + Thread *main_thread; + Thread *thread_list; struct team_loading_info *loading_info; struct list image_list; struct list watcher_list; @@ -259,18 +273,14 @@ struct team : AssociatedDataOwner { int supplementary_group_count; }; -typedef int32 (*thread_entry_func)(thread_func, void *); -typedef bool (*page_fault_callback)(addr_t address, addr_t faultAddress, - bool isWrite); - -struct thread { +struct Thread { int32 flags; // summary of events relevant in interrupt // handlers (signals pending, user debugging // enabled, etc.) - struct thread *all_next; - struct thread *team_next; - struct thread *queue_next; /* i.e. run queue, release queue, etc. */ + Thread *all_next; + Thread *team_next; + Thread *queue_next; /* i.e. run queue, release queue, etc. */ timer alarm; thread_id id; char name[B_OS_NAME_LENGTH]; @@ -332,7 +342,7 @@ struct thread { thread_entry_func entry; void *args1, *args2; - struct team *team; + BKernel::Team *team; struct { sem_id sem; @@ -370,9 +380,15 @@ struct thread { struct arch_thread arch_info; }; +} // namespace BKernel + +using BKernel::Team; +using BKernel::Thread; + + struct thread_queue { - struct thread *head; - struct thread *tail; + Thread* head; + Thread* tail; }; diff --git a/headers/private/kernel/tracing.h b/headers/private/kernel/tracing.h index c965f5d365..71a8b30d65 100644 --- a/headers/private/kernel/tracing.h +++ b/headers/private/kernel/tracing.h @@ -100,9 +100,9 @@ class AbstractTraceEntry : public TraceEntry { virtual void AddDump(TraceOutput& out); - thread_id Thread() const { return fThread; } - thread_id Team() const { return fTeam; } - bigtime_t Time() const { return fTime; } + thread_id ThreadID() const { return fThread; } + thread_id TeamID() const { return fTeam; } + bigtime_t Time() const { return fTime; } protected: thread_id fThread; diff --git a/headers/private/kernel/user_debugger.h b/headers/private/kernel/user_debugger.h index 43d5e9d977..cf9252271c 100644 --- a/headers/private/kernel/user_debugger.h +++ b/headers/private/kernel/user_debugger.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. * * Userland debugger support. @@ -24,7 +24,13 @@ struct BreakpointManager; struct ConditionVariable; struct function_profile_info; -struct thread; + +namespace BKernel { + struct Thread; +} + +using BKernel::Thread; + // Team related debugging data. // @@ -235,15 +241,15 @@ void user_debug_team_exec(); void user_debug_update_new_thread_flags(thread_id threadID); void user_debug_thread_created(thread_id threadID); void user_debug_thread_deleted(team_id teamID, thread_id threadID); -void user_debug_thread_exiting(struct thread* thread); +void user_debug_thread_exiting(Thread* thread); void user_debug_image_created(const image_info *imageInfo); void user_debug_image_deleted(const image_info *imageInfo); void user_debug_breakpoint_hit(bool software); void user_debug_watchpoint_hit(); void user_debug_single_stepped(); -void user_debug_thread_unscheduled(struct thread* thread); -void user_debug_thread_scheduled(struct thread* thread); +void user_debug_thread_unscheduled(Thread* thread); +void user_debug_thread_scheduled(Thread* thread); // syscalls diff --git a/headers/private/kernel/usergroup.h b/headers/private/kernel/usergroup.h index 5a6152b050..5ddbdb8d20 100644 --- a/headers/private/kernel/usergroup.h +++ b/headers/private/kernel/usergroup.h @@ -5,12 +5,17 @@ #ifndef _KERNEL_USERGROUP_H #define _KERNEL_USERGROUP_H + #include #include -struct team; +namespace BKernel { + struct Team; +} + +using BKernel::Team; #ifdef __cplusplus @@ -19,11 +24,9 @@ extern "C" { // kernel private functions -void inherit_parent_user_and_group(struct team* team, - struct team* parent); -void inherit_parent_user_and_group_locked(struct team* team, - struct team* parent); -status_t update_set_id_user_and_group(struct team* team, const char* file); +void inherit_parent_user_and_group(Team* team, Team* parent); +void inherit_parent_user_and_group_locked(Team* team, Team* parent); +status_t update_set_id_user_and_group(Team* team, const char* file); // syscalls diff --git a/headers/private/kernel/util/AutoLock.h b/headers/private/kernel/util/AutoLock.h index 5eedfb2df2..07b091493f 100644 --- a/headers/private/kernel/util/AutoLock.h +++ b/headers/private/kernel/util/AutoLock.h @@ -1,6 +1,6 @@ /* * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de. - * Copyright 2005-2007, Ingo Weinhold, bonefish@users.sf.net. All rights reserved. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * * Distributed under the terms of the MIT License. */ @@ -162,19 +162,19 @@ typedef AutoLocker InterruptsSpinLocker; class ThreadCPUPinLocking { public: - inline bool Lock(struct thread* thread) + inline bool Lock(Thread* thread) { thread_pin_to_current_cpu(thread); return true; } - inline void Unlock(struct thread* thread) + inline void Unlock(Thread* thread) { thread_unpin_from_current_cpu(thread); } }; -typedef AutoLocker ThreadCPUPinner; +typedef AutoLocker ThreadCPUPinner; } // namespace BPrivate diff --git a/headers/private/kernel/util/OpenHashTable.h b/headers/private/kernel/util/OpenHashTable.h index 63fe7bd0c3..be711c4ac8 100644 --- a/headers/private/kernel/util/OpenHashTable.h +++ b/headers/private/kernel/util/OpenHashTable.h @@ -401,7 +401,7 @@ protected: return true; } - void _Resize(ValueType** newTable, size_t newSize, void** oldTable = NULL) + void _Resize(ValueType** newTable, size_t newSize, void** _oldTable = NULL) { for (size_t i = 0; i < newSize; i++) newTable[i] = NULL; @@ -416,11 +416,12 @@ protected: } } - if (oldTable != NULL) - *oldTable = fTable; + if (_oldTable != NULL) + *_oldTable = fTable; else fAllocator.Free(fTable); - } + } else if (_oldTable != NULL) + *_oldTable = NULL; fTableSize = newSize; fTable = newTable; diff --git a/headers/private/kernel/vm/vm.h b/headers/private/kernel/vm/vm.h index 00c9f406eb..86cbbbd53f 100644 --- a/headers/private/kernel/vm/vm.h +++ b/headers/private/kernel/vm/vm.h @@ -19,7 +19,6 @@ struct generic_io_vec; struct kernel_args; struct ObjectCache; struct system_memory_info; -struct team; struct VMAddressSpace; struct VMArea; struct VMCache; diff --git a/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h b/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h index 0790f394a1..a761398517 100644 --- a/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h +++ b/src/add-ons/kernel/bus_managers/acpi/include/platform/achaiku.h @@ -120,10 +120,10 @@ #include "acgcc.h" -#include +#include -#include "lock.h" +struct mutex; /* Host-dependent types and defines for user- and kernel-space ACPICA */ @@ -132,7 +132,7 @@ #define ACPI_USE_STANDARD_HEADERS #define ACPI_MUTEX_TYPE ACPI_OSL_MUTEX -#define ACPI_MUTEX mutex * +#define ACPI_MUTEX struct mutex * #define ACPI_USE_NATIVE_DIVIDE diff --git a/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp b/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp index 09cc5da048..8ff706023d 100644 --- a/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp +++ b/src/add-ons/kernel/bus_managers/ata/ATAChannel.cpp @@ -1000,7 +1000,7 @@ ATAChannel::_TransferPIOPhysical(ATARequest *request, addr_t physicalAddress, // we must split up chunk into B_PAGE_SIZE blocks as we can map only // one page into address space at once while (length > 0) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); thread_pin_to_current_cpu(thread); void *handle; diff --git a/src/add-ons/kernel/bus_managers/firewire/Jamfile b/src/add-ons/kernel/bus_managers/firewire/Jamfile index d81261f489..a5f6b5d145 100644 --- a/src/add-ons/kernel/bus_managers/firewire/Jamfile +++ b/src/add-ons/kernel/bus_managers/firewire/Jamfile @@ -3,20 +3,20 @@ SubDir HAIKU_TOP src add-ons kernel bus_managers firewire ; UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ; UsePrivateHeaders firewire kernel ; -SubDirCcFlags [ FDefines _KERNEL=1 ] ; +DEFINES += _KERNEL=1 ; KernelAddon firewire : util.c - timer.c - firewire_module.c - firewire.c - fwdma.c - fwmem.c - fwohci.c - fwohci_pci.c + timer.cpp + firewire_module.cpp + firewire.cpp + fwdma.cpp + fwmem.cpp + fwohci.cpp + fwohci_pci.cpp fwcrom.c ; SEARCH on [ FGristFiles - fwcrom.c + fwcrom.c ] = [ FDirName $(HAIKU_TOP) src bin fwcontrol ] ; diff --git a/src/add-ons/kernel/bus_managers/firewire/firewire.c b/src/add-ons/kernel/bus_managers/firewire/firewire.cpp similarity index 96% rename from src/add-ons/kernel/bus_managers/firewire/firewire.c rename to src/add-ons/kernel/bus_managers/firewire/firewire.cpp index 799b5ea853..af0fd2333e 100644 --- a/src/add-ons/kernel/bus_managers/firewire/firewire.c +++ b/src/add-ons/kernel/bus_managers/firewire/firewire.cpp @@ -30,7 +30,7 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * $FreeBSD: src/sys/dev/firewire/firewire.c,v 1.100 2007/07/20 03:42:57 simokawa Exp $ * */ @@ -76,15 +76,16 @@ static int32 fw_bus_probe_thread(void *); static void fw_vmaccess (struct fw_xfer *); #endif static int fw_bmr (struct firewire_comm *); -static void fw_dump_hdr(struct fw_pkt *, char *); +static void fw_dump_hdr(struct fw_pkt *, const char *); -char *linkspeed[] = { +extern const char *const linkspeed[]; +const char *const linkspeed[] = { "S100", "S200", "S400", "S800", "S1600", "S3200", "undef", "undef" }; -static char *tcode_str[] = { +static const char *const tcode_str[] = { "WREQQ", "WREQB", "WRES", "undef", "RREQQ", "RREQB", "RRESQ", "RRESB", "CYCS", "LREQ", "STREAM", "LRES", @@ -192,7 +193,7 @@ fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) if (len != xfer->send.pay_len){ printf("len(%d) != send.pay_len(%d) %s(%x)\n", len, xfer->send.pay_len, tcode_str[tcode], tcode); - return EINVAL; + return EINVAL; } if(xferq->start == NULL){ @@ -325,7 +326,7 @@ firewire_xfer_timeout(void *arg) fc->timeout(fc); STAILQ_FOREACH_SAFE(xfer, &xfer_timeout, tlabel, txfer) - xfer->hand(xfer); + xfer->hand(xfer); } #define WATCHDOG_HZ 10 @@ -354,7 +355,7 @@ firewire_watchdog(void *arg) #if 0//to do status_t -firewire_add_child(struct firewire_softc *sc, const char *childname, +firewire_add_child(struct firewire_softc *sc, const char *childname, struct firewire_notify_hooks *hooks) { struct firewire_child_info *element, *info; @@ -408,7 +409,7 @@ firewire_remove_child(struct firewire_softc *sc, const char *childname) sc->fc->childList = NULL;//childList has only a node else temp->link = element->link; - + free(element); return B_OK; } @@ -428,7 +429,7 @@ int firewire_attach(struct firewire_comm *fc, struct firewire_softc *sc) { sc->fc = fc; - fc->status = FWBUSNOTREADY; + fc->status = (uint)FWBUSNOTREADY; // unit = device_get_unit(dev); if( fc->nisodma > FWMAXNDMA) fc->nisodma = FWMAXNDMA; @@ -469,13 +470,13 @@ firewire_attach(struct firewire_comm *fc, struct firewire_softc *sc) // callout_reset(&sc->fc->timeout_callout, hz, // (void *)firewire_watchdog, (void *)sc->fc); - fc->timeout_callout = create_timer(firewire_watchdog, fc, + fc->timeout_callout = create_timer(firewire_watchdog, fc, hz/WATCHDOG_HZ, B_PERIODIC_TIMER); /* create thread */ // kproc_create(fw_bus_probe_thread, (void *)fc, &fc->probe_thread, // 0, 0, "fw%d_probe", unit); - fc->probe_thread = spawn_kernel_thread(fw_bus_probe_thread, + fc->probe_thread = spawn_kernel_thread(fw_bus_probe_thread, "fw_probe", PROBE_THREAD_PRIORITY, fc); if(fc->probe_thread < B_OK) dprintf("can not Create bus probe thread\n"); @@ -494,7 +495,7 @@ firewire_attach(struct firewire_comm *fc, struct firewire_softc *sc) /* bus_reset */ FW_GLOCK(fc); - fw_busreset(fc, FWBUSNOTREADY); + fw_busreset(fc, (uint)FWBUSNOTREADY); FW_GUNLOCK(fc); fc->ibr(fc); @@ -514,7 +515,7 @@ firewire_detach(struct firewire_softc *sc) fc = sc->fc; mtx_lock(&fc->wait_lock); - fc->status = FWBUSDETACH; + fc->status = (uint)FWBUSDETACH; // wakeup(fc); release_sem(fc->Sem); /* if (msleep(fc->probe_thread, &fc->wait_lock, PWAIT, "fwthr", hz * 60)) @@ -614,7 +615,7 @@ fw_drain_txq(struct firewire_comm *fc) mtx_unlock(&fc->tlabel_lock); STAILQ_FOREACH_SAFE(xfer, &xfer_drain, tlabel, txfer) - xfer->hand(xfer); + xfer->hand(xfer); } static void @@ -628,9 +629,9 @@ fw_reset_csr(struct firewire_comm *fc) CSRARC(fc, NODE_IDS) = 0x3f; CSRARC(fc, TOPO_MAP + 8) = 0; - fc->irm = -1; + fc->irm = (uint)-1; - fc->max_node = -1; + fc->max_node = (uint)-1; for(i = 2; i < 0x100/4 - 2 ; i++){ CSRARC(fc, SPED_MAP + i * 4) = 0; @@ -655,8 +656,8 @@ fw_reset_csr(struct firewire_comm *fc) CSRARC(fc, CONF_ROM + 0xc) = 0; /* DV depend CSRs see blue book */ - CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; - CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; + CSRARC(fc, oPCR) &= ~DV_BROADCAST_ON; + CSRARC(fc, iPCR) &= ~DV_BROADCAST_ON; CSRARC(fc, STATE_CLEAR) &= ~(1 << 23 | 1 << 15 | 1 << 14 ); CSRARC(fc, STATE_SET) = CSRARC(fc, STATE_CLEAR); @@ -714,7 +715,7 @@ fw_reset_crom(struct firewire_comm *fc) crom_add_entry(root, CSRKEY_NCAP, 0x0083c0); /* XXX */ /* private company_id */ crom_add_entry(root, CSRKEY_VENDOR, CSRVAL_VENDOR_PRIVATE); -#if 0 +#if 0 #ifdef __DragonFly__ crom_add_simple_text(src, root, &buf->vendor, "DragonFly Project"); crom_add_entry(root, CSRKEY_HW, __DragonFly_cc_version); @@ -747,13 +748,13 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status) delete_timer(fc->bmr_callout); fc->status = new_status; fw_reset_csr(fc); - - if (fc->status == FWBUSNOTREADY) + + if ((int32)fc->status == FWBUSNOTREADY) fw_init_crom(fc); fw_reset_crom(fc); - + /* if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { for( i = 0 ; i < devcnt ; i++) if (device_get_state(devlistp[i]) >= DS_ATTACHED) { @@ -763,7 +764,7 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status) } free(devlistp); }*/ - + while(element){ // fdc = &element->cookie.fd; fdc = (struct firewire_dev_comm *)element->cookie; @@ -775,20 +776,20 @@ fw_busreset(struct firewire_comm *fc, uint32_t new_status) src = &fc->crom_src_buf->src; /* * If the old config rom needs to be overwritten, - * bump the businfo.generation indicator to + * bump the businfo.generation indicator to * indicate that we need to be reprobed * See 1394a-2000 8.3.2.5.4 for more details. * generation starts at 2 and rolls over at 0xF * back to 2. - * + * * A generation of 0 indicates a device * that is not 1394a-2000 compliant. * A generation of 1 indicates a device that - * does not change it's Bus Info Block or + * does not change it's Bus Info Block or * Configuration ROM. */ #define FW_MAX_GENERATION 0xF - newrom = malloc(CROMSIZE); + newrom = (uint32_t*)malloc(CROMSIZE); memset(newrom, 0, CROMSIZE); src = &fc->crom_src_buf->src; crom_load(src, newrom, CROMSIZE); @@ -827,7 +828,7 @@ void fw_init(struct firewire_comm *fc) STAILQ_INIT(&fc->atq->q); STAILQ_INIT(&fc->ats->q); - + fc->Sem = create_sem(0, "fc Sem"); for( i = 0 ; i < fc->nisodma ; i ++ ){ @@ -845,7 +846,7 @@ void fw_init(struct firewire_comm *fc) STAILQ_INIT(&fc->it[i]->q); STAILQ_INIT(&fc->ir[i]->q); - + snprintf(tempname, sizeof(tempname), "it%d ready sem", i); fc->it[i]->Sem = create_sem(0, tempname); snprintf(tempname, sizeof(tempname), "ir%d ready sem", i); @@ -879,13 +880,13 @@ void fw_init(struct firewire_comm *fc) CSRARC(fc, oMPR) = 0x3fff0001; /* # output channel = 1 */ CSRARC(fc, oPCR) = 0x8000007a; for(i = 4 ; i < 0x7c/4 ; i+=4){ - CSRARC(fc, i + oPCR) = 0x8000007a; + CSRARC(fc, i + oPCR) = 0x8000007a; } - + CSRARC(fc, iMPR) = 0x00ff0001; /* # input channel = 1 */ CSRARC(fc, iPCR) = 0x803f0000; for(i = 4 ; i < 0x7c/4 ; i+=4){ - CSRARC(fc, i + iPCR) = 0x0; + CSRARC(fc, i + iPCR) = 0x0; } #endif @@ -1018,7 +1019,7 @@ fw_xferlist_add(struct fw_xferlist *q, int slen, int rlen, int n, if (xfer == NULL) return (n); xfer->fc = fc; - xfer->sc = sc; + xfer->sc = (caddr_t)sc; xfer->hand = hand; s = splfw(); STAILQ_INSERT_TAIL(q, xfer, link); @@ -1042,7 +1043,7 @@ fw_xferlist_remove(struct fw_xferlist *q) * dump packet header */ static void -fw_dump_hdr(struct fw_pkt *fp, char *prefix) +fw_dump_hdr(struct fw_pkt *fp, const char *prefix) { printf("%s: dst=0x%02x tl=0x%02x rt=%d tcode=0x%x pri=0x%x " "src=0x%03x\n", prefix, @@ -1103,7 +1104,7 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) mtx_lock(&fc->tlabel_lock); STAILQ_FOREACH(xfer, &fc->tlabels[tlabel], tlabel) - if(xfer->send.hdr.mode.hdr.dst == node) { + if((uint)xfer->send.hdr.mode.hdr.dst == (uint)node) { mtx_unlock(&fc->tlabel_lock); splx(s); KASSERT(xfer->tl == tlabel, @@ -1116,7 +1117,7 @@ fw_tl2xfer(struct firewire_comm *fc, int node, int tlabel, int tcode) tcode, req); return(NULL); } - + if (firewire_debug > 2) printf("fw_tl2xfer: found tl=%d\n", tlabel); return(xfer); @@ -1136,7 +1137,7 @@ fw_xfer_alloc() { struct fw_xfer *xfer; - xfer = malloc(sizeof(struct fw_xfer)); + xfer = (fw_xfer*)malloc(sizeof(struct fw_xfer)); if (xfer == NULL) return xfer; memset(xfer, 0, sizeof(struct fw_xfer)); @@ -1166,7 +1167,7 @@ fw_xfer_alloc_buf(int send_len, int recv_len) return(NULL); } memset(xfer->send.payload 0, send_len);*/ - xfer->send.payArea = alloc_mem(&send_virt, &send_phy, + xfer->send.payArea = alloc_mem(&send_virt, &send_phy, send_len, 0, "firewire tx buf"); if (xfer->send.payArea < B_OK){ fw_xfer_free(xfer); @@ -1183,7 +1184,7 @@ fw_xfer_alloc_buf(int send_len, int recv_len) fw_xfer_free(xfer); return(NULL); }*/ - xfer->recv.payArea = alloc_mem(&recv_virt, &recv_phy, + xfer->recv.payArea = alloc_mem(&recv_virt, &recv_phy, recv_len, 0, "firewire rx buf"); if (xfer->recv.payArea < B_OK){ if (xfer->send.payArea > B_OK){ @@ -1250,7 +1251,7 @@ fw_xfer_unload(struct fw_xfer* xfer) xfer->resp = 0; } /* - * To free IEEE1394 XFER structure. + * To free IEEE1394 XFER structure. */ void fw_xfer_free_buf( struct fw_xfer* xfer) @@ -1301,7 +1302,7 @@ fw_asy_callback_free(struct fw_xfer *xfer) } /* - * To configure PHY. + * To configure PHY. */ static void fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) @@ -1334,7 +1335,7 @@ fw_phy_config(struct firewire_comm *fc, int root_node, int gap_count) } /* - * Dump self ID. + * Dump self ID. */ static void fw_print_sid(uint32_t sid) @@ -1367,7 +1368,7 @@ fw_print_sid(uint32_t sid) } /* - * To receive self ID. + * To receive self ID. */ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) { @@ -1394,9 +1395,9 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) continue; } *self_id = *((union fw_self_id *)sid); - fc->topology_map->crc_len++; + (void)(fc->topology_map->crc_len++); if(self_id->p0.sequel == 0){ - fc->topology_map->node_count ++; + (void)(fc->topology_map->node_count++); c_port = 0; if (firewire_debug) fw_print_sid(sid[0]); @@ -1411,10 +1412,10 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) for (j = 0; j < node; j ++) { fc->speed_map->speed[j][node] = fc->speed_map->speed[node][j] - = min(fc->speed_map->speed[j][j], + = min_c(fc->speed_map->speed[j][j], self_id->p0.phy_speed); } - if ((fc->irm == -1 || self_id->p0.phy_id > fc->irm) && + if ((fc->irm == (u_int)-1 || self_id->p0.phy_id > fc->irm) && (self_id->p0.link_active && self_id->p0.contender)) { fc->irm = self_id->p0.phy_id; } @@ -1433,7 +1434,7 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) } sid += 2; self_id++; - fc->topology_map->self_id_count ++; + (void)(fc->topology_map->self_id_count++); } /* CRC */ fc->topology_map->crc = fw_crc16( @@ -1455,11 +1456,11 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) fc->max_hop = fc->max_node - i_branch; device_printf(fc->bdev, "%d nodes, maxhop <= %d %s irm(%d) %s\n", fc->max_node + 1, fc->max_hop, - (fc->irm == -1) ? "Not IRM capable" : "cable IRM", + (fc->irm == (u_int)-1) ? "Not IRM capable" : "cable IRM", fc->irm, (fc->irm == fc->nodeid) ? " (me) " : ""); - if (try_bmr && (fc->irm != -1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) { + if (try_bmr && (fc->irm != (u_int)-1) && (CSRARC(fc, BUS_MGR_ID) == 0x3f)) { if (fc->irm == fc->nodeid) { fc->status = FWBUSMGRDONE; CSRARC(fc, BUS_MGR_ID) = fc->set_bmr(fc, fc->irm); @@ -1468,7 +1469,7 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) fc->status = FWBUSMGRELECT; // callout_reset(&fc->bmr_callout, hz/8, // (void *)fw_try_bmr, (void *)fc); - fc->bmr_callout = create_timer(fw_try_bmr, fc, + fc->bmr_callout = create_timer(fw_try_bmr, fc, hz/8, B_ONE_SHOT_RELATIVE_TIMER); } } else @@ -1476,12 +1477,12 @@ void fw_sidrcv(struct firewire_comm* fc, uint32_t *sid, u_int len) // callout_reset(&fc->busprobe_callout, hz/4, // (void *)fw_bus_probe, (void *)fc); - fc->busprobe_callout = create_timer(fw_bus_probe, fc, + fc->busprobe_callout = create_timer(fw_bus_probe, fc, hz/4, B_ONE_SHOT_RELATIVE_TIMER); } /* - * To probe devices on the IEEE1394 bus. + * To probe devices on the IEEE1394 bus. */ static void fw_bus_probe(void *arg) @@ -1528,7 +1529,7 @@ fw_explore_read_quads(struct fw_device *fwdev, int offset, int i, error; for (i = 0; i < length; i ++, offset += sizeof(uint32_t)) { - xfer = fwmem_read_quad(fwdev, NULL, -1, + xfer = fwmem_read_quad(fwdev, NULL, (uint8_t)-1, 0xffff, 0xf0000000 | offset, (void *)&tmp, fw_xferwake); if (xfer == NULL) @@ -1576,7 +1577,7 @@ fw_explore_csrblock(struct fw_device *fwdev, int offset, int recur) if (recur == 0) return (0); - for (i = 0; i < dir->crc_len; i ++, offset += sizeof(uint32_t)) { + for (i = 0; (uint)i < dir->crc_len; i ++, offset += sizeof(uint32_t)) { if ((reg[i].key & CSRTYPE_MASK) == CSRTYPE_D) recur = 1; else if ((reg[i].key & CSRTYPE_MASK) == CSRTYPE_L) @@ -1661,7 +1662,7 @@ fw_explore_node(struct fw_device *dfwdev) break; if (fwdev == NULL) { /* new device */ - fwdev = malloc(sizeof(struct fw_device)); + fwdev = (fw_device*)malloc(sizeof(struct fw_device)); if (fwdev == NULL) { device_printf(fc->bdev, "%s: node%d: no memory\n", __func__, node); @@ -1676,7 +1677,7 @@ fw_explore_node(struct fw_device *dfwdev) /* * Pre-1394a-2000 didn't have link_spd in - * the Bus Info block, so try and use the + * the Bus Info block, so try and use the * speed map value. * 1394a-2000 compliant devices only use * the Bus Info Block link spd value, so @@ -1704,7 +1705,7 @@ fw_explore_node(struct fw_device *dfwdev) fwdev->speed--; } else break; - + } /* inesrt into sorted fwdev list */ pfwdev = NULL; @@ -1767,7 +1768,7 @@ fw_find_self_id(struct firewire_comm *fc, int node) s = &fc->topology_map->self_id[i]; if (s->p0.sequel) continue; - if (s->p0.phy_id == node) + if ((int)s->p0.phy_id == node) return s; } return 0; @@ -1788,7 +1789,7 @@ fw_explore(struct firewire_comm *fc) dfwdev.maxrec = 8; /* 512 */ dfwdev.status = FWDEVINIT; - for (node = 0; node <= fc->max_node; node ++) { + for (node = 0; (uint)node <= fc->max_node; node ++) { /* We don't probe myself and linkdown nodes */ if (node == fc->nodeid) { if (firewire_debug) @@ -1839,7 +1840,7 @@ fw_bus_probe_thread(void *arg) fc = (struct firewire_comm *)arg; mtx_lock(&fc->wait_lock); - while (fc->status != FWBUSDETACH) { + while (fc->status != (uint32_t)FWBUSDETACH) { if (fc->status == FWBUSEXPLORE) { mtx_unlock(&fc->wait_lock); fw_explore(fc); @@ -1853,7 +1854,7 @@ fw_bus_probe_thread(void *arg) mtx_unlock(&fc->wait_lock); acquire_sem(fc->Sem); mtx_lock(&fc->wait_lock); - + } mtx_unlock(&fc->wait_lock); // kproc_exit(0); @@ -1909,7 +1910,7 @@ fw_attach_dev(struct firewire_comm *fc) } free(devlistp, M_TEMP); }*/ - + while(element){ // fdc = &element->cookie.fd; fdc = (struct firewire_dev_comm *)element->cookie; @@ -1971,7 +1972,7 @@ fw_rcv_copy(struct fw_rcv_buf *rb) pkt = (struct fw_pkt *)rb->vec->iov_base; tinfo = &rb->fc->tcode[pkt->mode.hdr.tcode]; - /* Copy header */ + /* Copy header */ p = (u_char *)&rb->xfer->recv.hdr; bcopy(rb->vec->iov_base, p, tinfo->hdr_len); rb->vec->iov_base = (u_char *)rb->vec->iov_base + tinfo->hdr_len; @@ -2154,7 +2155,7 @@ fw_rcv(struct fw_rcv_buf *rb) return; } len = 0; - for (i = 0; i < rb->nvec; i ++) + for (i = 0; (uint)i < rb->nvec; i ++) len += rb->vec[i].iov_len; rb->xfer = STAILQ_FIRST(&bind->xferlist); if (rb->xfer == NULL) { @@ -2181,7 +2182,7 @@ fw_rcv(struct fw_rcv_buf *rb) printf("receive queue is full\n"); return; } - /* XXX get xfer from xfer queue, we don't need copy for + /* XXX get xfer from xfer queue, we don't need copy for per packet mode */ rb->xfer = fw_xfer_alloc_buf(M_FWXFER, 0, /* XXX */ vec[0].iov_len); @@ -2365,7 +2366,7 @@ fw_vmaccess(struct fw_xfer *xfer){ /**/ return; } -#endif +#endif /* * CRC16 check-sum for IEEE1394 register blocks. diff --git a/src/add-ons/kernel/bus_managers/firewire/firewire_module.c b/src/add-ons/kernel/bus_managers/firewire/firewire_module.cpp similarity index 94% rename from src/add-ons/kernel/bus_managers/firewire/firewire_module.c rename to src/add-ons/kernel/bus_managers/firewire/firewire_module.cpp index 641bac3563..6f6fbf323d 100644 --- a/src/add-ons/kernel/bus_managers/firewire/firewire_module.c +++ b/src/add-ons/kernel/bus_managers/firewire/firewire_module.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 JiSheng Zhang . All rights reserved + * Copyright (C) 2007 JiSheng Zhang . All rights reserved * Distributed under the terms of the MIT license. * * Kernel driver for firewire @@ -38,7 +38,7 @@ dpc_module_info *gDpc; struct supported_device{ uint16 vendor_id; uint32 device_id; - char *name; + const char *name; }; struct supported_device supported_devices[] = { @@ -74,12 +74,12 @@ struct supported_device supported_devices[] = { }; -static int +static int find_device_name(pci_info *info) { struct supported_device *device; for (device = supported_devices; device->name; device++) { - if (info->vendor_id == device->vendor_id + if (info->vendor_id == device->vendor_id && info->device_id == device->device_id >> 16) { dprintf("%s\n", device->name); return 1; @@ -91,7 +91,7 @@ find_device_name(pci_info *info) #if 0 static status_t -fw_add_child(const char *childname, +fw_add_child(const char *childname, const struct firewire_notify_hooks *hooks) { status_t status; @@ -102,7 +102,7 @@ fw_add_child(const char *childname, if (status != B_OK) return status; } - + return B_OK; } @@ -118,13 +118,13 @@ fw_remove_child(const char *childname) if (status != B_OK) return status; } - + return B_OK; } #endif -static int +static int fw_get_handle(int socket, struct firewire_softc **handle) { if (handle == NULL) @@ -147,16 +147,16 @@ fw_module_init(void) fwohci_softc_t *fwohci_sc; struct firewire_softc *fw_sc; - info = malloc(sizeof(pci_info)); + info = (pci_info*)malloc(sizeof(pci_info)); if (!info) return B_NO_MEMORY; - + if ((status = get_module(B_PCI_MODULE_NAME,(module_info **)&gPci)) != B_OK) { TRACE("pci module unavailable\n"); free(info); return status; } - + if ((status = get_module(B_DPC_MODULE_NAME,(module_info **)&gDpc)) != B_OK) { TRACE("pci module unavailable\n"); free(info); @@ -175,15 +175,15 @@ fw_module_init(void) dprintf( "vendor=%x, device=%x, revision = %x\n", info->vendor_id, info->device_id, info->revision); pciInfo[found] = info; - fwohci_sc = malloc(sizeof(fwohci_softc_t)); + fwohci_sc = (fwohci_softc_t*)malloc(sizeof(fwohci_softc_t)); if (!fwohci_sc) { free(info); goto err_outofmem; } memset(fwohci_sc, 0, sizeof(fwohci_softc_t)); gFwohci_softc[found] = fwohci_sc; - - fw_sc = malloc(sizeof(struct firewire_softc)); + + fw_sc = (firewire_softc*)malloc(sizeof(struct firewire_softc)); if (!fw_sc) { free(info); free(fwohci_sc); @@ -192,9 +192,9 @@ fw_module_init(void) memset(fw_sc, 0, sizeof(struct firewire_softc)); gFirewire_softc[found] = fw_sc; gFirewire_softc[found+1] = NULL; - + found++; - info = malloc(sizeof(pci_info)); + info = (pci_info*)malloc(sizeof(pci_info)); if (!info) goto err_outofmem; @@ -230,7 +230,7 @@ err_outofmem: } put_module(B_PCI_MODULE_NAME); put_module(B_DPC_MODULE_NAME); - return B_ERROR; + return B_ERROR; } @@ -240,17 +240,17 @@ fw_module_uninit(void) int i; terminate_timer(); - + for (i = 0; gFirewire_softc[i] != NULL; i++) { fwohci_pci_detach(i); free(gFirewire_softc[i]); free(gFwohci_softc[i]); free(pciInfo[i]); } - + put_module(B_PCI_MODULE_NAME); put_module(B_DPC_MODULE_NAME); - + return B_OK; } diff --git a/src/add-ons/kernel/bus_managers/firewire/fwdma.c b/src/add-ons/kernel/bus_managers/firewire/fwdma.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/firewire/fwdma.c rename to src/add-ons/kernel/bus_managers/firewire/fwdma.cpp diff --git a/src/add-ons/kernel/bus_managers/firewire/fwmem.c b/src/add-ons/kernel/bus_managers/firewire/fwmem.cpp similarity index 92% rename from src/add-ons/kernel/bus_managers/firewire/fwmem.c rename to src/add-ons/kernel/bus_managers/firewire/fwmem.cpp index da1f927213..89fa6c519e 100644 --- a/src/add-ons/kernel/bus_managers/firewire/fwmem.c +++ b/src/add-ons/kernel/bus_managers/firewire/fwmem.cpp @@ -1,7 +1,7 @@ /*- * Copyright (c) 2002-2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -30,7 +30,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * */ #include @@ -68,8 +68,8 @@ fwmem_xfer_req( if (spd < 0) xfer->send.spd = fwdev->speed; else - xfer->send.spd = min(spd, fwdev->speed); - xfer->hand = hand; + xfer->send.spd = min_c(spd, fwdev->speed); + xfer->hand = (void (*)(fw_xfer*))hand; xfer->sc = sc; xfer->send.pay_len = slen; xfer->recv.pay_len = rlen; @@ -90,7 +90,7 @@ fwmem_read_quad( struct fw_xfer *xfer; struct fw_pkt *fp; - xfer = fwmem_xfer_req(fwdev, (void *)sc, spd, 0, 4, hand); + xfer = fwmem_xfer_req(fwdev, (char *)sc, spd, 0, 4, (void*)hand); if (xfer == NULL) { return NULL; } @@ -127,7 +127,7 @@ fwmem_write_quad( struct fw_xfer *xfer; struct fw_pkt *fp; - xfer = fwmem_xfer_req(fwdev, sc, spd, 0, 0, hand); + xfer = fwmem_xfer_req(fwdev, sc, spd, 0, 0, (void*)hand); if (xfer == NULL) return NULL; @@ -163,8 +163,8 @@ fwmem_read_block( { struct fw_xfer *xfer; struct fw_pkt *fp; - - xfer = fwmem_xfer_req(fwdev, sc, spd, 0, roundup2(len, 4), hand); + + xfer = fwmem_xfer_req(fwdev, sc, spd, 0, roundup2(len, 4), (void*)hand); if (xfer == NULL) return NULL; @@ -176,7 +176,7 @@ fwmem_read_block( fp->mode.rreqb.extcode = 0; xfer->send.payload = NULL; - xfer->recv.payload = data; + xfer->recv.payload = (uint32_t*)data; if (fwmem_debug) printf("fwmem_read_block: %d %04x:%08x %d\n", fwdev->dst, @@ -202,7 +202,7 @@ fwmem_write_block( struct fw_xfer *xfer; struct fw_pkt *fp; - xfer = fwmem_xfer_req(fwdev, sc, spd, len, 0, hand); + xfer = fwmem_xfer_req(fwdev, sc, spd, len, 0, (void*)hand); if (xfer == NULL) return NULL; @@ -213,7 +213,7 @@ fwmem_write_block( fp->mode.wreqb.len = len; fp->mode.wreqb.extcode = 0; - xfer->send.payload = data; + xfer->send.payload = (uint32_t*)data; xfer->recv.payload = NULL; if (fwmem_debug) diff --git a/src/add-ons/kernel/bus_managers/firewire/fwohci.c b/src/add-ons/kernel/bus_managers/firewire/fwohci.cpp similarity index 94% rename from src/add-ons/kernel/bus_managers/firewire/fwohci.c rename to src/add-ons/kernel/bus_managers/firewire/fwohci.cpp index 4120609688..7749bce24e 100644 --- a/src/add-ons/kernel/bus_managers/firewire/fwohci.c +++ b/src/add-ons/kernel/bus_managers/firewire/fwohci.cpp @@ -30,7 +30,7 @@ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * $FreeBSD: src/sys/dev/firewire/fwohci.c,v 1.93 2007/06/08 09:04:30 simokawa Exp $ * */ @@ -86,7 +86,7 @@ char fwohcicode[32][0x20]={ "Undef","ack data_err","ack type_err",""}; #define MAX_SPEED 3 -extern char *linkspeed[]; +extern const char *const linkspeed[]; uint32_t tagbit[4] = { 1 << 28, 1 << 29, 1 << 30, 1 << 31}; static struct tcode_info tinfo[] = { @@ -113,17 +113,17 @@ static struct tcode_info tinfo[] = { #define OHCI_READ_SIGMASK 0xffff0000 static void fwohci_ibr (struct firewire_comm *); -static void fwohci_db_init (struct fwohci_softc *, struct fwohci_dbch *); -static void fwohci_db_free (struct fwohci_dbch *); -static void fwohci_arcv (struct fwohci_softc *, struct fwohci_dbch *, int); -static void fwohci_txd (struct fwohci_softc *, struct fwohci_dbch *); +static void fwohci_db_init (struct fwohci_softc *, fwohci_softc::fwohci_dbch *); +static void fwohci_db_free (fwohci_softc::fwohci_dbch *); +static void fwohci_arcv (struct fwohci_softc *, fwohci_softc::fwohci_dbch *, int); +static void fwohci_txd (struct fwohci_softc *, fwohci_softc::fwohci_dbch *); static void fwohci_start_atq (struct firewire_comm *); static void fwohci_start_ats (struct firewire_comm *); -static void fwohci_start (struct fwohci_softc *, struct fwohci_dbch *); +static void fwohci_start (struct fwohci_softc *, fwohci_softc::fwohci_dbch *); static uint32_t fwphy_wrdata ( struct fwohci_softc *, uint32_t, uint32_t); static uint32_t fwphy_rddata ( struct fwohci_softc *, uint32_t); -static int fwohci_rx_enable (struct fwohci_softc *, struct fwohci_dbch *); -static int fwohci_tx_enable (struct fwohci_softc *, struct fwohci_dbch *); +static int fwohci_rx_enable (struct fwohci_softc *, fwohci_softc::fwohci_dbch *); +static int fwohci_tx_enable (struct fwohci_softc *, fwohci_softc::fwohci_dbch *); static int fwohci_irx_enable (struct firewire_comm *, int); static int fwohci_irx_disable (struct firewire_comm *, int); #if BYTE_ORDER == BIG_ENDIAN @@ -135,7 +135,7 @@ static void fwohci_timeout (void *); static void fwohci_set_intr (struct firewire_comm *, int); static inline void fwohci_set_rx_buf(struct fw_xferq *, struct fwohcidb_tr *, bus_addr_t dbuf[], int dsiz[]); -static int fwohci_add_tx_buf (struct fwohci_dbch *, struct fwohcidb_tr *, int); +static int fwohci_add_tx_buf (fwohci_softc::fwohci_dbch *, struct fwohcidb_tr *, int); static void dump_db (struct fwohci_softc *, uint32_t); static void print_db (struct fwohcidb_tr *, struct fwohcidb *, uint32_t , uint32_t); static void dump_dma (struct fwohci_softc *, uint32_t); @@ -408,7 +408,7 @@ fwohci_probe_phy(struct fwohci_softc *sc) /* * probe PHY parameters * 0. to prove PHY version, whether compliance of 1394a. - * 1. to probe maximum speed supported by the PHY and + * 1. to probe maximum speed supported by the PHY and * number of port supported by core-logic. * It is not actually available port on your PC . */ @@ -438,7 +438,7 @@ fwohci_probe_phy(struct fwohci_softc *sc) sc->fc.speed, MAX_SPEED); sc->fc.speed = MAX_SPEED; } - device_printf(dev, + device_printf(dev, "Phy 1394a available %s, %d ports.\n", linkspeed[sc->fc.speed], sc->fc.nport); @@ -450,7 +450,7 @@ fwohci_probe_phy(struct fwohci_softc *sc) if (e1394a) { #endif if (firewire_debug) - device_printf(dev, + device_printf(dev, "Enable 1394a Enhancements\n"); /* enable EAA EMC */ reg2 |= 0x03; @@ -482,7 +482,7 @@ fwohci_reset(struct fwohci_softc *sc) uint32_t reg, reg2; struct fwohcidb_tr *db_tr; - /* Disable interrupts */ + /* Disable interrupts */ OWRITE(sc, FWOHCI_INTMASKCLR, ~0); /* Now stopping all DMA channels */ @@ -500,7 +500,7 @@ fwohci_reset(struct fwohci_softc *sc) /* FLUSH FIFO and reset Transmitter/Reciever */ OWRITE(sc, OHCI_HCCCTL, OHCI_HCC_RESET); if (firewire_debug) - device_printf(dev, + device_printf(dev, "resetting OHCI..."); i = 0; while(OREAD(sc, OHCI_HCCCTL) & OHCI_HCC_RESET) { @@ -523,7 +523,7 @@ fwohci_reset(struct fwohci_softc *sc) linkspeed[speed], MAXREC(max_rec)); /* XXX fix max_rec */ sc->fc.maxrec = sc->fc.speed + 8; - if (max_rec != sc->fc.maxrec) { + if ((uint32_t)max_rec != sc->fc.maxrec) { reg2 = (reg2 & 0xffff0fff) | (sc->fc.maxrec << 12); device_printf(dev, "max_rec %d -> %d\n", MAXREC(max_rec), MAXREC(sc->fc.maxrec)); @@ -563,11 +563,11 @@ fwohci_reset(struct fwohci_softc *sc) sc->atrq.bottom = sc->atrq.top; sc->atrs.bottom = sc->atrs.top; - for( i = 0, db_tr = sc->atrq.top; i < sc->atrq.ndb ; + for( i = 0, db_tr = sc->atrq.top; (uint)i < sc->atrq.ndb ; i ++, db_tr = STAILQ_NEXT(db_tr, link)){ db_tr->xfer = NULL; } - for( i = 0, db_tr = sc->atrs.top; i < sc->atrs.ndb ; + for( i = 0, db_tr = sc->atrs.top; (uint)i < sc->atrs.ndb ; i ++, db_tr = STAILQ_NEXT(db_tr, link)){ db_tr->xfer = NULL; } @@ -575,7 +575,7 @@ fwohci_reset(struct fwohci_softc *sc) /* Enable interrupts */ sc->intmask = (OHCI_INT_ERR | OHCI_INT_PHY_SID - | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS + | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS | OHCI_INT_DMA_PRRQ | OHCI_INT_DMA_PRRS | OHCI_INT_PHY_BUS_R | OHCI_INT_PW_ERR); sc->intmask |= OHCI_INT_DMA_IR | OHCI_INT_DMA_IT; @@ -700,17 +700,18 @@ fwohci_init(struct fwohci_softc *sc) device_printf(dev, "dummy_dma alloc failed."); return ENOMEM; }*/ - //crom_sid_Area means config rom and sid buf etc. + //crom_sid_Area means config rom and sid buf etc. sc->fc.crom_sid_Area = alloc_mem(&buf_virt, &buf_phy, CROMSIZE+OHCI_SIDSIZE+sizeof(uint32_t), 0, "fwohci config etc. buf"); if (sc->fc.crom_sid_Area < B_OK) return B_NO_MEMORY; - sc->sid_buf = sc->sid_dma.v_addr = buf_virt; + sc->sid_buf = (uint32_t*)(sc->sid_dma.v_addr = buf_virt); sc->sid_dma.bus_addr = (bus_addr_t)buf_phy; - sc->fc.config_rom = sc->crom_dma.v_addr = buf_virt + OHCI_SIDSIZE; - sc->crom_dma.bus_addr = (bus_addr_t)(buf_phy + OHCI_SIDSIZE); - sc->dummy_dma.v_addr = buf_virt + OHCI_SIDSIZE + CROMSIZE; - sc->dummy_dma.bus_addr = (bus_addr_t)(buf_phy + - OHCI_SIDSIZE + CROMSIZE); + sc->fc.config_rom + = (uint32_t*)(sc->crom_dma.v_addr = (char*)buf_virt + OHCI_SIDSIZE); + sc->crom_dma.bus_addr = (bus_addr_t)buf_phy + OHCI_SIDSIZE; + sc->dummy_dma.v_addr = (char*)buf_virt + OHCI_SIDSIZE + CROMSIZE; + sc->dummy_dma.bus_addr = (bus_addr_t)buf_phy + + OHCI_SIDSIZE + CROMSIZE; fwohci_db_init(sc, &sc->arrq); if ((sc->arrq.flags & FWOHCI_DBCH_INIT) == 0) @@ -818,7 +819,7 @@ fwohci_detach(struct fwohci_softc *sc) taskqueue_drain(sc->fc.taskqueue, &sc->fc.task_timeout); taskqueue_free(sc->fc.taskqueue);*/ gDpc->delete_dpc_queue(sc->fc.taskqueue); - + sc->fc.taskqueue = NULL; } @@ -830,9 +831,9 @@ fwohci_detach(struct fwohci_softc *sc) int _cnt = _dbtr->dbcnt; \ db = &_dbtr->db[ (_cnt > 2) ? (_cnt -1) : 0]; \ } while (0) - + static void -fwohci_execute_db(void *arg, struct send_recv *info) +fwohci_execute_db(void *arg, fw_xfer::send_recv *info) { struct fwohcidb_tr *db_tr; struct fwohcidb *db; @@ -843,7 +844,7 @@ fwohci_execute_db(void *arg, struct send_recv *info) db_tr = (struct fwohcidb_tr *)arg; db = &db_tr->db[db_tr->dbcnt]; - + for (i = 0; i < j; i++) { FWOHCI_DMA_WRITE(db->db.desc.addr, bus_addr); FWOHCI_DMA_WRITE(db->db.desc.cmd, step); @@ -869,7 +870,7 @@ fwohci_execute_db2(void *arg, bus_dma_segment_t *segs, int nseg, }*/ static void -fwohci_start(struct fwohci_softc *sc, struct fwohci_dbch *dbch) +fwohci_start(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch) { int i, s; int tcode, hdr_len, pl_off; @@ -985,7 +986,7 @@ txloop: m_copydata(xfer->mbuf, 0, xfer->mbuf->m_pkthdr.len, mtod(m0, caddr_t)); - m0->m_len = m0->m_pkthdr.len = + m0->m_len = m0->m_pkthdr.len = xfer->mbuf->m_pkthdr.len; m_freem(xfer->mbuf); xfer->mbuf = m0; @@ -998,7 +999,7 @@ txloop: printf("dmamap_load: err=%d\n", err); bus_dmamap_sync(dbch->dmat, db_tr->dma_map, BUS_DMASYNC_PREWRITE); -#endif +#endif #if 0 /* OHCI_OUTPUT_MODE == 0 */ for (i = 2; i < db_tr->dbcnt; i++) FWOHCI_DMA_SET(db_tr->db[i].db.desc.cmd, @@ -1074,7 +1075,7 @@ fwohci_start_ats(struct firewire_comm *fc) } void -fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) +fwohci_txd(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch) { int s, ch, err = 0; struct fwohcidb_tr *tr; @@ -1103,7 +1104,7 @@ fwohci_txd(struct fwohci_softc *sc, struct fwohci_dbch *dbch) LAST_DB(tr, db); status = FWOHCI_DMA_READ(db->db.desc.res) >> OHCI_STATUS_SHIFT; if(!(status & OHCI_CNTL_DMA_ACTIVE)){ - if (fc->status != FWBUSINIT) + if (fc->status != FWBUSINIT) /* maybe out of order?? */ goto out; } @@ -1215,7 +1216,7 @@ out: } static void -fwohci_db_free(struct fwohci_dbch *dbch) +fwohci_db_free(fwohci_softc::fwohci_dbch *dbch) { struct fwohcidb_tr *db_tr; // int idb; @@ -1248,7 +1249,7 @@ fwohci_db_free(struct fwohci_dbch *dbch) } static void -fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) +fwohci_db_init(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch) { int idb; struct fwohcidb_tr *db_tr; @@ -1294,7 +1295,7 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) return; } /* Attach DB to DMA ch. */ - for(idb = 0 ; idb < dbch->ndb ; idb++){ + for(idb = 0 ; (uint)idb < dbch->ndb ; idb++){ db_tr->dbcnt = 0; db_tr->db = (struct fwohcidb *)fwdma_v_addr(dbch->am, idb); db_tr->bus_addr = fwdma_bus_addr(dbch->am, idb); @@ -1335,7 +1336,7 @@ fwohci_itx_disable(struct firewire_comm *fc, int dmach) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; - OWRITE(sc, OHCI_ITCTLCLR(dmach), + OWRITE(sc, OHCI_ITCTLCLR(dmach), OHCI_CNTL_DMA_RUN | OHCI_CNTL_CYCMATCH_S); OWRITE(sc, OHCI_IT_MASKCLR, 1 << dmach); OWRITE(sc, OHCI_IT_STATCLR, 1 << dmach); @@ -1373,7 +1374,7 @@ fwohci_irx_post (struct firewire_comm *fc , uint32_t *qld) #endif static int -fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) +fwohci_tx_enable(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch) { int err = 0; int idb, z, i, dmach = 0, ldesc; @@ -1399,11 +1400,11 @@ fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) if(dbch->xferq.flag & FWXFERQ_RUNNING) return err; dbch->xferq.flag |= FWXFERQ_RUNNING; - for( i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++){ + for( i = 0, dbch->bottom = dbch->top; (uint)i < (dbch->ndb - 1); i++){ dbch->bottom = STAILQ_NEXT(dbch->bottom, link); } db_tr = dbch->top; - for (idb = 0; idb < dbch->ndb; idb ++) { + for (idb = 0; (uint)idb < dbch->ndb; idb ++) { fwohci_add_tx_buf(dbch, db_tr, idb); if(STAILQ_NEXT(db_tr, link) == NULL){ break; @@ -1432,7 +1433,7 @@ fwohci_tx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) } static int -fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) +fwohci_rx_enable(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch) { int err = 0; int idb, z, i, dmach = 0, ldesc; @@ -1472,7 +1473,7 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) } dbch->xferq.flag |= FWXFERQ_RUNNING; dbch->top = STAILQ_FIRST(&dbch->db_trq); - for( i = 0, dbch->bottom = dbch->top; i < (dbch->ndb - 1); i++){ + for( i = 0, dbch->bottom = dbch->top; (uint)i < (dbch->ndb - 1); i++){ dbch->bottom = STAILQ_NEXT(dbch->bottom, link); } db_tr = dbch->top; @@ -1480,14 +1481,14 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) ir = &dbch->xferq; if(ir->buf == NULL && (ir->flag & FWXFERQ_EXTBUF) == 0) { if (dbch->Area <= 0) { - dbch->Area = alloc_mem(&buf_virt, &buf_phy, + dbch->Area = alloc_mem(&buf_virt, &buf_phy, ir->psize * dbch->ndb, 0, "fw rx Area"); if(dbch->Area < B_OK) return(ENOMEM); } } - - for (idb = 0; idb < dbch->ndb; idb ++) { + + for (idb = 0; (uint)idb < dbch->ndb; idb ++) { //fwohci_add_rx_buf(dbch, db_tr, idb, &sc->dummy_dma); if(ir->buf == NULL && (ir->flag & FWXFERQ_EXTBUF) == 0) { db_tr->buf = (caddr_t)buf_virt; @@ -1495,15 +1496,15 @@ fwohci_rx_enable(struct fwohci_softc *sc, struct fwohci_dbch *dbch) db_tr->dbcnt = 1; dsiz[0] = ir->psize; - buf_virt += ir->psize; - buf_phy += ir->psize; + buf_virt = (char*)buf_virt + ir->psize; + buf_phy = (char*)buf_phy + ir->psize; } else { db_tr->dbcnt = 0; dsiz[db_tr->dbcnt] = sizeof(uint32_t); dbuf[db_tr->dbcnt++] = sc->dummy_dma.bus_addr; dsiz[db_tr->dbcnt] = ir->psize; if (ir->buf != NULL) { - db_tr->buf = fwdma_v_addr(ir->buf, idb); + db_tr->buf = (char*)fwdma_v_addr(ir->buf, idb); dbuf[db_tr->dbcnt] = fwdma_bus_addr( ir->buf, idb); } @@ -1580,7 +1581,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach) struct fwohci_softc *sc = (struct fwohci_softc *)fc; int err = 0; unsigned short tag, ich; - struct fwohci_dbch *dbch; + fwohci_softc::fwohci_dbch *dbch; int cycle_match, cycle_now, s, ldesc; uint32_t stat; struct fw_bulkxfer *first, *chunk, *prev; @@ -1620,7 +1621,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach) OHCI_BRANCH_ALWAYS); #endif #if 0 /* if bulkxfer->npacket changes */ - db[ldesc].db.desc.depend = db[0].db.desc.depend = + db[ldesc].db.desc.depend = db[0].db.desc.depend = ((struct fwohcidb_tr *) (chunk->start))->bus_addr | dbch->ndesc; #else @@ -1687,7 +1688,7 @@ fwohci_itxbuf_enable(struct firewire_comm *fc, int dmach) dump_db(sc, ITX_CH + dmach); } } else if ((stat & OHCI_CNTL_CYCMATCH_S) == 0) { - device_printf(sc->fc.dev, + device_printf(sc->fc.dev, "IT DMA underrun (0x%08x)\n", stat); OWRITE(sc, OHCI_ITCTL(dmach), OHCI_CNTL_DMA_WAKE); } @@ -1702,7 +1703,7 @@ fwohci_irx_enable(struct firewire_comm *fc, int dmach) int err = 0, s, ldesc; unsigned short tag, ich; uint32_t stat; - struct fwohci_dbch *dbch; + fwohci_softc::fwohci_dbch *dbch; // struct fwohcidb_tr *db_tr; struct fw_bulkxfer *first, *prev, *chunk; struct fw_xferq *ir; @@ -1807,19 +1808,19 @@ fwohci_stop(struct fwohci_softc *sc) OWRITE(sc, OHCI_ATQCTLCLR, OHCI_CNTL_DMA_RUN); OWRITE(sc, OHCI_ATSCTLCLR, OHCI_CNTL_DMA_RUN); - for( i = 0 ; i < sc->fc.nisodma ; i ++ ){ + for( i = 0 ; i < (uint)sc->fc.nisodma ; i ++ ){ OWRITE(sc, OHCI_IRCTLCLR(i), OHCI_CNTL_DMA_RUN); OWRITE(sc, OHCI_ITCTLCLR(i), OHCI_CNTL_DMA_RUN); } -#if 0 /* Let dcons(4) be accessed */ +#if 0 /* Let dcons(4) be accessed */ /* Stop interrupt */ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_EN | OHCI_INT_ERR | OHCI_INT_PHY_SID | OHCI_INT_PHY_INT - | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS + | OHCI_INT_DMA_ATRQ | OHCI_INT_DMA_ATRS | OHCI_INT_DMA_PRRQ | OHCI_INT_DMA_PRRS - | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS + | OHCI_INT_DMA_ARRQ | OHCI_INT_DMA_ARRS | OHCI_INT_PHY_BUS_R); /* FLUSH FIFO and reset Transmitter/Reciever */ @@ -1857,7 +1858,7 @@ fwohci_dump_intr(struct fwohci_softc *sc, uint32_t stat) stat & OHCI_INT_DMA_ARRQ ? "DMA_ARRQ " :"", stat & OHCI_INT_DMA_ATRS ? "DMA_ATRS " :"", stat & OHCI_INT_DMA_ATRQ ? "DMA_ATRQ " :"", - stat, OREAD(sc, FWOHCI_INTMASK) + stat, OREAD(sc, FWOHCI_INTMASK) ); } #endif @@ -1872,7 +1873,7 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) fc->status = FWBUSRESET; /* Disable bus reset interrupt until sid recv. */ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); - + device_printf(fc->dev, "%s: BUS reset\n", __func__); OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); @@ -1884,7 +1885,7 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) // if (!kdb_active) // taskqueue_enqueue(sc->fc.taskqueue, &sc->fwohci_task_busreset); - gDpc->queue_dpc(sc->fc.taskqueue, fwohci_task_busreset, sc); + gDpc->queue_dpc(sc->fc.taskqueue, fwohci_task_busreset, sc); } if (stat & OHCI_INT_PHY_SID) { /* Enable bus reset interrupt */ @@ -1904,7 +1905,7 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) OWRITE(sc, OHCI_ATRETRY, 1<<(13+16) | 0xfff); /* - * Checking whether the node is root or not. If root, turn on + * Checking whether the node is root or not. If root, turn on * cycle master. */ node_id = OREAD(sc, FWOHCI_NODEID); @@ -1936,13 +1937,13 @@ fwohci_intr_core(struct fwohci_softc *sc, uint32_t stat, int count) // if (!kdb_active) // taskqueue_enqueue(sc->fc.taskqueue, &sc->fwohci_task_sid); - gDpc->queue_dpc(sc->fc.taskqueue, fwohci_task_sid, sc); + gDpc->queue_dpc(sc->fc.taskqueue, fwohci_task_sid, sc); } sidout: // if ((stat & ~(OHCI_INT_PHY_BUS_R | OHCI_INT_PHY_SID)) && (!kdb_active)) // taskqueue_enqueue(sc->fc.taskqueue, &sc->fwohci_task_dma); if ((stat & ~(OHCI_INT_PHY_BUS_R | OHCI_INT_PHY_SID))) - gDpc->queue_dpc(sc->fc.taskqueue, fwohci_task_dma, sc); + gDpc->queue_dpc(sc->fc.taskqueue, fwohci_task_dma, sc); } static void @@ -1954,13 +1955,13 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) if (stat & OHCI_INT_DMA_IR) { irstat = atomic_readandclear_int(&sc->irstat); - for(i = 0; i < fc->nisodma ; i++){ - struct fwohci_dbch *dbch; + for(i = 0; i < (uint)fc->nisodma ; i++){ + fwohci_softc::fwohci_dbch *dbch; if((irstat & (1 << i)) != 0){ dbch = &sc->ir[i]; if ((dbch->xferq.flag & FWXFERQ_OPEN) == 0) { - device_printf(sc->fc.dev, + device_printf(sc->fc.dev, "dma(%d) not active\n", i); continue; } @@ -1970,7 +1971,7 @@ fwohci_intr_dma(struct fwohci_softc *sc, uint32_t stat, int count) } if (stat & OHCI_INT_DMA_IT) { itstat = atomic_readandclear_int(&sc->itstat); - for(i = 0; i < fc->nisodma ; i++){ + for(i = 0; i < (uint)fc->nisodma ; i++){ if((itstat & (1 << i)) != 0){ fwohci_tbuf_update(sc, i); } @@ -2099,7 +2100,7 @@ fwohci_check_stat(struct fwohci_softc *sc) FW_GLOCK_ASSERT(&sc->fc); stat = OREAD(sc, FWOHCI_INTSTAT); if (stat == 0xffffffff) { - device_printf(sc->fc.dev, + device_printf(sc->fc.dev, "device physically ejected?\n"); return (B_UNHANDLED_INTERRUPT); } @@ -2184,7 +2185,7 @@ fwohci_tbuf_update(struct fwohci_softc *sc, int dmach) dump_db(sc, ITX_CH + dmach); while ((chunk = STAILQ_FIRST(&it->stdma)) != NULL) { db = ((struct fwohcidb_tr *)(chunk->end))->db; - stat = FWOHCI_DMA_READ(db[ldesc].db.desc.res) + stat = FWOHCI_DMA_READ(db[ldesc].db.desc.res) >> OHCI_STATUS_SHIFT; db = ((struct fwohcidb_tr *)(chunk->start))->db; /* timestamp */ @@ -2259,7 +2260,7 @@ fwohci_rbuf_update(struct fwohci_softc *sc, int dmach) break; default: chunk->resp = EINVAL; - device_printf(fc->dev, + device_printf(fc->dev, "Isochronous receive err %02x(%s)\n", stat, fwohcicode[stat & 0x1f]); } @@ -2271,7 +2272,7 @@ fwohci_rbuf_update(struct fwohci_softc *sc, int dmach) if (w == 0) return; - if (ir->flag & FWXFERQ_HANDLER) + if (ir->flag & FWXFERQ_HANDLER) ir->hand(ir); else wakeup(ir); @@ -2301,8 +2302,8 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch) device_printf(sc->fc.dev, "ch %1x cntl:0x%08x cmd:0x%08x match:0x%08x\n", ch, - cntl, - cmd, + cntl, + cmd, match); stat &= 0xffff ; if (stat) { @@ -2325,7 +2326,7 @@ dump_dma(struct fwohci_softc *sc, uint32_t ch) void dump_db(struct fwohci_softc *sc, uint32_t ch) { - struct fwohci_dbch *dbch; + fwohci_softc::fwohci_dbch *dbch; struct fwohcidb_tr *cp = NULL, *pp, *np = NULL; struct fwohcidb *curr = NULL, *prev, *next = NULL; int idb, jdb; @@ -2357,14 +2358,14 @@ dump_db(struct fwohci_softc *sc, uint32_t ch) } pp = dbch->top; prev = pp->db; - for(idb = 0 ; idb < dbch->ndb ; idb ++ ){ + for(idb = 0 ; (uint)idb < dbch->ndb ; idb ++ ){ cp = STAILQ_NEXT(pp, link); if(cp == NULL){ curr = NULL; goto outdb; } np = STAILQ_NEXT(cp, link); - for(jdb = 0 ; jdb < dbch->ndesc ; jdb ++ ){ + for(jdb = 0 ; (uint)jdb < dbch->ndesc ; jdb ++ ){ if ((cmd & 0xfffffff0) == cp->bus_addr) { curr = cp->db; if(np != NULL){ @@ -2425,7 +2426,7 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, "Depend", "Stat", "Cnt"); - for( i = 0 ; i <= max ; i ++){ + for( i = 0 ; (uint)i <= max ; i ++){ cmd = FWOHCI_DMA_READ(db[i].db.desc.cmd); res = FWOHCI_DMA_READ(db[i].db.desc.res); key = cmd & OHCI_KEY_MASK; @@ -2456,7 +2457,7 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, printf(" Nostat\n"); } if(key == OHCI_KEY_ST2 ){ - printf("0x%08x 0x%08x 0x%08x 0x%08x\n", + printf("0x%08x 0x%08x 0x%08x 0x%08x\n", FWOHCI_DMA_READ(db[i+1].db.immed[0]), FWOHCI_DMA_READ(db[i+1].db.immed[1]), FWOHCI_DMA_READ(db[i+1].db.immed[2]), @@ -2465,15 +2466,15 @@ print_db(struct fwohcidb_tr *db_tr, struct fwohcidb *db, if(key == OHCI_KEY_DEVICE){ return; } - if((cmd & OHCI_BRANCH_MASK) + if((cmd & OHCI_BRANCH_MASK) == OHCI_BRANCH_ALWAYS){ return; } - if((cmd & OHCI_CMD_MASK) + if((cmd & OHCI_CMD_MASK) == OHCI_OUTPUT_LAST){ return; } - if((cmd & OHCI_CMD_MASK) + if((cmd & OHCI_CMD_MASK) == OHCI_INPUT_LAST){ return; } @@ -2521,7 +2522,7 @@ void fwohci_txbufdb(struct fwohci_softc *sc, int dmach, struct fw_bulkxfer *bulkxfer) { struct fwohcidb_tr *db_tr, *fdb_tr; - struct fwohci_dbch *dbch; + fwohci_softc::fwohci_dbch *dbch; struct fwohcidb *db; struct fw_pkt *fp; struct fwohci_txpkthdr *ohcifp; @@ -2538,7 +2539,7 @@ fwohci_txbufdb(struct fwohci_softc *sc, int dmach, struct fw_bulkxfer *bulkxfer) /* device_printf(sc->fc.dev, "DB %08x %08x %08x\n", bulkxfer, db_tr->bus_addr, fdb_tr->bus_addr); */ - for (idb = 0; idb < dbch->xferq.bnpacket; idb ++) { + for (idb = 0; (uint)idb < dbch->xferq.bnpacket; idb ++) { db = db_tr->db; fp = (struct fw_pkt *)db_tr->buf; ohcifp = (struct fwohci_txpkthdr *) db[1].db.immed; @@ -2548,8 +2549,8 @@ device_printf(sc->fc.dev, "DB %08x %08x %08x\n", bulkxfer, db_tr->bus_addr, fdb_ ohcifp->mode.stream.chtag = chtag; ohcifp->mode.stream.tcode = 0xa; #if BYTE_ORDER == BIG_ENDIAN - FWOHCI_DMA_WRITE(db[1].db.immed[0], db[1].db.immed[0]); - FWOHCI_DMA_WRITE(db[1].db.immed[1], db[1].db.immed[1]); + FWOHCI_DMA_WRITE(db[1].db.immed[0], db[1].db.immed[0]); + FWOHCI_DMA_WRITE(db[1].db.immed[1], db[1].db.immed[1]); #endif FWOHCI_DMA_CLEAR(db[2].db.desc.cmd, OHCI_COUNT_MASK); @@ -2586,7 +2587,7 @@ device_printf(sc->fc.dev, "DB %08x %3d %08x %08x\n", bulkxfer, bulkxfer->npacket } static int -fwohci_add_tx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, +fwohci_add_tx_buf(fwohci_softc::fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, int poffset) { struct fwohcidb *db = db_tr->db; @@ -2598,7 +2599,7 @@ fwohci_add_tx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, err = EINVAL; return err; } - db_tr->buf = fwdma_v_addr(it->buf, poffset); + db_tr->buf = (char*)fwdma_v_addr(it->buf, poffset); db_tr->dbcnt = 3; FWOHCI_DMA_WRITE(db[0].db.desc.cmd, @@ -2618,7 +2619,7 @@ fwohci_add_tx_buf(struct fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, } static inline void -fwohci_set_rx_buf(struct fw_xferq *ir, struct fwohcidb_tr *db_tr, +fwohci_set_rx_buf(struct fw_xferq *ir, struct fwohcidb_tr *db_tr, bus_addr_t dbuf[], int dsiz[]) { int i, ldesc; @@ -2689,7 +2690,7 @@ fwohci_arcv_swap(struct fw_pkt *fp, int len) } static int -fwohci_get_plen(struct fwohci_softc *sc, struct fwohci_dbch *dbch, struct fw_pkt *fp) +fwohci_get_plen(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch, struct fw_pkt *fp) { struct tcode_info *info; int r; @@ -2706,7 +2707,7 @@ fwohci_get_plen(struct fwohci_softc *sc, struct fwohci_dbch *dbch, struct fw_pkt return (-1); } - if (r > dbch->xferq.psize) { + if ((uint)r > dbch->xferq.psize) { device_printf(sc->fc.dev, "Invalid packet length %d\n", r); return (-1); /* panic ? */ @@ -2716,7 +2717,7 @@ fwohci_get_plen(struct fwohci_softc *sc, struct fwohci_dbch *dbch, struct fw_pkt } static void -fwohci_arcv_free_buf(struct fwohci_softc *sc, struct fwohci_dbch *dbch, +fwohci_arcv_free_buf(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch, struct fwohcidb_tr *db_tr, uint32_t off, int wake) { struct fwohcidb *db = &db_tr->db[0]; @@ -2732,7 +2733,7 @@ fwohci_arcv_free_buf(struct fwohci_softc *sc, struct fwohci_dbch *dbch, } static void//to be done -fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) +fwohci_arcv(struct fwohci_softc *sc, fwohci_softc::fwohci_dbch *dbch, int count) { struct fwohcidb_tr *db_tr; struct iovec vec[2]; @@ -2896,7 +2897,7 @@ fwohci_arcv(struct fwohci_softc *sc, struct fwohci_dbch *dbch, int count) if ((vec[nvec-1].iov_len -= sizeof(struct fwohci_trailer)) == 0) - nvec--; + nvec--; rb.fc = &sc->fc; rb.vec = vec; rb.nvec = nvec; diff --git a/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.c b/src/add-ons/kernel/bus_managers/firewire/fwohci_pci.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/firewire/fwohci_pci.c rename to src/add-ons/kernel/bus_managers/firewire/fwohci_pci.cpp diff --git a/src/add-ons/kernel/bus_managers/firewire/timer.c b/src/add-ons/kernel/bus_managers/firewire/timer.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/firewire/timer.c rename to src/add-ons/kernel/bus_managers/firewire/timer.cpp diff --git a/src/add-ons/kernel/bus_managers/firewire/util.h b/src/add-ons/kernel/bus_managers/firewire/util.h index da5b892a7c..93ae94a1e8 100644 --- a/src/add-ons/kernel/bus_managers/firewire/util.h +++ b/src/add-ons/kernel/bus_managers/firewire/util.h @@ -1,7 +1,7 @@ /* Realtek RTL8169 Family Driver * Copyright (C) 2004 Marcus Overhagen . All rights reserved. * - * Permission to use, copy, modify and distribute this software and its + * Permission to use, copy, modify and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies, and that both the * copyright notice and this permission notice appear in supporting documentation. @@ -19,9 +19,18 @@ #ifndef __UTIL_H #define __UTIL_H + +#include + #include + +__BEGIN_DECLS + area_id alloc_mem(void **virt, void **phy, size_t size, uint32 protection, const char *name); area_id map_mem(void **virt, void *phy, size_t size, uint32 protection, const char *name); +__END_DECLS + + #endif diff --git a/src/add-ons/kernel/bus_managers/ide/pio.cpp b/src/add-ons/kernel/bus_managers/ide/pio.cpp index 072b9687c4..672cd9bce9 100644 --- a/src/add-ons/kernel/bus_managers/ide/pio.cpp +++ b/src/add-ons/kernel/bus_managers/ide/pio.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2007, Haiku, Inc. All RightsReserved. + * Copyright 2004-2011, Haiku, Inc. All rights reserved. * Copyright 2002-2004, Thomas Kurschel. All rights reserved. * * Distributed under the terms of the MIT License. @@ -148,7 +148,7 @@ transfer_PIO_physcont(ide_device_info *device, addr_t physicalAddress, void* handle; int page_left, cur_len; status_t err; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); SHOW_FLOW(4, "Transmitting to/from physical address %lx, %d bytes left", physicalAddress, length); diff --git a/src/add-ons/kernel/bus_managers/ps2/Jamfile b/src/add-ons/kernel/bus_managers/ps2/Jamfile index 7063057ccf..c72970da42 100644 --- a/src/add-ons/kernel/bus_managers/ps2/Jamfile +++ b/src/add-ons/kernel/bus_managers/ps2/Jamfile @@ -12,6 +12,6 @@ KernelAddon ps2 : ps2_standard_mouse.c ps2_synaptics.c ps2_trackpoint.c - ps2_service.c + ps2_service.cpp movement_maker.c ; diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_service.c b/src/add-ons/kernel/bus_managers/ps2/ps2_service.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/ps2/ps2_service.c rename to src/add-ons/kernel/bus_managers/ps2/ps2_service.cpp diff --git a/src/add-ons/kernel/bus_managers/scsi/Jamfile b/src/add-ons/kernel/bus_managers/scsi/Jamfile index 144bffb79c..c395bf5c94 100644 --- a/src/add-ons/kernel/bus_managers/scsi/Jamfile +++ b/src/add-ons/kernel/bus_managers/scsi/Jamfile @@ -10,19 +10,19 @@ if $(DEBUG) = 0 { } KernelAddon scsi : - bus_raw.c - busses.c - ccb.c - device_scan.c - devices.c + bus_raw.cpp + busses.cpp + ccb.cpp + device_scan.cpp + devices.cpp dma_buffer.cpp - dpc.c + dpc.cpp emulation.cpp - queuing.c - scsi.c - scsi_io.c - scatter_gather.c - sim_interface.c - virtual_memory.c + queuing.cpp + scsi.cpp + scsi_io.cpp + scatter_gather.cpp + sim_interface.cpp + virtual_memory.cpp ; diff --git a/src/add-ons/kernel/bus_managers/scsi/bus_raw.c b/src/add-ons/kernel/bus_managers/scsi/bus_raw.cpp similarity index 92% rename from src/add-ons/kernel/bus_managers/scsi/bus_raw.c rename to src/add-ons/kernel/bus_managers/scsi/bus_raw.cpp index 54bfab7f0f..c28e3b5786 100644 --- a/src/add-ons/kernel/bus_managers/scsi/bus_raw.c +++ b/src/add-ons/kernel/bus_managers/scsi/bus_raw.cpp @@ -32,7 +32,7 @@ scsi_bus_raw_init(void *driverCookie, void **_cookie) device_node *parent; bus_raw_info *bus; - bus = malloc(sizeof(*bus)); + bus = (bus_raw_info*)malloc(sizeof(*bus)); if (bus == NULL) return B_NO_MEMORY; @@ -81,14 +81,15 @@ scsi_bus_raw_free(void *cookie) static status_t scsi_bus_raw_control(void *_cookie, uint32 op, void *data, size_t length) { - bus_raw_info *bus = _cookie; + bus_raw_info *bus = (bus_raw_info*)_cookie; switch (op) { case B_SCSI_BUS_RAW_RESET: return bus->interface->reset_bus(bus->cookie); case B_SCSI_BUS_RAW_PATH_INQUIRY: - return bus->interface->path_inquiry(bus->cookie, data); + return bus->interface->path_inquiry(bus->cookie, + (scsi_path_inquiry*)data); } return B_ERROR; diff --git a/src/add-ons/kernel/bus_managers/scsi/busses.c b/src/add-ons/kernel/bus_managers/scsi/busses.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/scsi/busses.c rename to src/add-ons/kernel/bus_managers/scsi/busses.cpp diff --git a/src/add-ons/kernel/bus_managers/scsi/ccb.c b/src/add-ons/kernel/bus_managers/scsi/ccb.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/scsi/ccb.c rename to src/add-ons/kernel/bus_managers/scsi/ccb.cpp diff --git a/src/add-ons/kernel/bus_managers/scsi/device_scan.c b/src/add-ons/kernel/bus_managers/scsi/device_scan.cpp similarity index 97% rename from src/add-ons/kernel/bus_managers/scsi/device_scan.c rename to src/add-ons/kernel/bus_managers/scsi/device_scan.cpp index 7f2b60ac17..ad9016d027 100644 --- a/src/add-ons/kernel/bus_managers/scsi/device_scan.c +++ b/src/add-ons/kernel/bus_managers/scsi/device_scan.cpp @@ -18,6 +18,8 @@ #include #include +#include + /*! send TUR result: true, if device answered @@ -113,7 +115,8 @@ scsi_scan_get_inquiry(scsi_ccb *worker_req, scsi_res_inquiry *new_inquiry_data) // unfortunately, ATAPI CD-ROM drives tend to tell that they have // only minimal info (36 bytes), but still they return (valid!) 96 bytes - // bad luck - if (min(cmd->allocation_length, new_inquiry_data->additional_length + 4) + if (std::min((int)cmd->allocation_length, + new_inquiry_data->additional_length + 4) >= (int)offsetof(scsi_res_inquiry, version_descriptor[9])) { int i, previousStandard = -1; @@ -255,7 +258,7 @@ scsi_scan_bus(scsi_bus_info *bus) // as this function is optional for SIM, we ignore its result bus->interface->scan_bus(bus->sim_cookie); - for (target_id = 0; target_id < bus->max_target_count; ++target_id) { + for (target_id = 0; target_id < (int)bus->max_target_count; ++target_id) { int lun; SHOW_FLOW(3, "target: %d", target_id); diff --git a/src/add-ons/kernel/bus_managers/scsi/devices.c b/src/add-ons/kernel/bus_managers/scsi/devices.cpp similarity index 99% rename from src/add-ons/kernel/bus_managers/scsi/devices.c rename to src/add-ons/kernel/bus_managers/scsi/devices.cpp index d7cfc6e721..c86e05f75f 100644 --- a/src/add-ons/kernel/bus_managers/scsi/devices.c +++ b/src/add-ons/kernel/bus_managers/scsi/devices.cpp @@ -19,6 +19,8 @@ #include #include +#include + /** free autosense request of device */ @@ -104,7 +106,7 @@ scsi_register_device(scsi_bus_info *bus, uchar target_id, pnp->get_attr_uint32(bus->node, B_DMA_MAX_TRANSFER_BLOCKS, &orig_max_blocks, true); - max_blocks = min(max_blocks, orig_max_blocks); + max_blocks = std::min(max_blocks, orig_max_blocks); { char vendor_ident[sizeof( inquiry_data->vendor_ident ) + 1]; @@ -291,7 +293,7 @@ scsi_init_device(device_node *node, void **cookie) return B_NO_MEMORY; // never mind if there is no path - it might be an emulated controller - path_id = -1; + path_id = (uint8)-1; pnp->get_attr_uint8(node, SCSI_BUS_PATH_ID_ITEM, &path_id, true); diff --git a/src/add-ons/kernel/bus_managers/scsi/dpc.c b/src/add-ons/kernel/bus_managers/scsi/dpc.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/scsi/dpc.c rename to src/add-ons/kernel/bus_managers/scsi/dpc.cpp diff --git a/src/add-ons/kernel/bus_managers/scsi/queuing.c b/src/add-ons/kernel/bus_managers/scsi/queuing.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/scsi/queuing.c rename to src/add-ons/kernel/bus_managers/scsi/queuing.cpp diff --git a/src/add-ons/kernel/bus_managers/scsi/scatter_gather.c b/src/add-ons/kernel/bus_managers/scsi/scatter_gather.cpp similarity index 94% rename from src/add-ons/kernel/bus_managers/scsi/scatter_gather.c rename to src/add-ons/kernel/bus_managers/scsi/scatter_gather.cpp index 830dbd3ccb..f4b2da0020 100644 --- a/src/add-ons/kernel/bus_managers/scsi/scatter_gather.c +++ b/src/add-ons/kernel/bus_managers/scsi/scatter_gather.cpp @@ -16,6 +16,8 @@ #include #include +#include + static locked_pool_cookie temp_sg_pool; @@ -27,7 +29,8 @@ fill_temp_sg(scsi_ccb *ccb) scsi_bus_info *bus = ccb->bus; uint32 dma_boundary = bus->dma_params.dma_boundary; uint32 max_sg_block_size = bus->dma_params.max_sg_block_size; - uint32 max_sg_blocks = min(bus->dma_params.max_sg_blocks, MAX_TEMP_SG_FRAGMENTS); + uint32 max_sg_blocks = std::min(bus->dma_params.max_sg_blocks, + (uint32)MAX_TEMP_SG_FRAGMENTS); iovec vec = { ccb->data, ccb->data_length @@ -61,7 +64,7 @@ fill_temp_sg(scsi_ccb *ccb) max_len = (dma_boundary + 1) - (temp_sg[cur_idx].address & dma_boundary); // restrict size per sg item - max_len = min(max_len, max_sg_block_size); + max_len = std::min(max_len, max_sg_block_size); SHOW_FLOW(4, "addr=%#" B_PRIxPHYSADDR ", size=%x, max_len=%x, " "idx=%d, num=%d", temp_sg[cur_idx].address, @@ -106,7 +109,7 @@ create_temp_sg(scsi_ccb *ccb) SHOW_FLOW(3, "ccb=%p, data=%p, data_length=%lu", ccb, ccb->data, ccb->data_length); - ccb->sg_list = temp_sg = locked_pool->alloc(temp_sg_pool); + ccb->sg_list = temp_sg = (physical_entry*)locked_pool->alloc(temp_sg_pool); if (temp_sg == NULL) { SHOW_ERROR0(2, "cannot allocate memory for IO request!"); return false; diff --git a/src/add-ons/kernel/bus_managers/scsi/scsi.c b/src/add-ons/kernel/bus_managers/scsi/scsi.cpp similarity index 100% rename from src/add-ons/kernel/bus_managers/scsi/scsi.c rename to src/add-ons/kernel/bus_managers/scsi/scsi.cpp diff --git a/src/add-ons/kernel/bus_managers/scsi/scsi_io.c b/src/add-ons/kernel/bus_managers/scsi/scsi_io.cpp similarity index 99% rename from src/add-ons/kernel/bus_managers/scsi/scsi_io.c rename to src/add-ons/kernel/bus_managers/scsi/scsi_io.cpp index ed8cf59883..d07405a08d 100644 --- a/src/add-ons/kernel/bus_managers/scsi/scsi_io.c +++ b/src/add-ons/kernel/bus_managers/scsi/scsi_io.cpp @@ -13,6 +13,8 @@ #include +#include + /** put request back in queue because of device/bus overflow */ @@ -177,7 +179,7 @@ finish_autosense(scsi_device_info *device) int sense_len; // we got sense data -> copy it to sense buffer - sense_len = min(SCSI_MAX_SENSE_SIZE, + sense_len = std::min((uint32)SCSI_MAX_SENSE_SIZE, request->data_length - request->data_resid); SHOW_FLOW(3, "Got sense: %d bytes", sense_len); diff --git a/src/add-ons/kernel/bus_managers/scsi/sim_interface.c b/src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp similarity index 98% rename from src/add-ons/kernel/bus_managers/scsi/sim_interface.c rename to src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp index f431199888..bb4fa08c83 100644 --- a/src/add-ons/kernel/bus_managers/scsi/sim_interface.c +++ b/src/add-ons/kernel/bus_managers/scsi/sim_interface.cpp @@ -91,7 +91,7 @@ scsi_controller_register_raw_device(void *_cookie) pnp->get_attr_uint8(node, SCSI_BUS_PATH_ID_ITEM, &pathID, false); // put that on heap to not overflow the limited kernel stack - name = malloc(PATH_MAX + 1); + name = (char*)malloc(PATH_MAX + 1); if (name == NULL) return B_NO_MEMORY; diff --git a/src/add-ons/kernel/bus_managers/scsi/virtual_memory.c b/src/add-ons/kernel/bus_managers/scsi/virtual_memory.cpp similarity index 97% rename from src/add-ons/kernel/bus_managers/scsi/virtual_memory.c rename to src/add-ons/kernel/bus_managers/scsi/virtual_memory.cpp index d1ee61ad0f..94baaa832b 100644 --- a/src/add-ons/kernel/bus_managers/scsi/virtual_memory.c +++ b/src/add-ons/kernel/bus_managers/scsi/virtual_memory.cpp @@ -18,6 +18,8 @@ #include +#include + /** get sg list of iovec * TBD: this should be moved to somewhere in kernel @@ -52,7 +54,7 @@ get_iovec_memory_map(iovec *vec, size_t vec_count, size_t vec_offset, size_t len // map one iovec range_start = (char *)vec->iov_base + vec_offset; - range_len = min( vec->iov_len - vec_offset, left_len ); + range_len = std::min(vec->iov_len - vec_offset, left_len); SHOW_FLOW( 3, "range_start=%x, range_len=%x", (int)range_start, (int)range_len ); diff --git a/src/add-ons/kernel/debugger/demangle/demangle.cpp b/src/add-ons/kernel/debugger/demangle/demangle.cpp index dcff13c067..60c3626176 100644 --- a/src/add-ons/kernel/debugger/demangle/demangle.cpp +++ b/src/add-ons/kernel/debugger/demangle/demangle.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -7,7 +7,9 @@ #include -#include +#ifdef _KERNEL_MODE +# include +#endif static inline bool diff --git a/src/add-ons/kernel/debugger/demangle/gcc2.cpp b/src/add-ons/kernel/debugger/demangle/gcc2.cpp index b9c6efd897..6b9e73b8d6 100644 --- a/src/add-ons/kernel/debugger/demangle/gcc2.cpp +++ b/src/add-ons/kernel/debugger/demangle/gcc2.cpp @@ -10,7 +10,9 @@ #include -#include +#ifdef _KERNEL_MODE +# include +#endif #include "demangle.h" diff --git a/src/add-ons/kernel/debugger/demangle/gcc3+.cpp b/src/add-ons/kernel/debugger/demangle/gcc3+.cpp index 66bd56ae63..46419a7714 100644 --- a/src/add-ons/kernel/debugger/demangle/gcc3+.cpp +++ b/src/add-ons/kernel/debugger/demangle/gcc3+.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -13,7 +13,9 @@ #include -#include +#ifdef _KERNEL_MODE +# include +#endif #include "demangle.h" diff --git a/src/add-ons/kernel/file_cache/launch_speedup.cpp b/src/add-ons/kernel/file_cache/launch_speedup.cpp index 0f05c5e457..27a37cbe88 100644 --- a/src/add-ons/kernel/file_cache/launch_speedup.cpp +++ b/src/add-ons/kernel/file_cache/launch_speedup.cpp @@ -685,7 +685,7 @@ status_t SessionGetter::New(const char *name, dev_t device, ino_t node, Session **_session) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); fSession = start_session(thread->team->id, device, node, name); if (fSession != NULL) { diff --git a/src/add-ons/kernel/file_cache/log.cpp b/src/add-ons/kernel/file_cache/log.cpp index 6fe1b7b3e0..3c8aa4690c 100644 --- a/src/add-ons/kernel/file_cache/log.cpp +++ b/src/add-ons/kernel/file_cache/log.cpp @@ -83,7 +83,7 @@ get_log_entry() mutex_lock(&sLock); cache_log *log = &sLogEntries[sCurrentEntry++]; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); log->team = thread->team->id; strlcpy(log->team_name, thread->name, B_OS_NAME_LENGTH); @@ -167,7 +167,7 @@ log_node_launched(size_t argCount, char * const *args) for (uint32 i = 0; i < argCount; i++) { if (i == 0) { // cut off path from parent team name - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; char name[B_OS_NAME_LENGTH]; cpu_status state; diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp index fdf376fdcc..5c76c75c75 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2001-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -732,7 +732,7 @@ FileSystem::_NodeListenerEventOccurred(NodeListenerProxy* proxy, if (error != B_OK) return; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); request->team = thread->team->id; request->thread = thread->id; request->user = geteuid(); diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp index 78b61bca4f..0bfbed90cb 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2001-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -4386,7 +4386,7 @@ Volume::_SendRequest(RequestPort* port, RequestAllocator* allocator, // fill in the caller info KernelRequest* request = static_cast( allocator->GetRequest()); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); request->team = thread->team->id; request->thread = thread->id; request->user = geteuid(); diff --git a/src/add-ons/kernel/network/stack/utility.cpp b/src/add-ons/kernel/network/stack/utility.cpp index 99b83dead8..f31656de27 100644 --- a/src/add-ons/kernel/network/stack/utility.cpp +++ b/src/add-ons/kernel/network/stack/utility.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2011, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -698,7 +698,7 @@ uninit_timers(void) bool is_syscall(void) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); return (thread->flags & THREAD_FLAGS_SYSCALL) != 0; } @@ -713,7 +713,7 @@ is_restarted_syscall(void) void store_syscall_restart_timeout(bigtime_t timeout) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if ((thread->flags & THREAD_FLAGS_SYSCALL) != 0) *(bigtime_t*)thread->syscall_restart.parameters = timeout; } @@ -722,7 +722,7 @@ store_syscall_restart_timeout(bigtime_t timeout) bigtime_t restore_syscall_restart_timeout(void) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); return *(bigtime_t*)thread->syscall_restart.parameters; } diff --git a/src/apps/debugger/demangler/Jamfile b/src/apps/debugger/demangler/Jamfile index e66ddc6e3f..613c6aace5 100644 --- a/src/apps/debugger/demangler/Jamfile +++ b/src/apps/debugger/demangler/Jamfile @@ -3,8 +3,6 @@ SubDir HAIKU_TOP src apps debugger demangler ; CCFLAGS += -Werror ; C++FLAGS += -Werror ; -UsePrivateHeaders kernel ; - SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel debugger demangle ] ; @@ -12,7 +10,7 @@ SEARCH_SOURCE MergeObject Debugger_demangler.o : Demangler.cpp - + demangle.cpp gcc2.cpp gcc3+.cpp diff --git a/src/bin/fwcontrol/fwcrom.c b/src/bin/fwcontrol/fwcrom.c index 7449fdd557..772c71d6bd 100644 --- a/src/bin/fwcontrol/fwcrom.c +++ b/src/bin/fwcontrol/fwcrom.c @@ -1,7 +1,7 @@ /*- * Copyright (c) 2002-2003 * Hidetoshi Shimokawa. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -18,7 +18,7 @@ * 4. Neither the name of the author nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -430,7 +430,7 @@ crom_add_entry(struct crom_chunk *chunk, int key, int val) struct csrreg reg; uint32_t i; } foo; - + foo.reg.key = key; foo.reg.val = val; return (crom_add_quad(chunk, foo.i)); @@ -460,7 +460,7 @@ crom_add_chunk(struct crom_src *src, struct crom_chunk *parent, #define MAX_TEXT ((CROM_MAX_CHUNK_LEN + 1) * 4 - sizeof(struct csrtext)) int crom_add_simple_text(struct crom_src *src, struct crom_chunk *parent, - struct crom_chunk *chunk, char *buf) + struct crom_chunk *chunk, const char *buf) { struct csrtext *tl; uint32_t *p; diff --git a/src/system/kernel/arch/arm/arch_debug.cpp b/src/system/kernel/arch/arm/arch_debug.cpp index 8be9482032..5b4cd603df 100644 --- a/src/system/kernel/arch/arm/arch_debug.cpp +++ b/src/system/kernel/arch/arm/arch_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2009, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -65,7 +65,7 @@ get_current_stack_frame() static status_t get_next_frame(addr_t framePointer, addr_t *next, addr_t *ip) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); addr_t oldFaultHandler = thread->fault_handler; // set fault handler, so that we can safely access user stacks @@ -88,7 +88,7 @@ error: static void -print_stack_frame(struct thread *thread, addr_t ip, addr_t framePointer, +print_stack_frame(Thread *thread, addr_t ip, addr_t framePointer, addr_t nextFramePointer) { addr_t diff = nextFramePointer - framePointer; @@ -128,7 +128,7 @@ stack_trace(int argc, char **argv) { uint32 previousLocations[NUM_PREVIOUS_LOCATIONS]; struct iframe_stack *frameStack; - struct thread *thread; + Thread *thread; addr_t framePointer; int32 i, num = 0, last = 0; @@ -234,7 +234,7 @@ arch_debug_save_registers(struct arch_debug_registers* registers) bool -arch_debug_contains_call(struct thread *thread, const char *symbol, +arch_debug_contains_call(Thread *thread, const char *symbol, addr_t start, addr_t end) { return false; diff --git a/src/system/kernel/arch/arm/arch_thread.cpp b/src/system/kernel/arch/arm/arch_thread.cpp index 71618f60e9..d97f15eb16 100644 --- a/src/system/kernel/arch/arm/arch_thread.cpp +++ b/src/system/kernel/arch/arm/arch_thread.cpp @@ -31,7 +31,7 @@ // a new thread structure. static struct arch_thread sInitialState; -struct thread *gCurrentThread; +Thread *gCurrentThread; status_t @@ -45,7 +45,7 @@ arch_thread_init(struct kernel_args *args) status_t -arch_team_init_team_struct(struct team *team, bool kernel) +arch_team_init_team_struct(Team *team, bool kernel) { // Nothing to do. The structure is empty. return B_OK; @@ -53,7 +53,7 @@ arch_team_init_team_struct(struct team *team, bool kernel) status_t -arch_thread_init_thread_struct(struct thread *thread) +arch_thread_init_thread_struct(Thread *thread) { // set up an initial state (stack & fpu) memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); @@ -63,7 +63,7 @@ arch_thread_init_thread_struct(struct thread *thread) status_t -arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), +arch_thread_init_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)) { /* addr_t *kstack = (addr_t *)t->kernel_stack_base; @@ -107,7 +107,7 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), status_t -arch_thread_init_tls(struct thread *thread) +arch_thread_init_tls(Thread *thread) { // TODO: Implement! return B_OK; @@ -115,7 +115,7 @@ arch_thread_init_tls(struct thread *thread) void -arch_thread_context_switch(struct thread *from, struct thread *to) +arch_thread_context_switch(Thread *from, Thread *to) { /* addr_t newPageDirectory; @@ -141,7 +141,7 @@ arch_thread_dump_info(void *info) status_t -arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, void *arg2) +arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) { panic("arch_thread_enter_uspace(): not yet implemented\n"); return B_ERROR; @@ -149,14 +149,14 @@ arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, voi bool -arch_on_signal_stack(struct thread *thread) +arch_on_signal_stack(Thread *thread) { return false; } status_t -arch_setup_signal_frame(struct thread *thread, struct sigaction *sa, int sig, int sigMask) +arch_setup_signal_frame(Thread *thread, struct sigaction *sa, int sig, int sigMask) { return B_ERROR; } @@ -170,7 +170,7 @@ arch_restore_signal_frame(void) void -arch_check_syscall_restart(struct thread *thread) +arch_check_syscall_restart(Thread *thread) { } diff --git a/src/system/kernel/arch/arm/arch_user_debugger.cpp b/src/system/kernel/arch/arm/arch_user_debugger.cpp index 4fceffabdd..dfc0f37038 100644 --- a/src/system/kernel/arch/arm/arch_user_debugger.cpp +++ b/src/system/kernel/arch/arm/arch_user_debugger.cpp @@ -59,8 +59,7 @@ arch_get_debug_cpu_state(debug_cpu_state *cpuState) status_t -arch_get_thread_debug_cpu_state(struct thread *thread, - debug_cpu_state *cpuState) +arch_get_thread_debug_cpu_state(Thread *thread, debug_cpu_state *cpuState) { return B_ERROR; } diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp b/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp index 9e9d42099c..719c42af74 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp +++ b/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp @@ -1,6 +1,6 @@ /* * Copyright 2010, Ithamar R. Adema, ithamar.adema@team-embedded.nl - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * @@ -184,7 +184,7 @@ ARMVMTranslationMap32Bit::Map(addr_t va, phys_addr_t pa, uint32 attributes, } // now, fill in the pentry - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -229,7 +229,7 @@ ARMVMTranslationMap32Bit::Unmap(addr_t start, addr_t end) continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -360,7 +360,7 @@ ARMVMTranslationMap32Bit::UnmapPages(VMArea* area, addr_t base, size_t size, continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -570,7 +570,7 @@ ARMVMTranslationMap32Bit::Query(addr_t va, phys_addr_t *_physical, return B_OK; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -675,7 +675,7 @@ ARMVMTranslationMap32Bit::Protect(addr_t start, addr_t end, uint32 attributes, continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -736,7 +736,7 @@ ARMVMTranslationMap32Bit::ClearFlags(addr_t va, uint32 flags) #else uint32 flagsToClear = 0; #endif - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( diff --git a/src/system/kernel/arch/arm/paging/ARMVMTranslationMap.cpp b/src/system/kernel/arch/arm/paging/ARMVMTranslationMap.cpp index b915cd7229..ca5b73777a 100644 --- a/src/system/kernel/arch/arm/paging/ARMVMTranslationMap.cpp +++ b/src/system/kernel/arch/arm/paging/ARMVMTranslationMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * @@ -95,7 +95,7 @@ ARMVMTranslationMap::Flush() if (fInvalidPagesCount <= 0) return; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread_pin_to_current_cpu(thread); if (fInvalidPagesCount > PAGE_INVALIDATE_CACHE_SIZE) { diff --git a/src/system/kernel/arch/arm/paging/arm_physical_page_mapper_large_memory.cpp b/src/system/kernel/arch/arm/paging/arm_physical_page_mapper_large_memory.cpp index 6e54a5c508..ad3dde3faa 100644 --- a/src/system/kernel/arch/arm/paging/arm_physical_page_mapper_large_memory.cpp +++ b/src/system/kernel/arch/arm/paging/arm_physical_page_mapper_large_memory.cpp @@ -1,6 +1,6 @@ /* * Copyright 2010, Ithamar R. Adema, ithamar.adema@team-embedded.nl - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -573,7 +573,7 @@ LargeMemoryPhysicalPageMapper::MemsetPhysical(phys_addr_t address, int value, { phys_addr_t pageOffset = address % B_PAGE_SIZE; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, @@ -604,7 +604,7 @@ LargeMemoryPhysicalPageMapper::MemcpyFromPhysical(void* _to, phys_addr_t from, uint8* to = (uint8*)_to; phys_addr_t pageOffset = from % B_PAGE_SIZE; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, user); @@ -644,7 +644,7 @@ LargeMemoryPhysicalPageMapper::MemcpyToPhysical(phys_addr_t to, const uint8* from = (const uint8*)_from; phys_addr_t pageOffset = to % B_PAGE_SIZE; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, user); @@ -681,7 +681,7 @@ void LargeMemoryPhysicalPageMapper::MemcpyPhysicalPage(phys_addr_t to, phys_addr_t from) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, diff --git a/src/system/kernel/arch/m68k/arch_debug.cpp b/src/system/kernel/arch/m68k/arch_debug.cpp index 00d1ef3e47..23175d60d6 100644 --- a/src/system/kernel/arch/m68k/arch_debug.cpp +++ b/src/system/kernel/arch/m68k/arch_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -79,7 +79,7 @@ get_next_frame(addr_t framePointer, addr_t *next, addr_t *ip) static void -print_stack_frame(struct thread *thread, addr_t ip, addr_t framePointer, +print_stack_frame(Thread *thread, addr_t ip, addr_t framePointer, addr_t nextFramePointer) { addr_t diff = nextFramePointer - framePointer; @@ -119,7 +119,7 @@ stack_trace(int argc, char **argv) { uint32 previousLocations[NUM_PREVIOUS_LOCATIONS]; struct iframe_stack *frameStack; - struct thread *thread; + Thread *thread; addr_t framePointer; int32 i, num = 0, last = 0; @@ -262,7 +262,7 @@ arch_debug_stack_trace(void) bool -arch_debug_contains_call(struct thread *thread, const char *symbol, +arch_debug_contains_call(Thread *thread, const char *symbol, addr_t start, addr_t end) { return false; @@ -295,7 +295,7 @@ arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, if (skipIframes > 0) skipFrames = INT_MAX; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); framePointer = (addr_t)get_current_stack_frame(); bool onKernelStack = true; diff --git a/src/system/kernel/arch/m68k/arch_int.cpp b/src/system/kernel/arch/m68k/arch_int.cpp index 81e9365f39..0569f0a14c 100644 --- a/src/system/kernel/arch/m68k/arch_int.cpp +++ b/src/system/kernel/arch/m68k/arch_int.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -176,7 +176,7 @@ m68k_exception_entry(struct iframe *iframe) "pc: %p\n", system_time(), vector, iframe, (void*)iframe->cpu.pc); } - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); // push iframe if (thread) diff --git a/src/system/kernel/arch/m68k/arch_thread.cpp b/src/system/kernel/arch/m68k/arch_thread.cpp index 9bad8caffb..b5e0e8fdfd 100644 --- a/src/system/kernel/arch/m68k/arch_thread.cpp +++ b/src/system/kernel/arch/m68k/arch_thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -31,7 +31,7 @@ // a new thread structure. static struct arch_thread sInitialState; -struct thread *gCurrentThread; +Thread *gCurrentThread; // Helper function for thread creation, defined in arch_asm.S. extern "C" void m68k_kernel_thread_root(); @@ -61,7 +61,7 @@ m68k_pop_iframe(struct iframe_stack *stack) static struct iframe * m68k_get_current_iframe(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); ASSERT(thread->arch_info.iframes.index >= 0); return thread->arch_info.iframes.frames[thread->arch_info.iframes.index - 1]; @@ -77,7 +77,7 @@ m68k_get_current_iframe(void) struct iframe * m68k_get_user_iframe(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int i; for (i = thread->arch_info.iframes.index - 1; i >= 0; i--) { @@ -91,7 +91,7 @@ m68k_get_user_iframe(void) void * -m68k_next_page_directory(struct thread *from, struct thread *to) +m68k_next_page_directory(Thread *from, Thread *to) { if (from->team->address_space != NULL && to->team->address_space != NULL) { // they are both user space threads @@ -129,7 +129,7 @@ arch_thread_init(struct kernel_args *args) status_t -arch_team_init_team_struct(struct team *team, bool kernel) +arch_team_init_team_struct(Team *team, bool kernel) { // Nothing to do. The structure is empty. return B_OK; @@ -137,7 +137,7 @@ arch_team_init_team_struct(struct team *team, bool kernel) status_t -arch_thread_init_thread_struct(struct thread *thread) +arch_thread_init_thread_struct(Thread *thread) { // set up an initial state (stack & fpu) memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); @@ -147,7 +147,7 @@ arch_thread_init_thread_struct(struct thread *thread) status_t -arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), +arch_thread_init_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)) { addr_t *kstack = (addr_t *)t->kernel_stack_base; @@ -190,7 +190,7 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), status_t -arch_thread_init_tls(struct thread *thread) +arch_thread_init_tls(Thread *thread) { // TODO: Implement! return B_OK; @@ -198,7 +198,7 @@ arch_thread_init_tls(struct thread *thread) void -arch_thread_context_switch(struct thread *from, struct thread *to) +arch_thread_context_switch(Thread *from, Thread *to) { addr_t newPageDirectory; @@ -222,7 +222,7 @@ arch_thread_dump_info(void *info) status_t -arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, void *arg2) +arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) { panic("arch_thread_enter_uspace(): not yet implemented\n"); return B_ERROR; @@ -230,14 +230,14 @@ arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, voi bool -arch_on_signal_stack(struct thread *thread) +arch_on_signal_stack(Thread *thread) { return false; } status_t -arch_setup_signal_frame(struct thread *thread, struct sigaction *sa, int sig, int sigMask) +arch_setup_signal_frame(Thread *thread, struct sigaction *sa, int sig, int sigMask) { return B_ERROR; } @@ -251,7 +251,7 @@ arch_restore_signal_frame(void) void -arch_check_syscall_restart(struct thread *thread) +arch_check_syscall_restart(Thread *thread) { } diff --git a/src/system/kernel/arch/m68k/arch_user_debugger.cpp b/src/system/kernel/arch/m68k/arch_user_debugger.cpp index 028c63c012..7203483fc1 100644 --- a/src/system/kernel/arch/m68k/arch_user_debugger.cpp +++ b/src/system/kernel/arch/m68k/arch_user_debugger.cpp @@ -44,7 +44,7 @@ void arch_update_thread_single_step() { if (struct iframe* frame = m68k_get_user_iframe()) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); // set/clear T1 in SR depending on if single stepping is desired // T1 T0 diff --git a/src/system/kernel/arch/m68k/asm_offsets.cpp b/src/system/kernel/arch/m68k/asm_offsets.cpp index 4651bf4887..7cd600c416 100644 --- a/src/system/kernel/arch/m68k/asm_offsets.cpp +++ b/src/system/kernel/arch/m68k/asm_offsets.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -28,14 +28,14 @@ void dummy() { - // struct thread - DEFINE_OFFSET_MACRO(THREAD, thread, kernel_time); - DEFINE_OFFSET_MACRO(THREAD, thread, user_time); - DEFINE_OFFSET_MACRO(THREAD, thread, last_time); - DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); - DEFINE_OFFSET_MACRO(THREAD, thread, flags); - DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top); - DEFINE_OFFSET_MACRO(THREAD, thread, fault_handler); + // struct Thread + DEFINE_OFFSET_MACRO(THREAD, Thread, kernel_time); + DEFINE_OFFSET_MACRO(THREAD, Thread, user_time); + DEFINE_OFFSET_MACRO(THREAD, Thread, last_time); + DEFINE_OFFSET_MACRO(THREAD, Thread, in_kernel); + DEFINE_OFFSET_MACRO(THREAD, Thread, flags); + DEFINE_OFFSET_MACRO(THREAD, Thread, kernel_stack_top); + DEFINE_OFFSET_MACRO(THREAD, Thread, fault_handler); // struct iframe DEFINE_OFFSET_MACRO(IFRAME, iframe, fp); diff --git a/src/system/kernel/arch/mips/arch_thread.cpp b/src/system/kernel/arch/mips/arch_thread.cpp index c9a1b79c65..3365c0d1fa 100755 --- a/src/system/kernel/arch/mips/arch_thread.cpp +++ b/src/system/kernel/arch/mips/arch_thread.cpp @@ -1,4 +1,4 @@ -/* +/* ** Copyright 2001, Travis Geiselbrecht. All rights reserved. ** Distributed under the terms of the NewOS License. */ @@ -10,21 +10,21 @@ int arch_proc_init_proc_struct(struct proc *p, bool kernel) return 0; } -int arch_thread_init_thread_struct(struct thread *t) +int arch_thread_init_thread_struct(Thread *t) { return 0; } -int arch_thread_initialize_kthread_stack(struct thread *t, int (*start_func)(void), void (*entry_func)(void)) +int arch_thread_initialize_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void)) { return 0; } -void arch_thread_context_switch(struct thread *t_from, struct thread *t_to) +void arch_thread_context_switch(Thread *t_from, Thread *t_to) { #if 0 int i; - dprintf("arch_thread_context_switch: 0x%x->0x%x to sp 0x%x\n", + dprintf("arch_thread_context_switch: 0x%x->0x%x to sp 0x%x\n", t_from->id, t_to->id, t_to->arch_info.sp); #endif #if 0 @@ -34,7 +34,7 @@ void arch_thread_context_switch(struct thread *t_from, struct thread *t_to) #endif #if 0 sh4_set_kstack(t_to->kernel_stack_area->base + KSTACK_SIZE); - + if(t_from->proc->arch_info.pgdir != t_to->proc->arch_info.pgdir) sh4_set_user_pgdir((addr)t_to->proc->arch_info.pgdir); sh4_context_switch(&t_from->arch_info.sp, t_to->arch_info.sp); diff --git a/src/system/kernel/arch/mipsel/arch_debug.cpp b/src/system/kernel/arch/mipsel/arch_debug.cpp index 384ce7932f..b152cd2640 100644 --- a/src/system/kernel/arch/mipsel/arch_debug.cpp +++ b/src/system/kernel/arch/mipsel/arch_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2009, Haiku Inc. All rights reserved. + * Copyright 2003-201, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -42,7 +42,7 @@ arch_debug_save_registers(struct arch_debug_registers* registers) bool -arch_debug_contains_call(struct thread* thread, const char* symbol, +arch_debug_contains_call(Thread* thread, const char* symbol, addr_t start, addr_t end) { #warning IMPLEMENT arch_debug_contains_call diff --git a/src/system/kernel/arch/mipsel/arch_thread.cpp b/src/system/kernel/arch/mipsel/arch_thread.cpp index 3c25b8e37f..0730a98a34 100644 --- a/src/system/kernel/arch/mipsel/arch_thread.cpp +++ b/src/system/kernel/arch/mipsel/arch_thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010 Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -71,7 +71,7 @@ arch_thread_init(struct kernel_args *args) status_t -arch_team_init_team_struct(struct team *team, bool kernel) +arch_team_init_team_struct(Team *team, bool kernel) { #warning IMPLEMENT arch_team_init_team_struct return B_ERROR; @@ -79,7 +79,7 @@ arch_team_init_team_struct(struct team *team, bool kernel) status_t -arch_thread_init_thread_struct(struct thread *thread) +arch_thread_init_thread_struct(Thread *thread) { #warning IMPLEMENT arch_thread_init_thread_struct return B_ERROR; @@ -87,7 +87,7 @@ arch_thread_init_thread_struct(struct thread *thread) status_t -arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), +arch_thread_init_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)) { #warning IMPLEMENT arch_thread_init_kthread_stack @@ -96,7 +96,7 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), status_t -arch_thread_init_tls(struct thread *thread) +arch_thread_init_tls(Thread *thread) { #warning IMPLEMENT arch_thread_init_tls return B_ERROR; @@ -104,7 +104,7 @@ arch_thread_init_tls(struct thread *thread) void -arch_thread_context_switch(struct thread *from, struct thread *to) +arch_thread_context_switch(Thread *from, Thread *to) { #warning IMPLEMENT arch_thread_context_switch } @@ -118,7 +118,7 @@ arch_thread_dump_info(void *info) status_t -arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, +arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) { #warning IMPLEMENT arch_thread_enter_userspace @@ -128,7 +128,7 @@ arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, bool -arch_on_signal_stack(struct thread *thread) +arch_on_signal_stack(Thread *thread) { #warning IMPLEMENT arch_on_signal_stack return false; @@ -136,7 +136,7 @@ arch_on_signal_stack(struct thread *thread) status_t -arch_setup_signal_frame(struct thread *thread, struct sigaction *sa, int sig, +arch_setup_signal_frame(Thread *thread, struct sigaction *sa, int sig, int sigMask) { #warning IMPLEMENT arch_setup_signal_frame @@ -153,7 +153,7 @@ arch_restore_signal_frame(void) void -arch_check_syscall_restart(struct thread *thread) +arch_check_syscall_restart(Thread *thread) { #warning IMPLEMENT arch_check_syscall_restart } diff --git a/src/system/kernel/arch/mipsel/arch_user_debugger.cpp b/src/system/kernel/arch/mipsel/arch_user_debugger.cpp index acefbb0813..b639168021 100644 --- a/src/system/kernel/arch/mipsel/arch_user_debugger.cpp +++ b/src/system/kernel/arch/mipsel/arch_user_debugger.cpp @@ -61,7 +61,7 @@ arch_get_debug_cpu_state(debug_cpu_state* cpuState) status_t -arch_get_thread_debug_cpu_state(struct thread* thread, +arch_get_thread_debug_cpu_state(Thread* thread, debug_cpu_state* cpuState) { #warning IMPLEMENT arch_get_thread_debug_cpu_state diff --git a/src/system/kernel/arch/ppc/arch_debug.cpp b/src/system/kernel/arch/ppc/arch_debug.cpp index e472fa28d6..ef43956724 100644 --- a/src/system/kernel/arch/ppc/arch_debug.cpp +++ b/src/system/kernel/arch/ppc/arch_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -78,7 +78,7 @@ get_next_frame(addr_t framePointer, addr_t *next, addr_t *ip) static void -print_stack_frame(struct thread *thread, addr_t ip, addr_t framePointer, +print_stack_frame(Thread *thread, addr_t ip, addr_t framePointer, addr_t nextFramePointer) { addr_t diff = nextFramePointer - framePointer; @@ -118,7 +118,7 @@ stack_trace(int argc, char **argv) { uint32 previousLocations[NUM_PREVIOUS_LOCATIONS]; struct iframe_stack *frameStack; - struct thread *thread; + Thread *thread; addr_t framePointer; int32 i, num = 0, last = 0; @@ -273,7 +273,7 @@ arch_debug_stack_trace(void) bool -arch_debug_contains_call(struct thread *thread, const char *symbol, +arch_debug_contains_call(Thread *thread, const char *symbol, addr_t start, addr_t end) { return false; diff --git a/src/system/kernel/arch/ppc/arch_int.cpp b/src/system/kernel/arch/ppc/arch_int.cpp index 8de2fb083a..6830136478 100644 --- a/src/system/kernel/arch/ppc/arch_int.cpp +++ b/src/system/kernel/arch/ppc/arch_int.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -103,7 +103,7 @@ ppc_exception_entry(int vector, struct iframe *iframe) "srr0: %p\n", system_time(), vector, iframe, (void*)iframe->srr0); } - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); // push iframe if (thread) @@ -132,7 +132,7 @@ ppc_exception_entry(int vector, struct iframe *iframe) iframe->r1 = cpu->fault_handler_stack_pointer; break; } - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); if (thread && thread->fault_handler != 0) { iframe->srr0 = thread->fault_handler; break; diff --git a/src/system/kernel/arch/ppc/arch_thread.cpp b/src/system/kernel/arch/ppc/arch_thread.cpp index 0e145bc219..d9b023f6ff 100644 --- a/src/system/kernel/arch/ppc/arch_thread.cpp +++ b/src/system/kernel/arch/ppc/arch_thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku Inc. All rights reserved. + * Copyright 2003-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -56,7 +56,7 @@ ppc_pop_iframe(struct iframe_stack *stack) static struct iframe * ppc_get_current_iframe(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); ASSERT(thread->arch_info.iframes.index >= 0); return thread->arch_info.iframes.frames[thread->arch_info.iframes.index - 1]; @@ -72,7 +72,7 @@ ppc_get_current_iframe(void) struct iframe * ppc_get_user_iframe(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int i; for (i = thread->arch_info.iframes.index - 1; i >= 0; i--) { @@ -99,7 +99,7 @@ arch_thread_init(struct kernel_args *args) status_t -arch_team_init_team_struct(struct team *team, bool kernel) +arch_team_init_team_struct(Team *team, bool kernel) { // Nothing to do. The structure is empty. return B_OK; @@ -107,7 +107,7 @@ arch_team_init_team_struct(struct team *team, bool kernel) status_t -arch_thread_init_thread_struct(struct thread *thread) +arch_thread_init_thread_struct(Thread *thread) { // set up an initial state (stack & fpu) memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); @@ -117,7 +117,7 @@ arch_thread_init_thread_struct(struct thread *thread) status_t -arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), +arch_thread_init_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)) { addr_t *kstack = (addr_t *)t->kernel_stack_base; @@ -160,7 +160,7 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), status_t -arch_thread_init_tls(struct thread *thread) +arch_thread_init_tls(Thread *thread) { // TODO: Implement! return B_OK; @@ -168,7 +168,7 @@ arch_thread_init_tls(struct thread *thread) void -arch_thread_context_switch(struct thread *t_from, struct thread *t_to) +arch_thread_context_switch(Thread *t_from, Thread *t_to) { // set the new kernel stack in the EAR register. // this is used in the exception handler code to decide what kernel stack to @@ -199,7 +199,7 @@ arch_thread_dump_info(void *info) status_t -arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, void *arg2) +arch_thread_enter_userspace(Thread *thread, addr_t entry, void *arg1, void *arg2) { panic("arch_thread_enter_uspace(): not yet implemented\n"); return B_ERROR; @@ -207,14 +207,14 @@ arch_thread_enter_userspace(struct thread *thread, addr_t entry, void *arg1, voi bool -arch_on_signal_stack(struct thread *thread) +arch_on_signal_stack(Thread *thread) { return false; } status_t -arch_setup_signal_frame(struct thread *thread, struct sigaction *sa, int sig, int sigMask) +arch_setup_signal_frame(Thread *thread, struct sigaction *sa, int sig, int sigMask) { return B_ERROR; } diff --git a/src/system/kernel/arch/x86/arch_debug.cpp b/src/system/kernel/arch/x86/arch_debug.cpp index 62b9336416..f4e7a9bb35 100644 --- a/src/system/kernel/arch/x86/arch_debug.cpp +++ b/src/system/kernel/arch/x86/arch_debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -94,7 +94,7 @@ get_next_frame_debugger(addr_t ebp, addr_t *_next, addr_t *_eip) static status_t -lookup_symbol(struct thread* thread, addr_t address, addr_t *_baseAddress, +lookup_symbol(Thread* thread, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch) { status_t status = B_ENTRY_NOT_FOUND; @@ -307,7 +307,7 @@ print_demangled_call(const char* image, const char* symbol, addr_t args, static void -print_stack_frame(struct thread *thread, addr_t eip, addr_t ebp, addr_t nextEbp, +print_stack_frame(Thread *thread, addr_t eip, addr_t ebp, addr_t nextEbp, int32 callIndex, bool demangle) { const char *symbol, *image; @@ -380,10 +380,10 @@ print_iframe(struct iframe *frame) static bool -setup_for_thread(char *arg, struct thread **_thread, uint32 *_ebp, +setup_for_thread(char *arg, Thread **_thread, uint32 *_ebp, uint32 *_oldPageDirectory) { - struct thread *thread = NULL; + Thread *thread = NULL; if (arg != NULL) { thread_id id = strtoul(arg, NULL, 0); @@ -442,7 +442,7 @@ is_double_fault_stack_address(int32 cpu, addr_t address) static bool -is_kernel_stack_address(struct thread* thread, addr_t address) +is_kernel_stack_address(Thread* thread, addr_t address) { // We don't have a thread pointer in the early boot process, but then we are // on the kernel stack for sure. @@ -462,7 +462,7 @@ is_kernel_stack_address(struct thread* thread, addr_t address) static bool -is_iframe(struct thread* thread, addr_t frame) +is_iframe(Thread* thread, addr_t frame) { if (!is_kernel_stack_address(thread, frame)) return false; @@ -473,7 +473,7 @@ is_iframe(struct thread* thread, addr_t frame) static struct iframe * -find_previous_iframe(struct thread *thread, addr_t frame) +find_previous_iframe(Thread *thread, addr_t frame) { // iterate backwards through the stack frames, until we hit an iframe while (is_kernel_stack_address(thread, frame)) { @@ -488,7 +488,7 @@ find_previous_iframe(struct thread *thread, addr_t frame) static struct iframe* -get_previous_iframe(struct thread* thread, struct iframe* frame) +get_previous_iframe(Thread* thread, struct iframe* frame) { if (frame == NULL) return NULL; @@ -498,7 +498,7 @@ get_previous_iframe(struct thread* thread, struct iframe* frame) static struct iframe* -get_current_iframe(struct thread* thread) +get_current_iframe(Thread* thread) { if (thread == thread_get_current_thread()) return i386_get_current_iframe(); @@ -602,7 +602,7 @@ stack_trace(int argc, char **argv) } uint32 previousLocations[NUM_PREVIOUS_LOCATIONS]; - struct thread *thread = NULL; + Thread *thread = NULL; uint32 oldPageDirectory = 0; uint32 ebp = x86_read_ebp(); int32 num = 0, last = 0; @@ -676,7 +676,7 @@ stack_trace(int argc, char **argv) static void -print_call(struct thread *thread, addr_t eip, addr_t ebp, addr_t nextEbp, +print_call(Thread *thread, addr_t eip, addr_t ebp, addr_t nextEbp, int32 argCount) { const char *symbol, *image; @@ -756,7 +756,7 @@ show_call(int argc, char **argv) return 0; } - struct thread *thread = NULL; + Thread *thread = NULL; uint32 oldPageDirectory = 0; addr_t ebp = x86_read_ebp(); int32 argCount = 0; @@ -848,7 +848,7 @@ dump_iframes(int argc, char **argv) return 0; } - struct thread *thread = NULL; + Thread *thread = NULL; if (argc < 2) { thread = thread_get_current_thread(); @@ -880,7 +880,7 @@ dump_iframes(int argc, char **argv) static bool -is_calling(struct thread *thread, addr_t eip, const char *pattern, +is_calling(Thread *thread, addr_t eip, const char *pattern, addr_t start, addr_t end) { if (pattern == NULL) @@ -924,7 +924,7 @@ cmd_in_context(int argc, char** argv) return 0; // get the thread - struct thread* thread = thread_get_thread_struct_locked(threadID); + Thread* thread = thread_get_thread_struct_locked(threadID); if (thread == NULL) { kprintf("Could not find thread with ID \"%s\".\n", threadIDString); return 0; @@ -976,7 +976,7 @@ arch_debug_stack_trace(void) bool -arch_debug_contains_call(struct thread *thread, const char *symbol, +arch_debug_contains_call(Thread *thread, const char *symbol, addr_t start, addr_t end) { DebuggedThreadSetter threadSetter(thread); @@ -1060,7 +1060,7 @@ arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount, if (skipIframes > 0) skipFrames = INT_MAX; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); int32 count = 0; addr_t ebp = x86_read_ebp(); bool onKernelStack = true; diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index b7ca2cd520..939dee1601 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -1,6 +1,6 @@ /* * Copyright 2010, Clemens Zeidler, haiku@clemens-zeidler.de. - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -670,8 +670,8 @@ ioapic_init(kernel_args* args) uint32 config = 0; config |= irqDescriptor.polarity; config |= irqDescriptor.interrupt_mode; - - int32 num = entry.source_index; + + int32 num = entry.source_index; for (int a = 0; a < 16 && num == 0; a++) { if (irqDescriptor.irq >> i & 0x01) { num = a; @@ -759,7 +759,7 @@ exception_name(int number, char *buffer, int32 bufferSize) static void invalid_exception(struct iframe* frame) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); char name[32]; panic("unhandled trap 0x%lx (%s) at ip 0x%lx, thread %ld!\n", frame->vector, exception_name(frame->vector, name, sizeof(name)), @@ -836,7 +836,7 @@ unexpected_exception(struct iframe* frame) if (IFRAME_IS_USER(frame)) { struct sigaction action; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); enable_interrupts(); @@ -926,7 +926,7 @@ x86_page_fault_exception_double_fault(struct iframe* frame) static void page_fault_exception(struct iframe* frame) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); uint32 cr2; addr_t newip; @@ -1011,7 +1011,7 @@ hardware_interrupt(struct iframe* frame) { int32 vector = frame->vector - ARCH_INTERRUPT_BASE; bool levelTriggered = false; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (sCurrentPIC->is_spurious_interrupt(vector)) { TRACE(("got spurious interrupt at vector %ld\n", vector)); diff --git a/src/system/kernel/arch/x86/arch_interrupts.S b/src/system/kernel/arch/x86/arch_interrupts.S index ac496d63b0..f0fdca87f7 100644 --- a/src/system/kernel/arch/x86/arch_interrupts.S +++ b/src/system/kernel/arch/x86/arch_interrupts.S @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008, The Haiku Team. All rights reserved. + * Copyright 2002-2011, The Haiku Team. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2001, Travis Geiselbrecht. All rights reserved. @@ -852,7 +852,7 @@ FUNCTION(x86_vm86_enter): // get pointers movl 32(%esp), %esi // vm86 iframe push %esi // ... store iframe addr for x86_vm86_return - movl %dr3, %edi // struct thread + movl %dr3, %edi // Thread* // make sure eflags are in right shape movl VM86_IFRAME_flags(%esi), %eax diff --git a/src/system/kernel/arch/x86/arch_thread.cpp b/src/system/kernel/arch/x86/arch_thread.cpp index 10b031d012..b3457d6c36 100644 --- a/src/system/kernel/arch/x86/arch_thread.cpp +++ b/src/system/kernel/arch/x86/arch_thread.cpp @@ -93,7 +93,7 @@ arch_thread_init(struct kernel_args *args) static struct iframe * -find_previous_iframe(struct thread *thread, addr_t frame) +find_previous_iframe(Thread *thread, addr_t frame) { // iterate backwards through the stack frames, until we hit an iframe while (frame >= thread->kernel_stack_base @@ -161,7 +161,7 @@ i386_get_user_iframe(void) The thread must not be running and the threads spinlock must be held. */ struct iframe * -i386_get_thread_user_iframe(struct thread *thread) +i386_get_thread_user_iframe(Thread *thread) { if (thread->state == B_THREAD_RUNNING) return NULL; @@ -190,7 +190,7 @@ i386_get_current_iframe(void) uint32 -x86_next_page_directory(struct thread *from, struct thread *to) +x86_next_page_directory(Thread *from, Thread *to) { VMAddressSpace* toAddressSpace = to->team->address_space; if (from->team->address_space == toAddressSpace) { @@ -214,7 +214,7 @@ set_fs_register(uint32 segment) static void -set_tls_context(struct thread *thread) +set_tls_context(Thread *thread) { int entry = smp_get_current_cpu() + TLS_BASE_SEGMENT; @@ -226,7 +226,7 @@ set_tls_context(struct thread *thread) void x86_restart_syscall(struct iframe* frame) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); atomic_and(&thread->flags, ~THREAD_FLAGS_RESTART_SYSCALL); atomic_or(&thread->flags, THREAD_FLAGS_SYSCALL_RESTARTED); @@ -242,7 +242,7 @@ x86_restart_syscall(struct iframe* frame) static uint32 * -get_signal_stack(struct thread *thread, struct iframe *frame, int signal) +get_signal_stack(Thread *thread, struct iframe *frame, int signal) { // use the alternate signal stack if we should and can if (thread->signal_stack_enabled @@ -262,14 +262,14 @@ get_signal_stack(struct thread *thread, struct iframe *frame, int signal) status_t -arch_team_init_team_struct(struct team *p, bool kernel) +arch_team_init_team_struct(Team *p, bool kernel) { return B_OK; } status_t -arch_thread_init_thread_struct(struct thread *thread) +arch_thread_init_thread_struct(Thread *thread) { // set up an initial state (stack & fpu) memcpy(&thread->arch_info, &sInitialState, sizeof(struct arch_thread)); @@ -278,7 +278,7 @@ arch_thread_init_thread_struct(struct thread *thread) status_t -arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), +arch_thread_init_kthread_stack(Thread *t, int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void)) { addr_t *kstack = (addr_t *)t->kernel_stack_base; @@ -338,7 +338,7 @@ arch_thread_init_kthread_stack(struct thread *t, int (*start_func)(void), */ status_t -arch_thread_init_tls(struct thread *thread) +arch_thread_init_tls(Thread *thread) { uint32 tls[TLS_USER_THREAD_SLOT + 1]; @@ -356,7 +356,7 @@ arch_thread_init_tls(struct thread *thread) void -arch_thread_context_switch(struct thread *from, struct thread *to) +arch_thread_context_switch(Thread *from, Thread *to) { i386_set_tss_and_kstack(to->kernel_stack_top); x86_set_syscall_stack(to->kernel_stack_top); @@ -415,7 +415,7 @@ arch_thread_dump_info(void *info) */ status_t -arch_thread_enter_userspace(struct thread *t, addr_t entry, void *args1, +arch_thread_enter_userspace(Thread *t, addr_t entry, void *args1, void *args2) { addr_t stackTop = t->user_stack_base + t->user_stack_size; @@ -462,7 +462,7 @@ arch_thread_enter_userspace(struct thread *t, addr_t entry, void *args1, bool -arch_on_signal_stack(struct thread *thread) +arch_on_signal_stack(Thread *thread) { struct iframe *frame = get_current_iframe(); @@ -473,7 +473,7 @@ arch_on_signal_stack(struct thread *thread) status_t -arch_setup_signal_frame(struct thread *thread, struct sigaction *action, +arch_setup_signal_frame(Thread *thread, struct sigaction *action, int signal, int signalMask) { struct iframe *frame = get_current_iframe(); @@ -559,7 +559,7 @@ arch_setup_signal_frame(struct thread *thread, struct sigaction *action, int64 arch_restore_signal_frame(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); struct iframe *frame = get_current_iframe(); int32 signalMask; uint32 *userStack; @@ -648,7 +648,7 @@ arch_store_fork_frame(struct arch_fork_arg *arg) void arch_restore_fork_frame(struct arch_fork_arg *arg) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); disable_interrupts(); @@ -664,6 +664,6 @@ arch_restore_fork_frame(struct arch_fork_arg *arg) void arch_syscall_64_bit_return_value(void) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); atomic_or(&thread->flags, THREAD_FLAGS_64_BIT_SYSCALL_RETURN); } diff --git a/src/system/kernel/arch/x86/arch_user_debugger.cpp b/src/system/kernel/arch/x86/arch_user_debugger.cpp index 50c879140f..eb3bcf690e 100644 --- a/src/system/kernel/arch/x86/arch_user_debugger.cpp +++ b/src/system/kernel/arch/x86/arch_user_debugger.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -101,7 +101,7 @@ install_breakpoints(const arch_team_debug_info &teamInfo) asm("movl %0, %%dr1" : : "r"(teamInfo.breakpoints[1].address)); asm("movl %0, %%dr2" : : "r"(teamInfo.breakpoints[2].address)); // asm("movl %0, %%dr3" : : "r"(teamInfo.breakpoints[3].address)); - // DR3 is used to hold the current struct thread*. + // DR3 is used to hold the current Thread*. // enable breakpoints asm("movl %0, %%dr7" : : "r"(teamInfo.dr7)); @@ -207,7 +207,7 @@ set_breakpoint(void *address, uint32 type, uint32 length) if (!address) return B_BAD_VALUE; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); cpu_status state = disable_interrupts(); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); @@ -228,7 +228,7 @@ clear_breakpoint(void *address, bool watchpoint) if (!address) return B_BAD_VALUE; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); cpu_status state = disable_interrupts(); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); @@ -249,7 +249,7 @@ clear_breakpoint(void *address, bool watchpoint) static void install_breakpoints_per_cpu(void* /*cookie*/, int cpu) { - struct team* kernelTeam = team_get_kernel_team(); + Team* kernelTeam = team_get_kernel_team(); GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); @@ -265,7 +265,7 @@ set_kernel_breakpoint(void *address, uint32 type, uint32 length) if (!address) return B_BAD_VALUE; - struct team* kernelTeam = team_get_kernel_team(); + Team* kernelTeam = team_get_kernel_team(); cpu_status state = disable_interrupts(); GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); @@ -289,7 +289,7 @@ clear_kernel_breakpoint(void *address, bool watchpoint) if (!address) return B_BAD_VALUE; - struct team* kernelTeam = team_get_kernel_team(); + Team* kernelTeam = team_get_kernel_team(); cpu_status state = disable_interrupts(); GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); @@ -357,7 +357,7 @@ check_watch_point_parameters(void* address, uint32 type, int32 length, static int debugger_breakpoints(int argc, char** argv) { - struct team* kernelTeam = team_get_kernel_team(); + Team* kernelTeam = team_get_kernel_team(); arch_team_debug_info& info = kernelTeam->debug_info.arch_info; for (int32 i = 0; i < X86_BREAKPOINT_COUNT; i++) { @@ -569,7 +569,7 @@ void arch_update_thread_single_step() { if (struct iframe* frame = i386_get_user_iframe()) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); // set/clear TF in EFLAGS depending on whether single stepping is // desired @@ -592,7 +592,7 @@ arch_set_debug_cpu_state(const debug_cpu_state *cpuState) // guaranteed passed buffer, we use our thread's fpu_state field as // temporary buffer. We need to disable interrupts to make use of // it. - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); InterruptsLocker locker; memcpy(thread->arch_info.fpu_state, &cpuState->extended_registers, sizeof(cpuState->extended_registers)); @@ -636,7 +636,7 @@ arch_get_debug_cpu_state(debug_cpu_state *cpuState) // Since fxsave requires 16-byte alignment and this isn't guaranteed // passed buffer, we use our thread's fpu_state field as temporary // buffer. We need to disable interrupts to make use of it. - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); InterruptsLocker locker; i386_fxsave(thread->arch_info.fpu_state); // unlike fnsave, fxsave doesn't reinit the FPU state @@ -773,7 +773,7 @@ arch_clear_kernel_watchpoint(void *address) void x86_init_user_debug_at_kernel_exit(struct iframe *frame) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); if (!(thread->flags & THREAD_FLAGS_BREAKPOINTS_DEFINED)) return; @@ -802,7 +802,7 @@ x86_init_user_debug_at_kernel_exit(struct iframe *frame) void x86_exit_user_debug_at_kernel_entry() { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); // We need to save the current values of dr6 and dr7 in the CPU structure, // since in case of a debug exception we might overwrite them before @@ -821,7 +821,7 @@ x86_exit_user_debug_at_kernel_entry() disable_breakpoints(); // install kernel breakpoints - struct team* kernelTeam = team_get_kernel_team(); + Team* kernelTeam = team_get_kernel_team(); GRAB_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); install_breakpoints(kernelTeam->debug_info.arch_info); RELEASE_TEAM_DEBUG_INFO_LOCK(kernelTeam->debug_info); @@ -838,7 +838,7 @@ x86_exit_user_debug_at_kernel_entry() void x86_handle_debug_exception(struct iframe *frame) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); // Get dr6 and dr7. If the given iframe is a userland frame, the exception // obviously occurred in userland. In that case diff --git a/src/system/kernel/arch/x86/asm_offsets.cpp b/src/system/kernel/arch/x86/asm_offsets.cpp index 816c136344..490fab9dd2 100644 --- a/src/system/kernel/arch/x86/asm_offsets.cpp +++ b/src/system/kernel/arch/x86/asm_offsets.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -33,14 +33,14 @@ dummy() DEFINE_OFFSET_MACRO(CPU_ENT, cpu_ent, fault_handler); DEFINE_OFFSET_MACRO(CPU_ENT, cpu_ent, fault_handler_stack_pointer); - // struct thread - DEFINE_OFFSET_MACRO(THREAD, thread, kernel_time); - DEFINE_OFFSET_MACRO(THREAD, thread, user_time); - DEFINE_OFFSET_MACRO(THREAD, thread, last_time); - DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel); - DEFINE_OFFSET_MACRO(THREAD, thread, flags); - DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top); - DEFINE_OFFSET_MACRO(THREAD, thread, fault_handler); + // struct Thread + DEFINE_OFFSET_MACRO(THREAD, Thread, kernel_time); + DEFINE_OFFSET_MACRO(THREAD, Thread, user_time); + DEFINE_OFFSET_MACRO(THREAD, Thread, last_time); + DEFINE_OFFSET_MACRO(THREAD, Thread, in_kernel); + DEFINE_OFFSET_MACRO(THREAD, Thread, flags); + DEFINE_OFFSET_MACRO(THREAD, Thread, kernel_stack_top); + DEFINE_OFFSET_MACRO(THREAD, Thread, fault_handler); // struct iframe DEFINE_OFFSET_MACRO(IFRAME, iframe, cs); diff --git a/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.cpp b/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.cpp index a8f19fcf7c..450257e7ef 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.cpp +++ b/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * @@ -183,7 +183,7 @@ X86VMTranslationMap32Bit::Map(addr_t va, phys_addr_t pa, uint32 attributes, } // now, fill in the pentry - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -228,7 +228,7 @@ X86VMTranslationMap32Bit::Unmap(addr_t start, addr_t end) continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -356,7 +356,7 @@ X86VMTranslationMap32Bit::UnmapPages(VMArea* area, addr_t base, size_t size, continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -565,7 +565,7 @@ X86VMTranslationMap32Bit::Query(addr_t va, phys_addr_t *_physical, return B_OK; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -663,7 +663,7 @@ X86VMTranslationMap32Bit::Protect(addr_t start, addr_t end, uint32 attributes, continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( @@ -722,7 +722,7 @@ X86VMTranslationMap32Bit::ClearFlags(addr_t va, uint32 flags) uint32 flagsToClear = ((flags & PAGE_MODIFIED) ? X86_PTE_DIRTY : 0) | ((flags & PAGE_ACCESSED) ? X86_PTE_ACCESSED : 0); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); page_table_entry* pt = (page_table_entry*)fPageMapper->GetPageTableAt( diff --git a/src/system/kernel/arch/x86/paging/X86VMTranslationMap.cpp b/src/system/kernel/arch/x86/paging/X86VMTranslationMap.cpp index 409c640196..393ca4eda7 100644 --- a/src/system/kernel/arch/x86/paging/X86VMTranslationMap.cpp +++ b/src/system/kernel/arch/x86/paging/X86VMTranslationMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * @@ -95,7 +95,7 @@ X86VMTranslationMap::Flush() if (fInvalidPagesCount <= 0) return; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread_pin_to_current_cpu(thread); if (fInvalidPagesCount > PAGE_INVALIDATE_CACHE_SIZE) { diff --git a/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.cpp b/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.cpp index 9d4be80006..1d522b031a 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.cpp +++ b/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -217,7 +217,7 @@ X86VMTranslationMapPAE::Map(addr_t virtualAddress, phys_addr_t physicalAddress, } // now, fill in the page table entry - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); pae_page_table_entry* pageTable @@ -265,7 +265,7 @@ X86VMTranslationMapPAE::Unmap(addr_t start, addr_t end) continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); pae_page_table_entry* pageTable @@ -398,7 +398,7 @@ X86VMTranslationMapPAE::UnmapPages(VMArea* area, addr_t base, size_t size, continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); pae_page_table_entry* pageTable @@ -613,7 +613,7 @@ X86VMTranslationMapPAE::Query(addr_t virtualAddress, } // get the page table entry - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); pae_page_table_entry* pageTable @@ -722,7 +722,7 @@ X86VMTranslationMapPAE::Protect(addr_t start, addr_t end, uint32 attributes, continue; } - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); pae_page_table_entry* pageTable @@ -785,7 +785,7 @@ X86VMTranslationMapPAE::ClearFlags(addr_t address, uint32 flags) uint64 flagsToClear = ((flags & PAGE_MODIFIED) ? X86_PAE_PTE_DIRTY : 0) | ((flags & PAGE_ACCESSED) ? X86_PAE_PTE_ACCESSED : 0); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner pinner(thread); pae_page_table_entry* entry diff --git a/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp b/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp index 514c8c5910..b317f92e28 100644 --- a/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp +++ b/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -570,7 +570,7 @@ LargeMemoryPhysicalPageMapper::MemsetPhysical(phys_addr_t address, int value, { addr_t pageOffset = address % B_PAGE_SIZE; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, @@ -601,7 +601,7 @@ LargeMemoryPhysicalPageMapper::MemcpyFromPhysical(void* _to, phys_addr_t from, uint8* to = (uint8*)_to; addr_t pageOffset = from % B_PAGE_SIZE; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, user); @@ -641,7 +641,7 @@ LargeMemoryPhysicalPageMapper::MemcpyToPhysical(phys_addr_t to, const uint8* from = (const uint8*)_from; addr_t pageOffset = to % B_PAGE_SIZE; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, user); @@ -678,7 +678,7 @@ void LargeMemoryPhysicalPageMapper::MemcpyPhysicalPage(phys_addr_t to, phys_addr_t from) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); ThreadCPUPinner _(thread); PhysicalPageSlotQueue* slotQueue = GetSlotQueue(thread->cpu->cpu_num, diff --git a/src/system/kernel/arch/x86/vm86.cpp b/src/system/kernel/arch/x86/vm86.cpp index f8a99cbc29..993fb24fb0 100644 --- a/src/system/kernel/arch/x86/vm86.cpp +++ b/src/system/kernel/arch/x86/vm86.cpp @@ -536,7 +536,7 @@ vm86_fault_callback(addr_t address, addr_t faultAddress, bool isWrite) extern "C" status_t vm86_prepare(struct vm86_state *state, unsigned int ramSize) { - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; status_t ret = B_OK; area_id vectors; @@ -603,7 +603,7 @@ error: extern "C" void vm86_cleanup(struct vm86_state *state) { - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; if (state->bios_area > B_OK) vm_delete_area(team->id, state->bios_area, true); @@ -629,7 +629,7 @@ vm86_do_int(struct vm86_state *state, uint8 vec) { int8 *ip; int emuState = 0; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); status_t ret; // prepare environment diff --git a/src/system/kernel/debug/debug.cpp b/src/system/kernel/debug/debug.cpp index ba3b618655..ceda5adaee 100644 --- a/src/system/kernel/debug/debug.cpp +++ b/src/system/kernel/debug/debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -139,7 +139,7 @@ static int32 sCurrentLine = 0; static debugger_demangle_module_info* sDemangleModule; -static struct thread* sDebuggedThread; +static Thread* sDebuggedThread; static vint32 sInDebugger = 0; static bool sPreviousDprintfState; static volatile bool sHandOverKDL = false; @@ -818,11 +818,11 @@ kernel_debugger_loop(const char* messagePrefix, const char* message, // thread we are running. set_debug_variable("_cpu", sDebuggerOnCPU); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread == NULL) { kprintf("Running on CPU %ld\n", sDebuggerOnCPU); } else if (!debug_is_kernel_memory_accessible((addr_t)thread, - sizeof(struct thread), B_KERNEL_READ_AREA)) { + sizeof(Thread), B_KERNEL_READ_AREA)) { kprintf("Running on CPU %ld\n", sDebuggerOnCPU); kprintf("Current thread pointer is %p, which is an address we " "can't read from.\n", thread); @@ -840,7 +840,7 @@ kernel_debugger_loop(const char* messagePrefix, const char* message, arch_debug_unset_current_thread(); } else if (thread->team != NULL) { if (debug_is_kernel_memory_accessible((addr_t)thread->team, - sizeof(struct team), B_KERNEL_READ_AREA)) { + sizeof(Team), B_KERNEL_READ_AREA)) { set_debug_variable("_team", (uint64)(addr_t)thread->team); set_debug_variable("_teamID", thread->team->id); } else { @@ -2185,16 +2185,16 @@ debug_get_debug_registers(int32 cpu) } -struct thread* -debug_set_debugged_thread(struct thread* thread) +Thread* +debug_set_debugged_thread(Thread* thread) { - struct thread* previous = sDebuggedThread; + Thread* previous = sDebuggedThread; sDebuggedThread = thread; return previous; } -struct thread* +Thread* debug_get_debugged_thread() { return sDebuggedThread != NULL @@ -2212,7 +2212,7 @@ debug_is_debugged_team(team_id teamID) if (teamID == B_CURRENT_TEAM) return true; - struct thread* thread = debug_get_debugged_thread(); + Thread* thread = debug_get_debugged_thread(); return thread != NULL && thread->team != NULL && thread->team->id == teamID; } diff --git a/src/system/kernel/debug/system_profiler.cpp b/src/system/kernel/debug/system_profiler.cpp index 7a6d34f018..6c034503af 100644 --- a/src/system/kernel/debug/system_profiler.cpp +++ b/src/system/kernel/debug/system_profiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -59,7 +59,7 @@ public: parameters); ~SystemProfiler(); - team_id Team() const { return fTeam; } + team_id TeamID() const { return fTeam; } status_t Init(); status_t NextBuffer(size_t bytesRead, @@ -69,11 +69,10 @@ private: virtual void EventOccurred(NotificationService& service, const KMessage* event); - virtual void ThreadEnqueuedInRunQueue(struct thread* thread); - virtual void ThreadRemovedFromRunQueue( - struct thread* thread); - virtual void ThreadScheduled(struct thread* oldThread, - struct thread* newThread); + virtual void ThreadEnqueuedInRunQueue(Thread* thread); + virtual void ThreadRemovedFromRunQueue(Thread* thread); + virtual void ThreadScheduled(Thread* oldThread, + Thread* newThread); virtual void SemaphoreCreated(sem_id id, const char* name); @@ -82,12 +81,12 @@ private: virtual void MutexInitialized(mutex* lock); virtual void RWLockInitialized(rw_lock* lock); - bool _TeamAdded(struct team* team); - bool _TeamRemoved(struct team* team); - bool _TeamExec(struct team* team); + bool _TeamAdded(Team* team); + bool _TeamRemoved(Team* team); + bool _TeamExec(Team* team); - bool _ThreadAdded(struct thread* thread); - bool _ThreadRemoved(struct thread* thread); + bool _ThreadAdded(Thread* thread); + bool _ThreadRemoved(Thread* thread); bool _ImageAdded(struct image* image); bool _ImageRemoved(struct image* image); @@ -109,9 +108,9 @@ private: inline void _MaybeNotifyProfilerThreadLocked(); inline void _MaybeNotifyProfilerThread(); - static bool _InitialTeamIterator(struct team* team, + static bool _InitialTeamIterator(Team* team, void* cookie); - static bool _InitialThreadIterator(struct thread* thread, + static bool _InitialThreadIterator(Thread* thread, void* cookie); static bool _InitialImageIterator(struct image* image, void* cookie); @@ -200,11 +199,11 @@ private: bool fIONotificationsEnabled; bool fSchedulerNotificationsRequested; bool fWaitObjectNotificationsRequested; - struct thread* volatile fWaitingProfilerThread; + Thread* volatile fWaitingProfilerThread; bool fProfilingActive; bool fReentered[B_MAX_CPU_COUNT]; CPUProfileData fCPUData[B_MAX_CPU_COUNT]; - struct thread** fRunningThreads; + Thread** fRunningThreads; WaitObject* fWaitObjectBuffer; int32 fWaitObjectCount; WaitObjectList fUsedWaitObjects; @@ -461,7 +460,7 @@ SystemProfiler::Init() } // threads - struct thread* runningThreads[B_MAX_CPU_COUNT]; + Thread* runningThreads[B_MAX_CPU_COUNT]; memset(runningThreads, 0, sizeof(runningThreads)); fRunningThreads = runningThreads; @@ -543,7 +542,7 @@ SystemProfiler::NextBuffer(size_t bytesRead, uint64* _droppedEvents) // Wait until the buffer gets too full or an error or a timeout occurs. while (true) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); fWaitingProfilerThread = thread; thread_prepare_to_block(thread, B_CAN_INTERRUPT, @@ -591,8 +590,7 @@ SystemProfiler::EventOccurred(NotificationService& service, if (!fTeamNotificationsEnabled) return; - struct team* team = (struct team*)event->GetPointer("teamStruct", - NULL); + Team* team = (Team*)event->GetPointer("teamStruct", NULL); if (team == NULL) return; @@ -626,8 +624,7 @@ SystemProfiler::EventOccurred(NotificationService& service, if (!fThreadNotificationsEnabled) return; - struct thread* thread = (struct thread*)event->GetPointer( - "threadStruct", NULL); + Thread* thread = (Thread*)event->GetPointer("threadStruct", NULL); if (thread == NULL) return; @@ -703,7 +700,7 @@ SystemProfiler::EventOccurred(NotificationService& service, void -SystemProfiler::ThreadEnqueuedInRunQueue(struct thread* thread) +SystemProfiler::ThreadEnqueuedInRunQueue(Thread* thread) { int cpu = smp_get_current_cpu(); @@ -734,7 +731,7 @@ SystemProfiler::ThreadEnqueuedInRunQueue(struct thread* thread) void -SystemProfiler::ThreadRemovedFromRunQueue(struct thread* thread) +SystemProfiler::ThreadRemovedFromRunQueue(Thread* thread) { int cpu = smp_get_current_cpu(); @@ -760,8 +757,7 @@ SystemProfiler::ThreadRemovedFromRunQueue(struct thread* thread) void -SystemProfiler::ThreadScheduled(struct thread* oldThread, - struct thread* newThread) +SystemProfiler::ThreadScheduled(Thread* oldThread, Thread* newThread) { int cpu = smp_get_current_cpu(); @@ -822,7 +818,7 @@ SystemProfiler::RWLockInitialized(rw_lock* lock) bool -SystemProfiler::_TeamAdded(struct team* team) +SystemProfiler::_TeamAdded(Team* team) { size_t nameLen = strlen(team->name); size_t argsLen = strlen(team->args); @@ -848,7 +844,7 @@ SystemProfiler::_TeamAdded(struct team* team) bool -SystemProfiler::_TeamRemoved(struct team* team) +SystemProfiler::_TeamRemoved(Team* team) { InterruptsSpinLocker locker(fLock); @@ -867,7 +863,7 @@ SystemProfiler::_TeamRemoved(struct team* team) bool -SystemProfiler::_TeamExec(struct team* team) +SystemProfiler::_TeamExec(Team* team) { size_t argsLen = strlen(team->args); @@ -891,7 +887,7 @@ SystemProfiler::_TeamExec(struct team* team) bool -SystemProfiler::_ThreadAdded(struct thread* thread) +SystemProfiler::_ThreadAdded(Thread* thread) { InterruptsSpinLocker locker(fLock); @@ -912,7 +908,7 @@ SystemProfiler::_ThreadAdded(struct thread* thread) bool -SystemProfiler::_ThreadRemoved(struct thread* thread) +SystemProfiler::_ThreadRemoved(Thread* thread) { InterruptsSpinLocker locker(fLock); @@ -1241,7 +1237,7 @@ SystemProfiler::_WaitObjectUsed(addr_t object, uint32 type) /*static*/ bool -SystemProfiler::_InitialTeamIterator(struct team* team, void* cookie) +SystemProfiler::_InitialTeamIterator(Team* team, void* cookie) { SystemProfiler* self = (SystemProfiler*)cookie; return !self->_TeamAdded(team); @@ -1249,7 +1245,7 @@ SystemProfiler::_InitialTeamIterator(struct team* team, void* cookie) /*static*/ bool -SystemProfiler::_InitialThreadIterator(struct thread* thread, void* cookie) +SystemProfiler::_InitialThreadIterator(Thread* thread, void* cookie) { SystemProfiler* self = (SystemProfiler*)cookie; @@ -1343,7 +1339,7 @@ SystemProfiler::_ScheduleTimer(int cpu) void SystemProfiler::_DoSample() { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); int cpu = thread->cpu->cpu_num; CPUProfileData& cpuData = fCPUData[cpu]; @@ -1553,7 +1549,7 @@ _user_system_profiler_next_buffer(size_t bytesRead, uint64* _droppedEvents) team_id team = thread_get_current_thread()->team->id; InterruptsSpinLocker locker(sProfilerLock); - if (sProfiler == NULL || sProfiler->Team() != team) + if (sProfiler == NULL || sProfiler->TeamID() != team) return B_BAD_VALUE; // get a reference to the profiler @@ -1577,7 +1573,7 @@ _user_system_profiler_stop() team_id team = thread_get_current_thread()->team->id; InterruptsSpinLocker locker(sProfilerLock); - if (sProfiler == NULL || sProfiler->Team() != team) + if (sProfiler == NULL || sProfiler->TeamID() != team) return B_BAD_VALUE; SystemProfiler* profiler = sProfiler; diff --git a/src/system/kernel/debug/tracing.cpp b/src/system/kernel/debug/tracing.cpp index 868341a01a..75cd8b771e 100644 --- a/src/system/kernel/debug/tracing.cpp +++ b/src/system/kernel/debug/tracing.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -739,7 +739,7 @@ TraceEntry::operator new(size_t size, const std::nothrow_t&) throw() AbstractTraceEntry::AbstractTraceEntry() { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL) { fThread = thread->id; if (thread->team) @@ -886,7 +886,7 @@ public: { const AbstractTraceEntry* entry = dynamic_cast(_entry); - return (entry != NULL && entry->Thread() == fThread); + return (entry != NULL && entry->ThreadID() == fThread); } }; @@ -897,7 +897,7 @@ public: { const AbstractTraceEntry* entry = dynamic_cast(_entry); - return (entry != NULL && entry->Team() == fTeam); + return (entry != NULL && entry->TeamID() == fTeam); } }; diff --git a/src/system/kernel/debug/user_debugger.cpp b/src/system/kernel/debug/user_debugger.cpp index 2ddd89262e..bde389b349 100644 --- a/src/system/kernel/debug/user_debugger.cpp +++ b/src/system/kernel/debug/user_debugger.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -58,8 +58,7 @@ static timer sProfilingTimers[B_MAX_CPU_COUNT]; // on that CPU -static void schedule_profiling_timer(struct thread* thread, - bigtime_t interval); +static void schedule_profiling_timer(Thread* thread, bigtime_t interval); static int32 profiling_event(timer* unused); static status_t ensure_debugger_installed(); static void get_team_debug_info(team_debug_info &teamDebugInfo); @@ -131,7 +130,7 @@ debugger_write(port_id port, int32 code, const void *buffer, size_t bufferSize, Interrupts must be disabled and the thread lock must be held. */ static void -update_thread_user_debug_flag(struct thread* thread) +update_thread_user_debug_flag(Thread* thread) { if ((atomic_get(&thread->debug_info.flags) & B_THREAD_DEBUG_STOP) != 0) atomic_or(&thread->flags, THREAD_FLAGS_DEBUG_THREAD); @@ -145,9 +144,9 @@ update_thread_user_debug_flag(struct thread* thread) Interrupts must be disabled and the team lock must be held. */ static void -update_thread_breakpoints_flag(struct thread* thread) +update_thread_breakpoints_flag(Thread* thread) { - struct team* team = thread->team; + Team* team = thread->team; if (arch_has_breakpoints(&team->debug_info.arch_info)) atomic_or(&thread->flags, THREAD_FLAGS_BREAKPOINTS_DEFINED); @@ -158,15 +157,14 @@ update_thread_breakpoints_flag(struct thread* thread) /*! Updates the thread::flags THREAD_FLAGS_BREAKPOINTS_DEFINED bit of all threads of the current team. - Interrupts must be disabled and the team lock must be held. */ static void update_threads_breakpoints_flag() { InterruptsSpinLocker _(gTeamSpinlock); - struct team* team = thread_get_current_thread()->team; - struct thread* thread = team->thread_list; + Team* team = thread_get_current_thread()->team; + Thread* thread = team->thread_list; if (arch_has_breakpoints(&team->debug_info.arch_info)) { for (; thread != NULL; thread = thread->team_next) @@ -183,9 +181,9 @@ update_threads_breakpoints_flag() Interrupts must be disabled and the team lock must be held. */ static void -update_thread_debugger_installed_flag(struct thread* thread) +update_thread_debugger_installed_flag(Thread* thread) { - struct team* team = thread->team; + Team* team = thread->team; if (atomic_get(&team->debug_info.flags) & B_TEAM_DEBUG_DEBUGGER_INSTALLED) atomic_or(&thread->flags, THREAD_FLAGS_DEBUGGER_INSTALLED); @@ -199,9 +197,9 @@ update_thread_debugger_installed_flag(struct thread* thread) Interrupts must be disabled and the team lock must be held. */ static void -update_threads_debugger_installed_flag(struct team* team) +update_threads_debugger_installed_flag(Team* team) { - struct thread* thread = team->thread_list; + Thread* thread = team->thread_list; if (atomic_get(&team->debug_info.flags) & B_TEAM_DEBUG_DEBUGGER_INSTALLED) { for (; thread != NULL; thread = thread->team_next) @@ -366,7 +364,7 @@ destroy_thread_debug_info(struct thread_debug_info *info) static status_t prepare_debugger_change(team_id teamID, ConditionVariable& condition, - struct team*& team) + Team*& team) { // We look up the team by ID, even in case of the current team, so we can be // sure, that the team is not already dying. @@ -409,7 +407,7 @@ prepare_debugger_change(team_id teamID, ConditionVariable& condition, static void -prepare_debugger_change(struct team* team, ConditionVariable& condition) +prepare_debugger_change(Team* team, ConditionVariable& condition) { while (true) { // check whether the condition is already set @@ -435,7 +433,7 @@ prepare_debugger_change(struct team* team, ConditionVariable& condition) static void -finish_debugger_change(struct team* team) +finish_debugger_change(Team* team) { // unset our condition variable and notify all threads waiting on it InterruptsSpinLocker threadLocker(gThreadSpinlock); @@ -451,8 +449,8 @@ finish_debugger_change(struct team* team) void user_debug_prepare_for_exec() { - struct thread *thread = thread_get_current_thread(); - struct team *team = thread->team; + Thread *thread = thread_get_current_thread(); + Team *team = thread->team; // If a debugger is installed for the team and the thread debug stuff // initialized, change the ownership of the debug port for the thread @@ -481,8 +479,8 @@ user_debug_prepare_for_exec() void user_debug_finish_after_exec() { - struct thread *thread = thread_get_current_thread(); - struct team *team = thread->team; + Thread *thread = thread_get_current_thread(); + Team *team = thread->team; // If a debugger is installed for the team and the thread debug stuff // initialized for this thread, change the ownership of its debug port @@ -519,7 +517,7 @@ init_user_debug() static void get_team_debug_info(team_debug_info &teamDebugInfo) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); cpu_status state = disable_interrupts(); GRAB_TEAM_DEBUG_INFO_LOCK(thread->team->debug_info); @@ -536,7 +534,7 @@ thread_hit_debug_event_internal(debug_debugger_message event, const void *message, int32 size, bool requireDebugger, bool &restart) { restart = false; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); TRACE(("thread_hit_debug_event(): thread: %ld, event: %lu, message: %p, " "size: %ld\n", thread->id, (uint32)event, message, size)); @@ -795,7 +793,7 @@ thread_hit_debug_event(debug_debugger_message event, const void *message, // Prepare to continue -- we install a debugger change condition, so no-one // will change the debugger while we're playing with the breakpoint manager. // TODO: Maybe better use ref-counting and a flag in the breakpoint manager. - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; ConditionVariable debugChangeCondition; prepare_debugger_change(team, debugChangeCondition); @@ -819,7 +817,7 @@ thread_hit_serious_debug_event(debug_debugger_message event, // ensure that a debugger is installed for this team status_t error = ensure_debugger_installed(); if (error != B_OK) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); dprintf("thread_hit_serious_debug_event(): Failed to install debugger: " "thread: %ld: %s\n", thread->id, strerror(error)); return error; @@ -834,7 +832,7 @@ void user_debug_pre_syscall(uint32 syscall, void *args) { // check whether a debugger is installed - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (!(teamDebugFlags & B_TEAM_DEBUG_DEBUGGER_INSTALLED)) return; @@ -866,7 +864,7 @@ user_debug_post_syscall(uint32 syscall, void *args, uint64 returnValue, bigtime_t startTime) { // check whether a debugger is installed - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (!(teamDebugFlags & B_TEAM_DEBUG_DEBUGGER_INSTALLED)) return; @@ -933,7 +931,7 @@ bool user_debug_handle_signal(int signal, struct sigaction *handler, bool deadly) { // check, if a debugger is installed and is interested in signals - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_SIGNALS)) { @@ -957,7 +955,7 @@ user_debug_stop_thread() { // check whether this is actually an emulated single-step notification InterruptsSpinLocker threadsLocker(gThreadSpinlock); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); bool singleStepped = false; if ((atomic_and(&thread->debug_info.flags, ~B_THREAD_DEBUG_NOTIFY_SINGLE_STEP) @@ -982,7 +980,7 @@ user_debug_team_created(team_id teamID) { // check, if a debugger is installed and is interested in team creation // events - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_TEAM_CREATION)) { @@ -1020,7 +1018,7 @@ user_debug_team_exec() { // check, if a debugger is installed and is interested in team creation // events - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_TEAM_CREATION)) { @@ -1047,7 +1045,7 @@ user_debug_update_new_thread_flags(thread_id threadID) SpinLocker teamLocker(gTeamSpinlock); SpinLocker threadLocker(gThreadSpinlock); - struct thread *thread = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (!thread) return; @@ -1061,7 +1059,7 @@ void user_debug_thread_created(thread_id threadID) { // check, if a debugger is installed and is interested in thread events - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_THREADS)) { @@ -1086,7 +1084,7 @@ user_debug_thread_deleted(team_id teamID, thread_id threadID) // get the team debug flags and debugger port InterruptsSpinLocker teamLocker(gTeamSpinlock); - struct team *team = team_get_team_struct_locked(teamID); + Team *team = team_get_team_struct_locked(teamID); if (team == NULL) return; @@ -1144,12 +1142,12 @@ user_debug_thread_deleted(team_id teamID, thread_id threadID) void -user_debug_thread_exiting(struct thread* thread) +user_debug_thread_exiting(Thread* thread) { InterruptsLocker interruptsLocker; SpinLocker teamLocker(gTeamSpinlock); - struct team* team = thread->team; + Team* team = thread->team; GRAB_TEAM_DEBUG_INFO_LOCK(team->debug_info); @@ -1216,7 +1214,7 @@ void user_debug_image_created(const image_info *imageInfo) { // check, if a debugger is installed and is interested in image events - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_IMAGES)) { @@ -1238,7 +1236,7 @@ void user_debug_image_deleted(const image_info *imageInfo) { // check, if a debugger is installed and is interested in image events - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int32 teamDebugFlags = atomic_get(&thread->team->debug_info.flags); if (~teamDebugFlags & (B_TEAM_DEBUG_DEBUGGER_INSTALLED | B_TEAM_DEBUG_IMAGES)) { @@ -1284,7 +1282,7 @@ void user_debug_single_stepped() { // clear the single-step thread flag - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); atomic_and(&thread->flags, ~(int32)THREAD_FLAGS_SINGLE_STEP); // prepare the message @@ -1297,7 +1295,7 @@ user_debug_single_stepped() static void -schedule_profiling_timer(struct thread* thread, bigtime_t interval) +schedule_profiling_timer(Thread* thread, bigtime_t interval) { struct timer* timer = &sProfilingTimers[thread->cpu->cpu_num]; thread->debug_info.profile.installed_timer = timer; @@ -1310,7 +1308,7 @@ schedule_profiling_timer(struct thread* thread, bigtime_t interval) static bool profiling_do_sample(bool& flushBuffer) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread_debug_info& debugInfo = thread->debug_info; if (debugInfo.profile.samples == NULL) @@ -1387,7 +1385,7 @@ profiling_do_sample(bool& flushBuffer) static void profiling_buffer_full(void*) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread_debug_info& debugInfo = thread->debug_info; GRAB_THREAD_LOCK(); @@ -1438,7 +1436,7 @@ profiling_buffer_full(void*) static int32 profiling_event(timer* /*unused*/) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread_debug_info& debugInfo = thread->debug_info; bool flushBuffer = false; @@ -1461,7 +1459,7 @@ profiling_event(timer* /*unused*/) void -user_debug_thread_unscheduled(struct thread* thread) +user_debug_thread_unscheduled(Thread* thread) { // if running, cancel the profiling timer struct timer* timer = thread->debug_info.profile.installed_timer; @@ -1478,7 +1476,7 @@ user_debug_thread_unscheduled(struct thread* thread) void -user_debug_thread_scheduled(struct thread* thread) +user_debug_thread_scheduled(Thread* thread) { if (thread->debug_info.profile.samples != NULL && !thread->debug_info.profile.buffer_full) { @@ -1494,7 +1492,7 @@ user_debug_thread_scheduled(struct thread* thread) thus have a debug port). */ static void -broadcast_debugged_thread_message(struct thread *nubThread, int32 code, +broadcast_debugged_thread_message(Thread *nubThread, int32 code, const void *message, int32 size) { // iterate through the threads @@ -1508,8 +1506,7 @@ broadcast_debugged_thread_message(struct thread *nubThread, int32 code, port_id threadDebugPort = -1; thread_id threadID = -1; - struct thread *thread - = thread_get_thread_struct_locked(threadInfo.thread); + Thread *thread = thread_get_thread_struct_locked(threadInfo.thread); if (thread && thread != nubThread && thread->team == nubThread->team && (thread->debug_info.flags & B_THREAD_DEBUG_INITIALIZED) != 0 && (thread->debug_info.flags & B_THREAD_DEBUG_STOPPED) != 0) { @@ -1534,7 +1531,7 @@ broadcast_debugged_thread_message(struct thread *nubThread, int32 code, static void -nub_thread_cleanup(struct thread *nubThread) +nub_thread_cleanup(Thread *nubThread) { TRACE(("nub_thread_cleanup(%ld): debugger port: %ld\n", nubThread->id, nubThread->team->debug_info.debugger_port)); @@ -1580,7 +1577,7 @@ nub_thread_cleanup(struct thread *nubThread) * a thread of the same team. */ static status_t -debug_nub_thread_get_thread_debug_port(struct thread *nubThread, +debug_nub_thread_get_thread_debug_port(Thread *nubThread, thread_id threadID, port_id &threadDebugPort) { status_t result = B_OK; @@ -1589,7 +1586,7 @@ debug_nub_thread_get_thread_debug_port(struct thread *nubThread, cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread) { if (thread->team != nubThread->team) result = B_BAD_VALUE; @@ -1613,7 +1610,7 @@ debug_nub_thread_get_thread_debug_port(struct thread *nubThread, static status_t debug_nub_thread(void *) { - struct thread *nubThread = thread_get_current_thread(); + Thread *nubThread = thread_get_current_thread(); // check, if we're still the current nub thread and get our port cpu_status state = disable_interrupts(); @@ -1755,7 +1752,7 @@ debug_nub_thread(void *) TRACE(("nub thread %ld: B_DEBUG_MESSAGE_SET_TEAM_FLAGS: " "flags: %lx\n", nubThread->id, flags)); - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; // set the flags cpu_status state = disable_interrupts(); @@ -1785,8 +1782,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread && thread->team == thread_get_current_thread()->team) { flags |= thread->debug_info.flags @@ -2032,8 +2028,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread && thread->team == thread_get_current_thread()->team) { thread_debug_info &threadDebugInfo = thread->debug_info; @@ -2084,8 +2079,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread) { ignore = thread->debug_info.ignore_signals; ignoreOnce = thread->debug_info.ignore_signals_once; @@ -2124,8 +2118,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread && thread->team != thread_get_current_thread()->team) { thread = NULL; @@ -2153,8 +2146,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread) { if (thread->team != thread_get_current_thread()->team) result = B_BAD_VALUE; @@ -2189,7 +2181,7 @@ debug_nub_thread(void *) TRACE(("nub thread %ld: B_DEBUG_MESSAGE_PREPARE_HANDOVER\n", nubThread->id)); - struct team *team = nubThread->team; + Team *team = nubThread->team; // Acquire the debugger write lock. As soon as we have it and // have set the B_TEAM_DEBUG_DEBUGGER_HANDOVER flag, no thread @@ -2286,8 +2278,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread && thread->team == nubThread->team) { thread_debug_info &threadDebugInfo = thread->debug_info; if (threadDebugInfo.profile.samples == NULL) { @@ -2361,8 +2352,7 @@ debug_nub_thread(void *) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread - = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (thread && thread->team == nubThread->team) { thread_debug_info &threadDebugInfo = thread->debug_info; if (threadDebugInfo.profile.samples != NULL) { @@ -2442,7 +2432,7 @@ debug_nub_thread(void *) (including among other things formerly set break/watchpoints). */ static void -install_team_debugger_init_debug_infos(struct team *team, team_id debuggerTeam, +install_team_debugger_init_debug_infos(Team *team, team_id debuggerTeam, port_id debuggerPort, port_id nubPort, thread_id nubThread, sem_id debuggerPortWriteLock, thread_id causingThread) { @@ -2462,7 +2452,7 @@ install_team_debugger_init_debug_infos(struct team *team, team_id debuggerTeam, // set the user debug flags and signal masks of all threads to the default GRAB_THREAD_LOCK(); - for (struct thread *thread = team->thread_list; + for (Thread *thread = team->thread_list; thread; thread = thread->team_next) { if (thread->id == nubThread) { @@ -2515,7 +2505,7 @@ install_team_debugger(team_id teamID, port_id debuggerPort, } // get the team - struct team* team; + Team* team; ConditionVariable debugChangeCondition; error = prepare_debugger_change(teamID, debugChangeCondition, team); if (error != B_OK) @@ -2777,7 +2767,7 @@ _user_debugger(const char *userMessage) int _user_disable_debugger(int state) { - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; TRACE(("_user_disable_debugger(%d): team: %ld\n", state, team->id)); @@ -2832,7 +2822,7 @@ _user_install_team_debugger(team_id teamID, port_id debuggerPort) status_t _user_remove_team_debugger(team_id teamID) { - struct team* team; + Team* team; ConditionVariable debugChangeCondition; status_t error = prepare_debugger_change(teamID, debugChangeCondition, team); @@ -2880,7 +2870,7 @@ _user_debug_thread(thread_id threadID) cpu_status state = disable_interrupts(); GRAB_THREAD_LOCK(); - struct thread *thread = thread_get_thread_struct_locked(threadID); + Thread *thread = thread_get_thread_struct_locked(threadID); if (!thread) { // thread doesn't exist any longer error = B_BAD_THREAD_ID; diff --git a/src/system/kernel/device_manager/IOCache.cpp b/src/system/kernel/device_manager/IOCache.cpp index 3fb711c2cb..574767e1a4 100644 --- a/src/system/kernel/device_manager/IOCache.cpp +++ b/src/system/kernel/device_manager/IOCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -163,7 +163,7 @@ IOCache::ScheduleRequest(IORequest* request) status_t error; IOBuffer* buffer = request->Buffer(); if (buffer->IsVirtual()) { - error = buffer->LockMemory(request->Team(), request->IsWrite()); + error = buffer->LockMemory(request->TeamID(), request->IsWrite()); if (error != B_OK) { request->SetStatusAndNotify(error); return error; @@ -178,7 +178,7 @@ IOCache::ScheduleRequest(IORequest* request) // unlock memory if (buffer->IsVirtual()) - buffer->UnlockMemory(request->Team(), request->IsWrite()); + buffer->UnlockMemory(request->TeamID(), request->IsWrite()); // set status and notify if (error == B_OK) { diff --git a/src/system/kernel/device_manager/IORequest.cpp b/src/system/kernel/device_manager/IORequest.cpp index 5ed8a28b89..e470103346 100644 --- a/src/system/kernel/device_manager/IORequest.cpp +++ b/src/system/kernel/device_manager/IORequest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -747,7 +747,7 @@ IORequest::Init(off_t offset, generic_size_t firstVecOffset, fRelativeParentOffset = 0; fTransferSize = 0; fFlags = flags; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); fTeam = thread->team->id; fThread = thread->id; fIsWrite = write; diff --git a/src/system/kernel/device_manager/IORequest.h b/src/system/kernel/device_manager/IORequest.h index 370c65ffc7..14dd3962ba 100644 --- a/src/system/kernel/device_manager/IORequest.h +++ b/src/system/kernel/device_manager/IORequest.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -277,8 +277,8 @@ struct IORequest : IORequestChunk, DoublyLinkedListLinkImpl { bool IsWrite() const { return fIsWrite; } bool IsRead() const { return !fIsWrite; } - team_id Team() const { return fTeam; } - thread_id Thread() const { return fThread; } + team_id TeamID() const { return fTeam; } + thread_id ThreadID() const { return fThread; } uint32 Flags() const { return fFlags; } IOBuffer* Buffer() const { return fBuffer; } diff --git a/src/system/kernel/device_manager/IOSchedulerSimple.cpp b/src/system/kernel/device_manager/IOSchedulerSimple.cpp index 73fdd47609..f2acf90133 100644 --- a/src/system/kernel/device_manager/IOSchedulerSimple.cpp +++ b/src/system/kernel/device_manager/IOSchedulerSimple.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2004-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -232,7 +232,7 @@ IOSchedulerSimple::ScheduleRequest(IORequest* request) // lock memory (via another thread or a dedicated call). if (buffer->IsVirtual()) { - status_t status = buffer->LockMemory(request->Team(), + status_t status = buffer->LockMemory(request->TeamID(), request->IsWrite()); if (status != B_OK) { request->SetStatusAndNotify(status); @@ -242,13 +242,13 @@ IOSchedulerSimple::ScheduleRequest(IORequest* request) MutexLocker locker(fLock); - IORequestOwner* owner = _GetRequestOwner(request->Team(), request->Thread(), - true); + IORequestOwner* owner = _GetRequestOwner(request->TeamID(), + request->ThreadID(), true); if (owner == NULL) { panic("IOSchedulerSimple: Out of request owners!\n"); locker.Unlock(); if (buffer->IsVirtual()) - buffer->UnlockMemory(request->Team(), request->IsWrite()); + buffer->UnlockMemory(request->TeamID(), request->IsWrite()); request->SetStatusAndNotify(B_NO_MEMORY); return B_NO_MEMORY; } @@ -257,7 +257,7 @@ IOSchedulerSimple::ScheduleRequest(IORequest* request) request->SetOwner(owner); owner->requests.Add(request); - int32 priority = thread_get_io_priority(request->Thread()); + int32 priority = thread_get_io_priority(request->ThreadID()); if (priority >= 0) owner->priority = priority; //dprintf(" request %p -> owner %p (thread %ld, active %d)\n", request, owner, owner->thread, wasActive); diff --git a/src/system/kernel/device_manager/dma_resources.cpp b/src/system/kernel/device_manager/dma_resources.cpp index 8fbf8a72f4..5c4b3de920 100644 --- a/src/system/kernel/device_manager/dma_resources.cpp +++ b/src/system/kernel/device_manager/dma_resources.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -453,7 +453,7 @@ DMAResource::TranslateNext(IORequest* request, IOOperation* operation, < fRestrictions.max_segment_count) { physical_entry entry; uint32 count = 1; - get_memory_map_etc(request->Team(), (void*)base, size, + get_memory_map_etc(request->TeamID(), (void*)base, size, &entry, &count); vecs[segmentCount].base = entry.address; diff --git a/src/system/kernel/device_manager/io_requests.cpp b/src/system/kernel/device_manager/io_requests.cpp index 7aba27d48b..e91d54a1b5 100644 --- a/src/system/kernel/device_manager/io_requests.cpp +++ b/src/system/kernel/device_manager/io_requests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -23,7 +23,8 @@ transfer_io_request_data(io_request* request, void* buffer, size_t size, // lock the request buffer memory, if it is user memory IOBuffer* ioBuffer = request->Buffer(); if (ioBuffer->IsUser() && !ioBuffer->IsMemoryLocked()) { - status_t error = ioBuffer->LockMemory(request->Team(), !writeToRequest); + status_t error = ioBuffer->LockMemory(request->TeamID(), + !writeToRequest); if (error != B_OK) return error; } diff --git a/src/system/kernel/elf.cpp b/src/system/kernel/elf.cpp index 9467e9ea70..5874697798 100644 --- a/src/system/kernel/elf.cpp +++ b/src/system/kernel/elf.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -1332,7 +1332,7 @@ public: return sLookup; } - status_t Init(struct team* team) + status_t Init(Team* team) { // find the runtime loader debug area VMArea* area; @@ -1714,7 +1714,7 @@ symbol_found: Note that the given team's address space must already be in effect. */ status_t -elf_debug_lookup_user_symbol_address(struct team* team, addr_t address, +elf_debug_lookup_user_symbol_address(Team* team, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch) { @@ -1773,8 +1773,7 @@ elf_debug_lookup_symbol(const char* searchName) status_t -elf_load_user_image(const char *path, struct team *team, int flags, - addr_t *entry) +elf_load_user_image(const char *path, Team *team, int flags, addr_t *entry) { struct Elf32_Ehdr elfHeader; struct Elf32_Phdr *programHeaders = NULL; diff --git a/src/system/kernel/fs/Vnode.h b/src/system/kernel/fs/Vnode.h index 637036ea9c..610b8c3cee 100644 --- a/src/system/kernel/fs/Vnode.h +++ b/src/system/kernel/fs/Vnode.h @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ #ifndef VNODE_H @@ -73,7 +73,7 @@ private: struct LockWaiter : DoublyLinkedListLinkImpl { LockWaiter* next; - struct thread* thread; + Thread* thread; struct vnode* vnode; }; diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp index d0d7ca6f44..4bc7bf9a53 100644 --- a/src/system/kernel/fs/fd.cpp +++ b/src/system/kernel/fs/fd.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -477,7 +477,7 @@ dup_foreign_fd(team_id fromTeam, int fd, bool kernel) { // get the I/O context for the team in question InterruptsSpinLocker teamsLocker(gTeamSpinlock); - struct team* team = team_get_team_struct_locked(fromTeam); + Team* team = team_get_team_struct_locked(fromTeam); if (team == NULL) return B_BAD_TEAM_ID; diff --git a/src/system/kernel/fs/fifo.cpp b/src/system/kernel/fs/fifo.cpp index cc855517f2..905e716045 100644 --- a/src/system/kernel/fs/fifo.cpp +++ b/src/system/kernel/fs/fifo.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2007-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2003-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -68,7 +68,7 @@ public: size_t Read(void* buffer, size_t length); ssize_t UserWrite(const void* buffer, ssize_t length); ssize_t UserRead(void* buffer, ssize_t length); - + size_t Readable() const; size_t Writable() const; @@ -112,10 +112,10 @@ public: } private: - spinlock fLock; - struct thread* fThread; - file_cookie* fCookie; - volatile bool fNotified; + spinlock fLock; + Thread* fThread; + file_cookie* fCookie; + volatile bool fNotified; }; @@ -156,9 +156,9 @@ public: { return fModificationTime; } void SetModificationTime(timespec modificationTime) { fModificationTime = modificationTime; } - + mutex* RequestLock() { return &fRequestLock; } - + status_t WriteDataToBuffer(const void* data, size_t* _length, bool nonBlocking); status_t ReadDataFromBuffer(void* data, size_t* _length, @@ -167,21 +167,21 @@ public: { return fBuffer.Readable(); } size_t BytesWritable() const { return fBuffer.Writable(); } - + void AddReadRequest(ReadRequest& request); void RemoveReadRequest(ReadRequest& request); status_t WaitForReadRequest(ReadRequest& request); - + void NotifyBytesRead(size_t bytes); void NotifyReadDone(); void NotifyBytesWritten(size_t bytes); void NotifyEndClosed(bool writer); - + void Open(int openMode); void Close(int openMode, file_cookie* cookie); int32 ReaderCount() const { return fReaderCount; } int32 WriterCount() const { return fWriterCount; } - + status_t Select(uint8 event, selectsync* sync, int openMode); status_t Deselect(uint8 event, selectsync* sync, @@ -190,20 +190,20 @@ public: private: timespec fCreationTime; timespec fModificationTime; - + RingBuffer fBuffer; - + ReadRequestList fReadRequests; WriteRequestList fWriteRequests; - + mutex fRequestLock; - + ConditionVariable fWriteCondition; - + int32 fReaderCount; int32 fWriterCount; bool fActive; - + select_sync_pool* fReadSelectSyncPool; select_sync_pool* fWriteSelectSyncPool; }; diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 58b7ad7d75..437cb04fa0 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -1774,7 +1774,7 @@ disconnect_mount_or_vnode_fds(struct fs_mount* mount, while (true) { struct io_context* context = NULL; bool contextLocked = false; - struct team* team = NULL; + Team* team = NULL; team_id lastTeamID; cpu_status state = disable_interrupts(); @@ -3335,7 +3335,7 @@ dump_io_context(int argc, char** argv) if (IS_KERNEL_ADDRESS(num)) context = (struct io_context*)num; else { - struct team* team = team_get_team_struct_locked(num); + Team* team = team_get_team_struct_locked(num); if (team == NULL) { kprintf("could not find team with ID %ld\n", num); return 0; @@ -7817,7 +7817,7 @@ _kern_get_next_fd_info(team_id teamID, uint32* _cookie, fd_info* info, return B_BAD_VALUE; struct io_context* context = NULL; - struct team* team = NULL; + Team* team = NULL; cpu_status state = disable_interrupts(); GRAB_TEAM_LOCK(); diff --git a/src/system/kernel/image.cpp b/src/system/kernel/image.cpp index ebf2398b2b..0643e00b14 100644 --- a/src/system/kernel/image.cpp +++ b/src/system/kernel/image.cpp @@ -78,7 +78,7 @@ static ImageNotificationService sNotificationService; /*! Registers an image with the specified team. */ image_id -register_image(struct team *team, image_info *_info, size_t size) +register_image(Team *team, image_info *_info, size_t size) { image_id id = atomic_add(&sNextImageID, 1); struct image *image; @@ -115,7 +115,7 @@ register_image(struct team *team, image_info *_info, size_t size) /*! Unregisters an image from the specified team. */ status_t -unregister_image(struct team *team, image_id id) +unregister_image(Team *team, image_id id) { status_t status = B_ENTRY_NOT_FOUND; @@ -148,7 +148,7 @@ unregister_image(struct team *team, image_id id) The team lock must be held when you call this function. */ int32 -count_images(struct team *team) +count_images(Team *team) { struct image *image = NULL; int32 count = 0; @@ -166,7 +166,7 @@ count_images(struct team *team) with a team that has already been removed from the list (in thread_exit()). */ status_t -remove_images(struct team *team) +remove_images(Team *team) { struct image *image; @@ -216,7 +216,7 @@ _get_next_image_info(team_id teamID, int32 *cookie, image_info *info, return B_BAD_VALUE; status_t status = B_ENTRY_NOT_FOUND; - struct team *team; + Team *team; cpu_status state; mutex_lock(&sImageMutex); @@ -262,7 +262,7 @@ static int dump_images_list(int argc, char **argv) { struct image *image = NULL; - struct team *team; + Team *team; if (argc > 1) { team_id id = strtol(argv[1], NULL, 0); @@ -307,7 +307,7 @@ image_iterate_through_images(image_iterator_callback callback, void* cookie) status_t -image_debug_lookup_user_symbol_address(struct team *team, addr_t address, +image_debug_lookup_user_symbol_address(Team *team, addr_t address, addr_t *_baseAddress, const char **_symbolName, const char **_imageName, bool *_exactMatch) { @@ -367,7 +367,7 @@ static void notify_loading_app(status_t result, bool suspend) { cpu_status state; - struct team *team; + Team *team; state = disable_interrupts(); GRAB_TEAM_LOCK(); diff --git a/src/system/kernel/lib/kernel_errno.cpp b/src/system/kernel/lib/kernel_errno.cpp index 87c4c11cb1..d111c3e990 100644 --- a/src/system/kernel/lib/kernel_errno.cpp +++ b/src/system/kernel/lib/kernel_errno.cpp @@ -16,7 +16,7 @@ int * _errnop(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); return &thread->kernel_errno; } diff --git a/src/system/kernel/locks/lock.cpp b/src/system/kernel/locks/lock.cpp index 259fc813a5..9f69313cb9 100644 --- a/src/system/kernel/locks/lock.cpp +++ b/src/system/kernel/locks/lock.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Distributed under the terms of the MIT License. * @@ -28,13 +28,13 @@ struct mutex_waiter { - struct thread* thread; + Thread* thread; mutex_waiter* next; // next in queue mutex_waiter* last; // last in queue (valid for the first in queue) }; struct rw_lock_waiter { - struct thread* thread; + Thread* thread; rw_lock_waiter* next; // next in queue rw_lock_waiter* last; // last in queue (valid for the first in queue) bool writer; diff --git a/src/system/kernel/port.cpp b/src/system/kernel/port.cpp index 4f4717e7c1..bb19d609e0 100644 --- a/src/system/kernel/port.cpp +++ b/src/system/kernel/port.cpp @@ -592,7 +592,7 @@ uninit_port_locked(struct port_entry& port) /*! This function delets all the ports that are owned by the passed team. */ void -delete_owned_ports(struct team* team) +delete_owned_ports(Team* team) { TRACE(("delete_owned_ports(owner = %ld)\n", team->id)); @@ -727,7 +727,7 @@ create_port(int32 queueLength, const char* name) if (queueLength < 1 || queueLength > MAX_QUEUE_LENGTH) return B_BAD_VALUE; - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; if (team == NULL) return B_BAD_TEAM_ID; @@ -1405,7 +1405,7 @@ set_port_owner(port_id id, team_id newTeamID) InterruptsSpinLocker teamLocker(gTeamSpinlock); - struct team* team = team_get_team_struct_locked(newTeamID); + Team* team = team_get_team_struct_locked(newTeamID); if (team == NULL) { T(OwnerChange(sPorts[slot], newTeamID, B_BAD_TEAM_ID)); return B_BAD_TEAM_ID; diff --git a/src/system/kernel/posix/realtime_sem.cpp b/src/system/kernel/posix/realtime_sem.cpp index ec16dda467..e244fef100 100644 --- a/src/system/kernel/posix/realtime_sem.cpp +++ b/src/system/kernel/posix/realtime_sem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -814,7 +814,7 @@ private: static realtime_sem_context* get_current_team_context() { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; // get context realtime_sem_context* context = atomic_pointer_get( diff --git a/src/system/kernel/posix/xsi_message_queue.cpp b/src/system/kernel/posix/xsi_message_queue.cpp index a20b9407f2..cab9239420 100644 --- a/src/system/kernel/posix/xsi_message_queue.cpp +++ b/src/system/kernel/posix/xsi_message_queue.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008, Haiku Inc. All rights reserved. + * Copyright 2008-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -35,7 +35,7 @@ // Queue for holding blocked threads struct queued_thread : DoublyLinkedListLinkImpl { - queued_thread(struct thread *_thread, int32 _message_length) + queued_thread(Thread *_thread, int32 _message_length) : thread(_thread), message_length(_message_length), @@ -43,9 +43,9 @@ struct queued_thread : DoublyLinkedListLinkImpl { { } - struct thread *thread; - int32 message_length; - bool queued; + Thread *thread; + int32 message_length; + bool queued; }; typedef DoublyLinkedList ThreadQueue; @@ -119,7 +119,7 @@ public: // Implemented after sXsiMessageCount is declared ~XsiMessageQueue(); - status_t BlockAndUnlock(struct thread *thread, MutexLocker *queueLocker) + status_t BlockAndUnlock(Thread *thread, MutexLocker *queueLocker) { thread_prepare_to_block(thread, B_CAN_INTERRUPT, THREAD_BLOCK_TYPE_OTHER, (void*)"xsi message queue"); @@ -758,7 +758,7 @@ _user_xsi_msgrcv(int messageQueueID, void *messagePointer, if (message == NULL && !(messageFlags & IPC_NOWAIT)) { // We are going to sleep - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); queued_thread queueEntry(thread, messageSize); messageQueue->Enqueue(&queueEntry, /* waitForMessage */ true); @@ -865,7 +865,7 @@ _user_xsi_msgsnd(int messageQueueID, const void *messagePointer, if (goToSleep && !(messageFlags & IPC_NOWAIT)) { // We are going to sleep - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); queued_thread queueEntry(thread, messageSize); messageQueue->Enqueue(&queueEntry, /* waitForMessage */ false); diff --git a/src/system/kernel/posix/xsi_semaphore.cpp b/src/system/kernel/posix/xsi_semaphore.cpp index d26b3f61d6..941ceca127 100644 --- a/src/system/kernel/posix/xsi_semaphore.cpp +++ b/src/system/kernel/posix/xsi_semaphore.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008, Haiku Inc. All rights reserved. + * Copyright 2008-2011, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -35,7 +35,7 @@ // Queue for holding blocked threads struct queued_thread : DoublyLinkedListLinkImpl { - queued_thread(struct thread *thread, int32 count) + queued_thread(Thread *thread, int32 count) : thread(thread), count(count), @@ -43,9 +43,9 @@ struct queued_thread : DoublyLinkedListLinkImpl { { } - struct thread *thread; - int32 count; - bool queued; + Thread *thread; + int32 count; + bool queued; }; typedef DoublyLinkedList ThreadQueue; @@ -53,7 +53,7 @@ typedef DoublyLinkedList ThreadQueue; class XsiSemaphoreSet; struct sem_undo : DoublyLinkedListLinkImpl { - sem_undo(XsiSemaphoreSet *semaphoreSet, struct team *team, int16 *undoValues) + sem_undo(XsiSemaphoreSet *semaphoreSet, Team *team, int16 *undoValues) : semaphore_set(semaphoreSet), team(team), @@ -63,7 +63,7 @@ struct sem_undo : DoublyLinkedListLinkImpl { DoublyLinkedListLink team_link; XsiSemaphoreSet *semaphore_set; - struct team *team; + Team *team; int16 *undo_values; }; @@ -136,7 +136,7 @@ public: } } - status_t BlockAndUnlock(struct thread *thread, MutexLocker *setLocker) + status_t BlockAndUnlock(Thread *thread, MutexLocker *setLocker) { thread_prepare_to_block(thread, B_CAN_INTERRUPT, THREAD_BLOCK_TYPE_OTHER, (void*)"xsi semaphore"); @@ -278,7 +278,7 @@ public: void ClearUndo(unsigned short semaphoreNumber) { - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; UndoList::Iterator iterator = fUndoList.GetIterator(); while (iterator.HasNext()) { struct sem_undo *current = iterator.Next(); @@ -297,7 +297,7 @@ public: { // Clear all undo_values (POSIX semadj equivalent) // of the calling team. This happens only on semctl SETALL. - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; DoublyLinkedList::Iterator iterator = fUndoList.GetIterator(); while (iterator.HasNext()) { struct sem_undo *current = iterator.Next(); @@ -391,7 +391,7 @@ public: // Look if there is already a record from the team caller // for the same semaphore set bool notFound = true; - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; DoublyLinkedList::Iterator iterator = fUndoList.GetIterator(); while (iterator.HasNext()) { struct sem_undo *current = iterator.Next(); @@ -463,7 +463,7 @@ public: void RevertUndo(short semaphoreNumber, short value) { // This can be called only when RecordUndo fails. - struct team *team = thread_get_current_thread()->team; + Team *team = thread_get_current_thread()->team; DoublyLinkedList::Iterator iterator = fUndoList.GetIterator(); while (iterator.HasNext()) { struct sem_undo *current = iterator.Next(); @@ -676,7 +676,7 @@ xsi_sem_init() /*! Function called on team exit to process any sem_undo requests */ void -xsi_sem_undo(struct team *team) +xsi_sem_undo(Team *team) { if (team->xsi_sem_context == NULL) return; @@ -1170,7 +1170,7 @@ _user_xsi_semop(int semaphoreID, struct sembuf *ops, size_t numOps) if (operations[i].sem_op != 0) waitOnZero = false; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); queued_thread queueEntry(thread, (int32)operations[i].sem_op); semaphore->Enqueue(&queueEntry, waitOnZero); diff --git a/src/system/kernel/scheduler/scheduler.cpp b/src/system/kernel/scheduler/scheduler.cpp index 5c2568d9b6..fc1a5d41a6 100644 --- a/src/system/kernel/scheduler/scheduler.cpp +++ b/src/system/kernel/scheduler/scheduler.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -24,7 +24,7 @@ static void (*sRescheduleFunction)(void); static void scheduler_reschedule_no_op(void) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL && thread->next_state != B_THREAD_READY) panic("scheduler_reschedule_no_op() called in non-ready thread"); } @@ -108,7 +108,7 @@ _user_estimate_max_scheduling_latency(thread_id id) InterruptsSpinLocker locker(gThreadSpinlock); - struct thread* thread = id < 0 + Thread* thread = id < 0 ? thread_get_current_thread() : thread_get_thread_struct_locked(id); if (thread == NULL) return 0; diff --git a/src/system/kernel/scheduler/scheduler_affine.cpp b/src/system/kernel/scheduler/scheduler_affine.cpp index 10fc81efa0..508808f39b 100644 --- a/src/system/kernel/scheduler/scheduler_affine.cpp +++ b/src/system/kernel/scheduler/scheduler_affine.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Rene Gollent, rene@gollent.com. - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Angelo Mottola, a.mottola@libero.it. * Distributed under the terms of the MIT License. @@ -42,9 +42,9 @@ // TODO: consolidate this such that HT/SMT entities on the same physical core // share a queue, once we have the necessary API for retrieving the topology // information -static struct thread* sRunQueue[B_MAX_CPU_COUNT]; +static Thread* sRunQueue[B_MAX_CPU_COUNT]; static int32 sRunQueueSize[B_MAX_CPU_COUNT]; -static struct thread* sIdleThreads; +static Thread* sIdleThreads; const int32 kMaxTrackingQuantums = 5; const bigtime_t kMinThreadQuantum = 3000; @@ -105,7 +105,7 @@ _rand(void) static int dump_run_queue(int argc, char **argv) { - struct thread *thread = NULL; + Thread *thread = NULL; for (int32 i = 0; i < smp_get_num_cpus(); i++) { thread = sRunQueue[i]; @@ -148,7 +148,7 @@ affine_get_most_idle_cpu() Note: thread lock must be held when entering this function */ static void -affine_enqueue_in_run_queue(struct thread *thread) +affine_enqueue_in_run_queue(Thread *thread) { int32 targetCPU = -1; if (thread->pinned_to_cpu > 0) @@ -164,7 +164,7 @@ affine_enqueue_in_run_queue(struct thread *thread) thread->queue_next = sIdleThreads; sIdleThreads = thread; } else { - struct thread *curr, *prev; + Thread *curr, *prev; for (curr = sRunQueue[targetCPU], prev = NULL; curr && curr->priority >= thread->next_priority; curr = curr->queue_next) { @@ -205,10 +205,10 @@ affine_enqueue_in_run_queue(struct thread *thread) /*! Dequeues the thread after the given \a prevThread from the run queue. */ -static inline struct thread * -dequeue_from_run_queue(struct thread *prevThread, int32 currentCPU) +static inline Thread * +dequeue_from_run_queue(Thread *prevThread, int32 currentCPU) { - struct thread *resultThread = NULL; + Thread *resultThread = NULL; if (prevThread != NULL) { resultThread = prevThread->queue_next; prevThread->queue_next = resultThread->queue_next; @@ -226,7 +226,7 @@ dequeue_from_run_queue(struct thread *prevThread, int32 currentCPU) /*! Looks for a possible thread to grab/run from another CPU. Note: thread lock must be held when entering this function */ -static struct thread * +static Thread * steal_thread_from_other_cpus(int32 currentCPU) { // look through the active CPUs - find the one @@ -254,8 +254,8 @@ steal_thread_from_other_cpus(int32 currentCPU) if (targetCPU < 0) return NULL; - struct thread* nextThread = sRunQueue[targetCPU]; - struct thread* prevThread = NULL; + Thread* nextThread = sRunQueue[targetCPU]; + Thread* prevThread = NULL; while (nextThread != NULL) { // grab the highest priority non-pinned thread @@ -277,7 +277,7 @@ steal_thread_from_other_cpus(int32 currentCPU) Note: thread lock must be held when entering this function */ static void -affine_set_thread_priority(struct thread *thread, int32 priority) +affine_set_thread_priority(Thread *thread, int32 priority) { int32 targetCPU = -1; @@ -299,7 +299,7 @@ affine_set_thread_priority(struct thread *thread, int32 priority) thread); // search run queues for the thread - struct thread *item = NULL, *prev = NULL; + Thread *item = NULL, *prev = NULL; targetCPU = thread->scheduler_data->fLastQueue; for (item = sRunQueue[targetCPU], prev = NULL; item && item != thread; @@ -322,12 +322,12 @@ affine_set_thread_priority(struct thread *thread, int32 priority) static bigtime_t -affine_estimate_max_scheduling_latency(struct thread* thread) +affine_estimate_max_scheduling_latency(Thread* thread) { // TODO: This is probably meant to be called periodically to return the // current estimate depending on the system usage; we return fixed estimates // per thread priority, though. - + if (thread->priority >= B_REAL_TIME_DISPLAY_PRIORITY) return kMinThreadQuantum / 4; if (thread->priority >= B_DISPLAY_PRIORITY) @@ -340,7 +340,7 @@ affine_estimate_max_scheduling_latency(struct thread* thread) static void -context_switch(struct thread *fromThread, struct thread *toThread) +context_switch(Thread *fromThread, Thread *toThread) { if ((fromThread->flags & THREAD_FLAGS_DEBUGGER_INSTALLED) != 0) user_debug_thread_unscheduled(fromThread); @@ -380,7 +380,7 @@ static void affine_reschedule(void) { int32 currentCPU = smp_get_current_cpu(); - struct thread *oldThread = thread_get_current_thread(); + Thread *oldThread = thread_get_current_thread(); // check whether we're only supposed to reschedule, if the current thread // is idle @@ -393,7 +393,7 @@ affine_reschedule(void) } } - struct thread *nextThread, *prevThread; + Thread *nextThread, *prevThread; TRACE(("reschedule(): cpu %ld, cur_thread = %ld\n", currentCPU, oldThread->id)); @@ -426,8 +426,8 @@ affine_reschedule(void) break; // find next thread with lower priority - struct thread *lowerNextThread = nextThread->queue_next; - struct thread *lowerPrevThread = nextThread; + Thread *lowerNextThread = nextThread->queue_next; + Thread *lowerPrevThread = nextThread; int32 priority = nextThread->priority; while (lowerNextThread != NULL @@ -534,7 +534,7 @@ affine_reschedule(void) static void -affine_on_thread_create(struct thread* thread) +affine_on_thread_create(Thread* thread) { thread->scheduler_data = new(std::nothrow) scheduler_thread_data(); if (thread->scheduler_data == NULL) @@ -543,14 +543,14 @@ affine_on_thread_create(struct thread* thread) static void -affine_on_thread_init(struct thread* thread) +affine_on_thread_init(Thread* thread) { ((scheduler_thread_data *)(thread->scheduler_data))->Init(); } static void -affine_on_thread_destroy(struct thread* thread) +affine_on_thread_destroy(Thread* thread) { delete thread->scheduler_data; } diff --git a/src/system/kernel/scheduler/scheduler_simple.cpp b/src/system/kernel/scheduler/scheduler_simple.cpp index 29b6f40ed2..b7a72d4e7f 100644 --- a/src/system/kernel/scheduler/scheduler_simple.cpp +++ b/src/system/kernel/scheduler/scheduler_simple.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Angelo Mottola, a.mottola@libero.it. * Distributed under the terms of the MIT License. @@ -40,7 +40,7 @@ const bigtime_t kThreadQuantum = 3000; // The run queue. Holds the threads ready to run ordered by priority. -static struct thread *sRunQueue = NULL; +static Thread *sRunQueue = NULL; static int @@ -59,7 +59,7 @@ _rand(void) static int dump_run_queue(int argc, char **argv) { - struct thread *thread; + Thread *thread; thread = sRunQueue; if (!thread) @@ -81,11 +81,11 @@ dump_run_queue(int argc, char **argv) Note: thread lock must be held when entering this function */ static void -simple_enqueue_in_run_queue(struct thread *thread) +simple_enqueue_in_run_queue(Thread *thread) { thread->state = thread->next_state = B_THREAD_READY; - struct thread *curr, *prev; + Thread *curr, *prev; for (curr = sRunQueue, prev = NULL; curr && curr->priority >= thread->next_priority; curr = curr->queue_next) { @@ -120,7 +120,7 @@ simple_enqueue_in_run_queue(struct thread *thread) Note: thread lock must be held when entering this function */ static void -simple_set_thread_priority(struct thread *thread, int32 priority) +simple_set_thread_priority(Thread *thread, int32 priority) { if (priority == thread->priority) return; @@ -140,7 +140,7 @@ simple_set_thread_priority(struct thread *thread, int32 priority) thread); // find thread in run queue - struct thread *item, *prev; + Thread *item, *prev; for (item = sRunQueue, prev = NULL; item && item != thread; item = item->queue_next) { if (prev) @@ -164,12 +164,12 @@ simple_set_thread_priority(struct thread *thread, int32 priority) static bigtime_t -simple_estimate_max_scheduling_latency(struct thread* thread) +simple_estimate_max_scheduling_latency(Thread* thread) { // TODO: This is probably meant to be called periodically to return the // current estimate depending on the system usage; we return fixed estimates // per thread priority, though. - + if (thread->priority >= B_REAL_TIME_DISPLAY_PRIORITY) return kThreadQuantum / 4; if (thread->priority >= B_DISPLAY_PRIORITY) @@ -180,7 +180,7 @@ simple_estimate_max_scheduling_latency(struct thread* thread) static void -context_switch(struct thread *fromThread, struct thread *toThread) +context_switch(Thread *fromThread, Thread *toThread) { if ((fromThread->flags & THREAD_FLAGS_DEBUGGER_INSTALLED) != 0) user_debug_thread_unscheduled(fromThread); @@ -219,8 +219,8 @@ reschedule_event(timer *unused) static void simple_reschedule(void) { - struct thread *oldThread = thread_get_current_thread(); - struct thread *nextThread, *prevThread; + Thread *oldThread = thread_get_current_thread(); + Thread *nextThread, *prevThread; // check whether we're only supposed to reschedule, if the current thread // is idle @@ -274,8 +274,8 @@ simple_reschedule(void) break; // find next thread with lower priority - struct thread *lowerNextThread = nextThread->queue_next; - struct thread *lowerPrevThread = nextThread; + Thread *lowerNextThread = nextThread->queue_next; + Thread *lowerPrevThread = nextThread; int32 priority = nextThread->priority; while (lowerNextThread != NULL @@ -358,21 +358,21 @@ simple_reschedule(void) static void -simple_on_thread_create(struct thread* thread) +simple_on_thread_create(Thread* thread) { // do nothing } static void -simple_on_thread_init(struct thread* thread) +simple_on_thread_init(Thread* thread) { // do nothing } static void -simple_on_thread_destroy(struct thread* thread) +simple_on_thread_destroy(Thread* thread) { // do nothing } diff --git a/src/system/kernel/scheduler/scheduler_simple_smp.cpp b/src/system/kernel/scheduler/scheduler_simple_smp.cpp index dbe1702fbc..49b434e14b 100644 --- a/src/system/kernel/scheduler/scheduler_simple_smp.cpp +++ b/src/system/kernel/scheduler/scheduler_simple_smp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Copyright 2002, Angelo Mottola, a.mottola@libero.it. * Distributed under the terms of the MIT License. @@ -41,7 +41,7 @@ const bigtime_t kThreadQuantum = 3000; // The run queue. Holds the threads ready to run ordered by priority. -static struct thread *sRunQueue = NULL; +static Thread *sRunQueue = NULL; static int32 sCPUCount = 1; static int32 sNextCPUForSelection = 0; @@ -62,7 +62,7 @@ _rand(void) static int dump_run_queue(int argc, char **argv) { - struct thread *thread; + Thread *thread; thread = sRunQueue; if (!thread) @@ -81,7 +81,7 @@ dump_run_queue(int argc, char **argv) static int32 -select_cpu(int32 currentCPU, struct thread* thread, int32& targetPriority) +select_cpu(int32 currentCPU, Thread* thread, int32& targetPriority) { if (thread->pinned_to_cpu > 0) { // the thread is pinned to a specific CPU @@ -124,11 +124,11 @@ select_cpu(int32 currentCPU, struct thread* thread, int32& targetPriority) Note: thread lock must be held when entering this function */ static void -enqueue_in_run_queue(struct thread *thread) +enqueue_in_run_queue(Thread *thread) { thread->state = thread->next_state = B_THREAD_READY; - struct thread *curr, *prev; + Thread *curr, *prev; for (curr = sRunQueue, prev = NULL; curr && curr->priority >= thread->next_priority; curr = curr->queue_next) { @@ -185,7 +185,7 @@ enqueue_in_run_queue(struct thread *thread) Note: thread lock must be held when entering this function */ static void -set_thread_priority(struct thread *thread, int32 priority) +set_thread_priority(Thread *thread, int32 priority) { if (priority == thread->priority) return; @@ -205,7 +205,7 @@ set_thread_priority(struct thread *thread, int32 priority) thread); // find thread in run queue - struct thread *item, *prev; + Thread *item, *prev; for (item = sRunQueue, prev = NULL; item && item != thread; item = item->queue_next) { if (prev) @@ -229,7 +229,7 @@ set_thread_priority(struct thread *thread, int32 priority) static bigtime_t -estimate_max_scheduling_latency(struct thread* thread) +estimate_max_scheduling_latency(Thread* thread) { // TODO: This is probably meant to be called periodically to return the // current estimate depending on the system usage; we return fixed estimates @@ -245,7 +245,7 @@ estimate_max_scheduling_latency(struct thread* thread) static void -context_switch(struct thread *fromThread, struct thread *toThread) +context_switch(Thread *fromThread, Thread *toThread) { if ((fromThread->flags & THREAD_FLAGS_DEBUGGER_INSTALLED) != 0) user_debug_thread_unscheduled(fromThread); @@ -284,8 +284,8 @@ reschedule_event(timer *unused) static void reschedule(void) { - struct thread *oldThread = thread_get_current_thread(); - struct thread *nextThread, *prevThread; + Thread *oldThread = thread_get_current_thread(); + Thread *nextThread, *prevThread; // check whether we're only supposed to reschedule, if the current thread // is idle @@ -362,8 +362,8 @@ reschedule(void) break; // find next thread with lower priority - struct thread *lowerNextThread = nextThread->queue_next; - struct thread *lowerPrevThread = nextThread; + Thread *lowerNextThread = nextThread->queue_next; + Thread *lowerPrevThread = nextThread; int32 priority = nextThread->priority; while (lowerNextThread != NULL @@ -457,21 +457,21 @@ reschedule(void) static void -on_thread_create(struct thread* thread) +on_thread_create(Thread* thread) { // do nothing } static void -on_thread_init(struct thread* thread) +on_thread_init(Thread* thread) { // do nothing } static void -on_thread_destroy(struct thread* thread) +on_thread_destroy(Thread* thread) { // do nothing } diff --git a/src/system/kernel/scheduler/scheduler_tracing.h b/src/system/kernel/scheduler/scheduler_tracing.h index a6929e0e87..422834d3d8 100644 --- a/src/system/kernel/scheduler/scheduler_tracing.h +++ b/src/system/kernel/scheduler/scheduler_tracing.h @@ -1,11 +1,12 @@ /* - * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ #ifndef KERNEL_SCHEDULER_TRACING_H #define KERNEL_SCHEDULER_TRACING_H + #include #include #include @@ -18,7 +19,7 @@ namespace SchedulerTracing { class SchedulerTraceEntry : public AbstractTraceEntry { public: - SchedulerTraceEntry(struct thread* thread) + SchedulerTraceEntry(Thread* thread) : fID(thread->id) { @@ -35,8 +36,7 @@ protected: class EnqueueThread : public SchedulerTraceEntry { public: - EnqueueThread(struct thread* thread, struct thread* previous, - struct thread* next) + EnqueueThread(Thread* thread, Thread* previous, Thread* next) : SchedulerTraceEntry(thread), fPreviousID(-1), @@ -66,7 +66,7 @@ private: class RemoveThread : public SchedulerTraceEntry { public: - RemoveThread(struct thread* thread) + RemoveThread(Thread* thread) : SchedulerTraceEntry(thread), fPriority(thread->priority) @@ -85,7 +85,7 @@ private: class ScheduleThread : public SchedulerTraceEntry { public: - ScheduleThread(struct thread* thread, struct thread* previous) + ScheduleThread(Thread* thread, Thread* previous) : SchedulerTraceEntry(thread), fPreviousID(previous->id), diff --git a/src/system/kernel/sem.cpp b/src/system/kernel/sem.cpp index 9c7505c714..cf47fb2e9f 100644 --- a/src/system/kernel/sem.cpp +++ b/src/system/kernel/sem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -57,7 +57,7 @@ struct queued_thread : DoublyLinkedListLinkImpl { - queued_thread(struct thread *thread, int32 count) + queued_thread(Thread *thread, int32 count) : thread(thread), count(count), @@ -65,9 +65,9 @@ struct queued_thread : DoublyLinkedListLinkImpl { { } - struct thread *thread; - int32 count; - bool queued; + Thread *thread; + int32 count; + bool queued; }; typedef DoublyLinkedList ThreadQueue; @@ -82,7 +82,7 @@ struct sem_entry { // count + acquisition count of all blocked // threads char* name; - struct team* owner; + Team* owner; select_info* select_infos; thread_id last_acquirer; #if DEBUG_SEM_LAST_ACQUIRER @@ -488,7 +488,7 @@ create_sem_etc(int32 count, const char* name, team_id owner) strlcpy(tempName, name, nameLength); - struct team* team = NULL; + Team* team = NULL; if (owner == team_get_kernel_team_id()) team = team_get_kernel_team(); else if (owner == team_get_current_team_id()) @@ -700,7 +700,7 @@ remove_thread_from_sem(queued_thread *entry, struct sem_entry *sem) /*! This function deletes all semaphores belonging to a particular team. */ void -sem_delete_owned_sems(struct team* team) +sem_delete_owned_sems(Team* team) { struct list queue; @@ -839,7 +839,7 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count, if ((sSems[slot].u.used.count -= count) < 0) { // we need to block - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); TRACE(("switch_sem_etc(id = %ld): block name = %s, thread = %p," " name = %s\n", id, sSems[slot].u.used.name, thread, thread->name)); @@ -1125,7 +1125,7 @@ _get_next_sem_info(team_id teamID, int32 *_cookie, struct sem_info *info, InterruptsSpinLocker locker(gTeamSpinlock); - struct team* team; + Team* team; if (teamID == B_CURRENT_TEAM) team = thread_get_current_thread()->team; else @@ -1185,7 +1185,7 @@ set_sem_owner(sem_id id, team_id newTeamID) InterruptsSpinLocker teamLocker(gTeamSpinlock); - struct team* newTeam = team_get_team_struct_locked(newTeamID); + Team* newTeam = team_get_team_struct_locked(newTeamID); if (newTeam == NULL) return B_BAD_TEAM_ID; diff --git a/src/system/kernel/signal.cpp b/src/system/kernel/signal.cpp index f02d2d7daa..bd2520cc24 100644 --- a/src/system/kernel/signal.cpp +++ b/src/system/kernel/signal.cpp @@ -63,8 +63,7 @@ const char * const sigstr[NSIG] = { }; -static status_t deliver_signal(struct thread *thread, uint signal, - uint32 flags); +static status_t deliver_signal(Thread *thread, uint signal, uint32 flags); @@ -144,8 +143,7 @@ class SendSignal : public AbstractTraceEntry { class SigAction : public AbstractTraceEntry { public: - SigAction(struct thread* thread, uint32 signal, - const struct sigaction* act) + SigAction(Thread* thread, uint32 signal, const struct sigaction* act) : fThread(thread->id), fSignal(signal), @@ -263,7 +261,7 @@ class SigSuspendDone : public AbstractTraceEntry { Interrupts must be disabled and the thread lock must be held. */ static void -update_thread_signals_flag(struct thread* thread) +update_thread_signals_flag(Thread* thread) { sigset_t mask = ~atomic_get(&thread->sig_block_mask) | thread->sig_temp_enabled; @@ -284,7 +282,7 @@ update_current_thread_signals_flag() static bool -notify_debugger(struct thread *thread, int signal, struct sigaction *handler, +notify_debugger(Thread *thread, int signal, struct sigaction *handler, bool deadly) { uint64 signalMask = SIGNAL_TO_MASK(signal); @@ -308,7 +306,7 @@ notify_debugger(struct thread *thread, int signal, struct sigaction *handler, handler is prepared, or whatever the signal demands. */ bool -handle_signals(struct thread *thread) +handle_signals(Thread *thread) { uint32 signalMask = atomic_get(&thread->sig_pending) & (~atomic_get(&thread->sig_block_mask) | thread->sig_temp_enabled); @@ -425,7 +423,7 @@ handle_signals(struct thread *thread) // send a SIGCHLD to the parent (if it does have // SA_NOCLDSTOP defined) SpinLocker _(gThreadSpinlock); - struct thread* parentThread + Thread* parentThread = thread->team->parent->main_thread; struct sigaction& parentHandler = parentThread->sig_action[SIGCHLD - 1]; @@ -538,7 +536,7 @@ is_signal_blocked(int signal) thread lock held. */ static status_t -deliver_signal(struct thread *thread, uint signal, uint32 flags) +deliver_signal(Thread *thread, uint signal, uint32 flags) { if (flags & B_CHECK_PERMISSION) { // ToDo: introduce euid & uid fields to the team and check permission @@ -560,7 +558,7 @@ deliver_signal(struct thread *thread, uint signal, uint32 flags) case SIGKILL: { // Forward KILLTHR to the main thread of the team - struct thread *mainThread = thread->team->main_thread; + Thread *mainThread = thread->team->main_thread; atomic_or(&mainThread->sig_pending, SIGNAL_TO_MASK(SIGKILLTHR)); // Wake up main thread @@ -612,7 +610,7 @@ int send_signal_etc(pid_t id, uint signal, uint32 flags) { status_t status = B_BAD_THREAD_ID; - struct thread *thread; + Thread *thread; cpu_status state = 0; if (signal < 0 || signal > MAX_SIGNO) @@ -649,7 +647,7 @@ send_signal_etc(pid_t id, uint signal, uint32 flags) group = team_get_process_group_locked(NULL, id); if (group != NULL) { - struct team *team, *next; + Team *team, *next; // Send a signal to all teams in this process group @@ -700,7 +698,7 @@ send_signal(pid_t threadID, uint signal) int has_signals_pending(void *_thread) { - struct thread *thread = (struct thread *)_thread; + Thread *thread = (Thread *)_thread; if (thread == NULL) thread = thread_get_current_thread(); @@ -712,7 +710,7 @@ has_signals_pending(void *_thread) static int sigprocmask_internal(int how, const sigset_t *set, sigset_t *oldSet) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); sigset_t oldMask = atomic_get(&thread->sig_block_mask); if (set != NULL) { @@ -756,7 +754,7 @@ static status_t sigaction_etc_internal(thread_id threadID, int signal, const struct sigaction *act, struct sigaction *oldAction) { - struct thread *thread; + Thread *thread; cpu_status state; status_t error = B_OK; @@ -831,8 +829,7 @@ alarm_event(timer *t) // set_alarm(). // Since thread->alarm is this timer structure, we can just // cast it back - ugly but it works for now - struct thread *thread = (struct thread *)((uint8 *)t - - offsetof(struct thread, alarm)); + Thread *thread = (Thread *)((uint8 *)t - offsetof(Thread, alarm)); // ToDo: investigate adding one user parameter to the timer structure to fix this hack TRACE(("alarm_event: thread = %p\n", thread)); @@ -850,7 +847,7 @@ alarm_event(timer *t) bigtime_t set_alarm(bigtime_t time, uint32 mode) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); bigtime_t remainingTime = 0; ASSERT(B_ONE_SHOT_RELATIVE_ALARM == B_ONE_SHOT_RELATIVE_TIMER); @@ -882,7 +879,7 @@ sigwait_internal(const sigset_t *set, int *_signal) { sigset_t requestedSignals = *set & BLOCKABLE_SIGNALS; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); while (true) { sigset_t pendingSignals = atomic_get(&thread->sig_pending); @@ -938,7 +935,7 @@ sigsuspend_internal(const sigset_t *mask) { T(SigSuspend(*mask)); - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); sigset_t oldMask = atomic_get(&thread->sig_block_mask); // Set the new block mask and block until interrupted. @@ -975,7 +972,7 @@ sigsuspend(const sigset_t *mask) static status_t sigpending_internal(sigset_t *set) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); if (set == NULL) return B_BAD_VALUE; @@ -1073,7 +1070,7 @@ _user_sigwait(const sigset_t *userSet, int *_userSignal) status_t status = sigwait_internal(&set, &signal); if (status == B_INTERRUPTED) { // make sure we'll be restarted - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); atomic_or(&thread->flags, THREAD_FLAGS_ALWAYS_RESTART_SYSCALL | THREAD_FLAGS_RESTART_SYSCALL); return status; @@ -1120,7 +1117,7 @@ _user_sigpending(sigset_t *userSet) status_t _user_set_signal_stack(const stack_t *newUserStack, stack_t *oldUserStack) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); struct stack_t newStack, oldStack; bool onStack = false; diff --git a/src/system/kernel/syscalls.cpp b/src/system/kernel/syscalls.cpp index b8efd955a6..ac9da08b18 100644 --- a/src/system/kernel/syscalls.cpp +++ b/src/system/kernel/syscalls.cpp @@ -521,22 +521,22 @@ public: return fFilter->Filter(_entry, out); if (const PreSyscall* entry = dynamic_cast(_entry)) { - _RemovePendingThread(entry->Thread()); + _RemovePendingThread(entry->ThreadID()); bool accepted = fFilter->Filter(entry, out); if (accepted) - _AddPendingThread(entry->Thread()); + _AddPendingThread(entry->ThreadID()); return accepted; } else if (const PostSyscall* entry = dynamic_cast(_entry)) { - bool wasPending = _RemovePendingThread(entry->Thread()); + bool wasPending = _RemovePendingThread(entry->ThreadID()); return wasPending || fFilter->Filter(entry, out); } else if (const AbstractTraceEntry* entry = dynamic_cast(_entry)) { - bool isPending = _IsPendingThread(entry->Thread()); + bool isPending = _IsPendingThread(entry->ThreadID()); return isPending || fFilter->Filter(entry, out); diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index 0bed51fb2d..4f8360f701 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -97,30 +97,30 @@ class TeamNotificationService : public DefaultNotificationService { public: TeamNotificationService(); - void Notify(uint32 eventCode, struct team* team); + void Notify(uint32 eventCode, Team* team); }; struct TeamHashDefinition { typedef team_id KeyType; - typedef struct team ValueType; + typedef Team ValueType; size_t HashKey(team_id key) const { return key; } - size_t Hash(struct team* value) const + size_t Hash(Team* value) const { return HashKey(value->id); } - bool Compare(team_id key, struct team* value) const + bool Compare(team_id key, Team* value) const { return value->id == key; } - struct team*& GetLink(struct team* value) const + Team*& GetLink(Team* value) const { return value->next; } @@ -131,7 +131,7 @@ typedef BOpenHashTable TeamHashTable; static TeamHashTable sTeamHash; static hash_table* sGroupHash = NULL; -static struct team* sKernelTeam = NULL; +static Team* sKernelTeam = NULL; // some arbitrary chosen limits - should probably depend on the available // memory (the limit is not yet enforced) @@ -347,7 +347,7 @@ TeamNotificationService::TeamNotificationService() void -TeamNotificationService::Notify(uint32 eventCode, struct team* team) +TeamNotificationService::Notify(uint32 eventCode, Team* team) { char eventBuffer[128]; KMessage event; @@ -364,7 +364,7 @@ TeamNotificationService::Notify(uint32 eventCode, struct team* team) static void -_dump_team_info(struct team* team) +_dump_team_info(Team* team) { kprintf("TEAM: %p\n", team); kprintf("id: %ld (%#lx)\n", team->id, team->id); @@ -401,7 +401,7 @@ dump_team_info(int argc, char** argv) bool found = false; if (argc < 2) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL && thread->team != NULL) _dump_team_info(thread->team); else @@ -412,13 +412,13 @@ dump_team_info(int argc, char** argv) id = strtoul(argv[1], NULL, 0); if (IS_KERNEL_ADDRESS(id)) { // semi-hack - _dump_team_info((struct team*)id); + _dump_team_info((Team*)id); return 0; } // walk through the thread list, trying to match name or id for (TeamHashTable::Iterator it = sTeamHash.GetIterator(); - struct team* team = it.Next();) { + Team* team = it.Next();) { if ((team->name && strcmp(argv[1], team->name) == 0) || team->id == id) { _dump_team_info(team); @@ -439,7 +439,7 @@ dump_teams(int argc, char** argv) kprintf("team id parent name\n"); for (TeamHashTable::Iterator it = sTeamHash.GetIterator(); - struct team* team = it.Next();) { + Team* team = it.Next();) { kprintf("%p%7ld %p %s\n", team, team->id, team->parent, team->name); } @@ -474,7 +474,7 @@ process_group_hash(void* _group, const void* _key, uint32 range) static void -insert_team_into_parent(struct team* parent, struct team* team) +insert_team_into_parent(Team* parent, Team* team) { ASSERT(parent != NULL); @@ -486,10 +486,10 @@ insert_team_into_parent(struct team* parent, struct team* team) /*! Note: must have team lock held */ static void -remove_team_from_parent(struct team* parent, struct team* team) +remove_team_from_parent(Team* parent, Team* team) { - struct team* child; - struct team* last = NULL; + Team* child; + Team* last = NULL; for (child = parent->children; child != NULL; child = child->siblings_next) { @@ -511,9 +511,9 @@ remove_team_from_parent(struct team* parent, struct team* team) Note: must have team lock held */ static void -reparent_children(struct team* team) +reparent_children(Team* team) { - struct team* child; + Team* child; while ((child = team->children) != NULL) { // remove the child from the current proc and add to the parent @@ -522,10 +522,10 @@ reparent_children(struct team* team) } // move job control entries too - sKernelTeam->stopped_children->entries.MoveFrom( - &team->stopped_children->entries); - sKernelTeam->continued_children->entries.MoveFrom( - &team->continued_children->entries); + sKernelTeam->stopped_children.entries.MoveFrom( + &team->stopped_children.entries); + sKernelTeam->continued_children.entries.MoveFrom( + &team->continued_children.entries); // Note, we don't move the dead children entries. Those will be deleted // when the team structure is deleted. @@ -533,14 +533,14 @@ reparent_children(struct team* team) static bool -is_session_leader(struct team* team) +is_session_leader(Team* team) { return team->session_id == team->id; } static bool -is_process_group_leader(struct team* team) +is_process_group_leader(Team* team) { return team->group_id == team->id; } @@ -643,7 +643,7 @@ insert_group_into_session(struct process_session* session, /*! You must hold the team lock when calling this function. */ static void -insert_team_into_group(struct process_group* group, struct team* team) +insert_team_into_group(struct process_group* group, Team* team) { team->group = group; team->group_id = group->id; @@ -660,11 +660,11 @@ insert_team_into_group(struct process_group* group, struct team* team) \param team the team that'll be removed from it's group */ static void -remove_team_from_group(struct team* team) +remove_team_from_group(Team* team) { struct process_group* group = team->group; - struct team* current; - struct team* last = NULL; + Team* current; + Team* last = NULL; // the team must be in any team to let this function have any effect if (group == NULL) @@ -726,7 +726,7 @@ create_process_session(pid_t id) static void -set_team_name(struct team* team, const char* name) +set_team_name(Team* team, const char* name) { if (const char* lastSlash = strrchr(name, '/')) name = lastSlash + 1; @@ -735,13 +735,13 @@ set_team_name(struct team* team, const char* name) } -static struct team* +static Team* create_team_struct(const char* name, bool kernel) { - ::team* team = new(std::nothrow) ::team; + Team* team = new(std::nothrow) Team; if (team == NULL) return NULL; - ObjectDeleter< ::team> teamDeleter(team); + ObjectDeleter teamDeleter(team); team->next = team->siblings_next = team->children = team->parent = NULL; team->id = allocate_thread_id(); @@ -775,28 +775,9 @@ create_team_struct(const char* name, bool kernel) team->dead_threads_count = 0; // dead children - team->dead_children = new(nothrow) team_dead_children; - if (team->dead_children == NULL) - return NULL; - ObjectDeleter deadChildrenDeleter(team->dead_children); - - team->dead_children->count = 0; - team->dead_children->kernel_time = 0; - team->dead_children->user_time = 0; - - // stopped children - team->stopped_children = new(nothrow) team_job_control_children; - if (team->stopped_children == NULL) - return NULL; - ObjectDeleter stoppedChildrenDeleter( - team->stopped_children); - - // continued children - team->continued_children = new(nothrow) team_job_control_children; - if (team->continued_children == NULL) - return NULL; - ObjectDeleter continuedChildrenDeleter( - team->continued_children); + team->dead_children.count = 0; + team->dead_children.kernel_time = 0; + team->dead_children.user_time = 0; // job control entry team->job_control_entry = new(nothrow) job_control_entry; @@ -819,14 +800,11 @@ create_team_struct(const char* name, bool kernel) return NULL; // publish dead/stopped/continued children condition vars - team->dead_children->condition_variable.Init(team->dead_children, + team->dead_children.condition_variable.Init(&team->dead_children, "team children"); // keep all allocated structures jobControlEntryDeleter.Detach(); - continuedChildrenDeleter.Detach(); - stoppedChildrenDeleter.Detach(); - deadChildrenDeleter.Detach(); teamDeleter.Detach(); return team; @@ -834,7 +812,7 @@ create_team_struct(const char* name, bool kernel) static void -delete_team_struct(struct team* team) +delete_team_struct(Team* team) { // get rid of all associated data team->PrepareForDeletion(); @@ -844,7 +822,7 @@ delete_team_struct(struct team* team) free(threadDeathEntry); } - while (job_control_entry* entry = team->dead_children->entries.RemoveHead()) + while (job_control_entry* entry = team->dead_children.entries.RemoveHead()) delete entry; while (free_user_thread* entry = team->free_user_threads) { @@ -856,15 +834,12 @@ delete_team_struct(struct team* team) delete team->job_control_entry; // usually already NULL and transferred to the parent - delete team->continued_children; - delete team->stopped_children; - delete team->dead_children; delete team; } static status_t -create_team_user_data(struct team* team) +create_team_user_data(Team* team) { void* address; size_t size = 4 * B_PAGE_SIZE; @@ -888,7 +863,7 @@ create_team_user_data(struct team* team) static void -delete_team_user_data(struct team* team) +delete_team_user_data(Team* team) { if (team->user_data_area >= 0) { vm_delete_area(team->id, team->user_data_area, true); @@ -1008,8 +983,8 @@ static int32 team_create_thread_start(void* args) { status_t err; - struct thread* thread; - struct team* team; + Thread* thread; + Team* team; struct team_arg* teamArgs = (struct team_arg*)args; const char* path; addr_t entry; @@ -1160,7 +1135,7 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount, port_id errorPort, uint32 errorToken) { char** flatArgs = _flatArgs; - struct team* team; + Team* team; const char* threadName; thread_id thread; status_t status; @@ -1191,7 +1166,7 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount, InterruptsSpinLocker teamLocker(gTeamSpinlock); // get the parent team - struct team* parent; + Team* parent; if (parentID == B_CURRENT_TEAM) parent = thread_get_current_thread()->team; @@ -1275,7 +1250,7 @@ load_image_internal(char**& _flatArgs, size_t flatArgsSize, int32 argCount, // wait for the loader of the new team to finish its work if ((flags & B_WAIT_TILL_LOADED) != 0) { - struct thread* mainThread; + Thread* mainThread; state = disable_interrupts(); GRAB_THREAD_LOCK(); @@ -1356,12 +1331,12 @@ exec_team(const char* path, char**& _flatArgs, size_t flatArgsSize, // NOTE: Since this function normally doesn't return, don't use automatic // variables that need destruction in the function scope. char** flatArgs = _flatArgs; - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; struct team_arg* teamArgs; const char* threadName; status_t status = B_OK; cpu_status state; - struct thread* thread; + Thread* thread; thread_id nubThreadID = -1; TRACE(("exec_team(path = \"%s\", argc = %ld, envCount = %ld): team %ld\n", @@ -1484,7 +1459,7 @@ exec_team(const char* path, char**& _flatArgs, size_t flatArgsSize, static int32 fork_team_thread_start(void* _args) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); struct fork_arg* forkArgs = (struct fork_arg*)_args; struct arch_fork_arg archArgs = forkArgs->arch_info; @@ -1518,9 +1493,9 @@ fork_team_thread_start(void* _args) static thread_id fork_team(void) { - struct thread* parentThread = thread_get_current_thread(); - struct team* parentTeam = parentThread->team; - struct team* team; + Thread* parentThread = thread_get_current_thread(); + Team* parentTeam = parentThread->team; + Team* team; struct fork_arg* forkArgs; struct area_info info; thread_id threadID; @@ -1703,9 +1678,9 @@ err1: Must be called with the team lock held. */ static bool -has_children_in_group(struct team* parent, pid_t groupID) +has_children_in_group(Team* parent, pid_t groupID) { - struct team* team; + Team* team; struct process_group* group = team_get_process_group_locked( parent->group->session, groupID); @@ -1722,9 +1697,9 @@ has_children_in_group(struct team* parent, pid_t groupID) static job_control_entry* -get_job_control_entry(team_job_control_children* children, pid_t id) +get_job_control_entry(team_job_control_children& children, pid_t id) { - for (JobControlEntryList::Iterator it = children->entries.GetIterator(); + for (JobControlEntryList::Iterator it = children.entries.GetIterator(); job_control_entry* entry = it.Next();) { if (id > 0) { @@ -1745,7 +1720,7 @@ get_job_control_entry(team_job_control_children* children, pid_t id) static job_control_entry* -get_job_control_entry(struct team* team, pid_t id, uint32 flags) +get_job_control_entry(Team* team, pid_t id, uint32 flags) { job_control_entry* entry = get_job_control_entry(team->dead_children, id); @@ -1781,7 +1756,7 @@ void job_control_entry::InitDeadState() { if (team != NULL) { - struct thread* thread = team->main_thread; + Thread* thread = team->main_thread; group_id = team->group_id; this->thread = thread->id; status = thread->exit.status; @@ -1817,8 +1792,8 @@ static thread_id wait_for_child(pid_t child, uint32 flags, int32* _reason, status_t* _returnCode) { - struct thread* thread = thread_get_current_thread(); - struct team* team = thread->team; + Thread* thread = thread_get_current_thread(); + Team* team = thread->team; struct job_control_entry foundEntry; struct job_control_entry* freeDeathEntry = NULL; status_t status = B_OK; @@ -1852,7 +1827,7 @@ wait_for_child(pid_t child, uint32 flags, int32* _reason, } else if (child < -1) { childrenExist = has_children_in_group(team, -child); } else { - if (struct team* childTeam = team_get_team_struct_locked(child)) + if (Team* childTeam = team_get_team_struct_locked(child)) childrenExist = childTeam->parent == team; } @@ -1869,8 +1844,8 @@ wait_for_child(pid_t child, uint32 flags, int32* _reason, if (entry->state == JOB_CONTROL_STATE_DEAD) { // The child is dead. Reap its death entry. freeDeathEntry = entry; - team->dead_children->entries.Remove(entry); - team->dead_children->count--; + team->dead_children.entries.Remove(entry); + team->dead_children.count--; } else { // The child is well. Reset its job control state. team_set_job_control_state(entry->team, @@ -1883,7 +1858,7 @@ wait_for_child(pid_t child, uint32 flags, int32* _reason, ConditionVariableEntry deadWaitEntry; if (status == B_WOULD_BLOCK && (flags & WNOHANG) == 0) - team->dead_children->condition_variable.Add(&deadWaitEntry); + team->dead_children.condition_variable.Add(&deadWaitEntry); locker.Unlock(); @@ -1973,7 +1948,7 @@ wait_for_child(pid_t child, uint32 flags, int32* _reason, The team lock must be held when called. */ static status_t -fill_team_info(struct team* team, team_info* info, size_t size) +fill_team_info(Team* team, team_info* info, size_t size) { if (size != sizeof(team_info)) return B_BAD_VALUE; @@ -2011,9 +1986,9 @@ update_orphaned_process_group(process_group* group, pid_t dyingProcess) if (group->orphaned) return true; - struct team* team = group->teams; + Team* team = group->teams; while (team != NULL) { - struct team* parent = team->parent; + Team* parent = team->parent; if (team->id != dyingProcess && parent != NULL && parent->id != dyingProcess && parent->group_id != group->id @@ -2037,7 +2012,7 @@ process_group_has_stopped_processes(process_group* group) { SpinLocker _(gThreadSpinlock); - struct team* team = group->teams; + Team* team = group->teams; while (team != NULL) { if (team->main_thread->state == B_THREAD_SUSPENDED) return true; @@ -2137,11 +2112,11 @@ team_used_teams(void) /*! Iterates through the list of teams. The team spinlock must be held. */ -struct team* +Team* team_iterate_through_teams(team_iterator_callback callback, void* cookie) { for (TeamHashTable::Iterator it = sTeamHash.GetIterator(); - struct team* team = it.Next();) { + Team* team = it.Next();) { if (callback(team, cookie)) return team; } @@ -2154,7 +2129,7 @@ team_iterate_through_teams(team_iterator_callback callback, void* cookie) You need to have the team lock held when calling this function. */ job_control_entry* -team_get_death_entry(struct team* team, thread_id child, bool* _deleteEntry) +team_get_death_entry(Team* team, thread_id child, bool* _deleteEntry) { if (child <= 0) return NULL; @@ -2164,8 +2139,8 @@ team_get_death_entry(struct team* team, thread_id child, bool* _deleteEntry) if (entry) { // remove the entry only, if the caller is the parent of the found team if (team_get_current_team_id() == entry->thread) { - team->dead_children->entries.Remove(entry); - team->dead_children->count--; + team->dead_children.entries.Remove(entry); + team->dead_children.count--; *_deleteEntry = true; } else { *_deleteEntry = false; @@ -2180,7 +2155,7 @@ team_get_death_entry(struct team* team, thread_id child, bool* _deleteEntry) bool team_is_valid(team_id id) { - struct team* team; + Team* team; cpu_status state; if (id <= 0) @@ -2198,7 +2173,7 @@ team_is_valid(team_id id) } -struct team* +Team* team_get_team_struct_locked(team_id id) { return sTeamHash.Lookup(id); @@ -2246,7 +2221,7 @@ team_delete_process_group(struct process_group* group) void team_set_controlling_tty(int32 ttyIndex) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; InterruptsSpinLocker _(gTeamSpinlock); @@ -2258,7 +2233,7 @@ team_set_controlling_tty(int32 ttyIndex) int32 team_get_controlling_tty() { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; InterruptsSpinLocker _(gTeamSpinlock); @@ -2269,8 +2244,8 @@ team_get_controlling_tty() status_t team_set_foreground_process_group(int32 ttyIndex, pid_t processGroupID) { - struct thread* thread = thread_get_current_thread(); - struct team* team = thread->team; + Thread* thread = thread_get_current_thread(); + Team* team = thread->team; InterruptsSpinLocker locker(gTeamSpinlock); @@ -2309,15 +2284,15 @@ team_set_foreground_process_group(int32 ttyIndex, pid_t processGroupID) You must hold the team lock when you call this function. */ void -team_remove_team(struct team* team) +team_remove_team(Team* team) { - struct team* parent = team->parent; + Team* parent = team->parent; // remember how long this team lasted - parent->dead_children->kernel_time += team->dead_threads_kernel_time - + team->dead_children->kernel_time; - parent->dead_children->user_time += team->dead_threads_user_time - + team->dead_children->user_time; + parent->dead_children.kernel_time += team->dead_threads_kernel_time + + team->dead_children.kernel_time; + parent->dead_children.user_time += team->dead_threads_user_time + + team->dead_children.user_time; // Also grab the thread spinlock while removing the team from the hash. // This makes the following sequence safe: grab teams lock, lookup team, @@ -2347,7 +2322,7 @@ team_remove_team(struct team* team) // send SIGHUP + SIGCONT to all newly-orphaned process groups with // stopped processes - struct team* child = team->children; + Team* child = team->children; while (child != NULL) { process_group* childGroup = child->group; if (!childGroup->orphaned @@ -2363,7 +2338,7 @@ team_remove_team(struct team* team) } } else { // update "orphaned" flags of all children's process groups - struct team* child = team->children; + Team* child = team->children; while (child != NULL) { process_group* childGroup = child->group; if (!childGroup->orphaned) @@ -2398,7 +2373,7 @@ team_remove_team(struct team* team) team_delete_team(). */ port_id -team_shutdown_team(struct team* team, cpu_status& state) +team_shutdown_team(Team* team, cpu_status& state) { ASSERT(thread_get_current_thread() == team->main_thread); @@ -2448,7 +2423,7 @@ team_shutdown_team(struct team* team, cpu_status& state) team->death_entry = &deathEntry; deathEntry.remaining_threads = 0; - struct thread* thread = team->thread_list; + Thread* thread = team->thread_list; while (thread != NULL) { if (thread != team->main_thread) { send_signal_etc(thread->id, SIGKILLTHR, @@ -2485,7 +2460,7 @@ team_shutdown_team(struct team* team, cpu_status& state) void -team_delete_team(struct team* team, port_id debuggerPort) +team_delete_team(Team* team, port_id debuggerPort) { team_id teamID = team->id; @@ -2550,7 +2525,7 @@ team_delete_team(struct team* team, port_id debuggerPort) } -struct team* +Team* team_get_kernel_team(void) { return sKernelTeam; @@ -2578,7 +2553,7 @@ status_t team_get_address_space(team_id id, VMAddressSpace** _addressSpace) { cpu_status state; - struct team* team; + Team* team; status_t status; // ToDo: we need to do something about B_SYSTEM_TEAM vs. its real ID (1) @@ -2612,7 +2587,7 @@ team_get_address_space(team_id id, VMAddressSpace** _addressSpace) \a threadsLocked indicates whether the thread lock is being held, too. */ void -team_set_job_control_state(struct team* team, job_control_state newState, +team_set_job_control_state(Team* team, job_control_state newState, int signal, bool threadsLocked) { if (team == NULL || team->job_control_entry == NULL) @@ -2635,10 +2610,10 @@ team_set_job_control_state(struct team* team, job_control_state newState, // can't get here break; case JOB_CONTROL_STATE_STOPPED: - team->parent->stopped_children->entries.Remove(entry); + team->parent->stopped_children.entries.Remove(entry); break; case JOB_CONTROL_STATE_CONTINUED: - team->parent->continued_children->entries.Remove(entry); + team->parent->continued_children.entries.Remove(entry); break; } @@ -2652,20 +2627,20 @@ team_set_job_control_state(struct team* team, job_control_state newState, // entry doesn't get into any list break; case JOB_CONTROL_STATE_DEAD: - childList = team->parent->dead_children; - team->parent->dead_children->count++; + childList = &team->parent->dead_children; + team->parent->dead_children.count++; break; case JOB_CONTROL_STATE_STOPPED: - childList = team->parent->stopped_children; + childList = &team->parent->stopped_children; break; case JOB_CONTROL_STATE_CONTINUED: - childList = team->parent->continued_children; + childList = &team->parent->continued_children; break; } if (childList != NULL) { childList->entries.Add(entry); - team->parent->dead_children->condition_variable.NotifyAll( + team->parent->dead_children.condition_variable.NotifyAll( threadsLocked); } } @@ -2679,7 +2654,7 @@ status_t start_watching_team(team_id teamID, void (*hook)(team_id, void*), void* data) { struct team_watcher* watcher; - struct team* team; + Team* team; cpu_status state; if (hook == NULL || teamID < B_OK) @@ -2717,7 +2692,7 @@ status_t stop_watching_team(team_id teamID, void (*hook)(team_id, void*), void* data) { struct team_watcher* watcher = NULL; - struct team* team; + Team* team; cpu_status state; if (hook == NULL || teamID < B_OK) @@ -2755,7 +2730,7 @@ stop_watching_team(team_id teamID, void (*hook)(team_id, void*), void* data) /*! The team lock must be held or the team must still be single threaded. */ struct user_thread* -team_allocate_user_thread(struct team* team) +team_allocate_user_thread(Team* team) { if (team->user_data == 0) return NULL; @@ -2792,7 +2767,7 @@ team_allocate_user_thread(struct team* team) /*! The team lock must not be held. \a thread must be the current thread. */ void -team_free_user_thread(struct thread* thread) +team_free_user_thread(Thread* thread) { user_thread* userThread = thread->user_thread; if (userThread == NULL) @@ -3014,7 +2989,7 @@ load_image_etc(int32 argCount, const char* const* args, status_t wait_for_team(team_id id, status_t* _returnCode) { - struct team* team; + Team* team; thread_id thread; cpu_status state; @@ -3044,7 +3019,7 @@ kill_team(team_id id) { status_t status = B_OK; thread_id threadID = -1; - struct team* team; + Team* team; cpu_status state; state = disable_interrupts(); @@ -3077,7 +3052,7 @@ _get_team_info(team_id id, team_info* info, size_t size) { cpu_status state; status_t status = B_OK; - struct team* team; + Team* team; state = disable_interrupts(); GRAB_TEAM_LOCK(); @@ -3106,7 +3081,7 @@ status_t _get_next_team_info(int32* cookie, team_info* info, size_t size) { status_t status = B_BAD_TEAM_ID; - struct team* team = NULL; + Team* team = NULL; int32 slot = *cookie; team_id lastTeamID; cpu_status state; @@ -3143,7 +3118,7 @@ _get_team_usage_info(team_id id, int32 who, team_usage_info* info, size_t size) { bigtime_t kernelTime = 0, userTime = 0; status_t status = B_OK; - struct team* team; + Team* team; cpu_status state; if (size != sizeof(team_usage_info) @@ -3166,7 +3141,7 @@ _get_team_usage_info(team_id id, int32 who, team_usage_info* info, size_t size) switch (who) { case B_TEAM_USAGE_SELF: { - struct thread* thread = team->thread_list; + Thread* thread = team->thread_list; for (; thread != NULL; thread = thread->team_next) { kernelTime += thread->kernel_time; @@ -3180,9 +3155,9 @@ _get_team_usage_info(team_id id, int32 who, team_usage_info* info, size_t size) case B_TEAM_USAGE_CHILDREN: { - struct team* child = team->children; + Team* child = team->children; for (; child != NULL; child = child->siblings_next) { - struct thread* thread = team->thread_list; + Thread* thread = team->thread_list; for (; thread != NULL; thread = thread->team_next) { kernelTime += thread->kernel_time; @@ -3193,8 +3168,8 @@ _get_team_usage_info(team_id id, int32 who, team_usage_info* info, size_t size) userTime += child->dead_threads_user_time; } - kernelTime += team->dead_children->kernel_time; - userTime += team->dead_children->user_time; + kernelTime += team->dead_children.kernel_time; + userTime += team->dead_children.user_time; break; } } @@ -3222,7 +3197,7 @@ getpid(void) pid_t getppid(void) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; cpu_status state; pid_t parent; @@ -3241,7 +3216,7 @@ getppid(void) pid_t getpgid(pid_t process) { - struct thread* thread; + Thread* thread; pid_t result = -1; cpu_status state; @@ -3265,7 +3240,7 @@ getpgid(pid_t process) pid_t getsid(pid_t process) { - struct thread* thread; + Thread* thread; pid_t result = -1; cpu_status state; @@ -3379,9 +3354,9 @@ _user_process_info(pid_t process, int32 which) pid_t _user_setpgid(pid_t processID, pid_t groupID) { - struct thread* thread = thread_get_current_thread(); - struct team* currentTeam = thread->team; - struct team* team; + Thread* thread = thread_get_current_thread(); + Team* currentTeam = thread->team; + Team* team; if (groupID < 0) return B_BAD_VALUE; @@ -3484,13 +3459,13 @@ _user_setpgid(pid_t processID, pid_t groupID) } // the team's new group - struct team* parent = team->parent; + Team* parent = team->parent; targetGroup->orphaned &= parent == NULL || parent->group == targetGroup || team->parent->session_id != team->session_id; // children's groups - struct team* child = team->children; + Team* child = team->children; while (child != NULL) { child->group->orphaned = false; update_orphaned_process_group(child->group, -1); @@ -3506,7 +3481,7 @@ _user_setpgid(pid_t processID, pid_t groupID) // Changing the process group might have changed the situation for a parent // waiting in wait_for_child(). Hence we notify it. if (status == B_OK) - team->parent->dead_children->condition_variable.NotifyAll(false); + team->parent->dead_children.condition_variable.NotifyAll(false); locker.Unlock(); @@ -3524,7 +3499,7 @@ _user_setpgid(pid_t processID, pid_t groupID) pid_t _user_setsid(void) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; struct process_session* session; struct process_group* group; cpu_status state; @@ -3621,9 +3596,9 @@ _user_load_image(const char* const* userFlatArgs, size_t flatArgsSize, void _user_exit_team(status_t returnValue) { - struct thread* thread = thread_get_current_thread(); - struct team* team = thread->team; - struct thread* mainThread = team->main_thread; + Thread* thread = thread_get_current_thread(); + Team* team = thread->team; + Thread* mainThread = team->main_thread; mainThread->exit.status = returnValue; mainThread->exit.reason = THREAD_RETURN_EXIT; @@ -3738,16 +3713,16 @@ _user_get_extended_team_info(team_id teamID, uint32 flags, void* buffer, if ((flags & B_TEAM_INFO_BASIC) != 0) { // allocate memory for a copy of the team struct - struct team* teamClone = new(std::nothrow) team; + Team* teamClone = new(std::nothrow) Team; if (teamClone == NULL) return B_NO_MEMORY; - ObjectDeleter teamCloneDeleter(teamClone); + ObjectDeleter teamCloneDeleter(teamClone); io_context* ioContext; { // get the team structure InterruptsSpinLocker _(gTeamSpinlock); - struct team* team = teamID == B_CURRENT_TEAM + Team* team = teamID == B_CURRENT_TEAM ? thread_get_current_thread()->team : team_get_team_struct_locked(teamID); if (team == NULL) diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index ac2a7d831b..5663367315 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -68,7 +68,7 @@ struct thread_key { spinlock gThreadSpinlock = B_SPINLOCK_INITIALIZER; // thread list -static struct thread sIdleThreads[B_MAX_CPU_COUNT]; +static Thread sIdleThreads[B_MAX_CPU_COUNT]; static hash_table *sThreadHash = NULL; static thread_id sNextThreadID = 1; @@ -78,10 +78,10 @@ static int32 sMaxThreads = 4096; static int32 sUsedThreads = 0; struct UndertakerEntry : DoublyLinkedListLinkImpl { - struct thread* thread; - team_id teamID; + Thread* thread; + team_id teamID; - UndertakerEntry(struct thread* thread, team_id teamID) + UndertakerEntry(Thread* thread, team_id teamID) : thread(thread), teamID(teamID) @@ -98,7 +98,7 @@ public: } void Notify(uint32 eventCode, team_id teamID, thread_id threadID, - struct thread* thread = NULL) + Thread* thread = NULL) { char eventBuffer[128]; KMessage event; @@ -112,7 +112,7 @@ public: DefaultNotificationService::Notify(event, eventCode); } - void Notify(uint32 eventCode, struct thread* thread) + void Notify(uint32 eventCode, Thread* thread) { return Notify(eventCode, thread->id, thread->team->id, thread); } @@ -135,7 +135,7 @@ static void thread_kthread_exit(void); You must hold the team lock when you call this function. */ static void -insert_thread_into_team(struct team *team, struct thread *thread) +insert_thread_into_team(Team *team, Thread *thread) { thread->team_next = team->thread_list; team->thread_list = thread; @@ -153,9 +153,9 @@ insert_thread_into_team(struct team *team, struct thread *thread) You must hold the team lock when you call this function. */ static void -remove_thread_from_team(struct team *team, struct thread *thread) +remove_thread_from_team(Team *team, Thread *thread) { - struct thread *temp, *last = NULL; + Thread *temp, *last = NULL; for (temp = team->thread_list; temp != NULL; temp = temp->team_next) { if (temp == thread) { @@ -175,7 +175,7 @@ remove_thread_from_team(struct team *team, struct thread *thread) static int thread_struct_compare(void *_t, const void *_key) { - struct thread *thread = (struct thread*)_t; + Thread *thread = (Thread*)_t; const struct thread_key *key = (const struct thread_key*)_key; if (thread->id == key->id) @@ -188,7 +188,7 @@ thread_struct_compare(void *_t, const void *_key) static uint32 thread_struct_hash(void *_t, const void *_key, uint32 range) { - struct thread *thread = (struct thread*)_t; + Thread *thread = (Thread*)_t; const struct thread_key *key = (const struct thread_key*)_key; if (thread != NULL) @@ -199,7 +199,7 @@ thread_struct_hash(void *_t, const void *_key, uint32 range) static void -reset_signals(struct thread *thread) +reset_signals(Thread *thread) { thread->sig_pending = 0; thread->sig_block_mask = 0; @@ -217,15 +217,15 @@ reset_signals(struct thread *thread) \code < 0 \endcode a fresh one is allocated. \param thread initialize this thread struct if nonnull */ -static struct thread * -create_thread_struct(struct thread *inthread, const char *name, +static Thread * +create_thread_struct(Thread *inthread, const char *name, thread_id threadID, struct cpu_ent *cpu) { - struct thread *thread; + Thread *thread; char temp[64]; if (inthread == NULL) { - thread = (struct thread*)object_cache_alloc(sThreadCache, 0); + thread = (Thread*)object_cache_alloc(sThreadCache, 0); if (thread == NULL) return NULL; @@ -313,7 +313,7 @@ err1: static void -delete_thread_struct(struct thread *thread) +delete_thread_struct(Thread *thread) { delete_sem(thread->exit.sem); delete_sem(thread->msg.write_sem); @@ -328,7 +328,7 @@ delete_thread_struct(struct thread *thread) static void thread_kthread_entry(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); // The thread is new and has been scheduled the first time. Notify the user // debugger code. @@ -349,7 +349,7 @@ thread_kthread_entry(void) static void thread_kthread_exit(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); thread->exit.reason = THREAD_RETURN_EXIT; thread_exit(); @@ -363,7 +363,7 @@ thread_kthread_exit(void) static int _create_user_thread_kentry(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); // jump to the entry point in user space arch_thread_enter_userspace(thread, (addr_t)thread->entry, @@ -378,7 +378,7 @@ _create_user_thread_kentry(void) static int _create_kernel_thread_kentry(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); int (*func)(void *args) = (int (*)(void *))thread->entry; // call the entry function with the appropriate args @@ -394,8 +394,8 @@ _create_kernel_thread_kentry(void) static thread_id create_thread(thread_creation_attributes& attributes, bool kernel) { - struct thread *thread, *currentThread; - struct team *team; + Thread *thread, *currentThread; + Team *team; cpu_status state; char stack_name[B_OS_NAME_LENGTH]; status_t status; @@ -603,7 +603,7 @@ undertaker(void* /*args*/) // we need a copy, since the original entry is on the thread's stack // we've got an entry - struct thread* thread = entry.thread; + Thread* thread = entry.thread; // delete the old kernel stack area delete_area(thread->kernel_stack_area); @@ -628,7 +628,7 @@ undertaker(void* /*args*/) static sem_id -get_thread_wait_sem(struct thread* thread) +get_thread_wait_sem(Thread* thread) { if (thread->state == B_THREAD_WAITING && thread->wait.type == THREAD_BLOCK_TYPE_SEMAPHORE) { @@ -643,7 +643,7 @@ get_thread_wait_sem(struct thread* thread) The thread lock must be held when called. */ static void -fill_thread_info(struct thread *thread, thread_info *info, size_t size) +fill_thread_info(Thread *thread, thread_info *info, size_t size) { info->thread = thread->id; info->team = thread->team->id; @@ -687,7 +687,7 @@ static status_t send_data_etc(thread_id id, int32 code, const void *buffer, size_t bufferSize, int32 flags) { - struct thread *target; + Thread *target; sem_id cachedSem; cpu_status state; status_t status; @@ -760,7 +760,7 @@ static int32 receive_data_etc(thread_id *_sender, void *buffer, size_t bufferSize, int32 flags) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); status_t status; size_t size; int32 code; @@ -812,7 +812,7 @@ common_getrlimit(int resource, struct rlimit * rlp) case RLIMIT_STACK: { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); if (!thread) return B_ERROR; rlp->rlim_cur = thread->user_stack_size; @@ -859,7 +859,7 @@ common_setrlimit(int resource, const struct rlimit * rlp) static int make_thread_unreal(int argc, char **argv) { - struct thread *thread; + Thread *thread; struct hash_iterator i; int32 id = -1; @@ -873,7 +873,7 @@ make_thread_unreal(int argc, char **argv) hash_open(sThreadHash, &i); - while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { + while ((thread = (Thread*)hash_next(sThreadHash, &i)) != NULL) { if (id != -1 && thread->id != id) continue; @@ -891,7 +891,7 @@ make_thread_unreal(int argc, char **argv) static int set_thread_prio(int argc, char **argv) { - struct thread *thread; + Thread *thread; struct hash_iterator i; int32 id; int32 prio; @@ -914,7 +914,7 @@ set_thread_prio(int argc, char **argv) hash_open(sThreadHash, &i); - while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { + while ((thread = (Thread*)hash_next(sThreadHash, &i)) != NULL) { if (thread->id != id) continue; thread->priority = thread->next_priority = prio; @@ -932,7 +932,7 @@ set_thread_prio(int argc, char **argv) static int make_thread_suspended(int argc, char **argv) { - struct thread *thread; + Thread *thread; struct hash_iterator i; int32 id; @@ -948,7 +948,7 @@ make_thread_suspended(int argc, char **argv) hash_open(sThreadHash, &i); - while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { + while ((thread = (Thread*)hash_next(sThreadHash, &i)) != NULL) { if (thread->id != id) continue; @@ -967,7 +967,7 @@ make_thread_suspended(int argc, char **argv) static int make_thread_resumed(int argc, char **argv) { - struct thread *thread; + Thread *thread; struct hash_iterator i; int32 id; @@ -982,7 +982,7 @@ make_thread_resumed(int argc, char **argv) hash_open(sThreadHash, &i); - while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { + while ((thread = (Thread*)hash_next(sThreadHash, &i)) != NULL) { if (thread->id != id) continue; @@ -1027,7 +1027,7 @@ drop_into_debugger(int argc, char **argv) static const char * -state_to_text(struct thread *thread, int32 state) +state_to_text(Thread *thread, int32 state) { switch (state) { case B_THREAD_READY: @@ -1077,7 +1077,7 @@ print_thread_list_table_head() static void -_dump_thread_info(struct thread *thread, bool shortInfo) +_dump_thread_info(Thread *thread, bool shortInfo) { if (shortInfo) { kprintf("%p %6ld %-10s", thread, thread->id, state_to_text(thread, @@ -1259,7 +1259,7 @@ dump_thread_info(int argc, char **argv) if (IS_KERNEL_ADDRESS(id)) { // semi-hack - _dump_thread_info((struct thread *)id, shortInfo); + _dump_thread_info((Thread *)id, shortInfo); continue; } @@ -1267,8 +1267,8 @@ dump_thread_info(int argc, char **argv) bool found = false; struct hash_iterator i; hash_open(sThreadHash, &i); - struct thread *thread; - while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { + Thread *thread; + while ((thread = (Thread*)hash_next(sThreadHash, &i)) != NULL) { if (!strcmp(name, thread->name) || thread->id == id) { _dump_thread_info(thread, shortInfo); found = true; @@ -1288,7 +1288,7 @@ dump_thread_info(int argc, char **argv) static int dump_thread_list(int argc, char **argv) { - struct thread *thread; + Thread *thread; struct hash_iterator i; bool realTimeOnly = false; bool calling = false; @@ -1333,7 +1333,7 @@ dump_thread_list(int argc, char **argv) print_thread_list_table_head(); hash_open(sThreadHash, &i); - while ((thread = (struct thread*)hash_next(sThreadHash, &i)) != NULL) { + while ((thread = (Thread*)hash_next(sThreadHash, &i)) != NULL) { // filter out threads not matching the search criteria if ((requiredState && thread->state != requiredState) || (calling && !arch_debug_contains_call(thread, callSymbol, @@ -1357,8 +1357,8 @@ void thread_exit(void) { cpu_status state; - struct thread *thread = thread_get_current_thread(); - struct team *team = thread->team; + Thread *thread = thread_get_current_thread(); + Team *team = thread->team; thread_id parentID = -1; status_t status; struct thread_debug_info debugInfo; @@ -1425,7 +1425,7 @@ thread_exit(void) } if (deleteTeam) { - struct team *parent = team->parent; + Team *parent = team->parent; // remember who our parent was so we can send a signal parentID = parent->id; @@ -1442,9 +1442,9 @@ thread_exit(void) // team_set_job_control_state() already moved our entry // into the parent's list. We just check the soft limit of // death entries. - if (parent->dead_children->count > MAX_DEAD_CHILDREN) { - death = parent->dead_children->entries.RemoveHead(); - parent->dead_children->count--; + if (parent->dead_children.count > MAX_DEAD_CHILDREN) { + death = parent->dead_children.entries.RemoveHead(); + parent->dead_children.count--; } else death = NULL; @@ -1610,10 +1610,10 @@ thread_exit(void) } -struct thread * +Thread * thread_get_thread_struct(thread_id id) { - struct thread *thread; + Thread *thread; cpu_status state; state = disable_interrupts(); @@ -1628,14 +1628,14 @@ thread_get_thread_struct(thread_id id) } -struct thread * +Thread * thread_get_thread_struct_locked(thread_id id) { struct thread_key key; key.id = id; - return (struct thread*)hash_lookup(sThreadHash, &key); + return (Thread*)hash_lookup(sThreadHash, &key); } @@ -1647,7 +1647,7 @@ thread_get_thread_struct_locked(thread_id id) void thread_at_kernel_entry(bigtime_t now) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); TRACE(("thread_at_kernel_entry: entry thread %ld\n", thread->id)); @@ -1667,7 +1667,7 @@ thread_at_kernel_entry(bigtime_t now) void thread_at_kernel_exit(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); TRACE(("thread_at_kernel_exit: exit thread %ld\n", thread->id)); @@ -1694,7 +1694,7 @@ thread_at_kernel_exit(void) void thread_at_kernel_exit_no_signals(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); TRACE(("thread_at_kernel_exit_no_signals: exit thread %ld\n", thread->id)); @@ -1710,7 +1710,7 @@ thread_at_kernel_exit_no_signals(void) void thread_reset_for_exec(void) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); reset_signals(thread); @@ -1720,7 +1720,7 @@ thread_reset_for_exec(void) /*! Insert a thread to the tail of a queue */ void -thread_enqueue(struct thread *thread, struct thread_queue *queue) +thread_enqueue(Thread *thread, struct thread_queue *queue) { thread->queue_next = NULL; if (queue->head == NULL) { @@ -1733,17 +1733,17 @@ thread_enqueue(struct thread *thread, struct thread_queue *queue) } -struct thread * +Thread * thread_lookat_queue(struct thread_queue *queue) { return queue->head; } -struct thread * +Thread * thread_dequeue(struct thread_queue *queue) { - struct thread *thread = queue->head; + Thread *thread = queue->head; if (thread != NULL) { queue->head = thread->queue_next; @@ -1754,11 +1754,11 @@ thread_dequeue(struct thread_queue *queue) } -struct thread * +Thread * thread_dequeue_id(struct thread_queue *q, thread_id id) { - struct thread *thread; - struct thread *last = NULL; + Thread *thread; + Thread *last = NULL; thread = q->head; while (thread != NULL) { @@ -1779,14 +1779,14 @@ thread_dequeue_id(struct thread_queue *q, thread_id id) } -struct thread* +Thread* thread_iterate_through_threads(thread_iterator_callback callback, void* cookie) { struct hash_iterator iterator; hash_open(sThreadHash, &iterator); - struct thread* thread; - while ((thread = (struct thread*)hash_next(sThreadHash, &iterator)) + Thread* thread; + while ((thread = (Thread*)hash_next(sThreadHash, &iterator)) != NULL) { if (callback(thread, cookie)) break; @@ -1827,7 +1827,7 @@ thread_yield(bool force) #if 0 cpu_status state; - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); if (thread == NULL) return; @@ -1843,7 +1843,7 @@ thread_yield(bool force) restore_interrupts(state); #endif } else { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); if (thread == NULL) return; @@ -1885,7 +1885,7 @@ wait_for_thread_etc(thread_id id, uint32 flags, bigtime_t timeout, sem_id exitSem = B_BAD_THREAD_ID; struct death_entry death; job_control_entry* freeDeath = NULL; - struct thread *thread; + Thread *thread; cpu_status state; status_t status = B_OK; @@ -1913,7 +1913,7 @@ wait_for_thread_etc(thread_id id, uint32 flags, bigtime_t timeout, // find its death entry in our team GRAB_TEAM_LOCK(); - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; // check the child death entries first (i.e. main threads of child // teams) @@ -2001,7 +2001,7 @@ select_thread(int32 id, struct select_info* info, bool kernel) InterruptsSpinLocker locker(gThreadSpinlock); // get thread - struct thread* thread = thread_get_thread_struct_locked(id); + Thread* thread = thread_get_thread_struct_locked(id); if (thread == NULL) return B_BAD_THREAD_ID; @@ -2027,7 +2027,7 @@ deselect_thread(int32 id, struct select_info* info, bool kernel) InterruptsSpinLocker locker(gThreadSpinlock); // get thread - struct thread* thread = thread_get_thread_struct_locked(id); + Thread* thread = thread_get_thread_struct_locked(id); if (thread == NULL) return B_BAD_THREAD_ID; @@ -2065,7 +2065,7 @@ thread_used_threads(void) const char* -thread_state_to_text(struct thread* thread, int32 state) +thread_state_to_text(Thread* thread, int32 state) { return state_to_text(thread, state); } @@ -2075,7 +2075,7 @@ int32 thread_get_io_priority(thread_id id) { // take a shortcut, if it is the current thread - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); int32 priority; if (id == thread->id) { int32 priority = thread->io_priority; @@ -2097,7 +2097,7 @@ thread_get_io_priority(thread_id id) void thread_set_io_priority(int32 priority) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread->io_priority = priority; } @@ -2110,11 +2110,11 @@ thread_init(kernel_args *args) TRACE(("thread_init: entry\n")); // create the thread hash table - sThreadHash = hash_init(15, offsetof(struct thread, all_next), + sThreadHash = hash_init(15, offsetof(Thread, all_next), &thread_struct_compare, &thread_struct_hash); // create the thread structure object cache - sThreadCache = create_object_cache("threads", sizeof(thread), 16, NULL, + sThreadCache = create_object_cache("threads", sizeof(Thread), 16, NULL, NULL, NULL); // Note: The x86 port requires 16 byte alignment of thread structures. if (sThreadCache == NULL) @@ -2129,7 +2129,7 @@ thread_init(kernel_args *args) // create an idle thread for each cpu for (i = 0; i < args->num_cpus; i++) { - struct thread *thread; + Thread *thread; area_info info; char name[64]; @@ -2267,7 +2267,7 @@ thread_block_timeout(timer* timer) // we're holding the thread lock already. This makes things comfortably // easy. - struct thread* thread = (struct thread*)timer->user_data; + Thread* thread = (Thread*)timer->user_data; thread_unblock_locked(thread, B_TIMED_OUT); return B_HANDLED_INTERRUPT; @@ -2287,7 +2287,7 @@ thread_unblock(status_t threadID, status_t status) { InterruptsSpinLocker _(gThreadSpinlock); - struct thread* thread = thread_get_thread_struct_locked(threadID); + Thread* thread = thread_get_thread_struct_locked(threadID); if (thread != NULL) thread_unblock_locked(thread, status); } @@ -2304,7 +2304,7 @@ thread_block_with_timeout(uint32 timeoutFlags, bigtime_t timeout) status_t thread_block_with_timeout_locked(uint32 timeoutFlags, bigtime_t timeout) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread->wait.status != 1) return thread->wait.status; @@ -2349,7 +2349,7 @@ thread_block_with_timeout_locked(uint32 timeoutFlags, bigtime_t timeout) static status_t user_unblock_thread(thread_id threadID, status_t status) { - struct thread* thread = thread_get_thread_struct_locked(threadID); + Thread* thread = thread_get_thread_struct_locked(threadID); if (thread == NULL) return B_BAD_THREAD_ID; if (thread->user_thread == NULL) @@ -2370,7 +2370,7 @@ user_unblock_thread(thread_id threadID, status_t status) void exit_thread(status_t returnValue) { - struct thread *thread = thread_get_current_thread(); + Thread *thread = thread_get_current_thread(); thread->exit.status = returnValue; thread->exit.reason = THREAD_RETURN_EXIT; @@ -2426,7 +2426,7 @@ status_t _get_thread_info(thread_id id, thread_info *info, size_t size) { status_t status = B_OK; - struct thread *thread; + Thread *thread; cpu_status state; if (info == NULL || size != sizeof(thread_info) || id < B_OK) @@ -2462,7 +2462,7 @@ _get_next_thread_info(team_id teamID, int32 *_cookie, thread_info *info, InterruptsSpinLocker teamLocker(gTeamSpinlock); - struct team* team; + Team* team; if (teamID == B_CURRENT_TEAM) team = thread_get_current_thread()->team; else @@ -2471,7 +2471,7 @@ _get_next_thread_info(team_id teamID, int32 *_cookie, thread_info *info, if (team == NULL) return B_BAD_VALUE; - struct thread* thread = NULL; + Thread* thread = NULL; if (lastID == 0) { // We start with the main thread @@ -2480,7 +2480,7 @@ _get_next_thread_info(team_id teamID, int32 *_cookie, thread_info *info, // Find the one thread with an ID higher than ours // (as long as the IDs don't overlap they are always sorted from // highest to lowest). - for (struct thread* next = team->thread_list; next != NULL; + for (Thread* next = team->thread_list; next != NULL; next = next->team_next) { if (next->id <= lastID) break; @@ -2506,7 +2506,7 @@ thread_id find_thread(const char *name) { struct hash_iterator iterator; - struct thread *thread; + Thread *thread; cpu_status state; if (name == NULL) @@ -2521,7 +2521,7 @@ find_thread(const char *name) // cheap either - although this function is probably used very rarely. hash_open(sThreadHash, &iterator); - while ((thread = (struct thread*)hash_next(sThreadHash, &iterator)) + while ((thread = (Thread*)hash_next(sThreadHash, &iterator)) != NULL) { // Search through hash if (!strcmp(thread->name, name)) { @@ -2543,7 +2543,7 @@ find_thread(const char *name) status_t rename_thread(thread_id id, const char* name) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (name == NULL) return B_BAD_VALUE; @@ -2575,7 +2575,7 @@ rename_thread(thread_id id, const char* name) status_t set_thread_priority(thread_id id, int32 priority) { - struct thread *thread; + Thread *thread; int32 oldPriority; // make sure the passed in priority is within bounds @@ -2623,7 +2623,7 @@ snooze_etc(bigtime_t timeout, int timebase, uint32 flags) return B_BAD_VALUE; InterruptsSpinLocker _(gThreadSpinlock); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); thread_prepare_to_block(thread, flags, THREAD_BLOCK_TYPE_SNOOZE, NULL); status = thread_block_with_timeout_locked(flags, timeout); @@ -2964,7 +2964,7 @@ _user_block_thread(uint32 flags, bigtime_t timeout) syscall_restart_handle_timeout_pre(flags, timeout); flags |= B_CAN_INTERRUPT; - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); InterruptsSpinLocker locker(gThreadSpinlock); diff --git a/src/system/kernel/usergroup.cpp b/src/system/kernel/usergroup.cpp index f13411d738..52ab74c2db 100644 --- a/src/system/kernel/usergroup.cpp +++ b/src/system/kernel/usergroup.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -27,7 +27,7 @@ static bool -is_privileged(struct team* team) +is_privileged(Team* team) { // currently only the root user is privileged return team->effective_uid == 0; @@ -37,7 +37,7 @@ is_privileged(struct team* team) static status_t common_setregid(gid_t rgid, gid_t egid, bool setAllIfPrivileged, bool kernel) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; InterruptsSpinLocker _(gTeamSpinlock); @@ -100,7 +100,7 @@ common_setregid(gid_t rgid, gid_t egid, bool setAllIfPrivileged, bool kernel) static status_t common_setreuid(uid_t ruid, uid_t euid, bool setAllIfPrivileged, bool kernel) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; InterruptsSpinLocker _(gTeamSpinlock); @@ -163,7 +163,7 @@ common_setreuid(uid_t ruid, uid_t euid, bool setAllIfPrivileged, bool kernel) ssize_t common_getgroups(int groupCount, gid_t* groupList, bool kernel) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; InterruptsSpinLocker _(gTeamSpinlock); @@ -225,7 +225,7 @@ common_setgroups(int groupCount, const gid_t* groupList, bool kernel) InterruptsSpinLocker locker(gTeamSpinlock); - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; gid_t* toFree = team->supplementary_groups; team->supplementary_groups = newGroups; @@ -243,7 +243,7 @@ common_setgroups(int groupCount, const gid_t* groupList, bool kernel) void -inherit_parent_user_and_group_locked(struct team* team, struct team* parent) +inherit_parent_user_and_group_locked(Team* team, Team* parent) { team->saved_set_uid = parent->saved_set_uid; team->real_uid = parent->real_uid; @@ -259,7 +259,7 @@ inherit_parent_user_and_group_locked(struct team* team, struct team* parent) void -inherit_parent_user_and_group(struct team* team, struct team* parent) +inherit_parent_user_and_group(Team* team, Team* parent) { InterruptsSpinLocker _(gTeamSpinlock); inherit_parent_user_and_group_locked(team, parent); @@ -267,7 +267,7 @@ inherit_parent_user_and_group(struct team* team, struct team* parent) status_t -update_set_id_user_and_group(struct team* team, const char* file) +update_set_id_user_and_group(Team* team, const char* file) { struct stat st; status_t status = vfs_read_stat(-1, file, true, &st, false); @@ -293,7 +293,7 @@ update_set_id_user_and_group(struct team* team, const char* file) gid_t _kern_getgid(bool effective) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; return effective ? team->effective_gid : team->real_gid; } @@ -302,7 +302,7 @@ _kern_getgid(bool effective) uid_t _kern_getuid(bool effective) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; return effective ? team->effective_uid : team->real_uid; } @@ -342,7 +342,7 @@ _kern_setgroups(int groupCount, const gid_t* groupList) gid_t _user_getgid(bool effective) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; return effective ? team->effective_gid : team->real_gid; } @@ -351,7 +351,7 @@ _user_getgid(bool effective) uid_t _user_getuid(bool effective) { - struct team* team = thread_get_current_thread()->team; + Team* team = thread_get_current_thread()->team; return effective ? team->effective_uid : team->real_uid; } diff --git a/src/system/kernel/vm/VMAddressSpace.cpp b/src/system/kernel/vm/VMAddressSpace.cpp index e56cf4dd94..7763149ecd 100644 --- a/src/system/kernel/vm/VMAddressSpace.cpp +++ b/src/system/kernel/vm/VMAddressSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -228,7 +228,7 @@ VMAddressSpace::GetKernel() /*static*/ team_id VMAddressSpace::CurrentID() { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL && thread->team->address_space != NULL) return thread->team->id; @@ -240,7 +240,7 @@ VMAddressSpace::CurrentID() /*static*/ VMAddressSpace* VMAddressSpace::GetCurrent() { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL) { VMAddressSpace* addressSpace = thread->team->address_space; diff --git a/src/system/kernel/vm/VMCache.cpp b/src/system/kernel/vm/VMCache.cpp index ac371cbe2b..e513c3a980 100644 --- a/src/system/kernel/vm/VMCache.cpp +++ b/src/system/kernel/vm/VMCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -49,7 +49,7 @@ static mutex sCacheListLock = MUTEX_INITIALIZER("global VMCache list"); struct VMCache::PageEventWaiter { - struct thread* thread; + Thread* thread; PageEventWaiter* next; vm_page* page; uint32 events; diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index ea42d3ae5a..0656302e84 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -3838,7 +3838,7 @@ vm_init_post_modules(kernel_args* args) void permit_page_faults(void) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL) atomic_add(&thread->page_faults_allowed, 1); } @@ -3847,7 +3847,7 @@ permit_page_faults(void) void forbid_page_faults(void) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL) atomic_add(&thread->page_faults_allowed, -1); } @@ -3908,7 +3908,7 @@ vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite, bool isUser, strerror(status), address, faultAddress, isWrite, isUser, thread_get_current_thread_id()); if (!isUser) { - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); if (thread != NULL && thread->fault_handler != 0) { // this will cause the arch dependant page fault handler to // modify the IP on the interrupt frame or whatever to return @@ -3927,7 +3927,7 @@ vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite, bool isUser, // (and tools) VMArea* area = addressSpace->LookupArea(faultAddress); - struct thread* thread = thread_get_current_thread(); + Thread* thread = thread_get_current_thread(); dprintf("vm_page_fault: thread \"%s\" (%ld) in team \"%s\" (%ld) " "tried to %s address %#lx, ip %#lx (\"%s\" +%#lx)\n", thread->name, thread->id, thread->team->name, thread->team->id, @@ -4850,7 +4850,7 @@ vm_debug_copy_page_memory(team_id teamID, void* unsafeMemory, void* buffer, if (IS_KERNEL_ADDRESS(unsafeMemory)) { addressSpace = VMAddressSpace::Kernel(); } else if (teamID == B_CURRENT_TEAM) { - struct thread* thread = debug_get_debugged_thread(); + Thread* thread = debug_get_debugged_thread(); if (thread == NULL || thread->team == NULL) return B_BAD_ADDRESS; diff --git a/src/system/kernel/vm/vm_page.cpp b/src/system/kernel/vm/vm_page.cpp index 18062cd19c..ab4f5e6c6b 100644 --- a/src/system/kernel/vm/vm_page.cpp +++ b/src/system/kernel/vm/vm_page.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2010-2011, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2002-2010, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. * @@ -150,10 +150,10 @@ struct page_stats { struct PageReservationWaiter : public DoublyLinkedListLinkImpl { - struct thread* thread; - uint32 dontTouch; // reserve not to touch - uint32 missing; // pages missing for the reservation - int32 threadPriority; + Thread* thread; + uint32 dontTouch; // reserve not to touch + uint32 missing; // pages missing for the reservation + int32 threadPriority; bool operator<(const PageReservationWaiter& other) const { diff --git a/src/tests/add-ons/kernel/kernelland_emu/lock.cpp b/src/tests/add-ons/kernel/kernelland_emu/lock.cpp index d7168d1596..5c2de209ee 100644 --- a/src/tests/add-ons/kernel/kernelland_emu/lock.cpp +++ b/src/tests/add-ons/kernel/kernelland_emu/lock.cpp @@ -25,13 +25,13 @@ struct mutex_waiter { - struct thread* thread; + Thread* thread; mutex_waiter* next; // next in queue mutex_waiter* last; // last in queue (valid for the first in queue) }; struct rw_lock_waiter { - struct thread* thread; + Thread* thread; rw_lock_waiter* next; // next in queue rw_lock_waiter* last; // last in queue (valid for the first in queue) bool writer; diff --git a/src/tests/add-ons/kernel/kernelland_emu/thread.h b/src/tests/add-ons/kernel/kernelland_emu/thread.h index 39eb4544fc..7b9357318c 100644 --- a/src/tests/add-ons/kernel/kernelland_emu/thread.h +++ b/src/tests/add-ons/kernel/kernelland_emu/thread.h @@ -8,20 +8,24 @@ #include -struct thread; +namespace BKernel { + struct Thread; +} + +using BKernel::Thread; -static inline struct thread* +static inline Thread* get_current_thread() { - return (struct thread*)find_thread(NULL); + return (Thread*)(addr_t)find_thread(NULL); } static inline thread_id -get_thread_id(struct thread* thread) +get_thread_id(Thread* thread) { - return (thread_id)thread; + return (thread_id)(addr_t)thread; }